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:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/CMakeLists.txt5
-rw-r--r--source/blender/avi/intern/avi.c34
-rw-r--r--source/blender/avi/intern/avi_mjpeg.c10
-rw-r--r--source/blender/avi/intern/avi_rgb.c2
-rw-r--r--source/blender/blenfont/BLF_api.h1
-rw-r--r--source/blender/blenfont/BLF_translation.h7
-rw-r--r--source/blender/blenfont/CMakeLists.txt2
-rw-r--r--source/blender/blenfont/SConscript3
-rw-r--r--source/blender/blenfont/intern/blf.c130
-rw-r--r--source/blender/blenfont/intern/blf_lang.c321
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h16
-rw-r--r--source/blender/blenkernel/BKE_armature.h2
-rw-r--r--source/blender/blenkernel/BKE_blender.h9
-rw-r--r--source/blender/blenkernel/BKE_bmesh.h4
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h4
-rw-r--r--source/blender/blenkernel/BKE_colortools.h5
-rw-r--r--source/blender/blenkernel/BKE_curve.h2
-rw-r--r--source/blender/blenkernel/BKE_customdata.h16
-rw-r--r--source/blender/blenkernel/BKE_deform.h1
-rw-r--r--source/blender/blenkernel/BKE_global.h18
-rw-r--r--source/blender/blenkernel/BKE_idprop.h29
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/BKE_key.h2
-rw-r--r--source/blender/blenkernel/BKE_lamp.h3
-rw-r--r--source/blender/blenkernel/BKE_lattice.h2
-rw-r--r--source/blender/blenkernel/BKE_library.h1
-rw-r--r--source/blender/blenkernel/BKE_mesh.h7
-rw-r--r--source/blender/blenkernel/BKE_modifier.h1
-rw-r--r--source/blender/blenkernel/BKE_multires.h5
-rw-r--r--source/blender/blenkernel/BKE_navmesh_conversion.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h29
-rw-r--r--source/blender/blenkernel/BKE_paint.h1
-rw-r--r--source/blender/blenkernel/BKE_particle.h21
-rw-r--r--source/blender/blenkernel/BKE_scene.h7
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h25
-rw-r--r--source/blender/blenkernel/BKE_smoke.h6
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h8
-rw-r--r--source/blender/blenkernel/BKE_tracking.h4
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h8
-rw-r--r--source/blender/blenkernel/CMakeLists.txt18
-rw-r--r--source/blender/blenkernel/SConscript2
-rw-r--r--source/blender/blenkernel/depsgraph_private.h2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c181
-rw-r--r--source/blender/blenkernel/intern/action.c16
-rw-r--r--source/blender/blenkernel/intern/anim.c131
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c31
-rw-r--r--source/blender/blenkernel/intern/armature.c27
-rw-r--r--source/blender/blenkernel/intern/blender.c22
-rw-r--r--source/blender/blenkernel/intern/bmfont.c15
-rw-r--r--source/blender/blenkernel/intern/boids.c30
-rw-r--r--source/blender/blenkernel/intern/booleanops_mesh.c12
-rw-r--r--source/blender/blenkernel/intern/brush.c44
-rw-r--r--source/blender/blenkernel/intern/bullet.c2
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c44
-rw-r--r--source/blender/blenkernel/intern/camera.c5
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c262
-rw-r--r--source/blender/blenkernel/intern/cloth.c41
-rw-r--r--source/blender/blenkernel/intern/collision.c29
-rw-r--r--source/blender/blenkernel/intern/colortools.c91
-rw-r--r--source/blender/blenkernel/intern/constraint.c118
-rw-r--r--source/blender/blenkernel/intern/context.c5
-rw-r--r--source/blender/blenkernel/intern/curve.c36
-rw-r--r--source/blender/blenkernel/intern/customdata.c249
-rw-r--r--source/blender/blenkernel/intern/deform.c24
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c204
-rw-r--r--source/blender/blenkernel/intern/displist.c117
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c75
-rw-r--r--source/blender/blenkernel/intern/effect.c50
-rw-r--r--source/blender/blenkernel/intern/fcurve.c34
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c36
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c13
-rw-r--r--source/blender/blenkernel/intern/font.c30
-rw-r--r--source/blender/blenkernel/intern/gpencil.c3
-rw-r--r--source/blender/blenkernel/intern/group.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c119
-rw-r--r--source/blender/blenkernel/intern/image.c75
-rw-r--r--source/blender/blenkernel/intern/image_gen.c2
-rw-r--r--source/blender/blenkernel/intern/implicit.c149
-rw-r--r--source/blender/blenkernel/intern/ipo.c20
-rw-r--r--source/blender/blenkernel/intern/key.c24
-rw-r--r--source/blender/blenkernel/intern/lamp.c40
-rw-r--r--source/blender/blenkernel/intern/lattice.c45
-rw-r--r--source/blender/blenkernel/intern/library.c25
-rw-r--r--source/blender/blenkernel/intern/mask.c16
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c8
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c28
-rw-r--r--source/blender/blenkernel/intern/material.c32
-rw-r--r--source/blender/blenkernel/intern/mball.c11
-rw-r--r--source/blender/blenkernel/intern/mesh.c89
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c11
-rw-r--r--source/blender/blenkernel/intern/modifier.c47
-rw-r--r--source/blender/blenkernel/intern/modifiers_bmesh.c11
-rw-r--r--source/blender/blenkernel/intern/movieclip.c56
-rw-r--r--source/blender/blenkernel/intern/multires.c15
-rw-r--r--source/blender/blenkernel/intern/navmesh_conversion.c338
-rw-r--r--source/blender/blenkernel/intern/nla.c14
-rw-r--r--source/blender/blenkernel/intern/node.c117
-rw-r--r--source/blender/blenkernel/intern/object.c76
-rw-r--r--source/blender/blenkernel/intern/ocean.c22
-rw-r--r--source/blender/blenkernel/intern/packedFile.c11
-rw-r--r--source/blender/blenkernel/intern/paint.c10
-rw-r--r--source/blender/blenkernel/intern/particle.c95
-rw-r--r--source/blender/blenkernel/intern/particle_system.c149
-rw-r--r--source/blender/blenkernel/intern/pointcache.c243
-rw-r--r--source/blender/blenkernel/intern/report.c48
-rw-r--r--source/blender/blenkernel/intern/sca.c4
-rw-r--r--source/blender/blenkernel/intern/scene.c68
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c18
-rw-r--r--source/blender/blenkernel/intern/seqmodifier.c4
-rw-r--r--source/blender/blenkernel/intern/sequencer.c116
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c246
-rw-r--r--source/blender/blenkernel/intern/smoke.c3049
-rw-r--r--source/blender/blenkernel/intern/softbody.c50
-rw-r--r--source/blender/blenkernel/intern/sound.c26
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c59
-rw-r--r--source/blender/blenkernel/intern/text.c86
-rw-r--r--source/blender/blenkernel/intern/texture.c7
-rw-r--r--source/blender/blenkernel/intern/tracking.c116
-rw-r--r--source/blender/blenkernel/intern/unit.c2
-rw-r--r--source/blender/blenkernel/intern/world.c2
-rw-r--r--source/blender/blenkernel/intern/writeavi.c28
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c28
-rw-r--r--source/blender/blenkernel/intern/writeframeserver.c8
-rw-r--r--source/blender/blenkernel/nla_private.h2
-rw-r--r--source/blender/blenlib/BLI_blenlib.h2
-rw-r--r--source/blender/blenlib/BLI_bpath.h7
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h4
-rw-r--r--source/blender/blenlib/BLI_endian_switch_inline.h12
-rw-r--r--source/blender/blenlib/BLI_heap.h8
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h25
-rw-r--r--source/blender/blenlib/BLI_kdtree.h2
-rw-r--r--source/blender/blenlib/BLI_math.h1
-rw-r--r--source/blender/blenlib/BLI_math_base.h7
-rw-r--r--source/blender/blenlib/BLI_math_geom.h39
-rw-r--r--source/blender/blenlib/BLI_math_interp.h35
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h22
-rw-r--r--source/blender/blenlib/BLI_math_vector.h8
-rw-r--r--source/blender/blenlib/BLI_pbvh.h5
-rw-r--r--source/blender/blenlib/BLI_quadric.h56
-rw-r--r--source/blender/blenlib/BLI_rand.h23
-rw-r--r--source/blender/blenlib/BLI_rect.h4
-rw-r--r--source/blender/blenlib/BLI_scanfill.h2
-rw-r--r--source/blender/blenlib/BLI_string.h22
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h14
-rw-r--r--source/blender/blenlib/BLI_utildefines.h125
-rw-r--r--source/blender/blenlib/BLI_voronoi.h2
-rw-r--r--source/blender/blenlib/CMakeLists.txt5
-rw-r--r--source/blender/blenlib/PIL_time.h28
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c4
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c137
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c201
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c10
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c2
-rw-r--r--source/blender/blenlib/intern/boxpack2d.c12
-rw-r--r--source/blender/blenlib/intern/bpath.c86
-rw-r--r--source/blender/blenlib/intern/edgehash.c2
-rw-r--r--source/blender/blenlib/intern/fileops.c2
-rw-r--r--source/blender/blenlib/intern/freetypefont.c26
-rw-r--r--source/blender/blenlib/intern/graph.c16
-rw-r--r--source/blender/blenlib/intern/listbase.c12
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c18
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c6
-rw-r--r--source/blender/blenlib/intern/math_geom.c133
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c20
-rw-r--r--source/blender/blenlib/intern/math_interp.c235
-rw-r--r--source/blender/blenlib/intern/math_matrix.c170
-rw-r--r--source/blender/blenlib/intern/math_rotation.c38
-rw-r--r--source/blender/blenlib/intern/math_vector.c11
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c41
-rw-r--r--source/blender/blenlib/intern/noise.c10
-rw-r--r--source/blender/blenlib/intern/path_util.c16
-rw-r--r--source/blender/blenlib/intern/pbvh.c56
-rw-r--r--source/blender/blenlib/intern/quadric.c126
-rw-r--r--source/blender/blenlib/intern/rand.c72
-rw-r--r--source/blender/blenlib/intern/rct.c57
-rw-r--r--source/blender/blenlib/intern/scanfill.c8
-rw-r--r--source/blender/blenlib/intern/smallhash.c18
-rw-r--r--source/blender/blenlib/intern/storage.c8
-rw-r--r--source/blender/blenlib/intern/string.c46
-rw-r--r--source/blender/blenlib/intern/string_utf8.c151
-rw-r--r--source/blender/blenlib/intern/time.c2
-rw-r--r--source/blender/blenlib/intern/voronoi.c16
-rw-r--r--source/blender/blenlib/intern/voxel.c52
-rw-r--r--source/blender/blenlib/intern/winstuff.c4
-rw-r--r--source/blender/blenloader/CMakeLists.txt5
-rw-r--r--source/blender/blenloader/SConscript5
-rw-r--r--source/blender/blenloader/intern/readblenentry.c18
-rw-r--r--source/blender/blenloader/intern/readfile.c602
-rw-r--r--source/blender/blenloader/intern/runtime.c12
-rw-r--r--source/blender/blenloader/intern/versioning_250.c8
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c2
-rw-r--r--source/blender/blenloader/intern/writefile.c96
-rw-r--r--source/blender/bmesh/CMakeLists.txt20
-rw-r--r--source/blender/bmesh/SConscript11
-rw-r--r--source/blender/bmesh/bmesh.h1
-rw-r--r--source/blender/bmesh/bmesh_class.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c16
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c65
-rw-r--r--source/blender/bmesh/intern/bmesh_core.h4
-rw-r--r--source/blender/bmesh/intern/bmesh_decimate.h41
-rw-r--r--source/blender/bmesh/intern/bmesh_decimate_collapse.c1044
-rw-r--r--source/blender/bmesh/intern/bmesh_decimate_dissolve.c243
-rw-r--r--source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c344
-rw-r--r--source/blender/bmesh/intern/bmesh_inline.h6
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c17
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.c148
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.h14
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c9
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c20
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c95
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h12
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c58
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h7
-rw-r--r--source/blender/bmesh/intern/bmesh_operators_private.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c12
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c198
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h12
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c9
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c1372
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c4
-rw-r--r--source/blender/bmesh/operators/bmo_create.c8
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c177
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c123
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c533
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c13
-rw-r--r--source/blender/bmesh/operators/bmo_mirror.c2
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c2
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c70
-rw-r--r--source/blender/bmesh/operators/bmo_similar.c614
-rw-r--r--source/blender/bmesh/operators/bmo_slide.c4
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c619
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c6
-rw-r--r--source/blender/bmesh/operators/bmo_symmetrize.c663
-rw-r--r--source/blender/bmesh/operators/bmo_unsubdivide.c59
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c557
-rw-r--r--source/blender/bmesh/tools/BME_bevel.c11
-rw-r--r--source/blender/collada/AnimationExporter.cpp22
-rw-r--r--source/blender/collada/AnimationExporter.h19
-rw-r--r--source/blender/collada/AnimationImporter.cpp25
-rw-r--r--source/blender/collada/AnimationImporter.h2
-rw-r--r--source/blender/collada/ArmatureExporter.cpp2
-rw-r--r--source/blender/collada/ArmatureImporter.h2
-rw-r--r--source/blender/collada/CMakeLists.txt2
-rw-r--r--source/blender/collada/DocumentExporter.cpp36
-rw-r--r--source/blender/collada/DocumentExporter.h2
-rw-r--r--source/blender/collada/DocumentImporter.cpp6
-rw-r--r--source/blender/collada/EffectExporter.cpp6
-rw-r--r--source/blender/collada/GeometryExporter.cpp6
-rw-r--r--source/blender/collada/ImageExporter.cpp2
-rw-r--r--source/blender/collada/MeshImporter.cpp6
-rw-r--r--source/blender/collada/SceneExporter.cpp6
-rw-r--r--source/blender/collada/collada_internal.h1
-rw-r--r--source/blender/collada/collada_utils.cpp5
-rw-r--r--source/blender/collada/collada_utils.h11
-rw-r--r--source/blender/compositor/CMakeLists.txt8
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp4
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp10
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp33
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h5
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp4
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.cpp11
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.h18
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp4
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp10
-rw-r--r--source/blender/compositor/intern/COM_Node.h6
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.h6
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp10
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h7
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp2
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.cpp10
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.h3
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.cpp17
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.cpp48
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cpp22
-rw-r--r--source/blender/compositor/nodes/COM_SeparateRGBANode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp3
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp46
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MixBaseOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp34
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h9
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl14
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.cpp49
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp55
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersBaseProg.h1
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp51
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp3
-rw-r--r--source/blender/datatoc/datatoc.c5
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c20
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c18
-rw-r--r--source/blender/editors/animation/anim_draw.c6
-rw-r--r--source/blender/editors/animation/anim_filter.c56
-rw-r--r--source/blender/editors/animation/anim_intern.h2
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c2
-rw-r--r--source/blender/editors/animation/anim_markers.c16
-rw-r--r--source/blender/editors/animation/anim_ops.c2
-rw-r--r--source/blender/editors/animation/drivers.c12
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c43
-rw-r--r--source/blender/editors/animation/keyframes_draw.c8
-rw-r--r--source/blender/editors/animation/keyframes_edit.c8
-rw-r--r--source/blender/editors/animation/keyframes_general.c4
-rw-r--r--source/blender/editors/animation/keyframing.c77
-rw-r--r--source/blender/editors/animation/keyingsets.c42
-rw-r--r--source/blender/editors/armature/armature_ops.c4
-rw-r--r--source/blender/editors/armature/editarmature.c110
-rw-r--r--source/blender/editors/armature/editarmature_generate.c2
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c40
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c32
-rw-r--r--source/blender/editors/armature/meshlaplacian.c21
-rw-r--r--source/blender/editors/armature/poseSlide.c15
-rw-r--r--source/blender/editors/armature/poseUtils.c2
-rw-r--r--source/blender/editors/armature/poselib.c32
-rw-r--r--source/blender/editors/armature/poseobject.c28
-rw-r--r--source/blender/editors/armature/reeb.c48
-rw-r--r--source/blender/editors/armature/reeb.h2
-rw-r--r--source/blender/editors/curve/editcurve.c218
-rw-r--r--source/blender/editors/curve/editfont.c79
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c47
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c176
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h1
-rw-r--r--source/blender/editors/include/ED_mask.h4
-rw-r--r--source/blender/editors/include/ED_mball.h2
-rw-r--r--source/blender/editors/include/ED_mesh.h10
-rw-r--r--source/blender/editors/include/ED_object.h23
-rw-r--r--source/blender/editors/include/ED_screen_types.h2
-rw-r--r--source/blender/editors/include/ED_view3d.h127
-rw-r--r--source/blender/editors/include/UI_icons.h9
-rw-r--r--source/blender/editors/include/UI_interface.h6
-rw-r--r--source/blender/editors/include/UI_resources.h6
-rw-r--r--source/blender/editors/interface/interface.c157
-rw-r--r--source/blender/editors/interface/interface_draw.c54
-rw-r--r--source/blender/editors/interface/interface_handlers.c343
-rw-r--r--source/blender/editors/interface/interface_icons.c14
-rw-r--r--source/blender/editors/interface/interface_intern.h29
-rw-r--r--source/blender/editors/interface/interface_layout.c44
-rw-r--r--source/blender/editors/interface/interface_ops.c28
-rw-r--r--source/blender/editors/interface/interface_panel.c16
-rw-r--r--source/blender/editors/interface/interface_regions.c78
-rw-r--r--source/blender/editors/interface/interface_style.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c68
-rw-r--r--source/blender/editors/interface/interface_widgets.c81
-rw-r--r--source/blender/editors/interface/resources.c88
-rw-r--r--source/blender/editors/interface/view2d.c30
-rw-r--r--source/blender/editors/interface/view2d_ops.c52
-rw-r--r--source/blender/editors/io/io_collada.c4
-rw-r--r--source/blender/editors/mask/mask_add.c24
-rw-r--r--source/blender/editors/mask/mask_draw.c80
-rw-r--r--source/blender/editors/mask/mask_intern.h3
-rw-r--r--source/blender/editors/mask/mask_ops.c22
-rw-r--r--source/blender/editors/mask/mask_select.c5
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt9
-rw-r--r--source/blender/editors/mesh/SConscript8
-rw-r--r--source/blender/editors/mesh/editface.c12
-rw-r--r--source/blender/editors/mesh/editmesh_add.c24
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.c9
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c29
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c12
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c361
-rw-r--r--source/blender/editors/mesh/editmesh_select.c664
-rw-r--r--source/blender/editors/mesh/editmesh_slide.c25
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c509
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c13
-rw-r--r--source/blender/editors/mesh/mesh_data.c45
-rw-r--r--source/blender/editors/mesh/mesh_intern.h9
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c2
-rw-r--r--source/blender/editors/mesh/mesh_ops.c22
-rw-r--r--source/blender/editors/mesh/meshtools.c36
-rw-r--r--source/blender/editors/metaball/mball_edit.c4
-rw-r--r--source/blender/editors/object/object_add.c53
-rw-r--r--source/blender/editors/object/object_bake.c69
-rw-r--r--source/blender/editors/object/object_constraint.c24
-rw-r--r--source/blender/editors/object/object_edit.c14
-rw-r--r--source/blender/editors/object/object_group.c6
-rw-r--r--source/blender/editors/object/object_hook.c24
-rw-r--r--source/blender/editors/object/object_intern.h3
-rw-r--r--source/blender/editors/object/object_lattice.c278
-rw-r--r--source/blender/editors/object/object_modifier.c12
-rw-r--r--source/blender/editors/object/object_ops.c7
-rw-r--r--source/blender/editors/object/object_relations.c138
-rw-r--r--source/blender/editors/object/object_select.c12
-rw-r--r--source/blender/editors/object/object_shapekey.c8
-rw-r--r--source/blender/editors/object/object_transform.c70
-rw-r--r--source/blender/editors/object/object_vgroup.c635
-rw-r--r--source/blender/editors/physics/CMakeLists.txt5
-rw-r--r--source/blender/editors/physics/SConscript12
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c65
-rw-r--r--source/blender/editors/physics/particle_boids.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c112
-rw-r--r--source/blender/editors/physics/particle_object.c11
-rw-r--r--source/blender/editors/physics/physics_fluid.c42
-rw-r--r--source/blender/editors/physics/physics_ops.c2
-rw-r--r--source/blender/editors/physics/physics_pointcache.c6
-rw-r--r--source/blender/editors/render/render_internal.c22
-rw-r--r--source/blender/editors/render/render_opengl.c18
-rw-r--r--source/blender/editors/render/render_preview.c82
-rw-r--r--source/blender/editors/render/render_shading.c6
-rw-r--r--source/blender/editors/render/render_update.c62
-rw-r--r--source/blender/editors/render/render_view.c3
-rw-r--r--source/blender/editors/screen/area.c75
-rw-r--r--source/blender/editors/screen/glutil.c8
-rw-r--r--source/blender/editors/screen/screen_context.c4
-rw-r--r--source/blender/editors/screen/screen_edit.c19
-rw-r--r--source/blender/editors/screen/screen_ops.c128
-rw-r--r--source/blender/editors/screen/screendump.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c313
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c31
-rw-r--r--source/blender/editors/sculpt_paint/paint_undo.c12
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c114
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c23
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c4
-rw-r--r--source/blender/editors/space_action/action_draw.c6
-rw-r--r--source/blender/editors/space_action/action_edit.c75
-rw-r--r--source/blender/editors/space_action/action_intern.h4
-rw-r--r--source/blender/editors/space_action/action_ops.c5
-rw-r--r--source/blender/editors/space_action/action_select.c12
-rw-r--r--source/blender/editors/space_action/space_action.c6
-rw-r--r--source/blender/editors/space_api/spacetypes.c4
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c17
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c4
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/editors/space_clip/clip_draw.c28
-rw-r--r--source/blender/editors/space_clip/clip_editor.c5
-rw-r--r--source/blender/editors/space_clip/clip_ops.c36
-rw-r--r--source/blender/editors/space_clip/clip_utils.c22
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c63
-rw-r--r--source/blender/editors/space_clip/tracking_select.c9
-rw-r--r--source/blender/editors/space_console/console_draw.c15
-rw-r--r--source/blender/editors/space_console/console_ops.c24
-rw-r--r--source/blender/editors/space_console/space_console.c8
-rw-r--r--source/blender/editors/space_file/file_draw.c18
-rw-r--r--source/blender/editors/space_file/file_ops.c61
-rw-r--r--source/blender/editors/space_file/file_panels.c18
-rw-r--r--source/blender/editors/space_file/filelist.c67
-rw-r--r--source/blender/editors/space_file/filesel.c17
-rw-r--r--source/blender/editors/space_file/fsmenu.c41
-rw-r--r--source/blender/editors/space_file/fsmenu.h1
-rw-r--r--source/blender/editors/space_file/space_file.c8
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c45
-rw-r--r--source/blender/editors/space_graph/graph_draw.c40
-rw-r--r--source/blender/editors/space_graph/graph_edit.c90
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/editors/space_graph/graph_ops.c5
-rw-r--r--source/blender/editors/space_graph/graph_select.c8
-rw-r--r--source/blender/editors/space_graph/space_graph.c10
-rw-r--r--source/blender/editors/space_image/image_buttons.c13
-rw-r--r--source/blender/editors/space_image/image_draw.c4
-rw-r--r--source/blender/editors/space_image/image_edit.c4
-rw-r--r--source/blender/editors/space_image/image_ops.c73
-rw-r--r--source/blender/editors/space_image/space_image.c9
-rw-r--r--source/blender/editors/space_info/info_draw.c2
-rw-r--r--source/blender/editors/space_info/info_ops.c8
-rw-r--r--source/blender/editors/space_info/info_report.c8
-rw-r--r--source/blender/editors/space_info/space_info.c16
-rw-r--r--source/blender/editors/space_info/textview.c7
-rw-r--r--source/blender/editors/space_logic/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_logic/SConscript5
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c24
-rw-r--r--source/blender/editors/space_logic/logic_ops.c6
-rw-r--r--source/blender/editors/space_logic/logic_window.c159
-rw-r--r--source/blender/editors/space_logic/space_logic.c60
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c8
-rw-r--r--source/blender/editors/space_nla/nla_channels.c2
-rw-r--r--source/blender/editors/space_nla/nla_draw.c16
-rw-r--r--source/blender/editors/space_nla/nla_edit.c26
-rw-r--r--source/blender/editors/space_nla/nla_ops.c2
-rw-r--r--source/blender/editors/space_nla/nla_select.c6
-rw-r--r--source/blender/editors/space_node/drawnode.c192
-rw-r--r--source/blender/editors/space_node/node_add.c183
-rw-r--r--source/blender/editors/space_node/node_draw.c27
-rw-r--r--source/blender/editors/space_node/node_edit.c126
-rw-r--r--source/blender/editors/space_node/node_group.c54
-rw-r--r--source/blender/editors/space_node/node_header.c12
-rw-r--r--source/blender/editors/space_node/node_intern.h2
-rw-r--r--source/blender/editors/space_node/node_ops.c2
-rw-r--r--source/blender/editors/space_node/node_relationships.c4
-rw-r--r--source/blender/editors/space_node/node_select.c2
-rw-r--r--source/blender/editors/space_node/node_templates.c14
-rw-r--r--source/blender/editors/space_node/space_node.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c44
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c22
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c14
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c89
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c42
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_sequencer/SConscript7
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c25
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c60
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c9
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c4
-rw-r--r--source/blender/editors/space_text/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_text/SConscript3
-rw-r--r--source/blender/editors/space_text/space_text.c2
-rw-r--r--source/blender/editors/space_text/text_draw.c77
-rw-r--r--source/blender/editors/space_text/text_ops.c56
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_view3d/drawanimviz.c8
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c55
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c9
-rw-r--r--source/blender/editors/space_view3d/drawobject.c582
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c304
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c365
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c215
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c437
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c24
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h21
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c416
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c18
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c493
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c329
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c83
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c507
-rw-r--r--source/blender/editors/transform/transform.c203
-rw-r--r--source/blender/editors/transform/transform.h3
-rw-r--r--source/blender/editors/transform/transform_constraints.c2
-rw-r--r--source/blender/editors/transform/transform_conversions.c194
-rw-r--r--source/blender/editors/transform/transform_generics.c18
-rw-r--r--source/blender/editors/transform/transform_manipulator.c24
-rw-r--r--source/blender/editors/transform/transform_ops.c22
-rw-r--r--source/blender/editors/transform/transform_orientations.c11
-rw-r--r--source/blender/editors/transform/transform_snap.c169
-rw-r--r--source/blender/editors/util/crazyspace.c2
-rw-r--r--source/blender/editors/util/editmode_undo.c4
-rw-r--r--source/blender/editors/util/undo.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c54
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h25
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c59
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c12
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c84
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c150
-rw-r--r--source/blender/gpu/GPU_buffers.h45
-rw-r--r--source/blender/gpu/GPU_draw.h4
-rw-r--r--source/blender/gpu/GPU_extensions.h4
-rw-r--r--source/blender/gpu/GPU_material.h3
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c289
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c38
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h6
-rw-r--r--source/blender/gpu/intern/gpu_deprecated.h5
-rw-r--r--source/blender/gpu/intern/gpu_draw.c92
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c20
-rw-r--r--source/blender/gpu/intern/gpu_material.c12
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl46
-rw-r--r--source/blender/ikplugin/BIK_api.h5
-rw-r--r--source/blender/ikplugin/CMakeLists.txt4
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.c2
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.h3
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.h3
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp2
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.h3
-rw-r--r--source/blender/imbuf/CMakeLists.txt27
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h3
-rw-r--r--source/blender/imbuf/IMB_imbuf.h4
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h10
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h4
-rw-r--r--source/blender/imbuf/intern/IMB_filetype.h6
-rw-r--r--source/blender/imbuf/intern/IMB_indexer.h2
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c2
-rw-r--r--source/blender/imbuf/intern/anim_movie.c24
-rw-r--r--source/blender/imbuf/intern/bmp.c2
-rw-r--r--source/blender/imbuf/intern/cineon/CMakeLists.txt14
-rw-r--r--source/blender/imbuf/intern/cineon/SConscript3
-rw-r--r--source/blender/imbuf/intern/cineon/cin_debug_stuff.h4
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c228
-rw-r--r--source/blender/imbuf/intern/cineon/cineonfile.h134
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c1007
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.h150
-rw-r--r--source/blender/imbuf/intern/cineon/dpxfile.h128
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c978
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.h162
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c1576
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.h322
-rw-r--r--source/blender/imbuf/intern/cineon/logImageLib.c183
-rw-r--r--source/blender/imbuf/intern/cineon/logImageLib.h87
-rw-r--r--source/blender/imbuf/intern/cineon/logmemfile.c142
-rw-r--r--source/blender/imbuf/intern/cineon/logmemfile.h50
-rw-r--r--source/blender/imbuf/intern/colormanagement.c58
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.cpp4
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.h38
-rw-r--r--source/blender/imbuf/intern/dds/CMakeLists.txt14
-rw-r--r--source/blender/imbuf/intern/dds/Color.h2
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.cpp2
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.h2
-rw-r--r--source/blender/imbuf/intern/dds/Common.h6
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp256
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.h4
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.cpp255
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.h32
-rw-r--r--source/blender/imbuf/intern/dds/Image.h2
-rw-r--r--source/blender/imbuf/intern/dds/PixelFormat.h64
-rw-r--r--source/blender/imbuf/intern/dds/SConscript2
-rw-r--r--source/blender/imbuf/intern/dds/Stream.h5
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp8
-rw-r--r--source/blender/imbuf/intern/divers.c33
-rw-r--r--source/blender/imbuf/intern/filetype.c4
-rw-r--r--source/blender/imbuf/intern/imageprocess.c2
-rw-r--r--source/blender/imbuf/intern/indexer.c33
-rw-r--r--source/blender/imbuf/intern/iris.c4
-rw-r--r--source/blender/imbuf/intern/jp2.c6
-rw-r--r--source/blender/imbuf/intern/jpeg.c14
-rw-r--r--source/blender/imbuf/intern/openexr/CMakeLists.txt5
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp6
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_stub.cpp34
-rw-r--r--source/blender/imbuf/intern/png.c3
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c3
-rw-r--r--source/blender/imbuf/intern/readimage.c6
-rw-r--r--source/blender/imbuf/intern/rectop.c10
-rw-r--r--source/blender/imbuf/intern/scaling.c14
-rw-r--r--source/blender/imbuf/intern/targa.c4
-rw-r--r--source/blender/imbuf/intern/thumbs.c12
-rw-r--r--source/blender/imbuf/intern/thumbs_blend.c2
-rw-r--r--source/blender/imbuf/intern/util.c13
-rw-r--r--source/blender/makesdna/DNA_action_types.h1
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h32
-rw-r--r--source/blender/makesdna/DNA_anim_types.h210
-rw-r--r--source/blender/makesdna/DNA_armature_types.h184
-rw-r--r--source/blender/makesdna/DNA_boid_types.h26
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h2
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h10
-rw-r--r--source/blender/makesdna/DNA_curve_types.h11
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h4
-rw-r--r--source/blender/makesdna/DNA_genfile.h6
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h6
-rw-r--r--source/blender/makesdna/DNA_image_types.h1
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h2
-rw-r--r--source/blender/makesdna/DNA_lamp_types.h2
-rw-r--r--source/blender/makesdna/DNA_mask_types.h2
-rw-r--r--source/blender/makesdna/DNA_material_types.h5
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h2
-rw-r--r--source/blender/makesdna/DNA_meta_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h47
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h56
-rw-r--r--source/blender/makesdna/DNA_nla_types.h2
-rw-r--r--source/blender/makesdna/DNA_node_types.h55
-rw-r--r--source/blender/makesdna/DNA_object_force.h15
-rw-r--r--source/blender/makesdna/DNA_object_types.h25
-rw-r--r--source/blender/makesdna/DNA_packedFile_types.h10
-rw-r--r--source/blender/makesdna/DNA_scene_types.h43
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h3
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h111
-rw-r--r--source/blender/makesdna/DNA_space_types.h6
-rw-r--r--source/blender/makesdna/DNA_texture_types.h13
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h162
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h443
-rw-r--r--source/blender/makesdna/DNA_view2d_types.h2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h2
-rw-r--r--source/blender/makesdna/DNA_world_types.h6
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c4
-rw-r--r--source/blender/makesdna/intern/makesdna.c34
-rw-r--r--source/blender/makesrna/RNA_access.h11
-rw-r--r--source/blender/makesrna/RNA_types.h2
-rw-r--r--source/blender/makesrna/intern/makesrna.c886
-rw-r--r--source/blender/makesrna/intern/rna_ID.c8
-rw-r--r--source/blender/makesrna/intern/rna_access.c61
-rw-r--r--source/blender/makesrna/intern/rna_action.c122
-rw-r--r--source/blender/makesrna/intern/rna_animation.c98
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_armature.c18
-rw-r--r--source/blender/makesrna/intern/rna_boid.c10
-rw-r--r--source/blender/makesrna/intern/rna_brush.c4
-rw-r--r--source/blender/makesrna/intern/rna_camera.c2
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c12
-rw-r--r--source/blender/makesrna/intern/rna_color.c75
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c7
-rw-r--r--source/blender/makesrna/intern/rna_controller.c2
-rw-r--r--source/blender/makesrna/intern/rna_curve.c58
-rw-r--r--source/blender/makesrna/intern/rna_define.c71
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c24
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c283
-rw-r--r--source/blender/makesrna/intern/rna_group.c4
-rw-r--r--source/blender/makesrna/intern/rna_image.c23
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c29
-rw-r--r--source/blender/makesrna/intern/rna_internal.h11
-rw-r--r--source/blender/makesrna/intern/rna_lattice.c8
-rw-r--r--source/blender/makesrna/intern/rna_main.c2
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c410
-rw-r--r--source/blender/makesrna/intern/rna_mask.c13
-rw-r--r--source/blender/makesrna/intern/rna_material.c38
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c19
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_meta.c16
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c172
-rw-r--r--source/blender/makesrna/intern/rna_nla.c24
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c439
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h9
-rw-r--r--source/blender/makesrna/intern/rna_object.c152
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c32
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c30
-rw-r--r--source/blender/makesrna/intern/rna_particle.c12
-rw-r--r--source/blender/makesrna/intern/rna_pose.c40
-rw-r--r--source/blender/makesrna/intern/rna_render.c41
-rw-r--r--source/blender/makesrna/intern/rna_rna.c2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c106
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c44
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c23
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c31
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c72
-rw-r--r--source/blender/makesrna/intern/rna_smoke.c251
-rw-r--r--source/blender/makesrna/intern/rna_space.c77
-rw-r--r--source/blender/makesrna/intern/rna_texture.c5
-rw-r--r--source/blender/makesrna/intern/rna_texture_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c72
-rw-r--r--source/blender/makesrna/intern/rna_ui.c8
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c35
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c111
-rw-r--r--source/blender/makesrna/intern/rna_wm.c55
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c47
-rwxr-xr-xsource/blender/makesrna/rna_cleanup/rna_cleaner.py12
-rw-r--r--source/blender/modifiers/CMakeLists.txt9
-rw-r--r--source/blender/modifiers/MOD_modifiertypes.h3
-rw-r--r--source/blender/modifiers/SConscript5
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c8
-rw-r--r--source/blender/modifiers/intern/MOD_array.c62
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c80
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c48
-rw-r--r--source/blender/modifiers/intern/MOD_boolean_util.c4
-rw-r--r--source/blender/modifiers/intern/MOD_boolean_util.h2
-rw-r--r--source/blender/modifiers/intern/MOD_build.c44
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c4
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c217
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c8
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c14
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c62
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c703
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c4
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c6
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c54
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c3
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c22
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c89
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c10
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c2
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c12
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c1
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c50
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c14
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c92
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c59
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c20
-rw-r--r--source/blender/modifiers/intern/MOD_util.c5
-rw-r--r--source/blender/modifiers/intern/MOD_util.h12
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c50
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c10
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c32
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c16
-rw-r--r--source/blender/nodes/CMakeLists.txt43
-rw-r--r--source/blender/nodes/NOD_composite.h6
-rw-r--r--source/blender/nodes/NOD_shader.h7
-rw-r--r--source/blender/nodes/NOD_socket.h1
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c4
-rw-r--r--source/blender/nodes/composite/node_composite_util.c138
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_alphaOver.c32
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehimage.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_boxmask.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_brightness.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_channelMatte.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_chromaMatte.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorMatte.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorSpill.c11
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorcorrection.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.c150
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_composite.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_crop.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_curves.c22
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_defocus.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_despeckle.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_diffMatte.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_dilate.c16
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_displace.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_distanceMatte.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_ellipsemask.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_filter.c44
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_flip.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_gamma.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_glare.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_hueSatVal.c14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_huecorrect.c14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_idMask.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_invert.c14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_keyingscreen.c27
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_lensdist.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_levels.c14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_lummaMatte.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mapUV.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mapValue.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_math.c71
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mixrgb.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_normal.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_normalize.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_pixelate.c57
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_premulkey.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_rgb.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_rotate.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c16
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c34
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c16
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_setalpha.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_splitViewer.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_stabilize2d.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switch.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_texture.c22
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_tonemap.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_translate.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_valToRgb.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_value.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_zcombine.c50
-rw-r--r--source/blender/nodes/intern/node_common.c179
-rw-r--r--source/blender/nodes/intern/node_common.h12
-rw-r--r--source/blender/nodes/intern/node_exec.c41
-rw-r--r--source/blender/nodes/intern/node_exec.h2
-rw-r--r--source/blender/nodes/intern/node_socket.c56
-rw-r--r--source/blender/nodes/intern/node_util.c17
-rw-r--r--source/blender/nodes/intern/node_util.h2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c5
-rw-r--r--source/blender/nodes/shader/node_shader_util.c16
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_add_shader.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c63
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_background.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_brightness.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c18
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c11
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c68
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bump.c68
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_camera.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c125
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_emission.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_fresnel.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_gamma.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geom.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geometry.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_holdout.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hueSatVal.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_invert.c14
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_layer_weight.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_falloff.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_path.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c16
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_material.c26
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c130
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mix_shader.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c70
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_object_info.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_lamp.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_material.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_world.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c24
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c86
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_squeeze.c21
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c60
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_brick.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_checker.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_coord.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c23
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_gradient.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c23
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_magic.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_noise.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_wave.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_texture.c31
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c77
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_transparent.c4
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c30
-rw-r--r--source/blender/nodes/texture/node_texture_util.c22
-rw-r--r--source/blender/nodes/texture/node_texture_util.h6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_at.c4
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_bricks.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_checker.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c125
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_compose.c4
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_coord.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_decompose.c4
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_distance.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_hueSatVal.c14
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_invert.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_mixRgb.c4
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c6
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c30
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_rotate.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_scale.c10
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_texture.c4
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_translate.c10
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToNor.c14
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToRgb.c8
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_viewer.c2
-rw-r--r--source/blender/opencl/CMakeLists.txt1
-rw-r--r--source/blender/python/BPY_extern.h1
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.h2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.c2
-rw-r--r--source/blender/python/generic/bgl.c4
-rw-r--r--source/blender/python/generic/bpy_internal_import.c18
-rw-r--r--source/blender/python/generic/idprop_py_api.c155
-rw-r--r--source/blender/python/generic/idprop_py_api.h11
-rw-r--r--source/blender/python/generic/py_capi_utils.c4
-rw-r--r--source/blender/python/generic/py_capi_utils.h2
-rw-r--r--source/blender/python/intern/CMakeLists.txt4
-rw-r--r--source/blender/python/intern/bpy.c7
-rw-r--r--source/blender/python/intern/bpy_app.c1
-rw-r--r--source/blender/python/intern/bpy_app.h2
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.h2
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c2
-rw-r--r--source/blender/python/intern/bpy_app_handlers.h2
-rw-r--r--source/blender/python/intern/bpy_driver.c2
-rw-r--r--source/blender/python/intern/bpy_driver.h2
-rw-r--r--source/blender/python/intern/bpy_interface.c20
-rw-r--r--source/blender/python/intern/bpy_props.c28
-rw-r--r--source/blender/python/intern/bpy_rna.c148
-rw-r--r--source/blender/python/intern/bpy_rna.h1
-rw-r--r--source/blender/python/intern/bpy_rna_array.c5
-rw-r--r--source/blender/python/intern/bpy_traceback.h2
-rw-r--r--source/blender/python/intern/bpy_util.c21
-rw-r--r--source/blender/python/intern/bpy_util.h14
-rw-r--r--source/blender/python/mathutils/mathutils.c4
-rw-r--r--source/blender/python/mathutils/mathutils_Color.c144
-rw-r--r--source/blender/python/mathutils/mathutils_Color.h4
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c146
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.h2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c181
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c162
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.h2
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c18
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c8
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c1
-rw-r--r--source/blender/python/mathutils/mathutils_noise.h2
-rw-r--r--source/blender/python/rna_dump.py4
-rw-r--r--source/blender/quicktime/apple/qtkit_export.m56
-rw-r--r--source/blender/quicktime/apple/qtkit_import.m71
-rw-r--r--source/blender/quicktime/apple/quicktime_export.c60
-rw-r--r--source/blender/quicktime/quicktime_export.h8
-rw-r--r--source/blender/quicktime/quicktime_import.h34
-rw-r--r--source/blender/render/extern/include/RE_engine.h7
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h7
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h8
-rw-r--r--source/blender/render/intern/include/envmap.h2
-rw-r--r--source/blender/render/intern/include/pointdensity.h2
-rw-r--r--source/blender/render/intern/include/rayobject.h2
-rw-r--r--source/blender/render/intern/include/render_types.h11
-rw-r--r--source/blender/render/intern/include/rendercore.h5
-rw-r--r--source/blender/render/intern/include/renderdatabase.h2
-rw-r--r--source/blender/render/intern/include/shadbuf.h18
-rw-r--r--source/blender/render/intern/include/shading.h2
-rw-r--r--source/blender/render/intern/include/sunsky.h5
-rw-r--r--source/blender/render/intern/include/texture_ocean.h7
-rw-r--r--source/blender/render/intern/include/volume_precache.h4
-rw-r--r--source/blender/render/intern/raytrace/bvh.h2
-rw-r--r--source/blender/render/intern/raytrace/rayobject.cpp2
-rw-r--r--source/blender/render/intern/raytrace/rayobject_blibvh.cpp4
-rw-r--r--source/blender/render/intern/raytrace/rayobject_instance.cpp2
-rw-r--r--source/blender/render/intern/raytrace/rayobject_internal.h9
-rw-r--r--source/blender/render/intern/raytrace/rayobject_octree.cpp8
-rw-r--r--source/blender/render/intern/raytrace/rayobject_qbvh.cpp2
-rw-r--r--source/blender/render/intern/raytrace/rayobject_raycounter.cpp4
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.cpp44
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.h13
-rw-r--r--source/blender/render/intern/raytrace/rayobject_vbvh.cpp4
-rw-r--r--source/blender/render/intern/raytrace/reorganize.h20
-rw-r--r--source/blender/render/intern/raytrace/svbvh.h36
-rw-r--r--source/blender/render/intern/raytrace/vbvh.h2
-rw-r--r--source/blender/render/intern/source/convertblender.c161
-rw-r--r--source/blender/render/intern/source/envmap.c40
-rw-r--r--source/blender/render/intern/source/external_engine.c37
-rw-r--r--source/blender/render/intern/source/gammaCorrectionTables.c8
-rw-r--r--source/blender/render/intern/source/imagetexture.c121
-rw-r--r--source/blender/render/intern/source/initrender.c27
-rw-r--r--source/blender/render/intern/source/occlusion.c13
-rw-r--r--source/blender/render/intern/source/pipeline.c78
-rw-r--r--source/blender/render/intern/source/pixelshading.c4
-rw-r--r--source/blender/render/intern/source/pointdensity.c13
-rw-r--r--source/blender/render/intern/source/rayshade.c28
-rw-r--r--source/blender/render/intern/source/render_result.c2
-rw-r--r--source/blender/render/intern/source/render_texture.c386
-rw-r--r--source/blender/render/intern/source/rendercore.c117
-rw-r--r--source/blender/render/intern/source/renderdatabase.c50
-rw-r--r--source/blender/render/intern/source/shadbuf.c52
-rw-r--r--source/blender/render/intern/source/shadeinput.c18
-rw-r--r--source/blender/render/intern/source/shadeoutput.c85
-rw-r--r--source/blender/render/intern/source/sss.c10
-rw-r--r--source/blender/render/intern/source/strand.c14
-rw-r--r--source/blender/render/intern/source/sunsky.c9
-rw-r--r--source/blender/render/intern/source/texture_ocean.c2
-rw-r--r--source/blender/render/intern/source/volume_precache.c10
-rw-r--r--source/blender/render/intern/source/volumetric.c6
-rw-r--r--source/blender/render/intern/source/voxeldata.c173
-rw-r--r--source/blender/render/intern/source/zbuf.c56
-rw-r--r--source/blender/windowmanager/CMakeLists.txt2
-rw-r--r--source/blender/windowmanager/WM_api.h12
-rw-r--r--source/blender/windowmanager/WM_keymap.h6
-rw-r--r--source/blender/windowmanager/WM_types.h21
-rw-r--r--source/blender/windowmanager/intern/wm.c2
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c10
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c2
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c6
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c520
-rw-r--r--source/blender/windowmanager/intern/wm_files.c32
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c13
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c48
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c72
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c160
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c63
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c8
-rw-r--r--source/blender/windowmanager/intern/wm_window.c23
-rw-r--r--source/blender/windowmanager/wm_event_system.h70
-rw-r--r--source/blender/windowmanager/wm_event_types.h3
1101 files changed, 35986 insertions, 19841 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 92785804b01..ae3f3dce396 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -101,7 +101,6 @@ add_subdirectory(blenloader)
add_subdirectory(ikplugin)
add_subdirectory(gpu)
add_subdirectory(imbuf)
-add_subdirectory(avi)
add_subdirectory(nodes)
add_subdirectory(modifiers)
add_subdirectory(makesdna)
@@ -124,6 +123,10 @@ if(WITH_IMAGE_CINEON)
add_subdirectory(imbuf/intern/cineon)
endif()
+if(WITH_CODEC_AVI)
+ add_subdirectory(avi)
+endif()
+
if(WITH_CODEC_QUICKTIME)
add_subdirectory(quicktime)
endif()
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c
index 15d8702a5ec..d6301b723a7 100644
--- a/source/blender/avi/intern/avi.c
+++ b/source/blender/avi/intern/avi.c
@@ -94,7 +94,7 @@ char *fcc_to_char(unsigned int fcc)
DEBUG_FCC[2] = (fcc >> 16) & 127;
DEBUG_FCC[3] = (fcc >> 24) & 127;
- return DEBUG_FCC;
+ return DEBUG_FCC;
}
char *tcc_to_char(unsigned int tcc)
@@ -104,7 +104,7 @@ char *tcc_to_char(unsigned int tcc)
DEBUG_FCC[2] = 0;
DEBUG_FCC[3] = 0;
- return DEBUG_FCC;
+ return DEBUG_FCC;
}
int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num)
@@ -302,7 +302,7 @@ int AVI_is_avi(const char *name)
MEM_freeN(movie.streams);
fclose(movie.fp);
- return 0;
+ return 0;
}
movie.streams[temp].sh.Type = GET_FCC(movie.fp);
@@ -401,12 +401,12 @@ int AVI_is_avi(const char *name)
}
}
- }
+ }
if (j > 0) fseek(movie.fp, j, SEEK_CUR);
}
else fseek(movie.fp, movie.streams[temp].sf_size, SEEK_CUR);
- /* Walk to the next LIST */
+ /* Walk to the next LIST */
while (GET_FCC(movie.fp) != FCC("LIST")) {
temp = GET_FCC(movie.fp);
if (temp < 0 || ftell(movie.fp) > movie.size) {
@@ -414,9 +414,9 @@ int AVI_is_avi(const char *name)
MEM_freeN(movie.streams);
fclose(movie.fp);
- return 0;
+ return 0;
}
- fseek(movie.fp, temp, SEEK_CUR);
+ fseek(movie.fp, temp, SEEK_CUR);
}
fseek(movie.fp, -4L, SEEK_CUR);
@@ -592,12 +592,12 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
}
}
- }
+ }
if (j > 0) fseek(movie->fp, j, SEEK_CUR);
}
else fseek(movie->fp, movie->streams[temp].sf_size, SEEK_CUR);
- /* Walk to the next LIST */
+ /* Walk to the next LIST */
while (GET_FCC(movie->fp) != FCC("LIST")) {
temp = GET_FCC(movie->fp);
if (temp < 0 || ftell(movie->fp) > movie->size) {
@@ -665,13 +665,13 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
}
}
-/* Some AVI's have offset entries in absolute coordinates
- * instead of an offset from the movie beginning... this is...
- * wacky, but we need to handle it. The wacky offset always
- * starts at movi_offset it seems... so we'll check that.
- * Note the the offset needs an extra 4 bytes for some
- * undetermined reason */
-
+ /* Some AVI's have offset entries in absolute coordinates
+ * instead of an offset from the movie beginning... this is...
+ * wacky, but we need to handle it. The wacky offset always
+ * starts at movi_offset it seems... so we'll check that.
+ * Note the the offset needs an extra 4 bytes for some
+ * undetermined reason */
+
if (movie->entries[0].Offset == movie->movi_offset)
movie->read_offset = 4;
}
@@ -827,7 +827,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...)
movie->streams[i].sh.right = 0;
movie->streams[i].sh.bottom = 0;
- if (movie->streams[i].sh.Type == FCC("vids")) {
+ if (movie->streams[i].sh.Type == FCC("vids")) {
#if 0
if (movie->streams[i].format == AVI_FORMAT_MJPEG) {
movie->streams[i].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader) +
diff --git a/source/blender/avi/intern/avi_mjpeg.c b/source/blender/avi/intern/avi_mjpeg.c
index b98e03d6a19..396f1199cd9 100644
--- a/source/blender/avi/intern/avi_mjpeg.c
+++ b/source/blender/avi/intern/avi_mjpeg.c
@@ -73,7 +73,7 @@ static void std_huff_tables(j_decompress_ptr dinfo)
0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
};
static const UINT8 val_dc_luminance[] =
- {
+ {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
@@ -82,7 +82,7 @@ static void std_huff_tables(j_decompress_ptr dinfo)
0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
};
static const UINT8 val_dc_chrominance[] =
- {
+ {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
@@ -91,7 +91,7 @@ static void std_huff_tables(j_decompress_ptr dinfo)
0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
};
static const UINT8 val_ac_luminance[] =
- {
+ {
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
@@ -119,7 +119,7 @@ static void std_huff_tables(j_decompress_ptr dinfo)
0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
};
static const UINT8 val_ac_chrominance[] =
- {
+ {
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
@@ -393,7 +393,7 @@ void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer,
numbytes = 0;
check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf + *size, buffer + (movie->header->Height / 2) * movie->header->Width * 3, movie->header->Width, movie->header->Height / 2, bufsize / 2);
}
- *size += numbytes;
+ *size += numbytes;
MEM_freeN(buffer);
return buf;
diff --git a/source/blender/avi/intern/avi_rgb.c b/source/blender/avi/intern/avi_rgb.c
index 61587e15e61..11d9bdf8612 100644
--- a/source/blender/avi/intern/avi_rgb.c
+++ b/source/blender/avi/intern/avi_rgb.c
@@ -86,7 +86,7 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buf
*(to++) = ((*pxl >> 10) & 0x1f) * 8;
*(to++) = ((*pxl >> 5) & 0x1f) * 8;
*(to++) = (*pxl & 0x1f) * 8;
- pxl++;
+ pxl++;
}
}
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 702023fa555..69147ac2156 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -116,6 +116,7 @@ float BLF_fixed_width(int fontid);
* of the string, using the default font and both value
* are multiplied by the aspect of the font.
*/
+void BLF_width_and_height_default(const char *str, float *width, float *height);
float BLF_width_default(const char *str);
float BLF_height_default(const char *str);
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h
index 278c45dac52..b01ce93cb65 100644
--- a/source/blender/blenfont/BLF_translation.h
+++ b/source/blender/blenfont/BLF_translation.h
@@ -49,9 +49,13 @@ const char *BLF_pgettext(const char *context, const char *message);
/* Search the path directory to the locale files, this try all
* the case for Linux, Win and Mac.
+ * Also dynamically builds locales and locales' menu from "languages" text file.
*/
void BLF_lang_init(void);
+/* Free languages and locales_menu arrays created by BLF_lang_init. */
+void BLF_lang_free(void);
+
/* Set the current locale. */
void BLF_lang_set(const char *);
/* Get the current locale (short code, e.g. es_ES). */
@@ -60,6 +64,9 @@ const char *BLF_lang_get(void);
/* Set the current encoding name. */
void BLF_lang_encoding(const char *str);
+/* Get EnumPropertyItem's for translations menu. */
+struct EnumPropertyItem *BLF_RNA_lang_enum_properties(void);
+
/* translation */
int BLF_translate_iface(void);
int BLF_translate_tooltips(void);
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index 90c2e36a762..40d5d6c75f2 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -25,8 +25,10 @@ set(INC
.
../blenkernel
../blenlib
+ ../blenloader
../editors/include
../makesdna
+ ../makesrna
../imbuf
../../../intern/guardedalloc
../gpu
diff --git a/source/blender/blenfont/SConscript b/source/blender/blenfont/SConscript
index 93368088a61..9971adb885b 100644
--- a/source/blender/blenfont/SConscript
+++ b/source/blender/blenfont/SConscript
@@ -4,7 +4,8 @@ Import ('env')
sources = env.Glob('intern/*.c')
-incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../imbuf ../editors/include ../gpu'
+incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../blenloader'
+incs += ' ../makesdna ../makesrna ../imbuf ../editors/include ../gpu'
incs += ' #/extern/glew/include'
incs += ' ' + env['BF_FREETYPE_INC']
incs += ' ' + env['BF_GETTEXT_INC']
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 7e41d2874f0..27db65f87ac 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -70,7 +70,7 @@ static int global_font_dpi = 72;
int blf_mono_font = -1;
int blf_mono_font_render = -1;
-static FontBLF *BLF_get(int fontid)
+static FontBLF *blf_get(int fontid)
{
if (fontid >= 0 && fontid < BLF_MAX_FONT)
return global_font[fontid];
@@ -142,6 +142,21 @@ static int blf_search_available(void)
return -1;
}
+static int blf_global_font_init(void)
+{
+ if (global_font_default == -1) {
+ global_font_default = blf_search("default");
+ }
+
+ if (global_font_default == -1) {
+ printf("Warning: Can't find default font!\n");
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+}
+
int BLF_load(const char *name)
{
FontBLF *font;
@@ -220,7 +235,7 @@ int BLF_load_unique(const char *name)
void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
blf_font_attach_from_mem(font, mem, mem_size);
@@ -312,7 +327,7 @@ void BLF_unload(const char *name)
void BLF_enable(int fontid, int option)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->flags |= option;
@@ -321,7 +336,7 @@ void BLF_enable(int fontid, int option)
void BLF_disable(int fontid, int option)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->flags &= ~option;
@@ -330,7 +345,7 @@ void BLF_disable(int fontid, int option)
void BLF_enable_default(int option)
{
- FontBLF *font = BLF_get(global_font_default);
+ FontBLF *font = blf_get(global_font_default);
if (font) {
font->flags |= option;
@@ -339,7 +354,7 @@ void BLF_enable_default(int option)
void BLF_disable_default(int option)
{
- FontBLF *font = BLF_get(global_font_default);
+ FontBLF *font = blf_get(global_font_default);
if (font) {
font->flags &= ~option;
@@ -348,7 +363,7 @@ void BLF_disable_default(int option)
void BLF_aspect(int fontid, float x, float y, float z)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->aspect[0] = x;
@@ -359,7 +374,7 @@ void BLF_aspect(int fontid, float x, float y, float z)
void BLF_matrix(int fontid, const double m[16])
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
memcpy(font->m, m, sizeof(font->m));
@@ -368,7 +383,7 @@ void BLF_matrix(int fontid, const double m[16])
void BLF_position(int fontid, float x, float y, float z)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
float xa, ya, za;
@@ -417,7 +432,7 @@ void BLF_position(int fontid, float x, float y, float z)
void BLF_size(int fontid, int size, int dpi)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
blf_font_size(font, size, dpi);
@@ -426,44 +441,30 @@ void BLF_size(int fontid, int size, int dpi)
void BLF_blur(int fontid, int size)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->blur = size;
}
}
-static int get_default(void)
-{
- if (global_font_default == -1) {
- global_font_default = blf_search("default");
-
- if (global_font_default == -1) {
- printf("Warning: Can't found default font!!\n");
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
void BLF_draw_default_lock(void)
{
- if (get_default()) {
+ if (blf_global_font_init()) {
BLF_draw_lock(global_font_default);
}
}
void BLF_draw_default_unlock(void)
{
- if (get_default()) {
+ if (blf_global_font_init()) {
BLF_draw_unlock(global_font_default);
}
}
void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
{
- if (str && get_default()) {
+ if (str && blf_global_font_init()) {
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, len);
@@ -473,7 +474,7 @@ void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
/* same as above but call 'BLF_draw_ascii' */
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
{
- if (str && get_default()) {
+ if (str && blf_global_font_init()) {
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, len); /* XXX, use real length */
}
@@ -481,7 +482,7 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l
void BLF_rotation_default(float angle)
{
- FontBLF *font = BLF_get(global_font_default);
+ FontBLF *font = blf_get(global_font_default);
if (font) {
font->angle = angle;
@@ -530,12 +531,12 @@ static void draw_unlock(FontBLF *font)
void BLF_draw_lock(int fontid)
{
- draw_lock(BLF_get(fontid));
+ draw_lock(blf_get(fontid));
}
void BLF_draw_unlock(int fontid)
{
- draw_unlock(BLF_get(fontid));
+ draw_unlock(blf_get(fontid));
}
static void blf_draw__start(FontBLF *font)
@@ -603,7 +604,7 @@ static void blf_draw__end(FontBLF *font)
void BLF_draw(int fontid, const char *str, size_t len)
{
if (len > 0 && str[0]) {
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
blf_draw__start(font);
@@ -616,7 +617,7 @@ void BLF_draw(int fontid, const char *str, size_t len)
void BLF_draw_ascii(int fontid, const char *str, size_t len)
{
if (len > 0 && str[0]) {
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
blf_draw__start(font);
@@ -628,7 +629,7 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len)
void BLF_boundbox(int fontid, const char *str, rctf *box)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
blf_font_boundbox(font, str, box);
@@ -637,16 +638,29 @@ void BLF_boundbox(int fontid, const char *str, rctf *box)
void BLF_width_and_height(int fontid, const char *str, float *width, float *height)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
blf_font_width_and_height(font, str, width, height);
}
+ else {
+ *width = *height = 0.0f;
+ }
+}
+
+void BLF_width_and_height_default(const char *str, float *width, float *height)
+{
+ if (!blf_global_font_init()) {
+ *width = *height = 0.0f;
+ return;
+ }
+
+ BLF_width_and_height(global_font_default, str, width, height);
}
float BLF_width(int fontid, const char *str)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return blf_font_width(font, str);
@@ -657,7 +671,7 @@ float BLF_width(int fontid, const char *str)
float BLF_fixed_width(int fontid)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return blf_font_fixed_width(font);
@@ -668,13 +682,8 @@ float BLF_fixed_width(int fontid)
float BLF_width_default(const char *str)
{
- if (global_font_default == -1)
- global_font_default = blf_search("default");
-
- if (global_font_default == -1) {
- printf("Error: Can't found default font!!\n");
+ if (!blf_global_font_init())
return 0.0f;
- }
BLF_size(global_font_default, global_font_points, global_font_dpi);
return BLF_width(global_font_default, str);
@@ -682,7 +691,7 @@ float BLF_width_default(const char *str)
float BLF_height(int fontid, const char *str)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return blf_font_height(font, str);
@@ -693,7 +702,7 @@ float BLF_height(int fontid, const char *str)
float BLF_height_max(int fontid)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return font->glyph_cache->max_glyph_height;
@@ -704,7 +713,7 @@ float BLF_height_max(int fontid)
float BLF_width_max(int fontid)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return font->glyph_cache->max_glyph_width;
@@ -715,7 +724,7 @@ float BLF_width_max(int fontid)
float BLF_descender(int fontid)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return font->glyph_cache->descender;
@@ -726,7 +735,7 @@ float BLF_descender(int fontid)
float BLF_ascender(int fontid)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
return font->glyph_cache->ascender;
@@ -737,13 +746,8 @@ float BLF_ascender(int fontid)
float BLF_height_default(const char *str)
{
- if (global_font_default == -1)
- global_font_default = blf_search("default");
-
- if (global_font_default == -1) {
- printf("Error: Can't found default font!!\n");
+ if (!blf_global_font_init())
return 0.0f;
- }
BLF_size(global_font_default, global_font_points, global_font_dpi);
@@ -752,7 +756,7 @@ float BLF_height_default(const char *str)
void BLF_rotation(int fontid, float angle)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->angle = angle;
@@ -761,7 +765,7 @@ void BLF_rotation(int fontid, float angle)
void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->clip_rec.xmin = xmin;
@@ -773,7 +777,7 @@ void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax)
void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax)
{
- FontBLF *font = BLF_get(global_font_default);
+ FontBLF *font = blf_get(global_font_default);
if (font) {
font->clip_rec.xmin = xmin;
@@ -785,7 +789,7 @@ void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax)
void BLF_shadow(int fontid, int level, float r, float g, float b, float a)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->shadow = level;
@@ -798,7 +802,7 @@ void BLF_shadow(int fontid, int level, float r, float g, float b, float a)
void BLF_shadow_offset(int fontid, int x, int y)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->shadow_x = x;
@@ -808,7 +812,7 @@ void BLF_shadow_offset(int fontid, int x, int y)
void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->buf_info.fbuf = fbuf;
@@ -822,7 +826,7 @@ void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int
void BLF_buffer_col(int fontid, float r, float g, float b, float a)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font) {
font->buf_info.col[0] = r;
@@ -834,7 +838,7 @@ void BLF_buffer_col(int fontid, float r, float g, float b, float a)
void BLF_draw_buffer(int fontid, const char *str)
{
- FontBLF *font = BLF_get(fontid);
+ FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache && (font->buf_info.fbuf || font->buf_info.cbuf)) {
blf_font_buffer(font, str);
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index b694f1fafa7..f02d4a25554 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -35,30 +35,26 @@
#include "BKE_global.h"
#include "BLF_api.h"
-
#include "BLF_translation.h" /* own include */
#ifdef WITH_INTERNATIONAL
#include <locale.h>
-#if defined(_WIN32)
-#include <windows.h>
-#endif
-
#include "libintl.h"
#include "DNA_userdef_types.h"
-#include "DNA_listBase.h"
-#include "DNA_vec_types.h"
+#include "RNA_types.h"
#include "MEM_guardedalloc.h"
-#include "BLI_linklist.h" /* linknode */
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
+#include "BLI_fileops.h"
+#include "BLI_linklist.h"
+#include "BLI_string.h"
#define SYSTEM_ENCODING_DEFAULT "UTF-8"
#define FONT_SIZE_DEFAULT 12
@@ -68,48 +64,144 @@ static char global_messagepath[1024];
static char global_language[32];
static char global_encoding_name[32];
-/* Map from the rna_userdef.c:rna_def_userdef_system(BlenderRNA *brna):language_items */
-static const char *locales[] = {
- "", "",
- "english", "en_US",
- "japanese", "ja_JP",
- "dutch", "nl_NL",
- "italian", "it_IT",
- "german", "de_DE",
- "finnish", "fi_FI",
- "swedish", "sv_SE",
- "french", "fr_FR",
- "spanish", "es",
- "catalan", "ca_AD",
- "czech", "cs_CZ",
- "portuguese", "pt_PT",
-#if defined(_WIN32) && !defined(FREE_WINDOWS)
- "Chinese (Simplified)_China.1252", "zh_CN",
- "Chinese (Traditional)_China.1252", "zh_TW",
-#else
- "chs", "zh_CN",
- "cht", "zh_TW",
-#endif
- "russian", "ru_RU",
- "croatian", "hr_HR",
- "serbian", "sr_RS",
- "ukrainian", "uk_UA",
- "polish", "pl_PL",
- "romanian", "ro_RO",
- "arabic", "ar_EG",
- "bulgarian", "bg_BG",
- "greek", "el_GR",
- "korean", "ko_KR",
- "nepali", "ne_NP",
- "persian", "fa_IR",
- "indonesian", "id_ID",
- "serbian (latin)", "sr_RS@latin",
- "kyrgyz", "ky_KG",
- "turkish", "tr_TR",
- "hungarian", "hu_HU",
- "portuguese-brazilian", "pt_BR",
- "hebrew", "he_IL",
-};
+static const char **locales = NULL;
+static char **long_locales = NULL; /* XXX Temp fix until we get a final solution with modern intl lib under windows! */
+static int num_locales = 0;
+static EnumPropertyItem *locales_menu = NULL;
+static int num_locales_menu = 0;
+
+#define ULANGUAGE ((U.language >= 0 && U.language < num_locales) ? U.language : 0)
+#define LOCALE(_id) (locales ? locales[_id] : "")
+#define LONG_LOCALE(_id) (long_locales ? long_locales[_id] : "")
+
+static void free_locales(void)
+{
+ if (locales) {
+ int idx = num_locales_menu - 1; /* Last item does not need to be freed! */
+ while (idx--) {
+ MEM_freeN((void *)locales_menu[idx].identifier);
+ MEM_freeN((void *)locales_menu[idx].name);
+ MEM_freeN((void *)locales_menu[idx].description); /* Also frees locales's relevant value! */
+ }
+
+ idx = num_locales;
+ while (idx--) {
+ if (long_locales[idx]) {
+ MEM_freeN(long_locales[idx]);
+ }
+ }
+
+ MEM_freeN(locales);
+ locales = NULL;
+ MEM_freeN(long_locales);
+ long_locales = NULL;
+ }
+ if (locales_menu) {
+ MEM_freeN(locales_menu);
+ locales_menu = NULL;
+ }
+ num_locales = num_locales_menu = 0;
+}
+
+static void fill_locales(void)
+{
+ char *languages_path = BLI_get_folder(BLENDER_DATAFILES, "locale");
+ LinkNode *lines = NULL, *line;
+ char *str;
+ int idx = 0;
+
+ free_locales();
+
+ BLI_join_dirfile(languages_path, FILE_MAX, languages_path, "languages");
+ line = lines = BLI_file_read_as_lines(languages_path);
+
+ /* This whole "parsing" code is a bit weak, in that it expects strictly formated input file...
+ * Should not be a problem, though, as this file is script-generated! */
+
+ /* First loop to find highest locale ID */
+ while (line) {
+ int t;
+ str = (char*) line->link;
+ if (str[0] == '#' || str[0] == '\0') {
+ line = line->next;
+ continue; /* Comment or void... */
+ }
+ t = atoi(str);
+ if (t >= num_locales)
+ num_locales = t + 1;
+ num_locales_menu++;
+ line = line->next;
+ }
+ num_locales_menu++; /* The "closing" void item... */
+
+ /* And now, buil locales and locale_menu! */
+ locales_menu = MEM_callocN(num_locales_menu * sizeof(EnumPropertyItem), __func__);
+ line = lines;
+ /* Do not allocate locales with zero-sized mem, as LOCALE macro uses NULL locales as invalid marker! */
+ if (num_locales > 0) {
+ locales = MEM_callocN(num_locales * sizeof(char*), __func__);
+ long_locales = MEM_callocN(num_locales * sizeof(char*), __func__);
+ while (line) {
+ int id;
+ char *loc, *sep1, *sep2, *sep3;
+
+ str = (char*) line->link;
+ if (str[0] == '#' || str[0] == '\0') {
+ line = line->next;
+ continue;
+ }
+
+ id = atoi(str);
+ sep1 = strchr(str, ':');
+ if (sep1) {
+ sep1++;
+ sep2 = strchr(sep1, ':');
+ if (sep2) {
+ locales_menu[idx].value = id;
+ locales_menu[idx].icon = 0;
+ locales_menu[idx].name = BLI_strdupn(sep1, sep2 - sep1);
+
+ sep2++;
+ sep3 = strchr(sep2, ':');
+ if (sep3) {
+ locales_menu[idx].identifier = loc = BLI_strdupn(sep2, sep3 - sep2);
+
+ if (id == 0) {
+ /* The DEFAULT item... */
+ if (BLI_strnlen(loc, 2)) {
+ locales[id] = locales_menu[idx].description = BLI_strdup("");
+ long_locales[id] = BLI_strdup("");
+ }
+ /* Menu "label", not to be stored in locales! */
+ else {
+ locales_menu[idx].description = BLI_strdup("");
+ }
+ }
+ else {
+ locales[id] = locales_menu[idx].description = BLI_strdup(loc);
+ long_locales[id] = BLI_strdup(sep3 + 1);
+ }
+ idx++;
+ }
+ }
+ }
+
+ line = line->next;
+ }
+ }
+
+ /* Add closing item to menu! */
+ locales_menu[idx].identifier = NULL;
+ locales_menu[idx].value = locales_menu[idx].icon = 0;
+ locales_menu[idx].name = locales_menu[idx].description = "";
+
+ BLI_file_free_lines(lines);
+}
+
+EnumPropertyItem *BLF_RNA_lang_enum_properties(void)
+{
+ return locales_menu;
+}
void BLF_lang_init(void)
{
@@ -119,6 +211,7 @@ void BLF_lang_init(void)
if (messagepath) {
BLI_strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
+ fill_locales();
}
else {
printf("%s: 'locale' data path for translations not found, continuing\n", __func__);
@@ -126,6 +219,11 @@ void BLF_lang_init(void)
}
}
+void BLF_lang_free(void)
+{
+ free_locales();
+}
+
/* Get LANG/LANGUAGE environment variable. */
static void get_language_variable(const char *varname, char *var, const size_t maxlen)
{
@@ -167,41 +265,39 @@ static void get_language(const char *locale, const char *lang, char *language, c
void BLF_lang_set(const char *str)
{
char *locreturn;
- const char *short_locale;
- int ok = 1;
- const char *long_locale = locales[2 * U.language];
+ int ok = TRUE;
+ int ulang = ULANGUAGE;
if ((U.transopts & USER_DOTRANSLATE) == 0)
return;
- if (str)
- short_locale = str;
- else
- short_locale = locales[2 * U.language + 1];
-
#if defined(_WIN32) && !defined(FREE_WINDOWS)
- if (short_locale) {
- char *envStr;
+ {
+ const char *long_locale = str ? str : LONG_LOCALE(ulang);
+ if (long_locale) {
+ char *envStr;
- if (U.language == 0) /* Use system setting. */
- envStr = BLI_sprintfN("LANG=%s", getenv("LANG"));
- else
- envStr = BLI_sprintfN("LANG=%s", short_locale);
+ if (ulang)
+ envStr = BLI_sprintfN("LANG=%s", long_locale);
+ else /* Use system setting. */
+ envStr = BLI_sprintfN("LANG=%s", getenv("LANG"));
- gettext_putenv(envStr);
- MEM_freeN(envStr);
- }
+ gettext_putenv(envStr);
+ MEM_freeN(envStr);
+ }
- locreturn = setlocale(LC_ALL, long_locale);
+ locreturn = setlocale(LC_ALL, long_locale);
- if (locreturn == NULL) {
- if (G.debug & G_DEBUG)
- printf("Could not change locale to %s\n", long_locale);
+ if (locreturn == NULL) {
+ if (G.debug & G_DEBUG)
+ printf("Could not change locale to %s\n", long_locale);
- ok = 0;
+ ok = FALSE;
+ }
}
#else
{
+ const char *short_locale = str ? str : LOCALE(ulang);
static char default_lang[64] = "\0";
static char default_language[64] = "\0";
@@ -212,11 +308,33 @@ void BLF_lang_set(const char *str)
get_language_variable("LANGUAGE", default_language, sizeof(default_language));
if (short_locale[0]) {
+ char *short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale);
+
if (G.debug & G_DEBUG)
- printf("Setting LANG= and LANGUAGE to %s\n", short_locale);
+ printf("Setting LANG and LANGUAGE to %s\n", short_locale_utf8);
+
+ locreturn = setlocale(LC_ALL, short_locale_utf8);
+
+ if (locreturn != NULL) {
+ BLI_setenv("LANG", short_locale_utf8);
+ BLI_setenv("LANGUAGE", short_locale_utf8);
+ }
+ else {
+ if (G.debug & G_DEBUG)
+ printf("Setting LANG and LANGUAGE to %s\n", short_locale);
+
+ locreturn = setlocale(LC_ALL, short_locale);
+
+ if (locreturn != NULL) {
+ BLI_setenv("LANG", short_locale);
+ BLI_setenv("LANGUAGE", short_locale);
+ }
+ }
- BLI_setenv("LANG", short_locale);
- BLI_setenv("LANGUAGE", short_locale);
+ if (G.debug & G_DEBUG && locreturn == NULL)
+ printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
+
+ MEM_freeN(short_locale_utf8);
}
else {
if (G.debug & G_DEBUG)
@@ -224,43 +342,27 @@ void BLF_lang_set(const char *str)
BLI_setenv("LANG", default_lang);
BLI_setenv("LANGUAGE", default_language);
- }
+ locreturn = setlocale(LC_ALL, "");
- locreturn = setlocale(LC_ALL, short_locale);
+ if (G.debug & G_DEBUG && locreturn == NULL)
+ printf("Could not reset locale\n");
+ }
if (locreturn == NULL) {
- char *short_locale_utf8 = NULL;
-
- if (short_locale[0]) {
- short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale);
- locreturn = setlocale(LC_ALL, short_locale_utf8);
- }
+ char language[65];
- if (locreturn == NULL) {
- char language[65];
-
- get_language(long_locale, default_lang, language, sizeof(language));
-
- if (G.debug & G_DEBUG) {
- if (short_locale[0])
- printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
- else
- printf("Could not reset locale\n");
-
- printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language);
- }
+ get_language(short_locale, default_lang, language, sizeof(language));
- /* Fallback to default settings. */
- BLI_setenv("LANG", default_lang);
- BLI_setenv("LANGUAGE", language);
+ if (G.debug & G_DEBUG)
+ printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language);
- locreturn = setlocale(LC_ALL, "");
+ /* Fallback to default settings. */
+ BLI_setenv("LANG", default_lang);
+ BLI_setenv("LANGUAGE", language);
- ok = 0;
- }
+ locreturn = setlocale(LC_ALL, "");
- if (short_locale_utf8)
- MEM_freeN(short_locale_utf8);
+ ok = FALSE;
}
}
#endif
@@ -279,7 +381,8 @@ void BLF_lang_set(const char *str)
const char *BLF_lang_get(void)
{
- return locales[2 * U.language + 1];
+ int uilang = ULANGUAGE;
+ return LOCALE(uilang);
}
void BLF_lang_encoding(const char *str)
@@ -288,6 +391,9 @@ void BLF_lang_encoding(const char *str)
/* bind_textdomain_codeset(TEXT_DOMAIN_NAME, encoding_name); */
}
+#undef LOCALE
+#undef ULANGUAGE
+
#else /* ! WITH_INTERNATIONAL */
void BLF_lang_init(void)
@@ -295,6 +401,11 @@ void BLF_lang_init(void)
return;
}
+void BLF_lang_free(void)
+{
+ return;
+}
+
void BLF_lang_encoding(const char *str)
{
(void)str;
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 273da05a017..7733a59b810 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -149,6 +149,11 @@ typedef enum DMDrawFlag {
typedef enum DMDirtyFlag {
/* dm has valid tessellated faces, but tessellated CDDATA need to be updated. */
DM_DIRTY_TESS_CDLAYERS = 1 << 0,
+ /* One of the MCOL layers have been updated, force updating of GPUDrawObject's colors buffer.
+ * This is necessary with modern, VBO draw code, as e.g. in vpaint mode me->mcol may be updated
+ * without actually rebuilding dm (hence by defautl keeping same GPUDrawObject, and same colors
+ * buffer, which prevents update during a stroke!). */
+ DM_DIRTY_MCOL_UPDATE_DRAW = 1 << 1,
} DMDirtyFlag;
typedef struct DerivedMesh DerivedMesh;
@@ -224,6 +229,7 @@ struct DerivedMesh {
void *(*getVertData)(DerivedMesh * dm, int index, int type);
void *(*getEdgeData)(DerivedMesh * dm, int index, int type);
void *(*getTessFaceData)(DerivedMesh * dm, int index, int type);
+ void *(*getPolyData)(DerivedMesh * dm, int index, int type);
/** Return a pointer to the entire array of vert/edge/face custom data
* from the derived mesh (this gives a pointer to the actual data, not
@@ -232,7 +238,8 @@ struct DerivedMesh {
void *(*getVertDataArray)(DerivedMesh * dm, int type);
void *(*getEdgeDataArray)(DerivedMesh * dm, int type);
void *(*getTessFaceDataArray)(DerivedMesh * dm, int type);
-
+ void *(*getPolyDataArray)(DerivedMesh * dm, int type);
+
/** Retrieves the base CustomData structures for
* verts/edges/tessfaces/loops/facdes*/
CustomData *(*getVertDataLayout)(DerivedMesh * dm);
@@ -494,6 +501,7 @@ void DM_add_poly_layer(struct DerivedMesh *dm, int type, int alloctype,
void *DM_get_vert_data(struct DerivedMesh *dm, int index, int type);
void *DM_get_edge_data(struct DerivedMesh *dm, int index, int type);
void *DM_get_tessface_data(struct DerivedMesh *dm, int index, int type);
+void *DM_get_poly_data(struct DerivedMesh *dm, int index, int type);
/* custom data layer access functions
* return pointer to first data layer which matches type (a flat array)
@@ -702,4 +710,10 @@ void DM_debug_print(DerivedMesh *dm);
void DM_debug_print_cdlayers(CustomData *cdata);
#endif
+BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
+{
+ const int j = index_mf_to_mpoly[i];
+ return (j != ORIGINDEX_NONE) ? index_mp_to_orig[j] : ORIGINDEX_NONE;
+}
+
#endif
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 6b9de47836e..b0f372e0bac 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -99,7 +99,7 @@ void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
/* get_objectspace_bone_matrix has to be removed still */
void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][4], int root, int posed);
void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]);
-void mat3_to_vec_roll(float mat[][3], float *vec, float *roll);
+void mat3_to_vec_roll(float mat[][3], float r_vec[3], float *r_roll);
/* Common Conversions Between Co-ordinate Spaces */
void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]);
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 56dfdf404f8..3c210877de7 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,16 +42,15 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 264
-#define BLENDER_SUBVERSION 1
+#define BLENDER_SUBVERSION 9
-/* 262 was the last editmesh release but its has compatibility code for bmesh data,
- * so set the minversion to 2.61 */
-#define BLENDER_MINVERSION 261
+/* 262 was the last editmesh release but it has compatibility code for bmesh data */
+#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0
/* used by packaging tools */
/* can be left blank, otherwise a,b,c... etc with no quotes */
-#define BLENDER_VERSION_CHAR
+#define BLENDER_VERSION_CHAR a
/* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE alpha
diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h
index 67b21eb764c..8bfee836c0d 100644
--- a/source/blender/blenkernel/BKE_bmesh.h
+++ b/source/blender/blenkernel/BKE_bmesh.h
@@ -99,7 +99,7 @@ typedef struct BME_Glob { /* stored in Global G for Transform() purposes */
struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BMVert *v);
void BME_free_transdata(struct BME_TransData_Head *td);
-struct BMesh *BME_bevel(struct BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle,
- BME_TransData_Head **rtd, int do_tessface);
+struct BMesh *BME_bevel(struct BMesh *bm, float value, int res, int options, int defgrp_index, float angle,
+ BME_TransData_Head **rtd);
#endif
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index d7882d8e7ec..2b2497f3f50 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -55,8 +55,10 @@ int CDDM_Check(struct DerivedMesh *dm);
* data to not overwrite the original */
struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob);
+struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps);
+
/* creates a CDDerivedMesh from the given BMEditMesh */
-DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps, int use_tessface);
+DerivedMesh *CDDM_from_editbmesh(struct BMEditMesh *em, int use_mdisps, int use_tessface);
/* merge verts */
DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap);
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index 728f88b3c16..96e05aa87b9 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -63,8 +63,8 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, con
#define CURVEMAP_SLOPE_POSITIVE 1
void curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope);
void curvemap_remove(struct CurveMap *cuma, const short flag);
-void curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
-struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y);
+int curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
+struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y);
void curvemap_sethandle(struct CurveMap *cuma, int type);
void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles);
@@ -88,7 +88,6 @@ int curvemapping_RGBA_does_something(const struct CurveMapping *
void curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size);
/* non-const, these modify the curve */
-void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf);
void curvemapping_premultiply(struct CurveMapping *cumap, int restore);
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index e6161cebf54..536bbecb79b 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -108,7 +108,7 @@ void BKE_nurb_free(struct Nurb *nu);
struct Nurb *BKE_nurb_duplicate(struct Nurb *nu);
void BKE_nurb_test2D(struct Nurb *nu);
-void BKE_nurb_minmax(struct Nurb *nu, float *min, float *max);
+void BKE_nurb_minmax(struct Nurb *nu, float min[3], float max[3]);
void BKE_nurb_makeFaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
void BKE_nurb_makeCurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 33361b9921c..4736e7b7312 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -80,6 +80,13 @@ void customData_mask_layers__print(CustomDataMask mask);
* the below operations.
*/
int CustomData_layer_has_math(struct CustomData *data, int layer_n);
+int CustomData_layer_has_interp(struct CustomData *data, int layer_n);
+
+/**
+ * Checks if any of the customdata layers has math.
+ */
+int CustomData_has_math(struct CustomData *data);
+int CustomData_has_interp(struct CustomData *data);
/* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
* another, while not overwriting anything else (e.g. flags). probably only
@@ -115,7 +122,10 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
void CustomData_bmesh_merge(struct CustomData *source, struct CustomData *dest,
CustomDataMask mask, int alloctype, struct BMesh *bm, const char htype);
-/* frees data associated with a CustomData object (doesn't free the object
+/** NULL's all members and resets the typemap. */
+void CustomData_reset(struct CustomData *data);
+
+/** frees data associated with a CustomData object (doesn't free the object
* itself, though)
*/
void CustomData_free(struct CustomData *data, int totelem);
@@ -205,8 +215,8 @@ void CustomData_free_elem(struct CustomData *data, int index, int count);
void CustomData_interp(const struct CustomData *source, struct CustomData *dest,
int *src_indices, float *weights, float *sub_weights,
int count, int dest_index);
-void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks,
- float *weights, float *sub_weights, int count,
+void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks,
+ const float *weights, const float *sub_weights, int count,
void *dest_block);
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index 52a143ddf55..8306da71432 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -54,6 +54,7 @@ struct MDeformWeight *defvert_verify_index(struct MDeformVert *dv, const int
void defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight);
void defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
void defvert_clear(struct MDeformVert *dvert);
+int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup);
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 2656495a918..f6276a69d57 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -130,8 +130,9 @@ enum {
G_DEBUG_FFMPEG = (1 << 1),
G_DEBUG_PYTHON = (1 << 2), /* extra python info */
G_DEBUG_EVENTS = (1 << 3), /* input/window/screen events */
- G_DEBUG_WM = (1 << 4), /* operator, undo */
- G_DEBUG_JOBS = (1 << 5) /* jobs time profiling */
+ G_DEBUG_HANDLERS = (1 << 4), /* events handling */
+ G_DEBUG_WM = (1 << 5), /* operator, undo */
+ G_DEBUG_JOBS = (1 << 6) /* jobs time profiling */
};
#define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS)
@@ -145,17 +146,17 @@ enum {
#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) /* deprecated */
#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) /* deprecated */
#define G_FILE_SHOW_FRAMERATE (1 << 5) /* deprecated */
-/* #define G_FILE_SHOW_PROFILE (1 << 6) */ /* deprecated */
+/* #define G_FILE_SHOW_PROFILE (1 << 6) */ /* deprecated */
#define G_FILE_LOCK (1 << 7)
#define G_FILE_SIGN (1 << 8)
-/* #define G_FILE_PUBLISH (1 << 9) */ /* deprecated */
+/* #define G_FILE_PUBLISH (1 << 9) */ /* deprecated */
#define G_FILE_NO_UI (1 << 10)
-/* #define G_FILE_GAME_TO_IPO (1 << 11) */ /* deprecated */
+/* #define G_FILE_GAME_TO_IPO (1 << 11) */ /* deprecated */
#define G_FILE_GAME_MAT (1 << 12) /* deprecated */
-/* #define G_FILE_DISPLAY_LISTS (1 << 13) */ /* deprecated */
+/* #define G_FILE_DISPLAY_LISTS (1 << 13) */ /* deprecated */
#define G_FILE_SHOW_PHYSICS (1 << 14) /* deprecated */
#define G_FILE_GAME_MAT_GLSL (1 << 15) /* deprecated */
-/* #define G_FILE_GLSL_NO_LIGHTS (1 << 16) */ /* deprecated */
+/* #define G_FILE_GLSL_NO_LIGHTS (1 << 16) */ /* deprecated */
#define G_FILE_GLSL_NO_SHADERS (1 << 17) /* deprecated */
#define G_FILE_GLSL_NO_SHADOWS (1 << 18) /* deprecated */
#define G_FILE_GLSL_NO_RAMPS (1 << 19) /* deprecated */
@@ -166,6 +167,9 @@ enum {
#define G_FILE_RELATIVE_REMAP (1 << 24)
#define G_FILE_HISTORY (1 << 25)
#define G_FILE_MESH_COMPAT (1 << 26) /* BMesh option to save as older mesh format */
+#define G_FILE_SAVE_COPY (1 << 27) /* restore paths after editing them */
+
+#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_MESH_COMPAT | G_FILE_SAVE_COPY)
/* G.windowstate */
#define G_WINDOWSTATE_USERDEF 0
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 3cf4a2c5cdc..a9f6a61a655 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -154,6 +154,12 @@ __attribute__((nonnull))
#endif
;
+void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
+
/**
* This function has a sanity check to make sure ID properties with the same name don't
* get added to the group.
@@ -260,6 +266,12 @@ __attribute__((nonnull))
#endif
;
+int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+#endif
+;
+
int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2)
#ifdef __GNUC__
__attribute__((warn_unused_result))
@@ -306,11 +318,16 @@ void IDP_FreeProperty(struct IDProperty *prop);
/** Unlinks any struct IDProperty<->ID linkage that might be going on.*/
void IDP_UnlinkProperty(struct IDProperty *prop);
-#define IDP_Int(prop) ((prop)->data.val)
-#define IDP_Float(prop) (*(float *)&(prop)->data.val)
-#define IDP_String(prop) ((char *)(prop)->data.pointer)
-#define IDP_Array(prop) ((prop)->data.pointer)
-#define IDP_IDPArray(prop) ((IDProperty *)(prop)->data.pointer)
-#define IDP_Double(prop) (*(double *)&(prop)->data.val)
+#define IDP_Int(prop) ((prop)->data.val)
+#define IDP_Float(prop) (*(float *)&(prop)->data.val)
+#define IDP_Double(prop) (*(double *)&(prop)->data.val)
+#define IDP_String(prop) ((char *) (prop)->data.pointer)
+#define IDP_Array(prop) ((prop)->data.pointer)
+#define IDP_IDPArray(prop) ((IDProperty *) (prop)->data.pointer)
+
+#ifdef DEBUG
+/* for printout only */
+void IDP_spit(IDProperty *prop);
+#endif
#endif /* __BKE_IDPROP_H__ */
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 5e5f58f73fe..1875fd66628 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -127,6 +127,7 @@ enum {
#define IMA_SIGNAL_SRC_CHANGE 5
/* image-user gets a new image, check settings */
#define IMA_SIGNAL_USER_NEW_IMAGE 6
+#define IMA_SIGNAL_COLORMANAGE 7
#define IMA_CHAN_FLAG_BW 1
#define IMA_CHAN_FLAG_RGB 2
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 01baf8feb2a..d7d75b4c4c9 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -92,4 +92,4 @@ extern int slurph_opt;
};
#endif
-#endif // __BKE_KEY_H__
+#endif /* __BKE_KEY_H__ */
diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h
index 3acd4d1986e..244decf9d52 100644
--- a/source/blender/blenkernel/BKE_lamp.h
+++ b/source/blender/blenkernel/BKE_lamp.h
@@ -37,6 +37,7 @@ extern "C" {
#endif
struct Lamp;
+struct Scene;
struct Lamp *BKE_lamp_add(const char *name) WARN_UNUSED;
struct Lamp *BKE_lamp_copy(struct Lamp *la) WARN_UNUSED;
@@ -44,6 +45,8 @@ struct Lamp *localize_lamp(struct Lamp *la) WARN_UNUSED;
void BKE_lamp_make_local(struct Lamp *la);
void BKE_lamp_free(struct Lamp *la);
+void lamp_drivers_update(struct Scene *scene, struct Lamp *la, float ctime);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 31626ef4a58..34baa48dbe2 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -46,7 +46,7 @@ struct Lattice *BKE_lattice_add(const char *name);
struct Lattice *BKE_lattice_copy(struct Lattice *lt);
void BKE_lattice_free(struct Lattice *lt);
void BKE_lattice_make_local(struct Lattice *lt);
-void calc_lat_fudu(int flag, int res, float *fu, float *du);
+void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
void init_latt_deform(struct Object *oblatt, struct Object *ob);
void calc_latt_deform(struct Object *, float co[3], float weight);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 91756448297..bc081b7f308 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -81,6 +81,7 @@ int set_listbasepointers(struct Main *main, struct ListBase **lb);
void BKE_libblock_free(struct ListBase *lb, void *idv);
void BKE_libblock_free_us(struct ListBase *lb, void *idv);
+void BKE_libblock_free_data(struct ID *id);
void free_main(struct Main *mainvar);
void tag_main_idcode(struct Main *mainvar, const short type, const short tag);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index c14085a559a..e53d0efffbd 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -130,7 +130,7 @@ struct Mesh *BKE_mesh_copy(struct Mesh *me);
void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess_cd);
void BKE_mesh_make_local(struct Mesh *me);
-void BKE_mesh_boundbox_calc(struct Mesh *me, float *loc, float *size);
+void BKE_mesh_boundbox_calc(struct Mesh *me, float r_loc[3], float r_size[3]);
void BKE_mesh_texspace_calc(struct Mesh *me);
float *BKE_mesh_orco_verts_get(struct Object *ob);
void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert);
@@ -283,15 +283,16 @@ typedef struct IndexNode {
void create_vert_poly_map(MeshElemMap **map, int **mem,
const struct MPoly *mface, const struct MLoop *mloop,
int totvert, int totface, int totloop);
-
+
void create_vert_edge_map(MeshElemMap **map, int **mem,
- const struct MEdge *medge, int totvert, int totedge);
+ const struct MEdge *medge, int totvert, int totedge);
/* vertex level transformations & checks (no derived mesh) */
int BKE_mesh_minmax(struct Mesh *me, float r_min[3], float r_max[3]);
int BKE_mesh_center_median(struct Mesh *me, float cent[3]);
int BKE_mesh_center_bounds(struct Mesh *me, float cent[3]);
+int BKE_mesh_center_centroid(struct Mesh *me, float cent[3]);
void BKE_mesh_translate(struct Mesh *me, float offset[3], int do_keys);
/* mesh_validate.c */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 3b675f3b620..7ee1c85d0de 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -352,6 +352,7 @@ int modifiers_isParticleEnabled(struct Object *ob);
struct Object *modifiers_isDeformedByArmature(struct Object *ob);
struct Object *modifiers_isDeformedByLattice(struct Object *ob);
+struct Object *modifiers_isDeformedByCurve(struct Object *ob);
int modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
int modifiers_isCorrectableDeformed(struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 82a791348dd..bee2c374f27 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -48,7 +48,7 @@ struct Scene;
void multires_customdata_delete(struct Mesh *me);
void multires_set_tot_level(struct Object *ob,
- struct MultiresModifierData *mmd, int lvl);
+ struct MultiresModifierData *mmd, int lvl);
void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags);
@@ -116,5 +116,4 @@ void multires_topology_changed(struct Mesh *me);
void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v);
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
-#endif // __BKE_MULTIRES_H__
-
+#endif /* __BKE_MULTIRES_H__ */
diff --git a/source/blender/blenkernel/BKE_navmesh_conversion.h b/source/blender/blenkernel/BKE_navmesh_conversion.h
index aab359b307a..cc9c18c764d 100644
--- a/source/blender/blenkernel/BKE_navmesh_conversion.h
+++ b/source/blender/blenkernel/BKE_navmesh_conversion.h
@@ -60,4 +60,4 @@ int polyFindVertex(const unsigned short *p, const int vertsPerPoly, unsigned sho
float distPointToSegmentSq(const float *point, const float *a, const float *b);
-#endif //NAVMESH_CONVERSION_H
+#endif /* NAVMESH_CONVERSION_H */
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index acd6f120f93..b365d93b246 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -193,10 +193,8 @@ typedef struct bNodeType {
struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit);
void (*group_edit_clear)(struct bNode *node);
- /* Generate a temporary list of internal links (bNodeLink), for muting and disconnect operators.
- * Result must be freed by caller!
- */
- ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node);
+ /* Update the internal links list, for muting and disconnect operators. */
+ void (*update_internal_links)(struct bNodeTree *, struct bNode *node);
/* **** execution callbacks **** */
void *(*initexecfunc)(struct bNode *node);
@@ -247,6 +245,7 @@ typedef struct bNodeType {
#define NODE_CLASS_PARTICLES 25
#define NODE_CLASS_TRANSFORM 30
#define NODE_CLASS_COMBINE 31
+#define NODE_CLASS_SCRIPT 32
#define NODE_CLASS_SHADER 40
#define NODE_CLASS_LAYOUT 100
@@ -293,7 +292,7 @@ typedef struct bNodeTreeType {
int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link);
/* Default internal linking. */
- ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node);
+ void (*update_internal_links)(struct bNodeTree *, struct bNode *node);
} bNodeTreeType;
/* ************** GENERIC API, TREES *************** */
@@ -349,7 +348,7 @@ struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode *node
void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock);
void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node);
-void nodeAddToPreview(struct bNode *node, float col[4], int x, int y, int do_manage);
+void nodeAddToPreview(struct bNode *node, const float col[4], int x, int y, int do_manage);
struct bNode *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
@@ -389,6 +388,7 @@ struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree);
void nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
int nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
+void nodeUpdateInternalLinks(struct bNodeTree *ntree, struct bNode *node);
void nodeFreePreview(struct bNode *node);
@@ -445,7 +445,7 @@ void node_type_exec_new(struct bNodeType *ntype,
void (*freeexecfunc)(struct bNode *node, void *nodedata),
void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata,
struct bNodeStack **, struct bNodeStack **));
-void node_type_internal_connect(struct bNodeType *ntype, ListBase (*internal_connect)(struct bNodeTree *, struct bNode *));
+void node_type_internal_links(struct bNodeType *ntype, void (*update_internal_links)(struct bNodeTree *, struct bNode *));
void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node,
struct GPUNodeStack *in, struct GPUNodeStack *out));
void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node,
@@ -456,8 +456,8 @@ void node_type_compatibility(struct bNodeType *ntype, short compatibi
/* ************** COMMON NODES *************** */
#define NODE_GROUP 2
-#define NODE_FORLOOP 3
-#define NODE_WHILELOOP 4
+#define __NODE_FORLOOP 3 /* deprecated */
+#define __NODE_WHILELOOP 4 /* deprecated */
#define NODE_FRAME 5
#define NODE_REROUTE 6
@@ -551,6 +551,12 @@ struct ShadeResult;
#define SH_NODE_OBJECT_INFO 167
#define SH_NODE_PARTICLE_INFO 168
#define SH_NODE_TEX_BRICK 169
+#define SH_NODE_BUMP 170
+#define SH_NODE_SCRIPT 171
+#define SH_NODE_AMBIENT_OCCLUSION 172
+#define SH_NODE_BSDF_REFRACTION 173
+#define SH_NODE_TANGENT 174
+#define SH_NODE_NORMAL_MAP 175
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
@@ -698,6 +704,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria
#define CMP_NODE_BOKEHIMAGE 315
#define CMP_NODE_BOKEHBLUR 316
#define CMP_NODE_SWITCH 317
+#define CMP_NODE_PIXELATE 318
/* channel toggles */
#define CMP_CHAN_RGB 1
@@ -784,7 +791,9 @@ void ntreeTexCheckCyclics(struct bNodeTree *ntree);
struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
void ntreeTexEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
-int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, int osatex, short thread, struct Tex *tex, short which_output, int cfra, int preview, struct ShadeInput *shi, struct MTex *mtex);
+int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target,
+ float coord[3], float dxt[3], float dyt[3], int osatex, const short thread,
+ struct Tex *tex, short which_output, int cfra, int preview, struct ShadeInput *shi, struct MTex *mtex);
/*************************************************/
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index a93e542fe15..c452c177143 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -94,6 +94,7 @@ typedef struct SculptSession {
/* PBVH acceleration structure */
struct PBVH *pbvh;
+ int show_diffuse_color;
/* Paiting on deformed mesh */
int modifiers_active; /* object is deformed with some modifiers */
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index b3e650b2aa5..ec03f53dbdb 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -257,7 +257,9 @@ void psys_interpolate_mcol(const struct MCol *mcol, int quad, const float w[4],
void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time);
-void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor);
+void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache,
+ float fuv[4], float foffset, float vec[3], float nor[3],
+ float utan[3], float vtan[3], float orco[3], float ornor[3]);
struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys);
struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name);
@@ -282,8 +284,11 @@ void psys_get_particle_on_path(struct ParticleSimulationData *sim, int pa_num, s
int psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, int always);
/* for anim.c */
-void psys_get_dupli_texture(struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float *uv, float *orco);
-void psys_get_dupli_path_transform(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[][4], float *scale);
+void psys_get_dupli_texture(struct ParticleSystem *psys, struct ParticleSettings *part,
+ struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa,
+ float uv[2], float orco[3]);
+void psys_get_dupli_path_transform(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ChildParticle *cpa,
+ struct ParticleCacheKey *cache, float mat[][4], float *scale);
ParticleThread *psys_threads_create(struct ParticleSimulationData *sim);
void psys_threads_free(ParticleThread *threads);
@@ -327,13 +332,17 @@ void psys_free_pdd(struct ParticleSystem *psys);
float *psys_cache_vgroup(struct DerivedMesh *dm, struct ParticleSystem *psys, int vgroup);
void psys_get_texture(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleTexture *ptex, int event, float cfra);
-void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFace *tface, float (*orcodata)[3], float *uv, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor);
+void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFace *tface,
+ float (*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3],
+ float orco[3], float ornor[3]);
float psys_particle_value_from_verts(struct DerivedMesh *dm, short from, struct ParticleData *pa, float *values);
-void psys_get_from_key(struct ParticleKey *key, float *loc, float *vel, float *rot, float *time);
+void psys_get_from_key(struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time);
/* BLI_bvhtree_ray_cast callback */
void BKE_psys_collision_neartest_cb(void *userdata, int index, const struct BVHTreeRay *ray, struct BVHTreeRayHit *hit);
-void psys_particle_on_dm(struct DerivedMesh *dm, int from, int index, int index_dmcache, const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3], float ornor[3]);
+void psys_particle_on_dm(struct DerivedMesh *dm, int from, int index, int index_dmcache,
+ const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
+ float orco[3], float ornor[3]);
/* particle_system.c */
void initialize_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, int p);
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index c12e913be45..9927c7a42ed 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -55,7 +55,12 @@ struct Text;
#define SCE_COPY_LINK_DATA 3
#define SCE_COPY_FULL 4
-#define SETLOOPER(_sce_basis, _sce_iter, _base) _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL); _base; _base = _setlooper_base_step(&_sce_iter, _base)
+/* Use as the contents of a 'for' loop: for (SETLOOPER(...)) { ... */
+#define SETLOOPER(_sce_basis, _sce_iter, _base) \
+ _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL); \
+ _base; \
+ _base = _setlooper_base_step(&_sce_iter, _base)
+
struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base);
void free_avicodecdata(struct AviCodecData *acd);
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 80431682d6f..ba611817c8f 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -68,27 +68,27 @@ void BKE_sequence_iterator_begin(struct Editing *ed, SeqIterator *iter, int use_
void BKE_sequence_iterator_next(SeqIterator *iter);
void BKE_sequence_iterator_end(SeqIterator *iter);
-#define SEQP_BEGIN(ed, _seq) \
+#define SEQP_BEGIN(_ed, _seq) \
{ \
- SeqIterator iter; \
- for (BKE_sequence_iterator_begin(ed, &iter, 1); \
- iter.valid; \
- BKE_sequence_iterator_next(&iter)) \
+ SeqIterator iter_macro; \
+ for (BKE_sequence_iterator_begin(_ed, &iter_macro, 1); \
+ iter_macro.valid; \
+ BKE_sequence_iterator_next(&iter_macro)) \
{ \
- _seq = iter.seq;
+ _seq = iter_macro.seq;
#define SEQ_BEGIN(ed, _seq) \
{ \
- SeqIterator iter; \
- for (BKE_sequence_iterator_begin(ed, &iter, 0); \
- iter.valid; \
- BKE_sequence_iterator_next(&iter)) \
+ SeqIterator iter_macro; \
+ for (BKE_sequence_iterator_begin(ed, &iter_macro, 0); \
+ iter_macro.valid; \
+ BKE_sequence_iterator_next(&iter_macro)) \
{ \
- _seq = iter.seq;
+ _seq = iter_macro.seq;
#define SEQ_END \
} \
- BKE_sequence_iterator_end(&iter); \
+ BKE_sequence_iterator_end(&iter_macro); \
}
typedef struct SeqRenderData {
@@ -356,6 +356,7 @@ typedef struct SeqLoadInfo {
typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *);
struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine);
+void BKE_sequence_init_colorspace(struct Sequence *seq);
struct Sequence *BKE_sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h
index 1f824ccbafc..3a9d2b86b41 100644
--- a/source/blender/blenkernel/BKE_smoke.h
+++ b/source/blender/blenkernel/BKE_smoke.h
@@ -35,8 +35,10 @@
typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
-void smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
+struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
+void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
+void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
void smokeModifier_free(struct SmokeModifierData *smd);
void smokeModifier_reset(struct SmokeModifierData *smd);
void smokeModifier_reset_turbulence(struct SmokeModifierData *smd);
@@ -44,5 +46,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd);
void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData *tsmd);
long long smoke_get_mem_req(int xres, int yres, int zres, int amplify);
+float smoke_get_velocity_at(struct Object *ob, float position[3], float velocity[3]);
+int smoke_get_data_flags(struct SmokeDomainSettings *sds);
#endif /* __BKE_SMOKE_H__ */
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 3b8d0eafd4d..653f2a42675 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -64,10 +64,10 @@ typedef enum {
} SubsurfFlags;
struct DerivedMesh *subsurf_make_derived_from_derived(
- struct DerivedMesh *dm,
- struct SubsurfModifierData *smd,
- float (*vertCos)[3],
- SubsurfFlags flags);
+ struct DerivedMesh *dm,
+ struct SubsurfModifierData *smd,
+ float (*vertCos)[3],
+ SubsurfFlags flags);
void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]);
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index c14476a3b59..eb7004b1ced 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -80,7 +80,7 @@ int BKE_tracking_track_has_marker_at_frame(struct MovieTrackingTrack *track, int
int BKE_tracking_track_has_enabled_marker_at_frame(struct MovieTrackingTrack *track, int framenr);
void BKE_tracking_track_path_clear(struct MovieTrackingTrack *track, int ref_frame, int action);
-void BKE_tracking_tracks_join(struct MovieTrackingTrack *dst_track, struct MovieTrackingTrack *src_track);
+void BKE_tracking_tracks_join(struct MovieTracking *tracking, struct MovieTrackingTrack *dst_track, struct MovieTrackingTrack *src_track);
struct MovieTrackingTrack *BKE_tracking_track_get_named(struct MovieTracking *tracking,
struct MovieTrackingObject *object,
@@ -114,7 +114,7 @@ void BKE_tracking_marker_get_subframe_position(struct MovieTrackingTrack *track,
/* **** Object **** */
struct MovieTrackingObject *BKE_tracking_object_add(struct MovieTracking *tracking, const char *name);
-void BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object);
+int BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object);
void BKE_tracking_object_unique_name(struct MovieTracking *tracking, struct MovieTrackingObject *object);
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 63f5ec59a0b..7c1e0e97565 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -32,10 +32,14 @@
extern "C" {
#endif
-/* currently unused but we may want to add macros here for BKE later */
+#define BKE_BIT_TEST_SET(value, test, flag) \
+{ \
+ if (test) (value) |= flag; \
+ else (value) &= ~flag; \
+} (void)0
#ifdef __cplusplus
}
#endif
-#endif // __BKE_UTILDEFINES_H__
+#endif /* __BKE_UTILDEFINES_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index efdb80433c6..c5dc7da8edf 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -25,7 +25,6 @@
set(INC
.
- ../avi
../blenfont
../blenlib
../blenloader
@@ -194,8 +193,8 @@ set(SRC
BKE_lamp.h
BKE_lattice.h
BKE_library.h
- BKE_mask.h
BKE_main.h
+ BKE_mask.h
BKE_material.h
BKE_mball.h
BKE_mesh.h
@@ -250,7 +249,7 @@ if(WITH_AUDASPACE)
endif()
if(WITH_BULLET)
- list(APPEND INC
+ list(APPEND INC_SYS
../../../extern/bullet2/src
)
add_definitions(-DUSE_BULLET)
@@ -292,6 +291,13 @@ if(WITH_IMAGE_HDR)
add_definitions(-DWITH_HDR)
endif()
+if(WITH_CODEC_AVI)
+ list(APPEND INC
+ ../avi
+ )
+ add_definitions(-DWITH_AVI)
+endif()
+
if(WITH_CODEC_QUICKTIME)
list(APPEND INC
../quicktime
@@ -350,12 +356,6 @@ if(WITH_MOD_OCEANSIM)
add_definitions(-DWITH_OCEANSIM)
endif()
-if(WITH_MOD_DECIMATE)
- list(APPEND INC
- ../../../intern/decimation/extern
- )
-endif()
-
if(WITH_MOD_BOOLEAN)
list(APPEND INC
../../../intern/bsp/extern
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index d1a35b122e8..f7b8f59fa57 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -10,7 +10,7 @@ sources_mask = env.Glob('intern/mask*.c')
incs = '. #/intern/guardedalloc #/intern/memutil'
incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager'
-incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna'
+incs += ' ../render/extern/include ../makesrna'
incs += ' ../imbuf ../ikplugin ../avi #/intern/elbeem/extern ../nodes ../modifiers'
incs += ' #/intern/iksolver/extern ../blenloader'
incs += ' #/extern/bullet2/src'
diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h
index 512b799aeed..12c111f5f16 100644
--- a/source/blender/blenkernel/depsgraph_private.h
+++ b/source/blender/blenkernel/depsgraph_private.h
@@ -61,7 +61,7 @@ typedef struct DagAdjList {
typedef struct DagNode {
int color;
short type;
- float x, y, k;
+ float x, y, k;
void *ob;
void *first_ancestor;
int ancestor_count;
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 82ac0736b07..cc20470b4d5 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -868,7 +868,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
ss->oldVMap = ss->oldEMap = ss->oldFMap = NULL;
ss->lenTempArrays = 0;
ss->tempVerts = NULL;
- ss->tempEdges = NULL;
+ ss->tempEdges = NULL;
return ss;
}
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 5ff1ce2aec3..b329a502c42 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -51,8 +51,6 @@
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
-#include "BLF_translation.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"
#include "BKE_key.h"
@@ -266,9 +264,11 @@ void DM_init_funcs(DerivedMesh *dm)
dm->getVertData = DM_get_vert_data;
dm->getEdgeData = DM_get_edge_data;
dm->getTessFaceData = DM_get_tessface_data;
+ dm->getPolyData = DM_get_poly_data;
dm->getVertDataArray = DM_get_vert_data_layer;
dm->getEdgeDataArray = DM_get_edge_data_layer;
dm->getTessFaceDataArray = DM_get_tessface_data_layer;
+ dm->getPolyDataArray = DM_get_poly_data_layer;
bvhcache_init(&dm->bvhCache);
}
@@ -288,6 +288,13 @@ void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
dm->needsFree = 1;
dm->auto_bump_scale = -1.0f;
dm->dirty = 0;
+
+ /* don't use CustomData_reset(...); because we dont want to touch customdata */
+ fill_vn_i(dm->vertData.typemap, CD_NUMTYPES, -1);
+ fill_vn_i(dm->edgeData.typemap, CD_NUMTYPES, -1);
+ fill_vn_i(dm->faceData.typemap, CD_NUMTYPES, -1);
+ fill_vn_i(dm->loopData.typemap, CD_NUMTYPES, -1);
+ fill_vn_i(dm->polyData.typemap, CD_NUMTYPES, -1);
}
void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
@@ -384,7 +391,7 @@ void DM_ensure_tessface(DerivedMesh *dm)
}
else if (dm->dirty & DM_DIRTY_TESS_CDLAYERS) {
- BLI_assert(CustomData_has_layer(&dm->faceData, CD_POLYINDEX));
+ BLI_assert(CustomData_has_layer(&dm->faceData, CD_ORIGINDEX));
DM_update_tessface_data(dm);
}
@@ -408,7 +415,7 @@ void DM_update_tessface_data(DerivedMesh *dm)
const int hasPCol = CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL);
const int hasOrigSpace = CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP);
- int *polyindex = CustomData_get_layer(fdata, CD_POLYINDEX);
+ int *polyindex = CustomData_get_layer(fdata, CD_ORIGINDEX);
int mf_idx,
totface = dm->getNumTessFaces(dm),
@@ -465,11 +472,11 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
int did_shapekeys = 0;
- memset(&tmp.vdata, 0, sizeof(tmp.vdata));
- memset(&tmp.edata, 0, sizeof(tmp.edata));
- memset(&tmp.fdata, 0, sizeof(tmp.fdata));
- memset(&tmp.ldata, 0, sizeof(tmp.ldata));
- memset(&tmp.pdata, 0, sizeof(tmp.pdata));
+ CustomData_reset(&tmp.vdata);
+ CustomData_reset(&tmp.edata);
+ CustomData_reset(&tmp.fdata);
+ CustomData_reset(&tmp.ldata);
+ CustomData_reset(&tmp.pdata);
totvert = tmp.totvert = dm->getNumVerts(dm);
totedge = tmp.totedge = dm->getNumEdges(dm);
@@ -626,6 +633,12 @@ void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
return CustomData_get(&dm->faceData, index, type);
}
+void *DM_get_poly_data(DerivedMesh *dm, int index, int type)
+{
+ return CustomData_get(&dm->polyData, index, type);
+}
+
+
void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
{
if (type == CD_MVERT)
@@ -902,7 +915,7 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
float (*orco)[3];
int free;
- if (em) dm = CDDM_from_BMEditMesh(em, me, FALSE, FALSE);
+ if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
else dm = CDDM_from_mesh(me, ob);
orco = get_orco_coords_dm(ob, em, layer, &free);
@@ -1269,7 +1282,7 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
int i, j, tot;
if (!me->key)
- return;
+ return;
tot = CustomData_number_of_layers(&dm->vertData, CD_SHAPEKEY);
for (i = 0; i < tot; i++) {
@@ -1374,7 +1387,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
ModifierData *firstmd, *md, *previewmd = NULL;
CDMaskLink *datamasks, *curr;
/* XXX Always copying POLYINDEX, else tessellated data are no more valid! */
- CustomDataMask mask, nextmask, append_mask = CD_MASK_POLYINDEX;
+ CustomDataMask mask, nextmask, append_mask = CD_MASK_ORIGINDEX;
float (*deformedVerts)[3] = NULL;
DerivedMesh *dm = NULL, *orcodm, *clothorcodm, *finaldm;
int numVerts = me->totvert;
@@ -1506,7 +1519,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if (!modifier_isEnabled(scene, md, required_mode)) continue;
if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
- modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position."));
+ modifier_setError(md, "Modifier requires original data, bad stack position");
continue;
}
if (sculpt_mode && (!has_multires || multires_applied)) {
@@ -1519,7 +1532,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
unsupported |= multires_applied;
if (unsupported) {
- modifier_setError(md, "%s", TIP_("Not supported in sculpt mode."));
+ modifier_setError(md, "Not supported in sculpt mode");
continue;
}
}
@@ -1666,8 +1679,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
nextmask &= ~CD_MASK_ORCO;
DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX |
- (mti->requiredDataMask ?
- mti->requiredDataMask(ob, md) : 0));
+ (mti->requiredDataMask ?
+ mti->requiredDataMask(ob, md) : 0));
ndm = mti->applyModifier(md, ob, orcodm, app_flags & ~MOD_APPLY_USECACHE);
if (ndm) {
@@ -1802,7 +1815,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
#if 0
if (num_tessface == 0 && finaldm->getNumTessFaces(finaldm) == 0)
#else
- if (finaldm->getNumTessFaces(finaldm) == 0) /* || !CustomData_has_layer(&finaldm->faceData, CD_POLYINDEX)) */
+ if (finaldm->getNumTessFaces(finaldm) == 0) /* || !CustomData_has_layer(&finaldm->faceData, CD_ORIGINDEX)) */
#endif
{
finaldm->recalcTessellation(finaldm);
@@ -1810,8 +1823,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
/* Even if tessellation is not needed, some modifiers might have modified CD layers
* (like mloopcol or mloopuv), hence we have to update those. */
else if (finaldm->dirty & DM_DIRTY_TESS_CDLAYERS) {
- /* A tessellation already exists, it should always have a CD_POLYINDEX. */
- BLI_assert(CustomData_has_layer(&finaldm->faceData, CD_POLYINDEX));
+ /* A tessellation already exists, it should always have a CD_ORIGINDEX. */
+ BLI_assert(CustomData_has_layer(&finaldm->faceData, CD_ORIGINDEX));
DM_update_tessface_data(finaldm);
}
/* Need to watch this, it can cause issues, see bug [#29338] */
@@ -1880,7 +1893,7 @@ int editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *d
if (!modifier_isEnabled(scene, md, required_mode)) return 0;
if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
- modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position."));
+ modifier_setError(md, "Modifier requires original data, bad stack position");
return 0;
}
@@ -1975,7 +1988,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
}
else {
- dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
+ dm = CDDM_from_editbmesh(em, FALSE, FALSE);
if (deformedVerts) {
CDDM_apply_vert_coords(dm, deformedVerts);
@@ -2066,12 +2079,18 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
}
else if (dm) {
*final_r = dm;
- (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */
+
+ /* once we support skipping normal calculation with modifiers we may want to add this back */
+#if 0 // was added for bmesh but is not needed
+ (*final_r)->calcNormals(*final_r);
+#endif
}
else if (!deformedVerts && cage_r && *cage_r) {
/* cage should already have up to date normals */
*final_r = *cage_r;
- (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */
+#if 0 // was added for bmesh but is not needed
+ (*final_r)->calcNormals(*final_r);
+#endif
}
else {
/* this is just a copy of the editmesh, no need to calc normals */
@@ -2248,8 +2267,16 @@ DerivedMesh *mesh_create_derived_view(Scene *scene, Object *ob, CustomDataMask d
{
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(scene, ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1, 0, 0);
+ ob->transflag &= ~OB_NO_PSYS_UPDATE;
+
return final;
}
@@ -2419,7 +2446,7 @@ static int GetNumVertsOfFace(const SMikkTSpaceContext *pContext, const int face_
static void GetPosition(const SMikkTSpaceContext *pContext, float fPos[], const int face_num, const int vert_index)
{
- //assert(vert_index>=0 && vert_index<4);
+ //assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
const float *co = pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].co;
copy_v3_v3(fPos, co);
@@ -2427,7 +2454,7 @@ static void GetPosition(const SMikkTSpaceContext *pContext, float fPos[], const
static void GetTextureCoordinate(const SMikkTSpaceContext *pContext, float fUV[], const int face_num, const int vert_index)
{
- //assert(vert_index>=0 && vert_index<4);
+ //assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
if (pMesh->mtface != NULL) {
@@ -2442,7 +2469,7 @@ static void GetTextureCoordinate(const SMikkTSpaceContext *pContext, float fUV[]
static void GetNormal(const SMikkTSpaceContext *pContext, float fNorm[], const int face_num, const int vert_index)
{
- //assert(vert_index>=0 && vert_index<4);
+ //assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH);
@@ -2472,7 +2499,7 @@ static void GetNormal(const SMikkTSpaceContext *pContext, float fNorm[], const i
}
static void SetTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert)
{
- //assert(vert_index>=0 && vert_index<4);
+ //assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
float *pRes = pMesh->tangent[4 * face_num + iVert];
copy_v3_v3(pRes, fvTangent);
@@ -2483,15 +2510,11 @@ static void SetTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[
void DM_add_tangent_layer(DerivedMesh *dm)
{
/* mesh vars */
- MTFace *mtface, *tf;
- MFace *mface, *mf;
- MVert *mvert, *v1, *v2, *v3, *v4;
- MemArena *arena = NULL;
- VertexTangent **vtangents = NULL;
+ MVert *mvert;
+ MTFace *mtface;
+ MFace *mface;
float (*orco)[3] = NULL, (*tangent)[4];
- float *uv1, *uv2, *uv3, *uv4, *vtang;
- float fno[3], tang[3], uv[4][2];
- int i, j, len, mf_vi[4], totvert, totface, iCalcNewMethod;
+ int /* totvert, */ totface;
float *nors;
if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1)
@@ -2500,7 +2523,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
/* check we have all the needed layers */
- totvert = dm->getNumVerts(dm);
+ /* totvert = dm->getNumVerts(dm); */ /* UNUSED */
totface = dm->getNumTessFaces(dm);
mvert = dm->getVertArray(dm);
@@ -2517,14 +2540,8 @@ void DM_add_tangent_layer(DerivedMesh *dm)
DM_add_tessface_layer(dm, CD_TANGENT, CD_CALLOC, NULL);
tangent = DM_get_tessface_data_layer(dm, CD_TANGENT);
- /* allocate some space */
- arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "tangent layer arena");
- BLI_memarena_use_calloc(arena);
- vtangents = MEM_callocN(sizeof(VertexTangent *) * totvert, "VertexTangent");
-
/* new computation method */
- iCalcNewMethod = 1;
- if (iCalcNewMethod != 0) {
+ {
SGLSLMeshToTangent mesh2tangent = {0};
SMikkTSpaceContext sContext = {0};
SMikkTSpaceInterface sInterface = {0};
@@ -2547,87 +2564,13 @@ void DM_add_tangent_layer(DerivedMesh *dm)
sInterface.m_setTSpaceBasic = SetTSpace;
/* 0 if failed */
- iCalcNewMethod = genTangSpaceDefault(&sContext);
+ genTangSpaceDefault(&sContext);
}
-
- if (!iCalcNewMethod) {
- /* sum tangents at connected vertices */
- for (i = 0, tf = mtface, mf = mface; i < totface; mf++, tf++, i++) {
- v1 = &mvert[mf->v1];
- v2 = &mvert[mf->v2];
- v3 = &mvert[mf->v3];
-
- if (mf->v4) {
- v4 = &mvert[mf->v4];
- normal_quad_v3(fno, v4->co, v3->co, v2->co, v1->co);
- }
- else {
- v4 = NULL;
- normal_tri_v3(fno, v3->co, v2->co, v1->co);
- }
-
- if (mtface) {
- uv1 = tf->uv[0];
- uv2 = tf->uv[1];
- uv3 = tf->uv[2];
- uv4 = tf->uv[3];
- }
- else {
- uv1 = uv[0]; uv2 = uv[1]; uv3 = uv[2]; uv4 = uv[3];
- map_to_sphere(&uv[0][0], &uv[0][1], orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
- map_to_sphere(&uv[1][0], &uv[1][1], orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
- map_to_sphere(&uv[2][0], &uv[2][1], orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
- if (v4)
- map_to_sphere(&uv[3][0], &uv[3][1], orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
- }
-
- tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang);
- sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1);
- sum_or_add_vertex_tangent(arena, &vtangents[mf->v2], tang, uv2);
- sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3);
-
- if (mf->v4) {
- v4 = &mvert[mf->v4];
-
- tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, fno, tang);
- sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1);
- sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3);
- sum_or_add_vertex_tangent(arena, &vtangents[mf->v4], tang, uv4);
- }
- }
-
- /* write tangent to layer */
- for (i = 0, tf = mtface, mf = mface; i < totface; mf++, tf++, i++, tangent += 4) {
- len = (mf->v4) ? 4 : 3;
-
- if (mtface == NULL) {
- map_to_sphere(&uv[0][0], &uv[0][1], orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
- map_to_sphere(&uv[1][0], &uv[1][1], orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
- map_to_sphere(&uv[2][0], &uv[2][1], orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
- if (len == 4)
- map_to_sphere(&uv[3][0], &uv[3][1], orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
- }
-
- mf_vi[0] = mf->v1;
- mf_vi[1] = mf->v2;
- mf_vi[2] = mf->v3;
- mf_vi[3] = mf->v4;
-
- for (j = 0; j < len; j++) {
- vtang = find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]);
- normalize_v3_v3(tangent[j], vtang);
- ((float *) tangent[j])[3] = 1.0f;
- }
- }
- }
-
- BLI_memarena_free(arena);
- MEM_freeN(vtangents);
}
void DM_calc_auto_bump_scale(DerivedMesh *dm)
{
- /* int totvert= dm->getNumVerts(dm); */ /* UNUSED */
+ /* int totvert = dm->getNumVerts(dm); */ /* UNUSED */
int totface = dm->getNumTessFaces(dm);
MVert *mvert = dm->getVertArray(dm);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 66df7eccbd0..e95451252d0 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -224,7 +224,7 @@ bActionGroup *get_active_actiongroup(bAction *act)
{
bActionGroup *agrp = NULL;
- if (act && act->groups.first) {
+ if (act && act->groups.first) {
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
if (agrp->flag & AGRP_ACTIVE)
break;
@@ -301,7 +301,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
/* add to action, and validate */
BLI_addtail(&act->groups, agrp);
- BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
+ BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
/* return the new group */
return agrp;
@@ -380,7 +380,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
void action_groups_remove_channel(bAction *act, FCurve *fcu)
{
/* sanity checks */
- if (ELEM(NULL, act, fcu))
+ if (ELEM(NULL, act, fcu))
return;
/* check if any group used this directly */
@@ -906,8 +906,8 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE);
/* compare to the running tally */
- min = MIN2(min, nmin);
- max = MAX2(max, nmax);
+ min = min_ff(min, nmin);
+ max = max_ff(max, nmax);
foundvert = 1;
}
@@ -925,10 +925,10 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
FMod_Limits *fmd = (FMod_Limits *)fcm->data;
if (fmd->flag & FCM_LIMIT_XMIN) {
- min = MIN2(min, fmd->rect.xmin);
+ min = min_ff(min, fmd->rect.xmin);
}
if (fmd->flag & FCM_LIMIT_XMAX) {
- max = MAX2(max, fmd->rect.xmax);
+ max = max_ff(max, fmd->rect.xmax);
}
}
break;
@@ -955,7 +955,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
foundmod = 1;
}
}
- }
+ }
if (foundvert || foundmod) {
if (min == max) max += 1.0f;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 58d20fff2bc..f5c0660371b 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -40,6 +40,8 @@
#include "BLI_rand.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_group_types.h"
@@ -74,8 +76,8 @@
/* --------------------- */
/* forward declarations */
-static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int par_index,
- int level, short flag);
+static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4],
+ int persistent_id[MAX_DUPLI_RECUR], int level, int index, short flag);
/* ******************************************************************** */
/* Animation Visualization */
@@ -174,10 +176,10 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec
/* avoid 0 size allocs */
if (avs->path_sf >= avs->path_ef) {
BKE_reportf(reports, RPT_ERROR,
- "Motion Path frame extents invalid for %s (%d to %d).%s\n",
+ "Motion path frame extents invalid for %s (%d to %d)%s",
(pchan) ? pchan->name : ob->id.name,
avs->path_sf, avs->path_ef,
- (avs->path_sf == avs->path_ef) ? " Cannot have single-frame paths." : "");
+ (avs->path_sf == avs->path_ef) ? TIP_(", cannot have single-frame paths") : "");
return NULL;
}
@@ -704,31 +706,45 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
#define DUPLILIST_FOR_RENDER 2
#define DUPLILIST_ANIMATED 4
-static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int par_index, int type, short flag)
+static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay,
+ int persistent_id[MAX_DUPLI_RECUR], int level, int index, int type, short flag)
{
DupliObject *dob = MEM_callocN(sizeof(DupliObject), "dupliobject");
-
+ int i;
+
BLI_addtail(lb, dob);
dob->ob = ob;
copy_m4_m4(dob->mat, mat);
copy_m4_m4(dob->omat, ob->obmat);
dob->origlay = ob->lay;
- dob->index = index;
- dob->particle_index = par_index;
dob->type = type;
dob->animated = (type == OB_DUPLIGROUP) && (flag & DUPLILIST_ANIMATED);
ob->lay = lay;
+
+ /* set persistent id, which is an array with a persistent index for each level
+ * (particle number, vertex number, ..). by comparing this we can find the same
+ * dupli object between frames, which is needed for motion blur. last level
+ * goes first in the array. */
+ dob->persistent_id[0] = index;
+ for (i = 1; i < level; i++)
+ dob->persistent_id[i] = persistent_id[level - 1 - i];
+
+ /* metaballs never draw in duplis, they are instead merged into one by the basis
+ * mball outside of the group. this does mean that if that mball is not in the
+ * scene, they will not show up at all, limitation that should be solved once. */
+ if (ob->type == OB_MBALL)
+ dob->no_draw = TRUE;
return dob;
}
-static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_index,
+static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int persistent_id[MAX_DUPLI_RECUR],
int level, short flag)
{
DupliObject *dob;
Group *group;
GroupObject *go;
- float mat[4][4], tmat[4][4];
+ float mat[4][4], tmat[4][4], id;
if (ob->dup_group == NULL) return;
group = ob->dup_group;
@@ -748,7 +764,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
if (group_is_animated(ob, group))
flag |= DUPLILIST_ANIMATED;
- for (go = group->gobject.first; go; go = go->next) {
+ for (go = group->gobject.first, id = 0; go; go = go->next, id++) {
/* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
if (go->ob != ob) {
@@ -762,7 +778,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
}
- dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, par_index, OB_DUPLIGROUP, flag);
+ dob = new_dupli_object(lb, go->ob, mat, ob->lay, persistent_id, level, id, OB_DUPLIGROUP, flag);
/* check the group instance and object layers match, also that the object visible flags are ok. */
if ((dob->origlay & group->layer) == 0 ||
@@ -771,20 +787,17 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
{
dob->no_draw = TRUE;
}
- else {
- dob->no_draw = FALSE;
- }
if (go->ob->transflag & OB_DUPLI) {
copy_m4_m4(dob->ob->obmat, dob->mat);
- object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, par_index, level + 1, flag);
+ object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, persistent_id, level + 1, id, flag);
copy_m4_m4(dob->ob->obmat, dob->omat);
}
}
}
}
-static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_index, int level, short flag)
+static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int persistent_id[MAX_DUPLI_RECUR], int level, short flag)
{
extern int enable_cu_speed; /* object.c */
Object copyob;
@@ -822,7 +835,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_ind
ok = (ok < ob->dupon);
}
- if (ok) {
+ if (ok) {
DupliObject *dob;
/* WARNING: doing animation updates in this way is not terribly accurate, as the dependencies
@@ -832,7 +845,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_ind
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
- dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, par_index, OB_DUPLIFRAMES, flag);
+ dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, persistent_id, level, scene->r.cfra, OB_DUPLIFRAMES, flag);
copy_m4_m4(dob->omat, copyob.obmat);
}
}
@@ -863,7 +876,7 @@ typedef struct VertexDupliData {
Scene *scene;
Object *ob, *par;
float (*orco)[3];
- int par_index;
+ int *persistent_id;
} VertexDupliData;
/* ------------- */
@@ -900,7 +913,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
origlay = vdd->ob->lay;
- dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, vdd->par_index, OB_DUPLIVERTS, vdd->flag);
+ dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, vdd->persistent_id, vdd->level, index, OB_DUPLIVERTS, vdd->flag);
/* restore the original layer so that each dupli will have proper dob->origlay */
vdd->ob->lay = origlay;
@@ -912,12 +925,12 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
float tmpmat[4][4];
copy_m4_m4(tmpmat, vdd->ob->obmat);
copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
- object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->par_index, vdd->level + 1, vdd->flag);
+ object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->persistent_id, vdd->level + 1, index, vdd->flag);
copy_m4_m4(vdd->ob->obmat, tmpmat);
}
}
-static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int par_index,
+static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int persistent_id[MAX_DUPLI_RECUR],
int level, short flag)
{
Object *ob, *ob_iter;
@@ -968,7 +981,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
}
/* Start looping on Scene OR Group objects */
- while (base || go) {
+ while (base || go) {
if (sce) {
ob_iter = base->object;
oblay = base->lay;
@@ -1002,7 +1015,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
vdd.scene = scene;
vdd.par = par;
copy_m4_m4(vdd.pmat, pmat);
- vdd.par_index = par_index;
+ vdd.persistent_id = persistent_id;
/* mballs have a different dupli handling */
if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
@@ -1041,7 +1054,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
dm->release(dm);
}
-static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int par_index,
+static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int persistent_id[MAX_DUPLI_RECUR],
int level, short flag)
{
Object *ob, *ob_iter;
@@ -1102,7 +1115,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
}
/* Start looping on Scene OR Group objects */
- while (base || go) {
+ while (base || go) {
if (sce) {
ob_iter = base->object;
oblay = base->lay;
@@ -1184,7 +1197,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
copy_m4_m4(tmat, obmat);
mul_m4_m4m3(obmat, tmat, mat);
- dob = new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIFACES, (flag & DUPLILIST_ANIMATED));
+ dob = new_dupli_object(lb, ob, obmat, par->lay, persistent_id, level, a, OB_DUPLIFACES, (flag & DUPLILIST_ANIMATED));
if (flag & DUPLILIST_FOR_RENDER) {
w = 1.0f / (float)mp->totloop;
@@ -1207,7 +1220,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
float tmpmat[4][4];
copy_m4_m4(tmpmat, ob->obmat);
copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
- object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, par_index, level + 1, flag);
+ object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, persistent_id, level + 1, a, flag);
copy_m4_m4(ob->obmat, tmpmat);
}
}
@@ -1227,7 +1240,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
dm->release(dm);
}
-static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int UNUSED(par_index), ParticleSystem *psys,
+static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int persistent_id[MAX_DUPLI_RECUR], ParticleSystem *psys,
int level, short flag)
{
GroupObject *go;
@@ -1242,7 +1255,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
float ctime, pa_time, scale = 1.0f;
float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size = 0.0;
float (*obmat)[4], (*oldobmat)[4];
- int a, b, counter, index, hair = 0;
+ int a, b, hair = 0;
int totpart, totchild, totgroup = 0 /*, pa_num */;
int no_draw_flag = PARS_UNEXIST;
@@ -1358,8 +1371,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
else
a = totpart;
- index = 0;
- for (pa = psys->particles, counter = 0; a < totpart + totchild; a++, pa++, counter++) {
+ for (pa = psys->particles; a < totpart + totchild; a++, pa++) {
if (a < totpart) {
/* handle parent particle */
if (pa->flag & no_draw_flag)
@@ -1454,7 +1466,8 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
else
copy_m4_m4(mat, tmat);
- dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, index, OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED));
+ dob = new_dupli_object(lb, go->ob, mat, par->lay, persistent_id, level, a, OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED));
+ dob->particle_system = psys;
copy_m4_m4(dob->omat, obcopylist[b].obmat);
if (flag & DUPLILIST_FOR_RENDER)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
@@ -1514,14 +1527,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if (part->draw & PART_DRAW_GLOBAL_OB)
add_v3_v3v3(mat[3], mat[3], vec);
- dob = new_dupli_object(lb, ob, mat, ob->lay, counter, index, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED));
+ dob = new_dupli_object(lb, ob, mat, ob->lay, persistent_id, level, a, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED));
+ dob->particle_system = psys;
copy_m4_m4(dob->omat, oldobmat);
if (flag & DUPLILIST_FOR_RENDER)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
-
- /* only counts visible particles */
- index++;
}
/* restore objects since they were changed in BKE_object_where_is_calc_time */
@@ -1568,7 +1579,7 @@ static Object *find_family_object(Object **obar, char *family, char ch)
}
-static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_index, int level, short flag)
+static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int persistent_id[MAX_DUPLI_RECUR], int level, short flag)
{
Object *ob, *obar[256] = {NULL};
Curve *cu;
@@ -1607,7 +1618,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_inde
copy_m4_m4(obmat, par->obmat);
copy_v3_v3(obmat[3], vec);
- new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIVERTS, flag);
+ new_dupli_object(lb, ob, obmat, par->lay, persistent_id, level, a, OB_DUPLIVERTS, flag);
}
}
@@ -1616,8 +1627,8 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_inde
/* ------------- */
-static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int par_index,
- int level, short flag)
+static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4],
+ int persistent_id[MAX_DUPLI_RECUR], int level, int index, short flag)
{
if ((ob->transflag & OB_DUPLI) == 0)
return;
@@ -1634,34 +1645,45 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
}
}
+ /* keep track of persistent id */
+ if (level > 0)
+ persistent_id[level - 1] = index;
+
if (ob->transflag & OB_DUPLIPARTS) {
ParticleSystem *psys = ob->particlesystem.first;
- for (; psys; psys = psys->next)
- new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, psys, level + 1, flag);
+ int psysid = 0;
+
+ /* particle system take up one level in id, the particles another */
+ for (; psys; psys = psys->next, psysid++) {
+ persistent_id[level] = psysid;
+ new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, persistent_id, psys, level + 2, flag);
+ }
+
+ persistent_id[level] = 0;
}
else if (ob->transflag & OB_DUPLIVERTS) {
if (ob->type == OB_MESH) {
- vertex_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, level + 1, flag);
+ vertex_duplilist(duplilist, id, scene, ob, par_space_mat, persistent_id, level + 1, flag);
}
else if (ob->type == OB_FONT) {
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
- font_duplilist(duplilist, scene, ob, par_index, level + 1, flag);
+ font_duplilist(duplilist, scene, ob, persistent_id, level + 1, flag);
}
}
}
else if (ob->transflag & OB_DUPLIFACES) {
if (ob->type == OB_MESH)
- face_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, level + 1, flag);
+ face_duplilist(duplilist, id, scene, ob, par_space_mat, persistent_id, level + 1, flag);
}
else if (ob->transflag & OB_DUPLIFRAMES) {
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
- frames_duplilist(duplilist, scene, ob, par_index, level + 1, flag);
+ frames_duplilist(duplilist, scene, ob, persistent_id, level + 1, flag);
}
}
else if (ob->transflag & OB_DUPLIGROUP) {
DupliObject *dob;
- group_duplilist(duplilist, scene, ob, par_index, level + 1, flag); /* now recursive */
+ group_duplilist(duplilist, scene, ob, persistent_id, level + 1, flag); /* now recursive */
if (level == 0) {
for (dob = duplilist->first; dob; dob = dob->next)
@@ -1669,6 +1691,10 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
copy_m4_m4(dob->ob->obmat, dob->mat);
}
}
+
+ /* clear persistent id */
+ if (level > 0)
+ persistent_id[level - 1] = 0;
}
/* Returns a list of DupliObject
@@ -1676,13 +1702,14 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
ListBase *object_duplilist_ex(Scene *sce, Object *ob, int update, int for_render)
{
ListBase *duplilist = MEM_mallocN(sizeof(ListBase), "duplilist");
+ int persistent_id[MAX_DUPLI_RECUR] = {0};
int flag = 0;
- if(update) flag |= DUPLILIST_DO_UPDATE;
- if(for_render) flag |= DUPLILIST_FOR_RENDER;
+ if (update) flag |= DUPLILIST_DO_UPDATE;
+ if (for_render) flag |= DUPLILIST_FOR_RENDER;
duplilist->first = duplilist->last = NULL;
- object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0, flag);
+ object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, persistent_id, 0, 0, flag);
return duplilist;
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 5dae2035ab0..40b883e3f4e 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -188,9 +188,9 @@ short BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
else {
/* cannot set */
BKE_reportf(reports, RPT_ERROR,
- "Couldn't set Action '%s' onto ID '%s', as it doesn't have suitably rooted paths for this purpose",
- act->id.name + 2, id->name);
- //ok = 0;
+ "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths "
+ "for this purpose", act->id.name + 2, id->name);
+ /* ok = 0; */
}
}
else {
@@ -419,7 +419,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
/* should F-Curve be moved over?
* - we only need the start of the path to match basepath
*/
- if (animpath_matches_basepath(fcu->rna_path, basepath)) {
+ if (animpath_matches_basepath(fcu->rna_path, basepath)) {
bActionGroup *agrp = NULL;
/* if grouped... */
@@ -574,7 +574,7 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o
*/
if ( (prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr) ) {
/* if we haven't aren't able to resolve the path now, try again after fixing it */
- if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) {
+ if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) {
DynStr *ds = BLI_dynstr_new();
char *postfixPtr = oldNamePtr + oldNameLen;
char *newPath = NULL;
@@ -724,7 +724,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons
/* pad the names with [" "] so that only exact matches are made */
oldN = BLI_sprintfN("[\"%s\"]", oldName);
newN = BLI_sprintfN("[\"%s\"]", newName);
- }
+ }
else {
oldN = BLI_sprintfN("[%d]", oldSubscript);
newN = BLI_sprintfN("[%d]", newSubscript);
@@ -781,7 +781,7 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
ANIMDATA_NODETREE_IDS_CB(mainptr->tex.first, Tex);
/* lamps */
- ANIMDATA_IDS_CB(mainptr->lamp.first);
+ ANIMDATA_NODETREE_IDS_CB(mainptr->lamp.first, Lamp);
/* materials */
ANIMDATA_NODETREE_IDS_CB(mainptr->mat.first, Material);
@@ -823,7 +823,7 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
ANIMDATA_IDS_CB(mainptr->mask.first);
/* worlds */
- ANIMDATA_IDS_CB(mainptr->world.first);
+ ANIMDATA_NODETREE_IDS_CB(mainptr->world.first, World);
/* scenes */
ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene);
@@ -868,7 +868,7 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha
RENAMEFIX_ANIM_NODETREE_IDS(mainptr->tex.first, Tex);
/* lamps */
- RENAMEFIX_ANIM_IDS(mainptr->lamp.first);
+ RENAMEFIX_ANIM_NODETREE_IDS(mainptr->lamp.first, Lamp);
/* materials */
RENAMEFIX_ANIM_NODETREE_IDS(mainptr->mat.first, Material);
@@ -910,7 +910,7 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha
RENAMEFIX_ANIM_IDS(mainptr->mask.first);
/* worlds */
- RENAMEFIX_ANIM_IDS(mainptr->world.first);
+ RENAMEFIX_ANIM_NODETREE_IDS(mainptr->world.first, World);
/* scenes */
RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene);
@@ -973,9 +973,8 @@ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char nam
/* allocate new KeyingSet */
ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
- BLI_strncpy(ks->idname, idname ? idname : name ? name : "KeyingSet", sizeof(ks->idname));
-
- BLI_strncpy(ks->name, name ? name : idname ? idname : "Keying Set", sizeof(ks->name));
+ BLI_strncpy(ks->idname, (idname) ? idname : (name) ? name : "KeyingSet", sizeof(ks->idname));
+ BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : "Keying Set", sizeof(ks->name));
ks->flag = flag;
ks->keyingflag = keyingflag;
@@ -983,10 +982,10 @@ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char nam
/* add KeyingSet to list */
BLI_addtail(list, ks);
- /* Make sure KeyingSet has a unique idname. */
+ /* Make sure KeyingSet has a unique idname */
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, idname), sizeof(ks->idname));
- /* Make sure KeyingSet has a unique label (this helps with identification). */
+ /* Make sure KeyingSet has a unique label (this helps with identification) */
BLI_uniquename(list, ks, "Keying Set", '.', offsetof(KeyingSet, name), sizeof(ks->name));
/* return new KeyingSet for further editing */
@@ -1239,7 +1238,7 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in
if (new_ptr.type == &RNA_PoseBone) {
/* bone transforms - update pose (i.e. tag depsgraph) */
skip_updates_hack = 1;
- }
+ }
if (skip_updates_hack == 0)
RNA_property_update_cache_add(&new_ptr, prop);
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index b87342f85fa..b3cbc1f2b16 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -534,10 +534,12 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
mul_m4_v3(imat, h2);
/* if next bone is B-bone too, use average handle direction */
- if (next->bone->segments > 1)
- ;
- else
+ if (next->bone->segments > 1) {
+ /* pass */
+ }
+ else {
h2[1] -= length;
+ }
normalize_v3(h2);
/* find the next roll to interpolate as well */
@@ -945,7 +947,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
}
}
- if (use_dverts || armature_def_nr >= 0) {
+ if (use_dverts || armature_def_nr != -1) {
if (dm)
dvert = dm->getVertData(dm, i, CD_MDEFORMVERT);
else if (dverts && i < target_totvert)
@@ -956,7 +958,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
else
dvert = NULL;
- if (armature_def_nr >= 0 && dvert) {
+ if (armature_def_nr != -1 && dvert) {
armature_weight = defvert_find_weight(dvert, armature_def_nr);
if (invert_vgroup)
@@ -1423,19 +1425,20 @@ void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float
* *************************************************************************** */
/* Computes vector and roll based on a rotation.
* "mat" must contain only a rotation, and no scaling. */
-void mat3_to_vec_roll(float mat[][3], float vec[3], float *roll)
+void mat3_to_vec_roll(float mat[][3], float r_vec[3], float *r_roll)
{
- if (vec)
- copy_v3_v3(vec, mat[1]);
+ if (r_vec) {
+ copy_v3_v3(r_vec, mat[1]);
+ }
- if (roll) {
+ if (r_roll) {
float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
vec_roll_to_mat3(mat[1], 0.0f, vecmat);
invert_m3_m3(vecmatinv, vecmat);
mul_m3_m3m3(rollmat, vecmatinv, mat);
- *roll = (float)atan2(rollmat[2][0], rollmat[2][2]);
+ *r_roll = atan2f(rollmat[2][0], rollmat[2][2]);
}
}
@@ -1459,7 +1462,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3])
* so a value inbetween these is needed.
*
* was 0.000001, causes bug [#30438] (which is same as [#27675, imho).
- * Reseting it to org value seems to cause no more [#23954]...
+ * Resetting it to org value seems to cause no more [#23954]...
*
* was 0.0000000000001, caused bug [#31333], smaller values give unstable
* roll when toggling editmode again...
@@ -1590,7 +1593,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
if (UNLIKELY(pchanp == NULL)) {
/* happens for proxies that become invalid because of a missing link
- * for regulat cases it shouldn't happen at all */
+ * for regular cases it shouldn't happen at all */
}
else if (pchan->bone->layer & layer_protected) {
ListBase proxylocal_constraints = {NULL, NULL};
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 99b788e80ce..e1e868b234e 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -119,7 +119,7 @@ void free_blender(void)
BKE_sequencer_cache_destruct();
IMB_moviecache_destruct();
- free_nodesystem();
+ free_nodesystem();
}
void initglobals(void)
@@ -237,7 +237,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
/* free G.main Main database */
// CTX_wm_manager_set(C, NULL);
- clear_global();
+ clear_global();
/* clear old property update cache, in case some old references are left dangling */
RNA_property_update_cache_free();
@@ -338,7 +338,7 @@ static int handle_subversion_warning(Main *main, ReportList *reports)
(main->minversionfile == BLENDER_VERSION &&
main->minsubversionfile > BLENDER_SUBVERSION))
{
- BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d, expect loss of data!",
+ BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary (%d.%d), expect loss of data!",
main->minversionfile, main->minsubversionfile);
}
@@ -407,9 +407,9 @@ int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
}
else
setup_app_data(C, bfd, filepath); // frees BFD
- }
+ }
else
- BKE_reports_prependf(reports, "Loading %s failed: ", filepath);
+ BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
return (bfd ? retval : BKE_READ_FILE_FAIL);
}
@@ -485,7 +485,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
int success = 0, fileflags;
/* This is needed so undoing/redoing doesn't crash with threaded previews going */
- WM_jobs_stop_all(CTX_wm_manager(C));
+ WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */
@@ -612,7 +612,7 @@ void BKE_write_undo(bContext *C, const char *name)
}
}
-/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
+/* 1 = an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
void BKE_undo_step(bContext *C, int step)
{
@@ -621,7 +621,9 @@ void BKE_undo_step(bContext *C, int step)
}
else if (step == 1) {
/* curundo should never be NULL, after restart or load file it should call undo_save */
- if (curundo == NULL || curundo->prev == NULL) ; // XXX error("No undo available");
+ if (curundo == NULL || curundo->prev == NULL) {
+ // XXX error("No undo available");
+ }
else {
if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name);
curundo = curundo->prev;
@@ -631,7 +633,9 @@ void BKE_undo_step(bContext *C, int step)
else {
/* curundo has to remain current situation! */
- if (curundo == NULL || curundo->next == NULL) ; // XXX error("No redo available");
+ if (curundo == NULL || curundo->next == NULL) {
+ // XXX error("No redo available");
+ }
else {
read_undosave(C, curundo->next);
curundo = curundo->next;
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index a7d90f09160..0495e729937 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -102,7 +102,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step)
buffer = MEM_mallocN(bytes, "readBitmapFontVersion0:buffer");
- index = 0;
+ index = 0;
for (i = 0; i < bytes; i++) {
buffer[i] = rect[index];
index += step;
@@ -247,12 +247,13 @@ int locateGlyph(bmFont *bmfont, unsigned short unicode)
return(current);
}
-void matrixGlyph(ImBuf * ibuf, unsigned short unicode,
- float *centerx, float *centery,
- float *sizex, float *sizey,
- float *transx, float *transy,
- float *movex, float *movey,
- float *advance)
+void matrixGlyph(
+ ImBuf * ibuf, unsigned short unicode,
+ float *centerx, float *centery,
+ float *sizex, float *sizey,
+ float *transx, float *transy,
+ float *movex, float *movey,
+ float *advance)
{
int index;
bmFont *bmfont;
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 79d5e092a10..b6f1b88c912 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -101,13 +101,15 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
break;
}
}
- else if (rule->type == eBoidRuleType_Goal && eob == bpa->ground)
- ; /* skip current object */
+ else if (rule->type == eBoidRuleType_Goal && eob == bpa->ground) {
+ /* skip current object */
+ }
else if (pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(cur, &cur_efd, &epoint, 0)) {
float temp = mul * pd->f_strength * effector_falloff(cur, &cur_efd, &epoint, bbd->part->effector_weights);
- if (temp == 0.0f)
- ; /* do nothing */
+ if (temp == 0.0f) {
+ /* do nothing */
+ }
else if (temp > priority) {
priority = temp;
eff = cur;
@@ -954,7 +956,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
// }
//}
- bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f;
+ zero_v3(bbd->wanted_co);
+ bbd->wanted_speed = 0.0f;
/* create random seed for every particle & frame */
rand = (int)(PSYS_FRAND(psys->seed + p) * 1000);
@@ -988,7 +991,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
add_v3_v3(wanted_co, bbd->wanted_co);
wanted_speed += bbd->wanted_speed;
n++;
- bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f;
+ zero_v3(bbd->wanted_co);
+ bbd->wanted_speed = 0.0f;
}
}
@@ -1168,7 +1172,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* constrain direction with maximum angular velocity */
angle = saacos(dot_v3v3(old_dir, wanted_dir));
- angle = minf(angle, val.max_ave);
+ angle = min_ff(angle, val.max_ave);
cross_v3_v3v3(nor, old_dir, wanted_dir);
axis_angle_to_quat(q, nor, angle);
@@ -1264,9 +1268,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
{
float grav[3];
- grav[0]= 0.0f;
- grav[1]= 0.0f;
- grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f;
+ grav[0] = 0.0f;
+ grav[1] = 0.0f;
+ grav[2] = bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f;
/* don't take forward acceleration into account (better banking) */
if (dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
@@ -1307,9 +1311,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
{
float grav[3];
- grav[0]= 0.0f;
- grav[1]= 0.0f;
- grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f;
+ grav[0] = 0.0f;
+ grav[1] = 0.0f;
+ grav[2] = bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f;
/* gather apparent gravity */
diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c
index be79077bb58..461b945282f 100644
--- a/source/blender/blenkernel/intern/booleanops_mesh.c
+++ b/source/blender/blenkernel/intern/booleanops_mesh.c
@@ -142,7 +142,7 @@ CSG_AddMeshToBlender(
/* Create a new blender mesh object - using 'base' as
* a template for the new object. */
- ob_new= AddNewBlenderMesh(mesh->base);
+ ob_new = AddNewBlenderMesh(mesh->base);
me_new = ob_new->data;
@@ -180,7 +180,7 @@ CSG_PerformOp(
if ((mesh1 == NULL) || (mesh2 == NULL) || (output == NULL)) {
return 0;
- }
+ }
if ((int_op_type < 1) || (int_op_type > 3)) return 0;
switch (int_op_type) {
@@ -203,8 +203,8 @@ CSG_PerformOp(
mesh1->m_face_iterator,
mesh1->m_vertex_iterator,
mesh2->m_face_iterator,
- mesh2->m_vertex_iterator,
- InterpFaceVertexData
+ mesh2->m_vertex_iterator,
+ InterpFaceVertexData
);
}
else {
@@ -215,8 +215,8 @@ CSG_PerformOp(
mesh1->m_face_iterator,
mesh1->m_vertex_iterator,
mesh2->m_face_iterator,
- mesh2->m_vertex_iterator,
- InterpNoUserData
+ mesh2->m_vertex_iterator,
+ InterpNoUserData
);
}
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ce39eea5ceb..98b206712d6 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -618,18 +618,18 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
/* Unified Size and Strength */
-// XXX: be careful about setting size and unprojected radius
-// because they depend on one another
-// these functions do not set the other corresponding value
-// this can lead to odd behavior if size and unprojected
-// radius become inconsistent.
-// the biggest problem is that it isn't possible to change
-// unprojected radius because a view context is not
-// available. my ussual solution to this is to use the
-// ratio of change of the size to change the unprojected
-// radius. Not completely convinced that is correct.
-// In anycase, a better solution is needed to prevent
-// inconsistency.
+/* XXX: be careful about setting size and unprojected radius
+ * because they depend on one another
+ * these functions do not set the other corresponding value
+ * this can lead to odd behavior if size and unprojected
+ * radius become inconsistent.
+ * the biggest problem is that it isn't possible to change
+ * unprojected radius because a view context is not
+ * available. my ussual solution to this is to use the
+ * ratio of change of the size to change the unprojected
+ * radius. Not completely convinced that is correct.
+ * In anycase, a better solution is needed to prevent
+ * inconsistency. */
void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
{
@@ -741,7 +741,7 @@ void BKE_brush_scale_unprojected_radius(float *unprojected_radius,
}
/* scale brush size to reflect a change in the brush's unprojected radius */
-void BKE_brush_scale_size(int *BKE_brush_size_get,
+void BKE_brush_scale_size(int *r_brush_size,
float new_unprojected_radius,
float old_unprojected_radius)
{
@@ -749,7 +749,7 @@ void BKE_brush_scale_size(int *BKE_brush_size_get,
/* avoid division by zero */
if (old_unprojected_radius != 0)
scale /= new_unprojected_radius;
- (*BKE_brush_size_get) = (int)((float)(*BKE_brush_size_get) * scale);
+ (*r_brush_size) = (int)((float)(*r_brush_size) * scale);
}
/* Brush Painting */
@@ -876,8 +876,8 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf,
/* not sure if it's actually needed or it's a mistake in coords/sizes
* calculation in brush_painter_fixed_tex_partial_update(), but without this
* limitation memory gets corrupted at fast strokes with quite big spacing (sergey) */
- w = MIN2(w, ibuf->x);
- h = MIN2(h, ibuf->y);
+ w = min_ii(w, ibuf->x);
+ h = min_ii(h, ibuf->y);
if (painter->cache.flt) {
for (; y < h; y++) {
@@ -1052,13 +1052,13 @@ void BKE_brush_painter_break_stroke(BrushPainter *painter)
static void brush_pressure_apply(BrushPainter *painter, Brush *brush, float pressure)
{
if (BKE_brush_use_alpha_pressure(painter->scene, brush))
- brush_alpha_set(painter->scene, brush, maxf(0.0f, painter->startalpha * pressure));
+ brush_alpha_set(painter->scene, brush, max_ff(0.0f, painter->startalpha * pressure));
if (BKE_brush_use_size_pressure(painter->scene, brush))
- BKE_brush_size_set(painter->scene, brush, maxf(1.0f, painter->startsize * pressure));
+ BKE_brush_size_set(painter->scene, brush, max_ff(1.0f, painter->startsize * pressure));
if (brush->flag & BRUSH_JITTER_PRESSURE)
- brush->jitter = maxf(0.0f, painter->startjitter * pressure);
+ brush->jitter = max_ff(0.0f, painter->startjitter * pressure);
if (brush->flag & BRUSH_SPACING_PRESSURE)
- brush->spacing = maxf(1.0f, painter->startspacing * (1.5f - pressure));
+ brush->spacing = max_ff(1.0f, painter->startspacing * (1.5f - pressure));
}
void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2])
@@ -1158,7 +1158,7 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p
/* compute brush spacing adapted to brush radius, spacing may depend
* on pressure, so update it */
brush_pressure_apply(painter, brush, painter->lastpressure);
- spacing = maxf(1.0f, radius) * brush->spacing * 0.01f;
+ spacing = max_ff(1.0f, radius) * brush->spacing * 0.01f;
/* setup starting distance, direction vector and accumulated distance */
startdistance = painter->accumdistance;
@@ -1176,7 +1176,7 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p
t = step / len;
press = (1.0f - t) * painter->lastpressure + t * pressure;
brush_pressure_apply(painter, brush, press);
- spacing = maxf(1.0f, radius) * brush->spacing * 0.01f;
+ spacing = max_ff(1.0f, radius) * brush->spacing * 0.01f;
BKE_brush_jitter_pos(scene, brush, paintpos, finalpos);
diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c
index 7defa7e1be3..088031e16a7 100644
--- a/source/blender/blenkernel/intern/bullet.c
+++ b/source/blender/blenkernel/intern/bullet.c
@@ -54,7 +54,7 @@ BulletSoftBody *bsbNew(void)
bsb->viterations = 0;
- bsb->piterations = 2;
+ bsb->piterations = 2;
bsb->diterations = 0;
bsb->citerations = 4;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 32ae6d04934..ad828a70dd8 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -358,8 +358,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
* BVH from meshs callbacks
*/
-// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces.
-// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
+/* Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces.
+ * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */
static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
{
const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
@@ -395,8 +395,8 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
} while (t2);
}
-// Callback to bvh tree raycast. The tree must bust have been built using bvhtree_from_mesh_faces.
-// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
+/* Callback to bvh tree raycast. The tree must bust have been built using bvhtree_from_mesh_faces.
+ * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */
static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
{
const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
@@ -435,8 +435,8 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
} while (t2);
}
-// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges.
-// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
+/* Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges.
+ * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */
static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
{
const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
@@ -463,12 +463,12 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
/*
* BVH builders
*/
-// Builds a bvh tree.. where nodes are the vertexs of the given mesh
+/* Builds a bvh tree.. where nodes are the vertexs of the given mesh */
BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
{
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES);
- //Not in cache
+ /* Not in cache */
if (tree == NULL) {
int i;
int numVerts = mesh->getNumVerts(mesh);
@@ -484,7 +484,7 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float
BLI_bvhtree_balance(tree);
- //Save on cache for later use
+ /* Save on cache for later use */
// printf("BVHTree built and saved on cache\n");
bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_VERTICES);
}
@@ -495,15 +495,15 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
- //Setup BVHTreeFromMesh
+ /* Setup BVHTreeFromMesh */
memset(data, 0, sizeof(*data));
data->tree = tree;
if (data->tree) {
data->cached = TRUE;
- //a NULL nearest callback works fine
- //remeber the min distance to point is the same as the min distance to BV of point
+ /* a NULL nearest callback works fine
+ * remeber the min distance to point is the same as the min distance to BV of point */
data->nearest_callback = NULL;
data->raycast_callback = NULL;
@@ -517,12 +517,12 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float
return data->tree;
}
-// Builds a bvh tree.. where nodes are the faces of the given mesh.
+/* Builds a bvh tree.. where nodes are the faces of the given mesh. */
BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
{
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES);
- //Not in cache
+ /* Not in cache */
if (tree == NULL) {
int i;
int numFaces = mesh->getNumTessFaces(mesh);
@@ -616,7 +616,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
BLI_bvhtree_balance(tree);
- //Save on cache for later use
+ /* Save on cache for later use */
// printf("BVHTree built and saved on cache\n");
bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_FACES);
}
@@ -627,7 +627,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
- //Setup BVHTreeFromMesh
+ /* Setup BVHTreeFromMesh */
memset(data, 0, sizeof(*data));
data->tree = tree;
@@ -647,12 +647,12 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
-// Builds a bvh tree.. where nodes are the faces of the given mesh.
+/* Builds a bvh tree.. where nodes are the faces of the given mesh. */
BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
{
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
- //Not in cache
+ /* Not in cache */
if (tree == NULL) {
int i;
int numEdges = mesh->getNumEdges(mesh);
@@ -672,7 +672,7 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
BLI_bvhtree_balance(tree);
- //Save on cache for later use
+ /* Save on cache for later use */
// printf("BVHTree built and saved on cache\n");
bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_EDGES);
}
@@ -683,7 +683,7 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
- //Setup BVHTreeFromMesh
+ /* Setup BVHTreeFromMesh */
memset(data, 0, sizeof(*data));
data->tree = tree;
@@ -703,7 +703,7 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
-// Frees data allocated by a call to bvhtree_from_mesh_*.
+/* Frees data allocated by a call to bvhtree_from_mesh_*. */
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
{
if (data->tree) {
@@ -728,7 +728,7 @@ static void bvhcacheitem_set_if_match(void *_cached, void *_search)
BVHCacheItem *search = (BVHCacheItem *)_search;
if (search->type == cached->type) {
- search->tree = cached->tree;
+ search->tree = cached->tree;
}
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index ed7ac0e1a32..9118baeae6f 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -151,7 +151,7 @@ float BKE_camera_object_dof_distance(Object *ob)
Camera *cam = (Camera *)ob->data;
if (ob->type != OB_CAMERA)
return 0.0f;
- if (cam->dof_ob) {
+ if (cam->dof_ob) {
/* too simple, better to return the distance on the view axis only
* return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */
float mat[4][4], imat[4][4], obmat[4][4];
@@ -262,11 +262,12 @@ void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView
}
else if (rv3d->persp == RV3D_ORTHO) {
/* orthographic view */
+ int sensor_size = BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y);
params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality
params->clipsta = -params->clipend;
params->is_ortho = TRUE;
- params->ortho_scale = rv3d->dist;
+ params->ortho_scale = rv3d->dist * sensor_size / v3d->lens;
params->zoom = 2.0f;
}
else {
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index e93c9373107..b7ad135fa72 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -272,6 +272,8 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
cddm->pbvh = BLI_pbvh_new();
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
+ pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color);
+
BKE_mesh_tessface_ensure(me);
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
@@ -382,7 +384,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
for (i = 0; i < dm->numTessFaceData; i++, mf++) {
if (!(mf->flag & ME_HIDE)) {
draw = 1;
- }
+ }
else {
draw = 0;
}
@@ -449,7 +451,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
(drawLooseEdges || !(medge->flag & ME_LOOSEEDGE)))
{
draw = TRUE;
- }
+ }
else {
draw = FALSE;
}
@@ -499,7 +501,7 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
for (i = 0; i < dm->numEdgeData; i++, medge++) {
if (medge->flag & ME_LOOSEEDGE) {
draw = 1;
- }
+ }
else {
draw = 0;
}
@@ -566,7 +568,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
glShadeModel(shademodel = new_shademodel);
gpuBegin(glmode = new_glmode);
- }
+ }
if (drawCurrentMat) {
if (shademodel == GL_FLAT) {
@@ -627,14 +629,29 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
MVert *mv = cddm->mvert;
MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
- MCol *realcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL);
float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
- int i, j, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
- int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */;
- MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
- if (!mcol)
- mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
+ MCol *mcol;
+ int i, orig;
+ int colType, startFace = 0;
+
+ /* double lookup */
+ const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
+
+ colType = CD_TEXTURE_MCOL;
+ mcol = dm->getTessFaceDataArray(dm, colType);
+ if (!mcol) {
+ colType = CD_PREVIEW_MCOL;
+ mcol = dm->getTessFaceDataArray(dm, colType);
+ }
+ if (!mcol) {
+ colType = CD_MCOL;
+ mcol = dm->getTessFaceDataArray(dm, colType);
+ }
cdDM_update_normals_from_pbvh(dm);
@@ -650,8 +667,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
draw_option = drawParams(tf ? &tf[i] : NULL, (mcol != NULL), mf->mat_nr);
}
else {
- if (index) {
- orig = *index++;
+ if (index_mf_to_mpoly) {
+ orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, i);
if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; }
if (drawParamsMapped) { draw_option = drawParamsMapped(userData, orig); }
else { if (nors) nors += 3; continue; }
@@ -714,42 +731,11 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
gpuImmediateUnformat();
}
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
- MCol *col = realcol;
- if (!col)
- col = mcol;
-
GPU_vertex_setup(dm);
GPU_normal_setup(dm);
GPU_uv_setup(dm);
- if (col != NULL) {
-#if 0
- if (realcol && dm->drawObject->colType == CD_TEXTURE_MCOL) {
- col = 0;
- }
- else if (mcol && dm->drawObject->colType == CD_MCOL) {
- col = 0;
- }
-
- if (col != 0)
-#endif
- {
- unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm) * 4 * 3 * sizeof(unsigned char), "cdDM_drawFacesTex_common");
- for (i = 0; i < dm->getNumTessFaces(dm); i++) {
- for (j = 0; j < 4; j++) {
- /* bgr -> rgb is intentional (and stupid), but how its stored internally */
- colors[i * 12 + j * 3] = col[i * 4 + j].b;
- colors[i * 12 + j * 3 + 1] = col[i * 4 + j].g;
- colors[i * 12 + j * 3 + 2] = col[i * 4 + j].r;
- }
- }
- GPU_color3_upload(dm, colors);
- MEM_freeN(colors);
- if (realcol)
- dm->drawObject->colType = CD_TEXTURE_MCOL;
- else if (mcol)
- dm->drawObject->colType = CD_MCOL;
- }
- GPU_color_setup(dm);
+ if (mcol) {
+ GPU_color_setup(dm, colType);
}
if (!GPU_buffer_legacy(dm)) {
@@ -770,15 +756,18 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
draw_option = drawParams(tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr);
}
else {
- if (index) {
- orig = index[actualFace];
- if (orig == ORIGINDEX_NONE) continue;
- if (drawParamsMapped)
+ if (index_mf_to_mpoly) {
+ orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace);
+ if (orig == ORIGINDEX_NONE) {
+ continue;
+ }
+ if (drawParamsMapped) {
draw_option = drawParamsMapped(userData, orig);
+ }
}
- else
- if (drawParamsMapped)
+ else if (drawParamsMapped) {
draw_option = drawParamsMapped(userData, actualFace);
+ }
}
/* flush buffer if current triangle isn't drawable or it's last triangle */
@@ -796,7 +785,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
int count = (i - startFace + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3;
if (count) {
- if (col)
+ if (mcol && draw_option != DM_DRAW_OPTION_NO_MCOL)
GPU_color_switch(1);
else
GPU_color_switch(0);
@@ -833,12 +822,42 @@ static void cdDM_drawMappedFaces(
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
MVert *mv = cddm->mvert;
MFace *mf = cddm->mface;
-
float *nors;
- MCol *mc = NULL;
+ MCol *mcol;
int *index;
+ int colType;
+ int i;
+ int orig;
+ int *index_mf_to_mpoly;
+ int *index_mp_to_orig;
- int i, orig;
+
+ /* double lookup */
+ index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
+
+
+ if (flag & DM_DRAW_USE_COLORS) {
+ colType = CD_ID_MCOL;
+ mcol = DM_get_tessface_data_layer(dm, colType);
+
+ if (!mcol) {
+ colType = CD_PREVIEW_MCOL;
+ mcol = DM_get_tessface_data_layer(dm, colType);
+
+ if (!mcol) {
+ colType = CD_MCOL;
+ mcol = DM_get_tessface_data_layer(dm, colType);
+ }
+ }
+ }
+ else {
+ mcol = NULL;
+ }
+
if (flag & DM_DRAW_USE_NORMALS) {
nors = DM_get_tessface_data_layer(dm, CD_NORMAL);
@@ -849,20 +868,10 @@ static void cdDM_drawMappedFaces(
nors = NULL;
}
- if (flag & DM_DRAW_USE_COLORS) {
- mc = DM_get_tessface_data_layer(dm, CD_ID_MCOL);
-
- if (!mc) {
- mc = DM_get_tessface_data_layer(dm, CD_PREVIEW_MCOL);
-
- if (!mc) {
- mc = DM_get_tessface_data_layer(dm, CD_MCOL);
- }
- }
- }
-
+
index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+
/* back-buffer always uses legacy since VBO's would need the
* color array temporarily overwritten for drawing, then reset. */
if (GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
@@ -876,7 +885,7 @@ static void cdDM_drawMappedFaces(
int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH);
DMDrawOption draw_option;
- orig = (index == NULL) ? i : *index++;
+ orig = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, i) : i;
if (orig == ORIGINDEX_NONE)
draw_option = setMaterial(mf->mat_nr + 1, NULL);
@@ -888,8 +897,8 @@ static void cdDM_drawMappedFaces(
if (draw_option != DM_DRAW_OPTION_SKIP) {
unsigned char *cp = NULL;
- if (mc)
- cp = (unsigned char *)&mc[i * 4];
+ if (mcol)
+ cp = (unsigned char *)&mcol[i * 4];
gpuBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES);
@@ -951,8 +960,8 @@ static void cdDM_drawMappedFaces(
GPU_normal_setup(dm);
}
- if (mc) {
- GPU_color_setup(dm);
+ if (mcol) {
+ GPU_color_setup(dm, colType);
}
if (!GPU_buffer_legacy(dm)) {
@@ -982,7 +991,7 @@ static void cdDM_drawMappedFaces(
if (i != tottri - 1)
next_actualFace = dm->drawObject->triangle_to_mface[i + 1];
- orig = (index == NULL) ? actualFace : index[actualFace];
+ orig = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace) : actualFace;
if (orig == ORIGINDEX_NONE)
draw_option = setMaterial(mface->mat_nr + 1, NULL);
@@ -1174,7 +1183,14 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
/* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
float (*nors)[3] = dm->getTessFaceDataArray(dm, CD_NORMAL);
int a, b, do_draw, matnr, new_matnr;
- int orig, *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ int orig;
+
+ /* double lookup */
+ const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
cdDM_update_normals_from_pbvh(dm);
@@ -1210,7 +1226,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
continue;
}
else if (setDrawOptions) {
- orig = (index) ? index[a] : a;
+ orig = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
if (orig == ORIGINDEX_NONE) {
/* since the material is set by setMaterial(), faces with no
@@ -1316,13 +1332,13 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
datatypes[numdata].size = 2;
datatypes[numdata].type = GL_FLOAT;
numdata++;
- }
+ }
for (b = 0; b < attribs.totmcol; b++) {
datatypes[numdata].index = attribs.mcol[b].gl_index;
datatypes[numdata].size = 4;
datatypes[numdata].type = GL_UNSIGNED_BYTE;
numdata++;
- }
+ }
if (attribs.tottang) {
datatypes[numdata].index = attribs.tang.gl_index;
datatypes[numdata].size = 4;
@@ -1382,7 +1398,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
offset += sizeof(unsigned char) * 4;
- }
+ }
if (attribs.tottang) {
float *tang = attribs.tang.array[a * 4 + 0];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
@@ -1423,7 +1439,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
offset += sizeof(unsigned char) * 4;
- }
+ }
if (attribs.tottang) {
float *tang = attribs.tang.array[a * 4 + 2];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
@@ -1474,7 +1490,14 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
MFace *mf = cddm->mface;
float (*nors)[3] = dm->getTessFaceDataArray(dm, CD_NORMAL);
int a, matnr, new_matnr;
- int orig, *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ int orig;
+
+ /* double lookup */
+ const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
cdDM_update_normals_from_pbvh(dm);
@@ -1506,7 +1529,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
/* skipping faces */
if (setFace) {
- orig = (index) ? index[a] : a;
+ orig = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
if (orig != ORIGINDEX_NONE && !setFace(userData, orig))
continue;
@@ -1674,11 +1697,6 @@ void CDDM_recalc_tessellation_ex(DerivedMesh *dm, const int do_face_nor_cpy)
dm->numTessFaceData, dm->numLoopData, dm->numPolyData,
do_face_nor_cpy);
- if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) {
- int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX);
- CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_REFERENCE, polyIndex, dm->numTessFaceData);
- }
-
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
/* Tessellation recreated faceData, and the active layer indices need to get re-propagated
@@ -1790,7 +1808,6 @@ DerivedMesh *CDDM_new(int numVerts, int numEdges, int numTessFaces, int numLoops
CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts);
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces);
- CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numTessFaces);
CustomData_add_layer(&dm->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, numPolys);
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts);
@@ -1814,7 +1831,6 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
DerivedMesh *dm = &cddm->dm;
CustomDataMask mask = CD_MASK_MESH & (~CD_MASK_MDISPS);
int alloctype;
- int *polyindex = NULL;
/* this does a referenced copy, with an exception for fluidsim */
@@ -1829,7 +1845,7 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
mesh->totvert);
CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype,
mesh->totedge);
- CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_POLYINDEX, alloctype,
+ CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_ORIGINDEX, alloctype,
mesh->totface);
CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype,
mesh->totloop);
@@ -1842,17 +1858,12 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
- /* commented since even when CD_POLYINDEX was first added this line fails
+ /* commented since even when CD_ORIGINDEX was first added this line fails
* on the default cube, (after editmode toggle too) - campbell */
#if 0
- BLI_assert(CustomData_has_layer(&cddm->dm.faceData, CD_POLYINDEX));
+ BLI_assert(CustomData_has_layer(&cddm->dm.faceData, CD_ORIGINDEX));
#endif
- polyindex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX);
- if (!CustomData_has_layer(&cddm->dm.faceData, CD_ORIGINDEX)) {
- CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_REFERENCE, polyindex, mesh->totface);
- }
-
return dm;
}
@@ -1938,10 +1949,10 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase, int **orco
}
static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
- int cdindex, BMLoop *l3[3],
+ int cdindex, const BMLoop *l3[3],
int numCol, int numTex)
{
- BMLoop *l;
+ const BMLoop *l;
BMFace *f = l3[0]->f;
MTFace *texface;
MTexPoly *texpoly;
@@ -1984,13 +1995,16 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
}
}
-DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps, int use_tessface)
+/* used for both editbmesh and bmesh */
+static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
+ /* EditBMesh vars for use_tessface */
+ int use_tessface,
+ const int em_tottri, const BMLoop *(*em_looptris)[3]
+ )
{
- BMesh *bm = em->bm;
-
DerivedMesh *dm = CDDM_new(bm->totvert,
bm->totedge,
- use_tessface ? em->tottri : 0,
+ use_tessface ? em_tottri : 0,
bm->totloop,
bm->totface);
@@ -2036,7 +2050,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
/* add tessellation mface layers */
if (use_tessface) {
- CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
+ CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em_tottri);
}
index = dm->getVertDataArray(dm, CD_ORIGINDEX);
@@ -2094,15 +2108,13 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
/* avoid this where possiblem, takes extra memory */
if (use_tessface) {
- int *polyindex;
BM_mesh_elem_index_ensure(bm, BM_FACE);
- polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX);
index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- for (i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
+ for (i = 0; i < dm->numTessFaceData; i++, index++) {
MFace *mf = &mface[i];
- BMLoop **l = em->looptris[i];
+ const BMLoop **l = em_looptris[i];
efa = l[0]->f;
mf->v1 = BM_elem_index_get(l[0]->v);
@@ -2112,8 +2124,8 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
mf->mat_nr = efa->mat_nr;
mf->flag = BM_face_flag_to_mflag(efa);
- *index = add_orig ? BM_elem_index_get(efa) : *(int *)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
- *polyindex = BM_elem_index_get(efa);
+ /* map mfaces to polygons in the same cddm intentionally */
+ *index = BM_elem_index_get(efa);
loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
test_index_face(mf, &dm->faceData, i, 3);
@@ -2152,6 +2164,20 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
return dm;
}
+struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps)
+{
+ return cddm_from_bmesh_ex(bm, use_mdisps, FALSE,
+ /* these vars are for editmesh only */
+ 0, NULL);
+}
+
+DerivedMesh *CDDM_from_editbmesh(BMEditMesh *em, int use_mdisps, int use_tessface)
+{
+ return cddm_from_bmesh_ex(em->bm, use_mdisps,
+ /* editmesh */
+ use_tessface, em->tottri, (const BMLoop *(*)[3])em->looptris);
+}
+
static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces)
{
CDDerivedMesh *cddm = cdDM_create("CDDM_copy cddm");
@@ -2166,6 +2192,7 @@ static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces)
source->getVertDataArray(source, CD_ORIGINDEX);
source->getEdgeDataArray(source, CD_ORIGINDEX);
source->getTessFaceDataArray(source, CD_ORIGINDEX);
+ source->getPolyDataArray(source, CD_ORIGINDEX);
/* this initializes dm, and copies all non mvert/medge/mface layers */
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces,
@@ -2220,6 +2247,7 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source,
source->getVertDataArray(source, CD_ORIGINDEX);
source->getEdgeDataArray(source, CD_ORIGINDEX);
source->getTessFaceDataArray(source, CD_ORIGINDEX);
+ source->getPolyDataArray(source, CD_ORIGINDEX);
/* this does a copy of all non mvert/medge/mface layers */
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, numLoops, numPolys);
@@ -2237,8 +2265,6 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source,
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces);
- if (!CustomData_get_layer(&dm->faceData, CD_POLYINDEX))
- CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numTessFaces);
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
@@ -2303,8 +2329,8 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals
CDDM_recalc_tessellation_ex(dm, FALSE);
}
else {
- /* A tessellation already exists, it should always have a CD_POLYINDEX */
- BLI_assert(CustomData_has_layer(&dm->faceData, CD_POLYINDEX));
+ /* A tessellation already exists, it should always have a CD_ORIGINDEX */
+ BLI_assert(CustomData_has_layer(&dm->faceData, CD_ORIGINDEX));
CustomData_free_layers(&dm->faceData, CD_NORMAL, dm->numTessFaceData);
}
@@ -2314,7 +2340,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals
/* calculate face normals */
BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData,
- CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors,
+ CustomData_get_layer(&dm->faceData, CD_ORIGINDEX), face_nors,
only_face_normals);
CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN,
@@ -2488,7 +2514,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
BLI_array_append(oldp, i);
}
- /*create new cddm*/
+ /*create new cddm*/
cddm2 = (CDDerivedMesh *) CDDM_from_template((DerivedMesh *)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly));
/*update edge indices and copy customdata*/
@@ -2513,7 +2539,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap)
CustomData_copy_data(&dm->loopData, &cddm2->dm.loopData, oldl[i], i, 1);
}
- /*copy vertex customdata*/
+ /*copy vertex customdata*/
mv = mvert;
for (i = 0; i < cddm2->dm.numVertData; i++, mv++) {
CustomData_copy_data(&dm->vertData, &cddm2->dm.vertData, oldv[i], i, 1);
@@ -2588,7 +2614,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
numEdges = BLI_edgehash_size(eh);
/* write new edges into a temporary CustomData */
- memset(&edgeData, 0, sizeof(edgeData));
+ CustomData_reset(&edgeData);
CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
@@ -2653,7 +2679,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
numEdges = BLI_edgehash_size(eh);
/* write new edges into a temporary CustomData */
- memset(&edgeData, 0, sizeof(edgeData));
+ CustomData_reset(&edgeData);
CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 4241756a109..f1d73c7777a 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -41,8 +41,6 @@
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
-#include "BLF_translation.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_cloth.h"
#include "BKE_effect.h"
@@ -331,7 +329,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
cache= clmd->point_cache;
/* initialize simulation data if it didn't exist already */
- if (clmd->clothObject == NULL) {
+ if (clmd->clothObject == NULL) {
if (!cloth_from_object(ob, clmd, result, framenr, 1)) {
BKE_ptcache_invalidate(cache);
return 0;
@@ -773,11 +771,13 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
else
verts->goal= 0.0f;
+ /* Reset vertex flags */
+ verts->flags &= ~CLOTH_VERT_FLAG_PINNED;
+ verts->flags &= ~CLOTH_VERT_FLAG_NOSELFCOLL;
+
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
if ( dvert ) {
-
for ( j = 0; j < dvert->totweight; j++ ) {
- verts->flags &= ~CLOTH_VERT_FLAG_PINNED;
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) {
verts->goal = dvert->dw [j].weight;
@@ -789,7 +789,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
*/
verts->goal = powf(verts->goal, 4.0f);
- if ( verts->goal >=SOFTGOALSNAP )
+ if ( verts->goal >= SOFTGOALSNAP )
verts->flags |= CLOTH_VERT_FLAG_PINNED;
}
@@ -804,7 +804,6 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
}
}
- verts->flags &= ~CLOTH_VERT_FLAG_NOSELFCOLL;
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) {
if ( dvert->dw[j].def_nr == (clmd->coll_parms->vgroup_selfcol-1)) {
if (dvert->dw [j].weight > 0.0f) {
@@ -823,7 +822,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
int i = 0;
MVert *mvert = NULL;
ClothVertex *verts = NULL;
- float (*shapekey_rest)[3]= NULL;
+ float (*shapekey_rest)[3] = NULL;
float tnull[3] = {0, 0, 0};
Cloth *cloth = NULL;
float maxdist = 0;
@@ -844,7 +843,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
clmd->clothObject->edgehash = NULL;
}
else if (!clmd->clothObject) {
- modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject."));
+ modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject");
return 0;
}
@@ -906,7 +905,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
if ( !cloth_build_springs ( clmd, dm ) ) {
cloth_free_modifier ( clmd );
- modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs."));
+ modifier_setError(&(clmd->modifier), "Cannot build springs");
printf("cloth_free_modifier cloth_build_springs\n");
return 0;
}
@@ -948,7 +947,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" );
if ( clmd->clothObject->verts == NULL ) {
cloth_free_modifier ( clmd );
- modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts."));
+ modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject->verts");
printf("cloth_free_modifier clmd->clothObject->verts\n");
return;
}
@@ -958,7 +957,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" );
if ( clmd->clothObject->mfaces == NULL ) {
cloth_free_modifier ( clmd );
- modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces."));
+ modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject->mfaces");
printf("cloth_free_modifier clmd->clothObject->mfaces\n");
return;
}
@@ -1049,29 +1048,25 @@ static void cloth_update_springs( ClothModifierData *clmd )
spring->stiffness = 0.0f;
- if(spring->type == CLOTH_SPRING_TYPE_STRUCTURAL)
- {
+ if (spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0f;
}
- else if(spring->type == CLOTH_SPRING_TYPE_SHEAR)
- {
+ else if (spring->type == CLOTH_SPRING_TYPE_SHEAR) {
spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f;
}
- else if(spring->type == CLOTH_SPRING_TYPE_BENDING)
- {
+ else if (spring->type == CLOTH_SPRING_TYPE_BENDING) {
spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f;
}
- else if(spring->type == CLOTH_SPRING_TYPE_GOAL)
- {
+ else if (spring->type == CLOTH_SPRING_TYPE_GOAL) {
/* Warning: Appending NEW goal springs does not work because implicit solver would need reset! */
/* Activate / Deactivate existing springs */
- if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[spring->ij].goal > ALMOST_ZERO))
+ if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) &&
+ (cloth->verts[spring->ij].goal > ALMOST_ZERO))
{
spring->flags &= ~CLOTH_SPRING_FLAG_DEACTIVATE;
}
- else
- {
+ else {
spring->flags |= CLOTH_SPRING_FLAG_DEACTIVATE;
}
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 6631afcddaf..b488e683947 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -198,6 +198,9 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
w3[0] = 1.0f - w1[0] - w2[0];
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdouble-promotion"
+
DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 )
{
zero_v3(to);
@@ -272,7 +275,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
/* Decrease in magnitude of relative tangential velocity due to coulomb friction
* in original formula "magrelVel" should be the "change of relative velocity in normal direction" */
- magtangent = minf(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre)));
+ magtangent = min_ff(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre)));
/* Apply friction impulse. */
if ( magtangent > ALMOST_ZERO ) {
@@ -312,8 +315,8 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
/* stay on the safe side and clamp repulse */
if ( impulse > ALMOST_ZERO )
- repulse = MIN2 ( repulse, 5.0*impulse );
- repulse = MAX2 ( impulse, repulse );
+ repulse = min_ff( repulse, 5.0*impulse );
+ repulse = max_ff(impulse, repulse);
impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); /* original 2.0 / 0.25 */
VECADDMUL ( i1, collpair->normal, impulse );
@@ -331,12 +334,12 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
* We don't use dt!! */
float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
- float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
+ float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - (float)collpair->distance;
if ( d > ALMOST_ZERO) {
/* stay on the safe side and clamp repulse */
float repulse = d*1.0f/spf;
- float impulse = repulse / ( 3.0 * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); /* original 2.0 / 0.25 */
+ float impulse = repulse / ( 3.0f * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); /* original 2.0 / 0.25 */
VECADDMUL ( i1, collpair->normal, impulse );
VECADDMUL ( i2, collpair->normal, impulse );
@@ -368,6 +371,8 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
return result;
}
+#pragma GCC diagnostic pop
+
//Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned
static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
BVHTreeOverlap *overlap, CollPair *collpair, float UNUSED(dt))
@@ -458,7 +463,8 @@ static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO );
#endif
- if (distance <= (epsilon1 + epsilon2 + ALMOST_ZERO)) {
+ // distance -1 means no collision result
+ if (distance != -1.0 && (distance <= (double)(epsilon1 + epsilon2 + ALMOST_ZERO))) {
normalize_v3_v3(collpair->normal, collpair->vector);
collpair->distance = distance;
@@ -514,7 +520,7 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
if (((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) || (modifier_type != eModifierType_Collision))
cmd= (CollisionModifierData *)modifiers_findByType(ob, modifier_type);
- if (cmd) {
+ if (cmd) {
/* extend array */
if (*numobj >= *maxobj) {
*maxobj *= 2;
@@ -533,7 +539,7 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
/* add objects */
for (go= group->gobject.first; go; go= go->next)
add_collision_object(objs, numobj, maxobj, go->ob, self, level+1, modifier_type);
- }
+ }
}
// return all collision objects in scene
@@ -579,7 +585,7 @@ static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self,
if (ob->pd && ob->pd->deflect)
cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
- if (cmd && cmd->bvhtree) {
+ if (cmd && cmd->bvhtree) {
if (*objs == NULL)
*objs = MEM_callocN(sizeof(ListBase), "ColliderCache array");
@@ -737,8 +743,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo
collision_move_object ( collmd, step + dt, step );
}
- do
- {
+ do {
CollPair **collisions, **collisions_index;
ret2 = 0;
@@ -869,7 +874,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo
VECADD ( verts[i].tx, verts[i].tx, temp );
}
else {
- mul_v3_fl(temp, correction * -0.5);
+ mul_v3_fl(temp, correction * -0.5f);
VECADD ( verts[j].tx, verts[j].tx, temp );
sub_v3_v3v3(verts[i].tx, verts[i].tx, temp);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 1bd5786debd..75276adf518 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -65,10 +65,10 @@ void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float m
cumap->flag = CUMA_DO_CLIP;
if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */
- clipminx = minf(minx, maxx);
- clipminy = minf(miny, maxy);
- clipmaxx = maxf(minx, maxx);
- clipmaxy = maxf(miny, maxy);
+ clipminx = min_ff(minx, maxx);
+ clipminy = min_ff(miny, maxy);
+ clipmaxx = max_ff(minx, maxx);
+ clipmaxy = max_ff(miny, maxy);
BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy);
cumap->clipr = cumap->curr;
@@ -85,7 +85,7 @@ void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float m
cumap->cm[a].curve[0].y = miny;
cumap->cm[a].curve[1].x = maxx;
cumap->cm[a].curve[1].y = maxy;
- }
+ }
cumap->changed_timestamp = 0;
}
@@ -160,7 +160,7 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3],
int a;
for (a = 0; a < 3; a++) {
- const float delta = maxf(white[a] - black[a], 1e-5f);
+ const float delta = max_ff(white[a] - black[a], 1e-5f);
r_bwmul[a] = 1.0f / delta;
}
}
@@ -182,14 +182,14 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con
/* ********** NOTE: requires curvemapping_changed() call after ******** */
/* remove specified point */
-void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
+int curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
{
CurveMapPoint *cmp;
int a, b, removed = 0;
/* must have 2 points minimum */
if (cuma->totpoint <= 2)
- return;
+ return FALSE;
cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points");
@@ -205,6 +205,7 @@ void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
MEM_freeN(cuma->curve);
cuma->curve = cmp;
cuma->totpoint -= removed;
+ return (removed != 0);
}
/* removes with flag set */
@@ -498,8 +499,8 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr");
for (a = 0; a < cuma->totpoint; a++) {
- cuma->mintable = minf(cuma->mintable, cmp[a].x);
- cuma->maxtable = maxf(cuma->maxtable, cmp[a].x);
+ cuma->mintable = min_ff(cuma->mintable, cmp[a].x);
+ cuma->maxtable = max_ff(cuma->maxtable, cmp[a].x);
bezt[a].vec[1][0] = cmp[a].x;
bezt[a].vec[1][1] = cmp[a].y;
if (cmp[a].flag & CUMA_VECTOR)
@@ -555,7 +556,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec);
}
}
- }
+ }
/* make the bezier curve */
if (cuma->table)
MEM_freeN(cuma->table);
@@ -690,13 +691,13 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & CUMA_SELECT) {
if (cmp[a].x < clipr->xmin)
- dx = minf(dx, cmp[a].x - clipr->xmin);
+ dx = min_ff(dx, cmp[a].x - clipr->xmin);
else if (cmp[a].x > clipr->xmax)
- dx = maxf(dx, cmp[a].x - clipr->xmax);
+ dx = max_ff(dx, cmp[a].x - clipr->xmax);
if (cmp[a].y < clipr->ymin)
- dy = minf(dy, cmp[a].y - clipr->ymin);
+ dy = min_ff(dy, cmp[a].y - clipr->ymin);
else if (cmp[a].y > clipr->ymax)
- dy = maxf(dy, cmp[a].y - clipr->ymax);
+ dy = max_ff(dy, cmp[a].y - clipr->ymax);
}
}
for (a = 0; a < cuma->totpoint; a++) {
@@ -731,7 +732,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
}
if (a != cuma->totpoint - 1)
curvemap_remove(cuma, 2);
- }
+ }
curvemap_make_table(cuma, clipr);
}
@@ -835,64 +836,6 @@ void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, unsigned char ve
vecout_byte[2] = FTOCHAR(vecout[2]);
}
-
-/* only used for image editor curves */
-void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
-{
- ImBuf *tmpbuf;
- int pixel;
- float *pix_in;
- float col[3];
- int stride = 4;
- float *pix_out;
-
- if (ibuf == NULL)
- return;
- if (ibuf->rect_float == NULL)
- IMB_float_from_rect(ibuf);
- else if (ibuf->rect == NULL)
- imb_addrectImBuf(ibuf);
-
- if (!ibuf->rect || !ibuf->rect_float)
- return;
-
- /* work on a temp buffer, so can color manage afterwards.
- * No worse off memory wise than comp nodes */
- tmpbuf = IMB_dupImBuf(ibuf);
-
- curvemapping_premultiply(cumap, 0);
-
- pix_in = ibuf->rect_float;
- pix_out = tmpbuf->rect_float;
-
- if (ibuf->channels)
- stride = ibuf->channels;
-
- for (pixel = ibuf->x * ibuf->y; pixel > 0; pixel--, pix_in += stride, pix_out += stride) {
- if (stride < 3) {
- col[0] = curvemap_evaluateF(cumap->cm, *pix_in);
-
- pix_out[1] = pix_out[2] = pix_out[3] = pix_out[0] = col[0];
- }
- else {
- curvemapping_evaluate_premulRGBF(cumap, col, pix_in);
- pix_out[0] = col[0];
- pix_out[1] = col[1];
- pix_out[2] = col[2];
- if (stride > 3)
- pix_out[3] = pix_in[3];
- else
- pix_out[3] = 1.f;
- }
- }
-
- IMB_rect_from_float(tmpbuf);
- SWAP(unsigned int *, tmpbuf->rect, ibuf->rect);
- IMB_freeImBuf(tmpbuf);
-
- curvemapping_premultiply(cumap, 1);
-}
-
int curvemapping_RGBA_does_something(const CurveMapping *cumap)
{
int a;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index e3f7ae1b1c7..e300b5e0f19 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -221,51 +221,6 @@ void constraints_clear_evalob(bConstraintOb *cob)
/* -------------- Space-Conversion API -------------- */
-#if 0 /* XXX Old code, does the same as one in armature.c, will remove it later. */
-static void constraint_pchan_diff_mat(bPoseChannel *pchan, float diff_mat[4][4])
-{
- if (pchan->parent) {
- float offs_bone[4][4];
-
- /* construct offs_bone the same way it is done in armature.c */
- copy_m4_m3(offs_bone, pchan->bone->bone_mat);
- copy_v3_v3(offs_bone[3], pchan->bone->head);
- offs_bone[3][1] += pchan->bone->parent->length;
-
- if (pchan->bone->flag & BONE_HINGE) {
- /* pose_mat = par_pose-space_location * chan_mat */
- float tmat[4][4];
-
- /* the rotation of the parent restposition */
- copy_m4_m4(tmat, pchan->bone->parent->arm_mat);
-
- /* the location of actual parent transform */
- copy_v3_v3(tmat[3], offs_bone[3]);
- zero_v3(offs_bone[3]);
- mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
-
- mult_m4_m4m4(diff_mat, tmat, offs_bone);
- }
- else {
- /* pose_mat = par_pose_mat * bone_mat * chan_mat */
- if (pchan->bone->flag & BONE_NO_SCALE) {
- float tmat[4][4];
- copy_m4_m4(tmat, pchan->parent->pose_mat);
- normalize_m4(tmat);
- mult_m4_m4m4(diff_mat, tmat, offs_bone);
- }
- else {
- mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
- }
- }
- }
- else {
- /* pose_mat = chan_mat * arm_mat */
- copy_m4_m4(diff_mat, pchan->bone->arm_mat);
- }
-}
-#endif
-
/* This function is responsible for the correct transformations/conversions
* of a matrix from one space to another for constraint evaluation.
* For now, this is only implemented for Objects and PoseChannels.
@@ -307,18 +262,6 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
else if (to == CONSTRAINT_SPACE_LOCAL) {
if (pchan->bone) {
BKE_armature_mat_pose_to_bone(pchan, mat, mat);
-#if 0 /* XXX Old code, will remove it later. */
- constraint_pchan_diff_mat(pchan, diff_mat);
-
- invert_m4_m4(imat, diff_mat);
- mult_m4_m4m4(mat, imat, mat);
-
- /* override with local location */
- if ((pchan->parent) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) {
- BKE_armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat);
- copy_v3_v3(mat[3], tempmat[3]);
- }
-#endif
}
}
/* pose to local with parent */
@@ -336,24 +279,19 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4]
if (pchan->bone) {
/* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */
BKE_armature_mat_bone_to_pose(pchan, mat, mat);
-#if 0
- constraint_pchan_diff_mat(pchan, diff_mat);
-
- mult_m4_m4m4(mat, diff_mat, mat);
-#endif
}
/* use pose-space as stepping stone for other spaces */
if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL)) {
/* call self with slightly different values */
constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
- }
+ }
}
break;
case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */
{
/* local + parent to pose */
- if (pchan->bone) {
+ if (pchan->bone) {
copy_m4_m4(diff_mat, pchan->bone->arm_mat);
mult_m4_m4m4(mat, mat, diff_mat);
}
@@ -432,7 +370,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
/* get DerivedMesh */
if (em) {
/* target is in editmode, so get a special derived mesh */
- dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
+ dm = CDDM_from_editbmesh(em, FALSE, FALSE);
freeDM = 1;
}
else {
@@ -604,15 +542,15 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m
float tempmat[4][4], loc[3];
/* interpolate along length of bone */
- interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail);
+ interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail);
/* use interpolated distance for subtarget */
- copy_m4_m4(tempmat, pchan->pose_mat);
+ copy_m4_m4(tempmat, pchan->pose_mat);
copy_v3_v3(tempmat[3], loc);
mult_m4_m4m4(mat, ob->obmat, tempmat);
}
- }
+ }
else
copy_m4_m4(mat, ob->obmat);
@@ -976,11 +914,11 @@ static void vectomat(const float vec[3], const float target_up[3], short axis, s
else negate_v3(n);
/* n specifies the transformation of the track axis */
- if (flags & TARGET_Z_UP) {
+ if (flags & TARGET_Z_UP) {
/* target Z axis is the global up axis */
copy_v3_v3(u, target_up);
}
- else {
+ else {
/* world Z axis is the global up axis */
u[0] = 0;
u[1] = 0;
@@ -1034,7 +972,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
/* Get size property, since ob->size is only the object's own relative size, not its global one */
mat4_to_size(size, cob->matrix);
- /* Clear the object's rotation */
+ /* Clear the object's rotation */
cob->matrix[0][0] = size[0];
cob->matrix[0][1] = 0;
cob->matrix[0][2] = 0;
@@ -1468,7 +1406,7 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
if (data->flag & LIMIT_XMIN) {
if (size[0] < data->xmin)
- size[0] = data->xmin;
+ size[0] = data->xmin;
}
if (data->flag & LIMIT_XMAX) {
if (size[0] > data->xmax)
@@ -1476,7 +1414,7 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
}
if (data->flag & LIMIT_YMIN) {
if (size[1] < data->ymin)
- size[1] = data->ymin;
+ size[1] = data->ymin;
}
if (data->flag & LIMIT_YMAX) {
if (size[1] > data->ymax)
@@ -1484,7 +1422,7 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
}
if (data->flag & LIMIT_ZMIN) {
if (size[2] < data->zmin)
- size[2] = data->zmin;
+ size[2] = data->zmin;
}
if (data->flag & LIMIT_ZMAX) {
if (size[2] > data->zmax)
@@ -2002,7 +1940,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
/* this check is to make sure curve objects get updated on file load correctly.*/
if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
- BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
+ BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
}
/* firstly calculate the matrix the normal way, then let the py-function override
@@ -2764,7 +2702,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
default: /* should not happen, but in case*/
return;
} /* switch (data->volmode) */
-
+
/* Clear the object's rotation and scale */
cob->matrix[0][0] = size[0] * scale[0];
cob->matrix[0][1] = 0;
@@ -2787,10 +2725,10 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* othogonal to "new Y" "old X! plane */
cross_v3_v3v3(orth, vec, xx);
normalize_v3(orth);
-
+
/* new Z*/
copy_v3_v3(totmat[2], orth);
-
+
/* we decided to keep X plane*/
cross_v3_v3v3(xx, orth, vec);
normalize_v3_v3(totmat[0], xx);
@@ -2800,16 +2738,16 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* othogonal to "new Y" "old Z! plane */
cross_v3_v3v3(orth, vec, zz);
normalize_v3(orth);
-
+
/* new X */
negate_v3_v3(totmat[0], orth);
-
+
/* we decided to keep Z */
cross_v3_v3v3(zz, orth, vec);
normalize_v3_v3(totmat[2], zz);
break;
} /* switch (data->plane) */
-
+
mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
}
}
@@ -2937,7 +2875,7 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
if (data->flag & MINMAX_STICKY) {
if (data->flag & MINMAX_STUCK) {
copy_v3_v3(obmat[3], data->cache);
- }
+ }
else {
copy_v3_v3(data->cache, obmat[3]);
data->flag |= MINMAX_STUCK;
@@ -2947,11 +2885,11 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
/* get out of localspace */
mult_m4_m4m4(tmat, ct->matrix, obmat);
copy_m4_m4(cob->matrix, tmat);
- }
- else {
+ }
+ else {
copy_v3_v3(cob->matrix[3], obmat[3]);
}
- }
+ }
else {
data->flag &= ~MINMAX_STUCK;
}
@@ -3291,7 +3229,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* extract components of owner's matrix */
copy_v3_v3(loc, cob->matrix[3]);
mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
- mat4_to_size(size, cob->matrix);
+ mat4_to_size(size, cob->matrix);
/* determine where in range current transforms lie */
if (data->expo) {
@@ -3615,7 +3553,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
cross_v3_v3v3(raxis, obvec, tarvec);
rangle = dot_v3v3(obvec, tarvec);
- rangle = acos(maxf(-1.0f, minf(1.0f, rangle)));
+ rangle = acos(max_ff(-1.0f, min_ff(1.0f, rangle)));
/* construct rotation matrix from the axis-angle rotation found above
* - this call takes care to make sure that the axis provided is a unit vector first
@@ -4663,7 +4601,7 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan)
else {
/* FIXME: constraints on object-level are not handled well yet */
return 1;
- }
+ }
}
return 0;
@@ -4703,7 +4641,7 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n,
unit_m4(cob->matrix);
unit_m4(cob->startmat);
}
- }
+ }
break;
case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */
{
@@ -4839,7 +4777,7 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
* since some constraints may not convert the solution back to the input space before blending
* but all are guaranteed to end up in good "worldspace" result
*/
- /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */
+ /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka (r.32105) */
if (enf < 1.0f) {
float solution[4][4];
copy_m4_m4(solution, cob->matrix);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index be81c70f261..719ae7357b4 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -234,9 +234,8 @@ struct bContextDataResult {
static void *ctx_wm_python_context_get(const bContext *C, const char *member, void *fall_through)
{
#ifdef WITH_PYTHON
- bContextDataResult result;
-
- if (C && CTX_py_dict_get(C)) {
+ if (UNLIKELY(C && CTX_py_dict_get(C))) {
+ bContextDataResult result;
memset(&result, 0, sizeof(bContextDataResult));
BPY_context_member_get((bContext *)C, member, &result);
if (result.ptr.data)
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 0bda3b266b8..f2cd695d64a 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -820,8 +820,8 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
/* this is for float inaccuracy */
if (t < knots[0])
t = knots[0];
- else
- if (t > knots[opp2]) t = knots[opp2];
+ else if (t > knots[opp2])
+ t = knots[opp2];
/* this part is order '1' */
o2 = order + 1;
@@ -1050,10 +1050,13 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu,
MEM_freeN(jend);
}
+/**
+ * \param coord_array Has to be 3 * 4 * pntsu * resolu in size and zero-ed
+ * \param tilt_array set when non-NULL
+ * \param radius_array set when non-NULL
+ */
void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array,
int resolu, int stride)
-/* coord_array has to be 3*4*pntsu*resolu in size and zero-ed
- * tilt_array and radius_array will be written to if valid */
{
BPoint *bp;
float u, ustart, uend, ustep, sumdiv;
@@ -1114,12 +1117,12 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *
sumdiv += *fp;
}
if (sumdiv != 0.0f) if (sumdiv < 0.999f || sumdiv > 1.001f) {
- /* is normalizing needed? */
- fp = sum;
- for (i = istart; i <= iend; i++, fp++) {
- *fp /= sumdiv;
- }
+ /* is normalizing needed? */
+ fp = sum;
+ for (i = istart; i <= iend; i++, fp++) {
+ *fp /= sumdiv;
}
+ }
/* one! (1.0) real point */
fp = sum;
@@ -1476,7 +1479,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende
}
}
else if (cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
- ;
+ /* pass */
}
else if (cu->ext2 == 0.0f) {
dl = MEM_callocN(sizeof(DispList), "makebevelcurve2");
@@ -1945,7 +1948,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
if (bl->poly == -1) { /* check its not cyclic */
/* skip the first point */
- /* bevp0= bevp1; */
+ /* bevp0 = bevp1; */
bevp1 = bevp2;
bevp2++;
nr--;
@@ -1974,7 +1977,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5);
normalize_qt(bevp1->quat);
- /* bevp0= bevp1; */ /* UNUSED */
+ /* bevp0 = bevp1; */ /* UNUSED */
bevp1 = bevp2;
bevp2++;
}
@@ -2109,7 +2112,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
BevPoint *bevp2, *bevp1, *bevp0; /* standard for all make_bevel_list_3D_* funcs */
int nr;
- float bevp0_tan[3], cross_tmp[3];
+ float bevp0_tan[3];
bevel_list_calc_bisect(bl);
if (bl->poly == -1) /* check its not cyclic */
@@ -2123,6 +2126,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
nr = bl->nr;
while (nr--) {
+ float cross_tmp[3];
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir);
normalize_v3(bevp1->tan);
@@ -2150,7 +2154,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
normalize_v3(cross_tmp);
tri_to_quat(bevp1->quat, zero, cross_tmp, bevp1->tan); /* XXX - could be faster */
- /* bevp0= bevp1; */ /* UNUSED */
+ /* bevp0 = bevp1; */ /* UNUSED */
bevp1 = bevp2;
bevp2++;
}
@@ -2477,8 +2481,8 @@ void BKE_curve_bevelList_make(Object *ob)
else
bevp2 = bevp1 + 1;
- inp = (bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) +
- (bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]);
+ inp = ((bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) +
+ (bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]));
if (inp > 0.0f)
sd->dir = 1;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index de55751f2ec..93c776ae30e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -65,11 +65,20 @@
/* number of layers to add when growing a CustomData object */
#define CUSTOMDATA_GROW 5
+/* ensure typemap size is ok */
+BLI_STATIC_ASSERT(sizeof(((CustomData *)NULL)->typemap) /
+ sizeof(((CustomData *)NULL)->typemap[0]) == CD_NUMTYPES,
+ "size mismatch");
+
+
/********************* Layer type information **********************/
typedef struct LayerTypeInfo {
int size; /* the memory size of one element of this layer's data */
- const char *structname; /* name of the struct used, for file writing */
- int structnum; /* number of structs per element, for file writing */
+
+ /** name of the struct used, for file writing */
+ const char *structname;
+ /** number of structs per element, for file writing */
+ int structnum;
/**
* default layer name.
@@ -1055,8 +1064,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 8: CD_NORMAL */
/* 3 floats per normal vector */
{sizeof(float) * 3, "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
- /* 9: CD_POLYINDEX */
- {sizeof(int), "MIntProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* 9: CD_POLYINDEX (deprecated) */
+ {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 10: CD_PROP_FLT */
{sizeof(MFloatProperty), "MFloatProperty", 1, "Float", layerCopy_propFloat, NULL, NULL, NULL},
/* 11: CD_PROP_INT */
@@ -1076,7 +1085,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
layerAdd_mloopuv, layerDoMinMax_mloopuv, layerCopyValue_mloopuv},
/* 17: CD_MLOOPCOL */
- {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL,
+ {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL,
layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
/* 18: CD_TANGENT */
@@ -1174,7 +1183,7 @@ const CustomDataMask CD_MASK_DERIVEDMESH =
CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_PREVIEW_MLOOPCOL |
CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
CD_MASK_PREVIEW_MCOL | CD_MASK_NORMAL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
- CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX | CD_MASK_MVERT_SKIN;
+ CD_MASK_ORIGINDEX | CD_MASK_MVERT_SKIN;
const CustomDataMask CD_MASK_BMESH =
CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
@@ -1221,9 +1230,6 @@ void CustomData_update_typemap(CustomData *data)
{
int i, lasttype = -1;
- /* since we cant do in a pre-processor do here as an assert */
- BLI_assert(sizeof(data->typemap) / sizeof(int) >= CD_NUMTYPES);
-
for (i = 0; i < CD_NUMTYPES; i++) {
data->typemap[i] = -1;
}
@@ -1236,6 +1242,13 @@ void CustomData_update_typemap(CustomData *data)
}
}
+static int customdata_typemap_is_valid(const CustomData *data)
+{
+ CustomData data_copy = *data;
+ CustomData_update_typemap(&data_copy);
+ return (memcmp(data->typemap, data_copy.typemap, sizeof(data->typemap)) == 0);
+}
+
void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
CustomDataMask mask, int alloctype, int totelem)
{
@@ -1301,7 +1314,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
CustomDataMask mask, int alloctype, int totelem)
{
- memset(dest, 0, sizeof(*dest));
+ CustomData_reset(dest);
if (source->external)
dest->external = MEM_dupallocN(source->external);
@@ -1332,6 +1345,12 @@ static void CustomData_external_free(CustomData *data)
}
}
+void CustomData_reset(CustomData *data)
+{
+ memset(data, 0, sizeof(*data));
+ fill_vn_i(data->typemap, CD_NUMTYPES, -1);
+}
+
void CustomData_free(CustomData *data, int totelem)
{
int i;
@@ -1343,8 +1362,7 @@ void CustomData_free(CustomData *data, int totelem)
MEM_freeN(data->layers);
CustomData_external_free(data);
-
- memset(data, 0, sizeof(*data));
+ CustomData_reset(data);
}
static void customData_update_offsets(CustomData *data)
@@ -1363,9 +1381,10 @@ static void customData_update_offsets(CustomData *data)
CustomData_update_typemap(data);
}
-int CustomData_get_layer_index(const CustomData *data, int type)
+/* to use when we're in the middle of modifying layers */
+static int CustomData_get_layer_index__notypemap(const CustomData *data, int type)
{
- int i;
+ int i;
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
@@ -1374,11 +1393,21 @@ int CustomData_get_layer_index(const CustomData *data, int type)
return -1;
}
+/* -------------------------------------------------------------------- */
+/* index values to access the layers (offset from the layer start) */
+
+int CustomData_get_layer_index(const CustomData *data, int type)
+{
+ BLI_assert(customdata_typemap_is_valid(data));
+ return data->typemap[type];
+}
+
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n)
{
int i = CustomData_get_layer_index(data, type);
if (i != -1) {
+ BLI_assert(i + n < data->totlayer);
i = (data->layers[i + n].type == type) ? (i + n) : (-1);
}
@@ -1398,91 +1427,62 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha
int CustomData_get_active_layer_index(const CustomData *data, int type)
{
- if (!data->totlayer)
- return -1;
-
- if (data->typemap[type] != -1) {
- return data->typemap[type] + data->layers[data->typemap[type]].active;
- }
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? layer_index + data->layers[layer_index].active: -1;
}
int CustomData_get_render_layer_index(const CustomData *data, int type)
{
- int i;
-
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return i + data->layers[i].active_rnd;
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? layer_index + data->layers[layer_index].active_rnd : -1;
}
int CustomData_get_clone_layer_index(const CustomData *data, int type)
{
- int i;
-
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return i + data->layers[i].active_clone;
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? layer_index + data->layers[layer_index].active_clone : -1;
}
int CustomData_get_stencil_layer_index(const CustomData *data, int type)
{
- int i;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? layer_index + data->layers[layer_index].active_mask : -1;
+}
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return i + data->layers[i].active_mask;
- return -1;
-}
+/* -------------------------------------------------------------------- */
+/* index values per layer type */
int CustomData_get_active_layer(const CustomData *data, int type)
{
- int i;
-
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return data->layers[i].active;
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? data->layers[layer_index].active : -1;
}
int CustomData_get_render_layer(const CustomData *data, int type)
{
- int i;
-
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return data->layers[i].active_rnd;
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? data->layers[layer_index].active_rnd : -1;
}
int CustomData_get_clone_layer(const CustomData *data, int type)
{
- int i;
-
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return data->layers[i].active_clone;
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? data->layers[layer_index].active_clone : -1;
}
int CustomData_get_stencil_layer(const CustomData *data, int type)
{
- int i;
-
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- return data->layers[i].active_mask;
-
- return -1;
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (layer_index != -1) ? data->layers[layer_index].active_mask : -1;
}
void CustomData_set_layer_active(CustomData *data, int type, int n)
@@ -1713,7 +1713,7 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
/* if layer was last of type in array, set new active layer */
if ((index >= data->totlayer) || (data->layers[index].type != type)) {
- i = CustomData_get_layer_index(data, type);
+ i = CustomData_get_layer_index__notypemap(data, type);
if (i >= 0)
for (; i < data->totlayer && data->layers[i].type == type; i++) {
@@ -1728,7 +1728,6 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
customData_resize(data, -CUSTOMDATA_GROW);
customData_update_offsets(data);
- CustomData_update_typemap(data);
return 1;
}
@@ -2358,7 +2357,9 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
const LayerTypeInfo *typeInfo;
int i;
- if (!*block) return;
+ if (*block == NULL)
+ return;
+
for (i = 0; i < data->totlayer; ++i) {
if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
typeInfo = layerType_getInfo(data->layers[i].type);
@@ -2394,7 +2395,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
const LayerTypeInfo *typeInfo;
int dest_i, src_i;
- if (!*dest_block) {
+ if (*dest_block == NULL) {
CustomData_bmesh_alloc_block(dest, dest_block);
if (*dest_block)
memset(*dest_block, 0, dest->totsize);
@@ -2475,10 +2476,49 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n)
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
typeInfo->initminmax && typeInfo->dominmax)
{
- return 1;
+ return TRUE;
}
- return 0;
+ return FALSE;
+}
+
+int CustomData_layer_has_interp(struct CustomData *data, int layer_n)
+{
+ const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
+
+ if (typeInfo->interp) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int CustomData_has_math(struct CustomData *data)
+{
+ int i;
+
+ /* interpolates a layer at a time */
+ for (i = 0; i < data->totlayer; ++i) {
+ if (CustomData_layer_has_math(data, i)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+int CustomData_has_interp(struct CustomData *data)
+{
+ int i;
+
+ /* interpolates a layer at a time */
+ for (i = 0; i < data->totlayer; ++i) {
+ if (CustomData_layer_has_interp(data, i)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
/* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
@@ -2578,8 +2618,8 @@ void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, void *so
memcpy(dest, source, typeInfo->size);
}
-void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights,
- float *sub_weights, int count, void *dest_block)
+void CustomData_bmesh_interp(CustomData *data, void **src_blocks, const float *weights,
+ const float *sub_weights, int count, void *dest_block)
{
int i, j;
void *source_buf[SOURCE_BUF_SIZE];
@@ -2614,7 +2654,7 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
const LayerTypeInfo *typeInfo;
int i;
- if (!*block)
+ if (*block == NULL)
CustomData_bmesh_alloc_block(data, block);
for (i = 0; i < data->totlayer; ++i) {
@@ -2634,7 +2674,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
const LayerTypeInfo *typeInfo;
int dest_i, src_i, src_offset;
- if (!*dest_block)
+ if (*dest_block == NULL)
CustomData_bmesh_alloc_block(dest, dest_block);
/* copies a layer at a time */
@@ -2866,7 +2906,9 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
+ if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
+ /* pass */
+ }
else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
if (typeInfo->free)
typeInfo->free(layer->data, totelem, typeInfo->size);
@@ -2892,10 +2934,15 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
- else if (layer->flag & CD_FLAG_IN_MEMORY) ;
- else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read)
+ if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
+ /* pass */
+ }
+ else if (layer->flag & CD_FLAG_IN_MEMORY) {
+ /* pass */
+ }
+ else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
update = 1;
+ }
}
if (!update)
@@ -2913,15 +2960,23 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
- else if (layer->flag & CD_FLAG_IN_MEMORY) ;
+ if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
+ /* pass */
+ }
+ else if (layer->flag & CD_FLAG_IN_MEMORY) {
+ /* pass */
+ }
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
blay = cdf_layer_find(cdf, layer->type, layer->name);
if (blay) {
if (cdf_read_layer(cdf, blay)) {
- if (typeInfo->read(cdf, layer->data, totelem)) ;
- else break;
+ if (typeInfo->read(cdf, layer->data, totelem)) {
+ /* pass */
+ }
+ else {
+ break;
+ }
layer->flag |= CD_FLAG_IN_MEMORY;
}
else
@@ -2952,9 +3007,12 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
- else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write)
+ if (!(mask & CD_TYPE_AS_MASK(layer->type))) {
+ /* pass */
+ }
+ else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
update = 1;
+ }
}
if (!update)
@@ -2995,11 +3053,16 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
blay = cdf_layer_find(cdf, layer->type, layer->name);
if (cdf_write_layer(cdf, blay)) {
- if (typeInfo->write(cdf, layer->data, totelem)) ;
- else break;
+ if (typeInfo->write(cdf, layer->data, totelem)) {
+ /* pass */
+ }
+ else {
+ break;
+ }
}
- else
+ else {
break;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 4110d4565b2..7c13ca388e0 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -278,7 +278,7 @@ void defvert_normalize_lock_map(MDeformVert *dvert, const char *lock_flags, cons
}
}
- lock_iweight = maxf(0.0f, 1.0f - lock_iweight);
+ lock_iweight = max_ff(0.0f, 1.0f - lock_iweight);
if (tot_weight > 0.0f) {
/* paranoid, should be 1.0 but in case of float error clamp anyway */
@@ -431,7 +431,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in
if (strcmp(name, dg->name)) {
flip_num = defgroup_name_index(ob, name);
- if (flip_num >= 0) {
+ if (flip_num != -1) {
map[defgroup] = flip_num;
map[flip_num] = defgroup;
}
@@ -790,3 +790,23 @@ void defvert_clear(MDeformVert *dvert)
dvert->totweight = 0;
}
+
+/**
+ * \return The first group index shared by both deform verts
+ * or -1 if none are found.
+ */
+int defvert_find_shared(const MDeformVert *dvert_a, const MDeformVert *dvert_b)
+{
+ if (dvert_a->totweight && dvert_b->totweight) {
+ MDeformWeight *dw = dvert_a->dw;
+ unsigned int i;
+
+ for (i = dvert_a->totweight; i != 0; i--, dw++) {
+ if (dw->weight > 0.0f && defvert_find_weight(dvert_b, dw->def_nr) > 0.0f) {
+ return dw->def_nr;
+ }
+ }
+ }
+
+ return -1;
+}
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 48040867ad4..9d3a7ec57cf 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -45,6 +45,7 @@
#include "DNA_anim_types.h"
#include "DNA_camera_types.h"
#include "DNA_group_types.h"
+#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
@@ -150,8 +151,8 @@ void queue_delete(DagNodeQueue *queue)
MEM_freeN(temp);
}
- MEM_freeN(queue->freenodes);
- MEM_freeN(queue);
+ MEM_freeN(queue->freenodes);
+ MEM_freeN(queue);
}
/* insert in queue, remove in front */
@@ -190,8 +191,8 @@ void push_queue(DagNodeQueue *queue, DagNode *node)
}
queue->freenodes->count = DAGQUEUEALLOC;
- elem = queue->freenodes->first;
- queue->freenodes->first = elem->next;
+ elem = queue->freenodes->first;
+ queue->freenodes->first = elem->next;
}
elem->next = NULL;
elem->node = node;
@@ -211,7 +212,7 @@ void push_stack(DagNodeQueue *queue, DagNode *node)
DagNodeQueueElem *elem;
int i;
- elem = queue->freenodes->first;
+ elem = queue->freenodes->first;
if (elem != NULL) {
queue->freenodes->first = elem->next;
if (queue->freenodes->last == elem) {
@@ -235,8 +236,8 @@ void push_stack(DagNodeQueue *queue, DagNode *node)
}
queue->freenodes->count = DAGQUEUEALLOC;
- elem = queue->freenodes->first;
- queue->freenodes->first = elem->next;
+ elem = queue->freenodes->first;
+ queue->freenodes->first = elem->next;
}
elem->next = queue->first;
elem->node = node;
@@ -302,7 +303,7 @@ DagForest *dag_init(void)
}
/* isdata = object data... */
-// XXX this needs to be extended to be more flexible (so that not only objects are evaluated via depsgraph)...
+/* XXX this needs to be extended to be more flexible (so that not only objects are evaluated via depsgraph)... */
static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node, int isdata)
{
FCurve *fcu;
@@ -350,8 +351,8 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
/* XXX: forward def for material driver handling... */
static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma);
-/* recursive handling for material nodetree drivers */
-static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree)
+/* recursive handling for shader nodetree drivers */
+static void dag_add_shader_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree)
{
bNode *n;
@@ -367,7 +368,7 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *
dag_add_material_driver_relations(dag, node, (Material *)n->id);
}
else if (n->type == NODE_GROUP) {
- dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id);
+ dag_add_shader_nodetree_driver_relations(dag, node, (bNodeTree *)n->id);
}
}
}
@@ -386,21 +387,44 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat
ma->id.flag |= LIB_DOIT;
/* material itself */
- if (ma->adt) {
+ if (ma->adt)
dag_add_driver_relation(ma->adt, dag, node, 1);
- }
/* textures */
// TODO...
//dag_add_texture_driver_relations(DagForest *dag, DagNode *node, ID *id);
/* material's nodetree */
- if (ma->nodetree) {
- dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree);
- }
+ if (ma->nodetree)
+ dag_add_shader_nodetree_driver_relations(dag, node, ma->nodetree);
+}
+
+/* recursive handling for lamp drivers */
+static void dag_add_lamp_driver_relations(DagForest *dag, DagNode *node, Lamp *la)
+{
+ /* Prevent infinite recursion by checking (and tagging the lamp) as having been visited
+ * already (see build_dag()). This assumes la->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017]
+ */
+ if (la->id.flag & LIB_DOIT)
+ return;
+ else
+ la->id.flag |= LIB_DOIT;
+
+ /* lamp itself */
+ if (la->adt)
+ dag_add_driver_relation(la->adt, dag, node, 1);
+
+ /* textures */
+ // TODO...
+ //dag_add_texture_driver_relations(DagForest *dag, DagNode *node, ID *id);
+
+ /* lamp's nodetree */
+ if (la->nodetree)
+ dag_add_shader_nodetree_driver_relations(dag, node, la->nodetree);
}
-static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node)
+static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node, int skip_forcefield)
{
Base *base;
DagNode *node2;
@@ -411,7 +435,9 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec
if ((base->lay & ob->lay) && base->object->pd) {
Object *ob1 = base->object;
if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) {
- node2 = dag_get_node(dag, ob1);
+ if (skip_forcefield && ob1->pd->forcefield == skip_forcefield)
+ continue;
+ node2 = dag_get_node(dag, ob1);
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision");
}
}
@@ -443,7 +469,6 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ob->type == OB_ARMATURE) {
if (ob->pose) {
bPoseChannel *pchan;
- bConstraint *con;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
@@ -464,7 +489,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ct->tar->type == OB_MESH)
node3->customdata_mask |= CD_MASK_MDEFORMVERT;
}
- else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK))
+ else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK))
dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, cti->name);
else
dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name);
@@ -570,12 +595,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
/* softbody collision */
if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) {
if (ob->particlesystem.first ||
- modifiers_isModifierEnabled(ob, eModifierType_Softbody) ||
- modifiers_isModifierEnabled(ob, eModifierType_Cloth) ||
- modifiers_isModifierEnabled(ob, eModifierType_Smoke) ||
- modifiers_isModifierEnabled(ob, eModifierType_DynamicPaint))
+ modifiers_isModifierEnabled(ob, eModifierType_Softbody) ||
+ modifiers_isModifierEnabled(ob, eModifierType_Cloth) ||
+ modifiers_isModifierEnabled(ob, eModifierType_DynamicPaint))
{
- dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */
+ dag_add_collision_field_relation(dag, scene, ob, node, 0); /* TODO: use effectorweight->group */
+ }
+ else if (modifiers_isModifierEnabled(ob, eModifierType_Smoke)) {
+ dag_add_collision_field_relation(dag, scene, ob, node, PFIELD_SMOKEFLOW);
}
}
@@ -604,7 +631,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (mom != ob) {
node2 = dag_get_node(dag, mom);
- dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); // mom depends on children!
+ dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); /* mom depends on children! */
}
}
break;
@@ -632,18 +659,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
}
/* material drivers */
- //if (ob->totcol) {
- // int a;
- //
- // for (a = 1; a <= ob->totcol; a++) {
- // Material *ma = give_current_material(ob, a);
- //
- // if (ma) {
- // /* recursively figure out if there are drivers, and hook these up to this object */
- // dag_add_material_driver_relations(dag, node, ma);
- // }
- // }
- //}
+ if (ob->totcol) {
+ int a;
+
+ for (a = 1; a <= ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a);
+
+ if (ma) {
+ /* recursively figure out if there are drivers, and hook these up to this object */
+ dag_add_material_driver_relations(dag, node, ma);
+ }
+ }
+ }
+ else if(ob->type == OB_LAMP)
+ dag_add_lamp_driver_relations(dag, node, ob->data);
/* particles */
psys = ob->particlesystem.first;
@@ -814,9 +843,10 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask)
/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later [#32017] */
tag_main_idcode(bmain, ID_MA, FALSE);
+ tag_main_idcode(bmain, ID_LA, FALSE);
/* add base node for scene. scene is always the first node in DAG */
- scenenode = dag_add_node(dag, sce);
+ scenenode = dag_add_node(dag, sce);
/* add current scene objects */
for (base = sce->base.first; base; base = base->next) {
@@ -870,7 +900,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask)
}
/* cycle detection and solving */
- // solve_cycles(dag);
+ // solve_cycles(dag);
return dag;
}
@@ -879,23 +909,23 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask)
void free_forest(DagForest *Dag)
{ /* remove all nodes and deps */
DagNode *tempN;
- DagAdjList *tempA;
+ DagAdjList *tempA;
DagAdjList *itA;
DagNode *itN = Dag->DagNode.first;
while (itN) {
- itA = itN->child;
+ itA = itN->child;
while (itA) {
tempA = itA;
itA = itA->next;
- MEM_freeN(tempA);
+ MEM_freeN(tempA);
}
- itA = itN->parent;
+ itA = itN->parent;
while (itA) {
tempA = itA;
itA = itA->next;
- MEM_freeN(tempA);
+ MEM_freeN(tempA);
}
tempN = itN;
@@ -919,8 +949,8 @@ DagNode *dag_find_node(DagForest *forest, void *fob)
return NULL;
}
-static int ugly_hack_sorry = 1; // prevent type check
-static int dag_print_dependencies = 0; // debugging
+static int ugly_hack_sorry = 1; /* prevent type check */
+static int dag_print_dependencies = 0; /* debugging */
/* no checking of existence, use dag_find_node first or dag_get_node */
DagNode *dag_add_node(DagForest *forest, void *fob)
@@ -932,7 +962,7 @@ DagNode *dag_add_node(DagForest *forest, void *fob)
node->ob = fob;
node->color = DAG_WHITE;
- if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting
+ if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); /* sorry, done for pose sorting */
if (forest->numNodes) {
((DagNode *) forest->DagNode.last)->next = node;
forest->DagNode.last = node;
@@ -1151,7 +1181,7 @@ static void dag_check_cycle(DagForest *dag)
for (node = dag->DagNode.first; node; node = node->next) {
while (node->parent) {
itA = node->parent->next;
- MEM_freeN(node->parent);
+ MEM_freeN(node->parent);
node->parent = itA;
}
}
@@ -1240,7 +1270,7 @@ void graph_bfs(void)
itA = itA->next;
}
if (pos[node->BFS_dist] > node->k) {
- pos[node->BFS_dist] += 1;
+ pos[node->BFS_dist] += 1;
node->k = (float) pos[node->BFS_dist];
}
else {
@@ -1301,7 +1331,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a
pre_func(node->ob, data);
}
- else { // back or cross edge
+ else { /* back or cross edge */
retval = 1;
}
itA = itA->next;
@@ -1332,7 +1362,7 @@ DagNodeQueue *graph_dfs(void)
/* int is_cycle = 0; */ /* UNUSED */
/*
*fprintf(stderr, "starting DFS\n ------------\n");
- */
+ */
nqueue = queue_create(DAGQUEUEALLOC);
retqueue = queue_create(MainDag->numNodes);
for (i = 0; i < 50; i++)
@@ -1384,7 +1414,7 @@ DagNodeQueue *graph_dfs(void)
break;
}
else {
- if (itA->node->color == DAG_GRAY) { // back edge
+ if (itA->node->color == DAG_GRAY) { /* back edge */
fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name);
/* is_cycle = 1; */ /* UNUSED */
}
@@ -1462,7 +1492,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
int retval = 0;
/*
* fprintf(stderr, "starting DFS\n ------------\n");
- */
+ */
nqueue = queue_create(DAGQUEUEALLOC);
/* Init
@@ -1516,7 +1546,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
// }
}
itA = itA->next;
- }
+ }
if (!skip) {
node = pop_queue(nqueue);
@@ -1535,7 +1565,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
}
-// used to get the obs owning a datablock
+/* used to get the obs owning a datablock */
DagNodeQueue *get_obparents(struct DagForest *dag, void *ob)
{
DagNode *node, *node1;
@@ -1546,7 +1576,7 @@ DagNodeQueue *get_obparents(struct DagForest *dag, void *ob)
if (node == NULL) {
return NULL;
}
- else if (node->ancestor_count == 1) { // simple case
+ else if (node->ancestor_count == 1) { /* simple case */
nqueue = queue_create(1);
push_queue(nqueue, node);
}
@@ -1555,7 +1585,7 @@ DagNodeQueue *get_obparents(struct DagForest *dag, void *ob)
node1 = dag->DagNode.first;
do {
- if (node1->DFS_fntm > node->DFS_fntm) { // a parent is finished after child. must check adj list
+ if (node1->DFS_fntm > node->DFS_fntm) { /* a parent is finished after child. must check adj list */
itA = node->child;
while (itA != NULL) {
if ((itA->node == node) && (itA->type == DAG_RL_DATA)) {
@@ -1583,7 +1613,7 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob)
node1 = dag->DagNode.first;
do {
- if (node1->DFS_fntm > node->DFS_fntm) {
+ if (node1->DFS_fntm > node->DFS_fntm) {
itA = node->child;
while (itA != NULL) {
if (itA->node == node) {
@@ -1595,10 +1625,10 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob)
node1 = node1->next;
} while (node1);
- return nqueue;
+ return nqueue;
}
-// standard DFS list
+/* standard DFS list */
DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
{
DagNode *node;
@@ -1609,7 +1639,7 @@ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
int skip = 0;
nqueue = queue_create(DAGQUEUEALLOC);
- retqueue = queue_create(dag->numNodes); // was MainDag... why? (ton)
+ retqueue = queue_create(dag->numNodes); /* was MainDag... why? (ton) */
node = dag->DagNode.first;
while (node) {
@@ -1619,8 +1649,8 @@ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
time = 1;
- node = dag_find_node(dag, ob); // could be done in loop above (ton)
- if (node) { // can be null for newly added objects
+ node = dag_find_node(dag, ob); /* could be done in loop above (ton) */
+ if (node) { /* can be null for newly added objects */
node->color = DAG_GRAY;
time++;
@@ -1641,9 +1671,9 @@ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
push_stack(nqueue, itA->node);
skip = 1;
break;
- }
+ }
itA = itA->next;
- }
+ }
if (!skip) {
node = pop_queue(nqueue);
@@ -1671,7 +1701,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
while (itA != NULL) {
if (itA->node->ob == ob2) {
return itA->node->type;
- }
+ }
itA = itA->next;
}
return DAG_NO_RELATION;
@@ -1699,7 +1729,7 @@ void graph_print_queue(DagNodeQueue *nqueue)
queueElem = nqueue->first;
while (queueElem) {
fprintf(stderr, "** %s %i %i-%i ", ((ID *) queueElem->node->ob)->name, queueElem->node->color, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm);
- queueElem = queueElem->next;
+ queueElem = queueElem->next;
}
fprintf(stderr, "\n");
}
@@ -1719,7 +1749,7 @@ void graph_print_queue_dist(DagNodeQueue *nqueue)
fputc('|', stderr);
fputc('\n', stderr);
count = 0;
- queueElem = queueElem->next;
+ queueElem = queueElem->next;
}
fprintf(stderr, "\n");
}
@@ -1857,14 +1887,14 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
push_stack(nqueue, itA->node);
skip = 1;
break;
- }
+ }
itA = itA->next;
- }
+ }
if (!skip) {
if (node) {
node = pop_queue(nqueue);
- if (node->ob == sce) // we are done
+ if (node->ob == sce) /* we are done */
break;
node->color = DAG_BLACK;
@@ -1876,7 +1906,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
BLI_remlink(&sce->base, base);
BLI_addhead(&tempbase, base);
}
- }
+ }
}
}
@@ -2021,7 +2051,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
for (itA = node->child; itA; itA = itA->next) {
if (itA->node->type == ID_OB) {
if (itA->node->lasttime != curtime) {
- itA->lay = flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation
+ itA->lay = flush_layer_node(sce, itA->node, curtime); /* lay is only set once for each relation */
}
else itA->lay = itA->node->lay;
@@ -2069,12 +2099,12 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
Base *base;
int lasttime;
- firstnode = sce->theDag->DagNode.first; // always scene node
+ firstnode = sce->theDag->DagNode.first; /* always scene node */
for (itA = firstnode->child; itA; itA = itA->next)
itA->lay = 0;
- sce->theDag->time++; // so we know which nodes were accessed
+ sce->theDag->time++; /* so we know which nodes were accessed */
lasttime = sce->theDag->time;
/* update layer flags in nodes */
@@ -2146,13 +2176,13 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
DAG_scene_sort(bmain, sce);
}
- firstnode = sce->theDag->DagNode.first; // always scene node
+ firstnode = sce->theDag->DagNode.first; /* always scene node */
/* first we flush the layer flags */
dag_scene_flush_layers(sce, lay);
/* then we use the relationships + layer info to flush update events */
- sce->theDag->time++; // so we know which nodes were accessed
+ sce->theDag->time++; /* so we know which nodes were accessed */
lasttime = sce->theDag->time;
for (itA = firstnode->child; itA; itA = itA->next)
if (itA->node->lasttime != lasttime && itA->node->type == ID_OB)
@@ -2160,7 +2190,7 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
/* if update is not due to time change, do pointcache clears */
if (!time) {
- sce->theDag->time++; // so we know which nodes were accessed
+ sce->theDag->time++; /* so we know which nodes were accessed */
lasttime = sce->theDag->time;
for (itA = firstnode->child; itA; itA = itA->next) {
if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) {
@@ -2378,7 +2408,7 @@ static void dag_object_time_update_flags(Object *ob)
}
}
}
- }
+ }
if (ob->recalc & OB_RECALC_OB)
lib_id_recalc_tag(G.main, &ob->id);
@@ -2928,9 +2958,9 @@ void DAG_pose_sort(Object *ob)
int skip = 0;
dag = dag_init();
- ugly_hack_sorry = 0; // no ID structs
+ ugly_hack_sorry = 0; /* no ID structs */
- rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL
+ rootnode = dag_add_node(dag, NULL); /* node->ob becomes NULL */
/* we add the hierarchy and the constraints */
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -2975,7 +3005,7 @@ void DAG_pose_sort(Object *ob)
dag_add_relation(dag, node2, node3, 0, "IK Constraint");
segcount++;
- if (segcount == data->rootbone || segcount > 255) break; // 255 is weak
+ if (segcount == data->rootbone || segcount > 255) break; /* 255 is weak */
parchan = parchan->parent;
}
}
@@ -3018,21 +3048,21 @@ void DAG_pose_sort(Object *ob)
push_stack(nqueue, itA->node);
skip = 1;
break;
- }
+ }
itA = itA->next;
- }
+ }
if (!skip) {
if (node) {
node = pop_queue(nqueue);
- if (node->ob == NULL) // we are done
+ if (node->ob == NULL) /* we are done */
break;
node->color = DAG_BLACK;
/* put node in new list */
BLI_remlink(&pose->chanbase, node->ob);
BLI_addhead(&tempbase, node->ob);
- }
+ }
}
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 64959fd3aa1..a78a9af54ae 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -299,7 +299,9 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
else
resolu = nu->resolu;
- if (!BKE_nurb_check_valid_u(nu)) ;
+ if (!BKE_nurb_check_valid_u(nu)) {
+ /* pass */
+ }
else if (nu->type == CU_BEZIER) {
/* count */
len = 0;
@@ -628,7 +630,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis
* - first point left, last point right
* - based on subdivided points in original curve, not on points in taper curve (still)
*/
-float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
+static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
{
DispList *dl;
@@ -641,7 +643,6 @@ float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
dl = taperobj->disp.first;
}
if (dl) {
- float fac = ((float)cur) / (float)(tot - 1);
float minx, dx, *fp;
int a;
@@ -669,6 +670,13 @@ float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
return 1.0;
}
+float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
+{
+ float fac = ((float)cur) / (float)(tot - 1);
+
+ return displist_calc_taper(scene, taperobj, fac);
+}
+
void BKE_displist_make_mball(Scene *scene, Object *ob)
{
if (!ob || ob->type != OB_MBALL)
@@ -1238,7 +1246,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
}
}
-static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r)
+static void rotateBevelPiece(Curve *cu, BevPoint *bevp, BevPoint *nbevp, DispList *dlb, float bev_blend, float widfac, float fac, float **data_r)
{
float *fp, *data = *data_r;
int b;
@@ -1246,22 +1254,48 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid
fp = dlb->verts;
for (b = 0; b < dlb->nr; b++, fp += 3, data += 3) {
if (cu->flag & CU_3D) {
- float vec[3];
+ float vec[3], quat[4];
vec[0] = fp[1] + widfac;
vec[1] = fp[2];
vec[2] = 0.0;
- mul_qt_v3(bevp->quat, vec);
+ if (nbevp == NULL) {
+ copy_v3_v3(data, bevp->vec);
+ copy_qt_qt(quat, bevp->quat);
+ }
+ else {
+ interp_v3_v3v3(data, bevp->vec, nbevp->vec, bev_blend);
+ interp_qt_qtqt(quat, bevp->quat, nbevp->quat, bev_blend);
+ }
- data[0] = bevp->vec[0] + fac * vec[0];
- data[1] = bevp->vec[1] + fac * vec[1];
- data[2] = bevp->vec[2] + fac * vec[2];
+ mul_qt_v3(quat, vec);
+
+ data[0] += fac * vec[0];
+ data[1] += fac * vec[1];
+ data[2] += fac * vec[2];
}
else {
- data[0] = bevp->vec[0] + fac * (widfac + fp[1]) * bevp->sina;
- data[1] = bevp->vec[1] + fac * (widfac + fp[1]) * bevp->cosa;
- data[2] = bevp->vec[2] + fac * fp[2];
+ float sina, cosa;
+
+ if (nbevp == NULL) {
+ copy_v3_v3(data, bevp->vec);
+ sina = bevp->sina;
+ cosa = bevp->cosa;
+ }
+ else {
+ interp_v3_v3v3(data, bevp->vec, nbevp->vec, bev_blend);
+
+ /* perhaps we need to interpolate angles instead. but the thing is
+ * cosa and sina are not actually sine and cosine
+ */
+ sina = nbevp->sina * bev_blend + bevp->sina * (1.0f - bev_blend);
+ cosa = nbevp->cosa * bev_blend + bevp->cosa * (1.0f - bev_blend);
+ }
+
+ data[0] += fac * (widfac + fp[1]) * sina;
+ data[1] += fac * (widfac + fp[1]) * cosa;
+ data[2] += fac * fp[2];
}
}
@@ -1384,8 +1418,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
ListBase top_capbase = {NULL, NULL};
for (dlb = dlbev.first; dlb; dlb = dlb->next) {
- const float bevfac1 = minf(cu->bevfac1, cu->bevfac2);
- const float bevfac2 = maxf(cu->bevfac1, cu->bevfac2);
+ const float bevfac1 = min_ff(cu->bevfac1, cu->bevfac2);
+ const float bevfac2 = max_ff(cu->bevfac1, cu->bevfac2);
float firstblend = 0.0f, lastblend = 0.0f;
int i, start, steps;
@@ -1397,8 +1431,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
firstblend = 1.0f - (bevfac1 * (bl->nr - 1) - (int)(bevfac1 * (bl->nr - 1)));
lastblend = bevfac2 * (bl->nr - 1) - (int)(bevfac2 * (bl->nr - 1));
- if (steps > bl->nr) {
- steps = bl->nr;
+ if (start + steps > bl->nr) {
+ steps = bl->nr - start;
lastblend = 1.0f;
}
@@ -1436,7 +1470,29 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
fac = bevp->radius;
}
else {
- fac = BKE_displist_calc_taper(scene, cu->taperobj, i, bl->nr);
+ float len, taper_fac;
+
+ if (cu->flag & CU_MAP_TAPER) {
+ len = (steps - 3) + firstblend + lastblend;
+
+ if (a == 0)
+ taper_fac = 0.0f;
+ else if (a == steps - 1)
+ taper_fac = 1.0f;
+ else
+ taper_fac = ((float) a - (1.0f - firstblend)) / len;
+ }
+ else {
+ len = bl->nr - 1;
+ taper_fac = (float) i / len;
+
+ if (a == 0)
+ taper_fac += (1.0f - firstblend) / len;
+ else if (a == steps - 1)
+ taper_fac -= (1.0f - lastblend) / len;
+ }
+
+ fac = displist_calc_taper(scene, cu->taperobj, taper_fac);
}
if (bevp->split_tag) {
@@ -1444,27 +1500,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
}
/* rotate bevel piece and write in data */
- rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
-
- if (a == 1 || a == steps - 1) {
- float *cur_fp = cur_data, *prev_fp = cur_data - 3 * dlb->nr;
- int b;
-
- for (b = 0; b < dlb->nr; b++, prev_fp += 3, cur_fp += 3) {
- float cur[3], prev[3];
-
- copy_v3_v3(cur, cur_fp);
- copy_v3_v3(prev, prev_fp);
-
- if (a == 1)
- interp_v3_v3v3(prev, cur_fp, prev_fp, firstblend);
- if (a == steps - 1)
- interp_v3_v3v3(cur, prev_fp, cur_fp, lastblend);
-
- copy_v3_v3(cur_fp, cur);
- copy_v3_v3(prev_fp, prev);
- }
- }
+ if (a == 0)
+ rotateBevelPiece(cu, bevp, bevp + 1, dlb, 1.0f - firstblend, widfac, fac, &data);
+ else if (a == steps - 1)
+ rotateBevelPiece(cu, bevp, bevp - 1, dlb, 1.0f - lastblend, widfac, fac, &data);
+ else
+ rotateBevelPiece(cu, bevp, NULL, dlb, 0.0f, widfac, fac, &data);
if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) {
if (a == 1)
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index d55848514cc..89d728c0419 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -32,6 +32,8 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
@@ -87,6 +89,9 @@
#include <omp.h>
#endif
+/* could enable at some point but for now there are far too many conversions */
+#pragma GCC diagnostic ignored "-Wdouble-promotion"
+
/* precalculated gaussian factors for 5x super sampling */
static float gaussianFactors[5] = {0.996849f,
0.596145f,
@@ -120,8 +125,16 @@ static int neighY[8] = {0, 1, 1, 1, 0, -1, -1, -1};
/* drying limits */
#define MIN_WETNESS 0.001f
#define MAX_WETNESS 5.0f
-/* dissolve macro */
-#define VALUE_DISSOLVE(VALUE, TIME, SCALE, LOG) (VALUE) = (LOG) ? (VALUE) *(pow(MIN_WETNESS, 1.0f / (1.2f * ((float)(TIME)) / (SCALE)))) : (VALUE) -1.0f / (TIME)*(SCALE)
+
+
+/* dissolve inline function */
+BLI_INLINE void value_dissolve(float *r_value, const float time, const float scale, const int is_log)
+{
+ *r_value = (is_log) ?
+ (*r_value) * (powf(MIN_WETNESS, 1.0f / (1.2f * time / scale))) :
+ (*r_value) - 1.0f / time * scale;
+}
+
/***************************** Internal Structs ***************************/
@@ -569,7 +582,7 @@ static void scene_setSubframe(Scene *scene, float subframe)
static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
{
Base *base = NULL;
- GroupObject *go = NULL;
+ GroupObject *go = NULL;
Object *brushObj = NULL;
ModifierData *md = NULL;
@@ -757,7 +770,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
volume = td[0] * td[1] * td[2];
/* determine final grid size by trying to fit average 10.000 points per grid cell */
- dim_factor = (float)pow(volume / ((double)sData->total_points / 10000.0), 1.0 / (double)axis);
+ dim_factor = (float)pow((double)volume / ((double)sData->total_points / 10000.0), 1.0 / (double)axis);
/* define final grid size using dim_factor, use min 3 for active axises */
for (i = 0; i < 3; i++) {
@@ -848,7 +861,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
grid->s_num = MEM_reallocN(grid->s_num, sizeof(int) * grid_cells);
if (error || !grid->s_num) {
- setError(surface->canvas, "Not enough free memory.");
+ setError(surface->canvas, N_("Not enough free memory"));
freeGrid(sData);
}
}
@@ -1235,7 +1248,7 @@ static void dynamicPaint_allocateSurfaceType(DynamicPaintSurface *surface)
break;
}
- if (sData->type_data == NULL) setError(surface->canvas, "Not enough free memory!");
+ if (sData->type_data == NULL) setError(surface->canvas, N_("Not enough free memory"));
}
static int surface_usesAdjDistance(DynamicPaintSurface *surface)
@@ -1292,7 +1305,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
if (!ad->n_index || !ad->n_num || !ad->n_target || !temp_data) {
dynamicPaint_freeAdjData(sData);
if (temp_data) MEM_freeN(temp_data);
- setError(surface->canvas, "Not enough free memory.");
+ setError(surface->canvas, N_("Not enough free memory"));
return;
}
@@ -1762,10 +1775,10 @@ static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
}
/* apply weights into a vertex group, if doesnt exists add a new layer */
- if (defgrp_index >= 0 && !dvert && (surface->output_name[0] != '\0'))
+ if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0'))
dvert = CustomData_add_layer_named(&result->vertData, CD_MDEFORMVERT, CD_CALLOC,
NULL, sData->total_points, surface->output_name);
- if (defgrp_index >= 0 && dvert) {
+ if (defgrp_index != -1 && dvert) {
int i;
for (i = 0; i < sData->total_points; i++) {
MDeformVert *dv = &dvert[i];
@@ -2165,8 +2178,10 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
int *final_index;
int aa_samples;
- if (!dm) return setError(canvas, "Canvas mesh not updated.");
- if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) return setError(canvas, "Can't bake non-\"image sequence\" formats.");
+ if (!dm)
+ return setError(canvas, N_("Canvas mesh not updated"));
+ if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ)
+ return setError(canvas, N_("Cannot bake non-'image sequence' formats"));
numOfFaces = dm->getNumTessFaces(dm);
mface = dm->getTessFaceArray(dm);
@@ -2176,8 +2191,10 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
/* Check for validity */
- if (!tface) return setError(canvas, "No UV data on canvas.");
- if (surface->image_resolution < 16 || surface->image_resolution > 8192) return setError(canvas, "Invalid resolution.");
+ if (!tface)
+ return setError(canvas, N_("No UV data on canvas"));
+ if (surface->image_resolution < 16 || surface->image_resolution > 8192)
+ return setError(canvas, N_("Invalid resolution"));
w = h = surface->image_resolution;
@@ -2189,7 +2206,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
/* Init data struct */
if (surface->data) dynamicPaint_freeSurfaceData(surface);
sData = surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData");
- if (!surface->data) return setError(canvas, "Not enough free memory.");
+ if (!surface->data)
+ return setError(canvas, N_("Not enough free memory"));
aa_samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
tempPoints = (struct PaintUVPoint *) MEM_callocN(w * h * sizeof(struct PaintUVPoint), "Temp PaintUVPoint");
@@ -2547,7 +2565,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
}
}
}
- if (error == 1) setError(canvas, "Not enough free memory.");
+ if (error == 1)
+ setError(canvas, N_("Not enough free memory"));
if (faceBB) MEM_freeN(faceBB);
if (tempPoints) MEM_freeN(tempPoints);
@@ -2598,7 +2617,10 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam
int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG;
char output_file[FILE_MAX];
- if (!sData->type_data) { setError(surface->canvas, "Image save failed: Invalid surface."); return; }
+ if (!sData->type_data) {
+ setError(surface->canvas, N_("Image save failed: invalid surface"));
+ return;
+ }
/* if selected format is openexr, but current build doesnt support one */
#ifndef WITH_OPENEXR
if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG;
@@ -2612,7 +2634,10 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam
/* Init image buffer */
ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat);
- if (ibuf == NULL) { setError(surface->canvas, "Image save failed: Not enough free memory."); return; }
+ if (ibuf == NULL) {
+ setError(surface->canvas, N_("Image save failed: not enough free memory"));
+ return;
+ }
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++) {
@@ -4473,7 +4498,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time
int i;
float dry_ratio, f_color[4];
float p_wetness = pPoint->wetness;
- VALUE_DISSOLVE(pPoint->wetness, surface->dry_speed, timescale, (surface->flags & MOD_DPAINT_DRY_LOG));
+ value_dissolve(&pPoint->wetness, surface->dry_speed, timescale, (surface->flags & MOD_DPAINT_DRY_LOG));
if (pPoint->wetness < 0.0f) pPoint->wetness = 0.0f;
if (pPoint->wetness < surface->color_dry_threshold) {
@@ -4518,10 +4543,10 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time
}
if (surface->flags & MOD_DPAINT_DISSOLVE) {
- VALUE_DISSOLVE(pPoint->alpha, surface->diss_speed, timescale, (surface->flags & MOD_DPAINT_DISSOLVE_LOG));
+ value_dissolve(&pPoint->alpha, surface->diss_speed, timescale, (surface->flags & MOD_DPAINT_DISSOLVE_LOG));
if (pPoint->alpha < 0.0f) pPoint->alpha = 0.0f;
- VALUE_DISSOLVE(pPoint->e_alpha, surface->diss_speed, timescale, (surface->flags & MOD_DPAINT_DISSOLVE_LOG));
+ value_dissolve(&pPoint->e_alpha, surface->diss_speed, timescale, (surface->flags & MOD_DPAINT_DISSOLVE_LOG));
if (pPoint->e_alpha < 0.0f) pPoint->e_alpha = 0.0f;
}
}
@@ -4533,7 +4558,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time
float *point = &((float *)sData->type_data)[index];
/* log or linear */
- VALUE_DISSOLVE(*point, surface->diss_speed, timescale, (surface->flags & MOD_DPAINT_DISSOLVE_LOG));
+ value_dissolve(point, surface->diss_speed, timescale, (surface->flags & MOD_DPAINT_DISSOLVE_LOG));
if (*point < 0.0f) *point = 0.0f;
}
}
@@ -4649,7 +4674,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
if (bData->realCoord) MEM_freeN(bData->realCoord);
if (canvas_verts) MEM_freeN(canvas_verts);
- return setError(surface->canvas, "Not enough free memory.");
+ return setError(surface->canvas, N_("Not enough free memory"));
}
new_bdata = 1;
@@ -4811,7 +4836,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
*/
{
Base *base = NULL;
- GroupObject *go = NULL;
+ GroupObject *go = NULL;
Object *brushObj = NULL;
ModifierData *md = NULL;
@@ -4878,7 +4903,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
/* Apply brush on the surface depending on it's collision type */
/* Particle brush: */
if (brush->collision == MOD_DPAINT_COL_PSYS) {
- if (brush->psys && brush->psys->part && brush->psys->part->type == PART_EMITTER &&
+ if (brush->psys && brush->psys->part && ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID) &&
psys_check_enabled(brushObj, brush->psys))
{
@@ -4934,7 +4959,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
/* Allocate memory for surface previous points to read unchanged values from */
prevPoint = MEM_mallocN(sData->total_points * sizeof(struct PaintPoint), "PaintSurfaceDataCopy");
if (!prevPoint)
- return setError(canvas, "Not enough free memory.");
+ return setError(canvas, N_("Not enough free memory"));
/* Prepare effects and get number of required steps */
steps = dynamicPaint_prepareEffectStep(surface, scene, ob, &force, timescale);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 4f4bafd00b4..1f6db19ac27 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -54,6 +54,7 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
+#include "BLI_noise.h"
#include "BLI_jitter.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
@@ -84,6 +85,7 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
+#include "BKE_smoke.h"
#include "RE_render_ext.h"
@@ -137,6 +139,9 @@ PartDeflect *object_add_collision_fields(int type)
case PFIELD_TEXTURE:
pd->f_size = 1.0f;
break;
+ case PFIELD_SMOKEFLOW:
+ pd->f_flow = 1.0f;
+ break;
}
pd->flag = PFIELD_DO_LOCATION|PFIELD_DO_ROTATION;
@@ -161,7 +166,7 @@ void free_partdeflect(PartDeflect *pd)
pd->tex->id.us--;
if (pd->rng)
- rng_free(pd->rng);
+ BLI_rng_free(pd->rng);
MEM_freeN(pd);
}
@@ -170,9 +175,9 @@ static void precalculate_effector(EffectorCache *eff)
{
unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
if (!eff->pd->rng)
- eff->pd->rng = rng_new(eff->pd->seed + cfra);
+ eff->pd->rng = BLI_rng_new(eff->pd->seed + cfra);
else
- rng_srandom(eff->pd->rng, eff->pd->seed + cfra);
+ BLI_rng_srandom(eff->pd->rng, eff->pd->seed + cfra);
if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
Curve *cu= eff->ob->data;
@@ -200,7 +205,7 @@ static void precalculate_effector(EffectorCache *eff)
float old_vel[3];
BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f);
- copy_v3_v3(old_vel, eff->ob->obmat[3]);
+ copy_v3_v3(old_vel, eff->ob->obmat[3]);
BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra);
sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
}
@@ -450,8 +455,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
// noise function for wind e.g.
static float wind_func(struct RNG *rng, float strength)
{
- int random = (rng_getInt(rng)+1) % 128; // max 2357
- float force = rng_getFloat(rng) + 1.0f;
+ int random = (BLI_rng_get_int(rng)+1) % 128; // max 2357
+ float force = BLI_rng_get_float(rng) + 1.0f;
float ret;
float sign = 0;
@@ -713,8 +718,8 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin
if (eff->pd->forcefield == PFIELD_CHARGE) {
/* Only the charge of the effected particle is used for
- * interaction, not fall-offs. If the fall-offs aren't the
- * same this will be unphysical, but for animation this
+ * interaction, not fall-offs. If the fall-offs aren't the
+ * same this will be unphysical, but for animation this
* could be the wanted behavior. If you want physical
* correctness the fall-off should be spherical 2.0 anyways.
*/
@@ -823,7 +828,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
{
PartDeflect *pd = eff->pd;
RNG *rng = pd->rng;
- float force[3]={0, 0, 0};
+ float force[3] = {0, 0, 0};
float temp[3];
float fac;
float strength = pd->f_strength;
@@ -922,12 +927,27 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));
break;
+ case PFIELD_SMOKEFLOW:
+ zero_v3(force);
+ if (pd->f_source) {
+ float density;
+ if ((density = smoke_get_velocity_at(pd->f_source, point->loc, force)) >= 0.0f) {
+ float influence = strength * efd->falloff;
+ if (pd->flag & PFIELD_SMOKE_DENSITY)
+ influence *= density;
+ mul_v3_fl(force, influence);
+ /* apply flow */
+ madd_v3_v3fl(total_force, point->vel, -pd->f_flow * influence);
+ }
+ }
+ break;
+
}
if (pd->flag & PFIELD_DO_LOCATION) {
madd_v3_v3fl(total_force, force, 1.0f/point->vel_to_sec);
- if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG)==0 && pd->f_flow != 0.0f) {
+ if (ELEM3(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_SMOKEFLOW)==0 && pd->f_flow != 0.0f) {
madd_v3_v3fl(total_force, point->vel, -pd->f_flow * efd->falloff);
}
}
@@ -993,12 +1013,14 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
if (efd.falloff > 0.0f)
efd.falloff *= eff_calc_visibility(colliders, eff, &efd, point);
- if (efd.falloff <= 0.0f)
- ; /* don't do anything */
- else if (eff->pd->forcefield == PFIELD_TEXTURE)
+ if (efd.falloff <= 0.0f) {
+ /* don't do anything */
+ }
+ else if (eff->pd->forcefield == PFIELD_TEXTURE) {
do_texture_effector(eff, &efd, point, force);
+ }
else {
- float temp1[3]={0, 0, 0}, temp2[3];
+ float temp1[3] = {0, 0, 0}, temp2[3];
copy_v3_v3(temp1, force);
do_physical_effector(eff, &efd, point, force);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 2dbc63e6944..ec61311d89e 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -504,14 +504,14 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
xmaxv = MAX3(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]);
}
else {
- xminv = minf(xminv, bezt_first->vec[1][0]);
- xmaxv = maxf(xmaxv, bezt_last->vec[1][0]);
+ xminv = min_ff(xminv, bezt_first->vec[1][0]);
+ xmaxv = max_ff(xmaxv, bezt_last->vec[1][0]);
}
}
}
/* only loop over keyframes to find extents for values if needed */
- if (ymin || ymax) {
+ if (ymin || ymax) {
BezTriple *bezt;
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
@@ -521,8 +521,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
ymaxv = MAX4(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
}
else {
- yminv = minf(yminv, bezt->vec[1][1]);
- ymaxv = maxf(ymaxv, bezt->vec[1][1]);
+ yminv = min_ff(yminv, bezt->vec[1][1]);
+ ymaxv = max_ff(ymaxv, bezt->vec[1][1]);
}
foundvert = TRUE;
@@ -533,8 +533,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
else if (fcu->fpt) {
/* frame range can be directly calculated from end verts */
if (xmin || xmax) {
- xminv = minf(xminv, fcu->fpt[0].vec[0]);
- xmaxv = maxf(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]);
+ xminv = min_ff(xminv, fcu->fpt[0].vec[0]);
+ xmaxv = max_ff(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]);
}
/* only loop over keyframes to find extents for values if needed */
@@ -591,15 +591,15 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end,
if (bezt_first) {
BLI_assert(bezt_last != NULL);
- min = minf(min, bezt_first->vec[1][0]);
- max = maxf(max, bezt_last->vec[1][0]);
+ min = min_ff(min, bezt_first->vec[1][0]);
+ max = max_ff(max, bezt_last->vec[1][0]);
foundvert = TRUE;
}
}
else if (fcu->fpt) {
- min = minf(min, fcu->fpt[0].vec[0]);
- max = maxf(max, fcu->fpt[fcu->totvert - 1].vec[0]);
+ min = min_ff(min, fcu->fpt[0].vec[0]);
+ max = max_ff(max, fcu->fpt[fcu->totvert - 1].vec[0]);
foundvert = TRUE;
}
@@ -1039,7 +1039,7 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
if (RNA_path_resolve_full(&id_ptr, dtar->rna_path, &ptr, &prop, &index)) {
if (RNA_property_array_check(prop)) {
/* array */
- if (index < RNA_property_array_length(&ptr, prop)) {
+ if (index < RNA_property_array_length(&ptr, prop)) {
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
value = (float)RNA_property_boolean_get_index(&ptr, prop, index);
@@ -1143,7 +1143,7 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar)
/* stop here... */
return 0.0f;
- }
+ }
/* use the final posed locations */
mat4_to_quat(q1, pchan->pose_mat);
@@ -1549,7 +1549,7 @@ ChannelDriver *fcurve_copy_driver(ChannelDriver *driver)
for (dvar = ndriver->variables.first; dvar; dvar = dvar->next) {
/* need to go over all targets so that we don't leave any dangling paths */
DRIVER_TARGETS_LOOPER(dvar)
- {
+ {
/* make a copy of target's rna path if available */
if (dtar->rna_path)
dtar->rna_path = MEM_dupallocN(dtar->rna_path);
@@ -1832,7 +1832,7 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
return 1;
}
- return 0;
+ return 0;
}
}
@@ -1916,7 +1916,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
cvalue = prevbezt->vec[1][1];
}
}
- }
+ }
else {
/* Use the first handle (earlier) of first BezTriple to calculate the
* gradient and thus the value of the curve at evaltime
@@ -1968,7 +1968,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
cvalue = lastbezt->vec[1][1];
}
}
- }
+ }
else {
/* Use the gradient of the second handle (later) of last BezTriple to calculate the
* gradient and thus the value of the curve at evaltime
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 9be599ac66c..efc9869c5ca 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -41,7 +41,7 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_fluidsim.h"
-#include "DNA_object_force.h" // for pointcache
+#include "DNA_object_force.h" // for pointcache
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h" // N_T
@@ -66,14 +66,14 @@
//-------------------------------------------------------------------------------
void initElbeemMesh(struct Scene *scene, struct Object *ob,
- int *numVertices, float **vertices,
- int *numTriangles, int **triangles,
- int useGlobalCoords, int modifierIndex)
+ int *numVertices, float **vertices,
+ int *numTriangles, int **triangles,
+ int useGlobalCoords, int modifierIndex)
{
DerivedMesh *dm = NULL;
MVert *mvert;
MFace *mface;
- int countTris=0, i, totvert, totface;
+ int countTris = 0, i, totvert, totface;
float *verts;
int *tris;
@@ -87,35 +87,35 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
totface = dm->getNumTessFaces(dm);
*numVertices = totvert;
- verts = MEM_callocN(totvert*3*sizeof(float), "elbeemmesh_vertices");
- for (i=0; i<totvert; i++) {
- copy_v3_v3(&verts[i*3], mvert[i].co);
- if (useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); }
+ verts = MEM_callocN(totvert * 3 * sizeof(float), "elbeemmesh_vertices");
+ for (i = 0; i < totvert; i++) {
+ copy_v3_v3(&verts[i * 3], mvert[i].co);
+ if (useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i * 3]); }
}
*vertices = verts;
- for (i=0; i<totface; i++) {
+ for (i = 0; i < totface; i++) {
countTris++;
if (mface[i].v4) { countTris++; }
}
*numTriangles = countTris;
- tris = MEM_callocN(countTris*3*sizeof(int), "elbeemmesh_triangles");
+ tris = MEM_callocN(countTris * 3 * sizeof(int), "elbeemmesh_triangles");
countTris = 0;
- for (i=0; i<totface; i++) {
+ for (i = 0; i < totface; i++) {
int face[4];
face[0] = mface[i].v1;
face[1] = mface[i].v2;
face[2] = mface[i].v3;
face[3] = mface[i].v4;
- tris[countTris*3+0] = face[0];
- tris[countTris*3+1] = face[1];
- tris[countTris*3+2] = face[2];
+ tris[countTris * 3 + 0] = face[0];
+ tris[countTris * 3 + 1] = face[1];
+ tris[countTris * 3 + 2] = face[2];
countTris++;
if (face[3]) {
- tris[countTris*3+0] = face[0];
- tris[countTris*3+1] = face[2];
- tris[countTris*3+2] = face[3];
+ tris[countTris * 3 + 0] = face[0];
+ tris[countTris * 3 + 1] = face[2];
+ tris[countTris * 3 + 2] = face[3];
countTris++;
}
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 68321076398..2b393b4d90b 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -42,6 +42,7 @@
#include "BLF_translation.h"
#include "BLI_blenlib.h"
+#include "BLI_noise.h"
#include "BLI_math.h" /* windows needs for M_PI */
#include "BLI_utildefines.h"
@@ -155,7 +156,7 @@ static void fcm_generator_verify(FModifier *fcm)
/* free the old data */
MEM_freeN(data->coefficients);
- }
+ }
/* set the new data */
data->coefficients = nc;
@@ -181,7 +182,7 @@ static void fcm_generator_verify(FModifier *fcm)
/* free the old data */
MEM_freeN(data->coefficients);
- }
+ }
/* set the new data */
data->coefficients = nc;
@@ -275,7 +276,7 @@ static FModifierTypeInfo FMI_GENERATOR = {
/* Built-In Function Generator F-Curve Modifier --------------------------- */
/* This uses the general equation for equations:
- * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
+ * y = amplitude * fn(phase_multiplier * x + phase_offset) + y_offset
*
* where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients,
* x is the evaluation 'time', and 'y' is the resultant value
@@ -315,7 +316,7 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
* WARNING: must perform special argument validation hereto guard against crashes
*/
switch (data->type) {
- /* simple ones */
+ /* simple ones */
case FCM_GENERATOR_FN_SIN: /* sine wave */
fn = sin;
break;
@@ -1021,7 +1022,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type)
fcm->data = MEM_callocN(fmi->size, fmi->structName);
/* init custom settings if necessary */
- if (fmi->new_data)
+ if (fmi->new_data)
fmi->new_data(fcm->data);
/* return modifier for further editing */
@@ -1098,7 +1099,7 @@ int remove_fmodifier(ListBase *modifiers, FModifier *fcm)
if (modifiers) {
BLI_freelinkN(modifiers, fcm);
return 1;
- }
+ }
else {
/* XXX this case can probably be removed some day, as it shouldn't happen... */
printf("remove_fmodifier() - no modifier stack given\n");
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 8b35974ea62..d4634748c71 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -177,7 +177,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
}
}
- return vfont->data;
+ return vfont->data;
}
VFont *BKE_vfont_load(Main *bmain, const char *name)
@@ -306,23 +306,23 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
nu2->bp = bp;
nu2->bp[0].vec[0] = x1;
- nu2->bp[0].vec[1] = y1;
+ nu2->bp[0].vec[1] = y1;
nu2->bp[0].vec[2] = 0;
nu2->bp[0].vec[3] = 1.0f;
nu2->bp[1].vec[0] = x2;
nu2->bp[1].vec[1] = y1;
- nu2->bp[1].vec[2] = 0;
+ nu2->bp[1].vec[2] = 0;
nu2->bp[1].vec[3] = 1.0f;
nu2->bp[2].vec[0] = x2;
- nu2->bp[2].vec[1] = y2;
+ nu2->bp[2].vec[1] = y2;
nu2->bp[2].vec[2] = 0;
nu2->bp[2].vec[3] = 1.0f;
nu2->bp[3].vec[0] = x1;
nu2->bp[3].vec[1] = y2;
- nu2->bp[3].vec[2] = 0;
+ nu2->bp[3].vec[2] = 0;
nu2->bp[3].vec[3] = 1.0f;
- BLI_addtail(&(cu->nurb), nu2);
+ BLI_addtail(&(cu->nurb), nu2);
}
@@ -545,7 +545,7 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int
/* The VFont Data can not be found */
if (!vfd) {
if (mem)
- MEM_freeN(mem);
+ MEM_freeN(mem);
return NULL;
}
@@ -671,7 +671,7 @@ makebreak:
yof -= linedist;
- maxlen = maxf(maxlen, (xof - tb->x / cu->fsize));
+ maxlen = max_ff(maxlen, (xof - tb->x / cu->fsize));
linedata[lnr] = xof - tb->x / cu->fsize;
linedata2[lnr] = cnr;
linedata3[lnr] = tb->w / cu->fsize;
@@ -731,7 +731,7 @@ makebreak:
if (ascii == 32) {
wsfac = cu->wordspace;
wsnr++;
- }
+ }
else {
wsfac = 1.0f;
}
@@ -754,7 +754,7 @@ makebreak:
for (i = 0; i <= slen; i++, tmp++, ct++) {
ascii = *tmp;
if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++;
- }
+ }
/* linedata is now: width of line
* linedata2 is now: number of characters
@@ -792,7 +792,7 @@ makebreak:
// }
ct++;
}
- }
+ }
else if ((cu->spacemode == CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
float curofs = 0.0f;
for (i = 0; i <= slen; i++) {
@@ -928,8 +928,12 @@ makebreak:
* 3: curs down */
ct = chartransdata + cu->pos;
- if ((mode == FO_CURSUP || mode == FO_PAGEUP) && ct->linenr == 0) ;
- else if ((mode == FO_CURSDOWN || mode == FO_PAGEDOWN) && ct->linenr == lnr) ;
+ if ((mode == FO_CURSUP || mode == FO_PAGEUP) && ct->linenr == 0) {
+ /* pass */
+ }
+ else if ((mode == FO_CURSDOWN || mode == FO_PAGEDOWN) && ct->linenr == lnr) {
+ /* pass */
+ }
else {
switch (mode) {
case FO_CURSUP: lnr = ct->linenr - 1; break;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 84871375788..a7d0152a799 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -87,6 +87,7 @@ void free_gpencil_frames(bGPDlayer *gpl)
free_gpencil_strokes(gpf);
BLI_freelinkN(&gpl->frames, gpf);
}
+ gpl->actframe = NULL;
}
/* Free all of the gp-layers for a viewport (list should be &gpd->layers or so) */
@@ -516,7 +517,7 @@ void gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
if (ELEM(NULL, gpd, gpl))
return;
- /* free layer */
+ /* free layer */
free_gpencil_frames(gpl);
BLI_freelinkN(&gpd->layers, gpl);
}
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 634428d9194..20d874e7243 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -98,7 +98,7 @@ void BKE_group_unlink(Group *group)
base->object->flag &= ~OB_FROMGROUP;
base->flag &= ~OB_FROMGROUP;
}
- }
+ }
for (srl = sce->r.layers.first; srl; srl = srl->next) {
if (srl->light_override == group)
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 8ceaab56f83..5dd0f08dc71 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -492,6 +492,30 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
}
}
+/*
+ * If a property is missing in \a dest, add it.
+ */
+void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite)
+{
+ IDProperty *prop;
+
+ if (do_overwrite) {
+ for (prop = src->data.group.first; prop; prop = prop->next) {
+ IDProperty *copy = IDP_CopyProperty(prop);
+ IDP_ReplaceInGroup(dest, copy);
+ }
+ }
+ else {
+ for (prop = src->data.group.first; prop; prop = prop->next) {
+ if (IDP_GetPropertyFromGroup(dest, prop->name) == NULL) {
+ IDProperty *copy = IDP_CopyProperty(prop);
+ dest->len++;
+ BLI_addtail(&dest->data.group, copy);
+ }
+ }
+ }
+}
+
/* returns 0 if an id property with the same name exists and it failed,
* or 1 if it succeeded in adding to the group.*/
int IDP_AddToGroup(IDProperty *group, IDProperty *prop)
@@ -608,60 +632,77 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
}
}
-int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
+/**
+ * \param is_strict When FALSE treat missing items as a match */
+int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict)
{
if (prop1 == NULL && prop2 == NULL)
return 1;
else if (prop1 == NULL || prop2 == NULL)
- return 0;
+ return is_strict ? 0 : 1;
else if (prop1->type != prop2->type)
return 0;
- if (prop1->type == IDP_INT)
- return (IDP_Int(prop1) == IDP_Int(prop2));
- else if (prop1->type == IDP_FLOAT)
- return (IDP_Float(prop1) == IDP_Float(prop2));
- else if (prop1->type == IDP_DOUBLE)
- return (IDP_Double(prop1) == IDP_Double(prop2));
- else if (prop1->type == IDP_STRING)
- return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0);
- else if (prop1->type == IDP_ARRAY) {
- if (prop1->len == prop2->len && prop1->subtype == prop2->subtype)
- return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len);
- else
- return 0;
- }
- else if (prop1->type == IDP_GROUP) {
- IDProperty *link1, *link2;
-
- if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
- return 0;
-
- for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
- link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
-
- if (!IDP_EqualsProperties(link1, link2))
+ switch (prop1->type) {
+ case IDP_INT:
+ return (IDP_Int(prop1) == IDP_Int(prop2));
+ case IDP_FLOAT:
+ return (IDP_Float(prop1) == IDP_Float(prop2));
+ case IDP_DOUBLE:
+ return (IDP_Double(prop1) == IDP_Double(prop2));
+ case IDP_STRING:
+ return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0);
+ case IDP_ARRAY:
+ if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) {
+ return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len);
+ }
+ else {
return 0;
- }
+ }
+ case IDP_GROUP:
+ {
+ IDProperty *link1, *link2;
- return 1;
- }
- else if (prop1->type == IDP_IDPARRAY) {
- IDProperty *array1 = IDP_IDPArray(prop1);
- IDProperty *array2 = IDP_IDPArray(prop2);
- int i;
+ if (is_strict && BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
+ return 0;
- if (prop1->len != prop2->len)
- return 0;
-
- for (i = 0; i < prop1->len; i++)
- if (!IDP_EqualsProperties(&array1[i], &array2[i]))
+ for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
+ link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
+
+ if (!IDP_EqualsProperties_ex(link1, link2, is_strict))
+ return 0;
+ }
+
+ return 1;
+ }
+ case IDP_IDPARRAY:
+ {
+ IDProperty *array1 = IDP_IDPArray(prop1);
+ IDProperty *array2 = IDP_IDPArray(prop2);
+ int i;
+
+ if (prop1->len != prop2->len)
return 0;
+
+ for (i = 0; i < prop1->len; i++)
+ if (!IDP_EqualsProperties(&array1[i], &array2[i]))
+ return 0;
+ return 1;
+ }
+ default:
+ /* should never get here */
+ BLI_assert(0);
+ break;
}
-
+
return 1;
}
+int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
+{
+ return IDP_EqualsProperties_ex(prop1, prop2, TRUE);
+}
+
/* 'val' is never NULL, don't check */
IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
{
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index c003a86a0b7..55d37c91859 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1063,6 +1063,7 @@ char BKE_imtype_valid_channels(const char imtype)
case R_IMF_IMTYPE_DDS:
case R_IMF_IMTYPE_JP2:
case R_IMF_IMTYPE_QUICKTIME:
+ case R_IMF_IMTYPE_DPX:
chan_flag |= IMA_CHAN_FLAG_ALPHA;
}
@@ -1091,10 +1092,11 @@ char BKE_imtype_valid_depths(const char imtype)
return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
case R_IMF_IMTYPE_MULTILAYER:
return R_IMF_CHAN_DEPTH_32;
- /* eeh, cineone does some strange 10bits per channel */
+ /* eeh, cineon does some strange 10bits per channel */
case R_IMF_IMTYPE_DPX:
+ return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_10 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
case R_IMF_IMTYPE_CINEON:
- return R_IMF_CHAN_DEPTH_12;
+ return R_IMF_CHAN_DEPTH_10;
case R_IMF_IMTYPE_JP2:
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
/* most formats are 8bit only */
@@ -1559,7 +1561,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* also a little of space to the background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
/* and draw the text. */
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1576,7 +1578,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* and space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.note);
@@ -1592,7 +1594,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* and space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.date);
@@ -1608,7 +1610,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* and space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.rendertime);
@@ -1623,7 +1625,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
/* and pad the text. */
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1639,7 +1641,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
/* and pad the text. */
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1654,7 +1656,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
/* and pad the text. */
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1669,7 +1671,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.camera);
@@ -1682,7 +1684,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.cameralens);
}
@@ -1695,7 +1697,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
/* and pad the text. */
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1711,7 +1713,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
- x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+ x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.strip);
@@ -1825,9 +1827,33 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf)
#ifdef WITH_CINEON
else if (imtype == R_IMF_IMTYPE_CINEON) {
ibuf->ftype = CINEON;
+ if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
+ ibuf->ftype |= CINEON_LOG;
+ }
+ if (imf->depth == R_IMF_CHAN_DEPTH_16) {
+ ibuf->ftype |= CINEON_16BIT;
+ }
+ else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
+ ibuf->ftype |= CINEON_12BIT;
+ }
+ else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
+ ibuf->ftype |= CINEON_10BIT;
+ }
}
else if (imtype == R_IMF_IMTYPE_DPX) {
ibuf->ftype = DPX;
+ if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
+ ibuf->ftype |= CINEON_LOG;
+ }
+ if (imf->depth == R_IMF_CHAN_DEPTH_16) {
+ ibuf->ftype |= CINEON_16BIT;
+ }
+ else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
+ ibuf->ftype |= CINEON_12BIT;
+ }
+ else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
+ ibuf->ftype |= CINEON_10BIT;
+ }
}
#endif
else if (imtype == R_IMF_IMTYPE_TARGA) {
@@ -2120,6 +2146,15 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
}
}
break;
+ case IMA_SIGNAL_COLORMANAGE:
+ image_free_buffers(ima);
+
+ ima->ok = 1;
+
+ if (iuser)
+ iuser->ok = 1;
+
+ break;
}
/* don't use notifiers because they are not 100% sure to succeeded
@@ -2617,11 +2652,21 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
/* free rect buffer if float buffer changes, so it can be recreated with
* the updated result, and also in case we got byte buffer from sequencer,
* so we don't keep reference to freed buffer */
- if (ibuf->rect_float != rectf || rect || !rectf)
+ if (ibuf->rect_float != rectf || rect)
imb_freerectImBuf(ibuf);
- if (rect)
+ if (rect) {
ibuf->rect = rect;
+ }
+ else {
+ /* byte buffer of render result has been freed, make sure image buffers
+ * does not reference to this buffer anymore
+ * need check for whether byte buffer was allocated and owned by image itself
+ * or if it's reusing buffer from render result
+ */
+ if ((ibuf->mall & IB_rect) == 0)
+ ibuf->rect = NULL;
+ }
if (rectf) {
ibuf->rect_float = rectf;
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 37572eebed6..468a88775c6 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -244,7 +244,7 @@ static void checker_board_color_tint(unsigned char *rect, float *rect_float, int
}
}
- }
+ }
}
static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int width, int height, float blend)
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index ebb95a6561e..90cd7bc2df5 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -590,7 +590,7 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
}
- }
+ }
#pragma omp section
{
for (i = 0; i < from[0].vcount+from[0].scount; i++) {
@@ -623,7 +623,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
+ add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
}
@@ -634,7 +634,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
+ addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
}
@@ -645,7 +645,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
+ subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
}
@@ -656,7 +656,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
+ sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
}
@@ -667,7 +667,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount; i++) {
- sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m);
+ sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m);
}
}
@@ -678,7 +678,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
+ addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
}
@@ -691,7 +691,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
- subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
+ subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
}
}
@@ -711,7 +711,7 @@ static void update_matrixS(ClothVertex *verts, int numverts, fmatrix3x3 *S)
int i = 0;
/* Clear matrix from old vertex constraints */
- for(i = 0; i < S[0].vcount; i++)
+ for (i = 0; i < S[0].vcount; i++)
S[i].c = S[i].r = 0;
/* Set new vertex constraints */
@@ -749,7 +749,7 @@ int implicit_init(Object *UNUSED(ob), ClothModifierData *clmd)
id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat");
cloth->implicit = id;
- /* process diagonal elements */
+ /* process diagonal elements */
id->A = create_bfmatrix(cloth->numverts, cloth->numsprings);
id->dFdV = create_bfmatrix(cloth->numverts, cloth->numsprings);
id->dFdX = create_bfmatrix(cloth->numverts, cloth->numsprings);
@@ -844,41 +844,40 @@ int implicit_free(ClothModifierData *clmd)
DO_INLINE float fb(float length, float L)
{
- float x = length/L;
- return (-11.541f*pow(x, 4)+34.193f*pow(x, 3)-39.083f*pow(x, 2)+23.116f*x-9.713f);
+ float x = length / L;
+ return (-11.541f * powf(x, 4) + 34.193f * powf(x, 3) - 39.083f * powf(x, 2) + 23.116f * x - 9.713f);
}
DO_INLINE float fbderiv(float length, float L)
{
float x = length/L;
- return (-46.164f*pow(x, 3)+102.579f*pow(x, 2)-78.166f*x+23.116f);
+ return (-46.164f * powf(x, 3) + 102.579f * powf(x, 2) - 78.166f * x + 23.116f);
}
DO_INLINE float fbstar(float length, float L, float kb, float cb)
{
- float tempfb = kb * fb(length, L);
-
- float fbstar = cb * (length - L);
+ float tempfb_fl = kb * fb(length, L);
+ float fbstar_fl = cb * (length - L);
- if (tempfb < fbstar)
- return fbstar;
+ if (tempfb_fl < fbstar_fl)
+ return fbstar_fl;
else
- return tempfb;
+ return tempfb_fl;
}
// function to calculae bending spring force (taken from Choi & Co)
DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
{
- float tempfb = kb * fb(length, L);
- float fbstar = cb * (length - L);
+ float tempfb_fl = kb * fb(length, L);
+ float fbstar_fl = cb * (length - L);
- if (tempfb < fbstar) {
+ if (tempfb_fl < fbstar_fl) {
return cb;
}
else {
- return kb * fbderiv(length, L);
- }
+ return kb * fbderiv(length, L);
+ }
}
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
@@ -918,7 +917,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
cp_lfvector(d, r, numverts);
s = dot_lfvector(r, r, numverts);
- starget = s * sqrt(conjgrad_epsilon);
+ starget = s * sqrtf(conjgrad_epsilon);
while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
// Mul(q, A, d); // q = A*d;
@@ -1149,9 +1148,9 @@ DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length,
// dir is unit length direction, rest is spring's restlength, k is spring constant.
// return (outerprod(dir, dir)*k + (I - outerprod(dir, dir))*(k - ((k*L)/length)));
float temp[3][3];
- float temp1 = k*(1.0 - (L/length));
+ float temp1 = k * (1.0f - (L / length));
- mul_fvectorT_fvectorS(temp, extent, extent, 1.0 / dot);
+ mul_fvectorT_fvectorS(temp, extent, extent, 1.0f / dot);
sub_fmatrix_fmatrix(to, I, temp);
mul_fmatrix_S(to, temp1);
@@ -1219,7 +1218,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
float stretch_force[3] = {0, 0, 0};
float bending_force[3] = {0, 0, 0};
float damping_force[3] = {0, 0, 0};
- float nulldfdx[3][3]={ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
+ float nulldfdx[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
float scaling = 0.0;
@@ -1247,7 +1246,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
s->flags |= CSPRING_FLAG_DEACTIVATE;
return;
}
- }
+ }
*/
mul_fvector_S(dir, extent, 1.0f/length);
}
@@ -1308,7 +1307,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
VECADDS(s->f, s->f, extent, -k);
- mul_fvector_S(damping_force, dir, clmd->sim_parms->goalfrict * 0.01 * dot_v3v3(vel, dir));
+ mul_fvector_S(damping_force, dir, clmd->sim_parms->goalfrict * 0.01f * dot_v3v3(vel, dir));
VECADD(s->f, s->f, damping_force);
// HERE IS THE PROBLEM!!!!
@@ -1319,10 +1318,10 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
if (length < L) {
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
- k = clmd->sim_parms->bending;
+ k = clmd->sim_parms->bending;
- scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k);
- cb = k = scaling / (20.0*(clmd->sim_parms->avg_spring_len + FLT_EPSILON));
+ scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k);
+ cb = k = scaling / (20.0f * (clmd->sim_parms->avg_spring_len + FLT_EPSILON));
mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb));
VECADD(s->f, s->f, bending_force);
@@ -1338,7 +1337,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp
if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) {
sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv);
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
- add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
+ add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
}
VECADD(lF[s->ij], lF[s->ij], s->f);
@@ -1349,7 +1348,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp
sub_fmatrix_fmatrix(dFdX[s->kl].m, dFdX[s->kl].m, s->dfdx);
sub_fmatrix_fmatrix(dFdX[s->ij].m, dFdX[s->ij].m, s->dfdx);
add_fmatrix_fmatrix(dFdX[s->matrix_index].m, dFdX[s->matrix_index].m, s->dfdx);
- }
+ }
}
@@ -1357,15 +1356,15 @@ static void CalcFloat( float *v1, float *v2, float *v3, float *n)
{
float n1[3], n2[3];
- n1[0]= v1[0]-v2[0];
- n2[0]= v2[0]-v3[0];
- n1[1]= v1[1]-v2[1];
- n2[1]= v2[1]-v3[1];
- n1[2]= v1[2]-v2[2];
- n2[2]= v2[2]-v3[2];
- n[0]= n1[1]*n2[2]-n1[2]*n2[1];
- n[1]= n1[2]*n2[0]-n1[0]*n2[2];
- n[2]= n1[0]*n2[1]-n1[1]*n2[0];
+ n1[0] = v1[0]-v2[0];
+ n2[0] = v2[0]-v3[0];
+ n1[1] = v1[1]-v2[1];
+ n2[1] = v2[1]-v3[1];
+ n1[2] = v1[2]-v2[2];
+ n2[2] = v2[2]-v3[2];
+ n[0] = n1[1]*n2[2]-n1[2]*n2[1];
+ n[1] = n1[2]*n2[0]-n1[0]*n2[2];
+ n[2] = n1[0]*n2[1]-n1[1]*n2[0];
}
static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n)
@@ -1373,17 +1372,17 @@ static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n)
/* real cross! */
float n1[3], n2[3];
- n1[0]= v1[0]-v3[0];
- n1[1]= v1[1]-v3[1];
- n1[2]= v1[2]-v3[2];
+ n1[0] = v1[0]-v3[0];
+ n1[1] = v1[1]-v3[1];
+ n1[2] = v1[2]-v3[2];
- n2[0]= v2[0]-v4[0];
- n2[1]= v2[1]-v4[1];
- n2[2]= v2[2]-v4[2];
+ n2[0] = v2[0]-v4[0];
+ n2[1] = v2[1]-v4[1];
+ n2[2] = v2[2]-v4[2];
- n[0]= n1[1]*n2[2]-n1[2]*n2[1];
- n[1]= n1[2]*n2[0]-n1[0]*n2[2];
- n[2]= n1[0]*n2[1]-n1[1]*n2[0];
+ n[0] = n1[1]*n2[2]-n1[2]*n2[1];
+ n[1] = n1[2]*n2[0]-n1[0]*n2[2];
+ n[2] = n1[0]*n2[1]-n1[1]*n2[0];
}
static float calculateVertexWindForce(float wind[3], float vertexnormal[3])
@@ -1450,7 +1449,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0);
j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1);
k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2);
- if (i < 0 || j < 0 || k < 0 || i > 10 || j >= 10 || k >= 10)
+ if (i < 0 || j < 0 || k < 0 || i >= 10 || j >= 10 || k >= 10)
continue;
grid[i][j][k].velocity[0] += lV[v][0];
@@ -1480,7 +1479,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
colg[i][j][k].velocity[0] += vel[0];
colg[i][j][k].velocity[1] += vel[1];
colg[i][j][k].velocity[2] += vel[2];
- colg[i][j][k].density += 1.0;
+ colg[i][j][k].density += 1.0f;
}
}
}
@@ -1514,7 +1513,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0);
j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1);
k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2);
- if (i < 0 || j < 0 || k < 0 || i > 10 || j >= 10 || k >= 10)
+ if (i < 0 || j < 0 || k < 0 || i >= 10 || j >= 10 || k >= 10)
continue;
lF[v][0] += smoothfac * (grid[i][j][k].velocity[0] - lV[v][0]);
@@ -1545,7 +1544,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
lfVector *winvec;
EffectedPoint epoint;
- tm2[0][0]= tm2[1][1]= tm2[2][2]= -spring_air;
+ tm2[0][0] = tm2[1][1] = tm2[2][2] = -spring_air;
/* global acceleration (gravitation) */
if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
@@ -1589,11 +1588,11 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
}
for (i = 0; i < cloth->numfaces; i++) {
- float trinormal[3]={0, 0, 0}; // normalized triangle normal
- float triunnormal[3]={0, 0, 0}; // not-normalized-triangle normal
- float tmp[3]={0, 0, 0};
+ float trinormal[3] = {0, 0, 0}; // normalized triangle normal
+ float triunnormal[3] = {0, 0, 0}; // not-normalized-triangle normal
+ float tmp[3] = {0, 0, 0};
float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0;
- factor *= 0.02;
+ factor *= 0.02f;
// calculate face normal
if (mfaces[i].v4)
@@ -1629,9 +1628,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
/* Hair has only edges */
if (cloth->numfaces == 0) {
ClothSpring *spring;
- float edgevec[3]={0, 0, 0}; //edge vector
- float edgeunnormal[3]={0, 0, 0}; // not-normalized-edge normal
- float tmp[3]={0, 0, 0};
+ float edgevec[3] = {0, 0, 0}; //edge vector
+ float edgeunnormal[3] = {0, 0, 0}; // not-normalized-edge normal
+ float tmp[3] = {0, 0, 0};
float factor = 0.01;
search = cloth->springs;
@@ -1663,7 +1662,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
while (search) {
// only handle active springs
ClothSpring *spring = search->link;
- if( !(spring->flags & CLOTH_SPRING_FLAG_DEACTIVATE))
+ if (!(spring->flags & CLOTH_SPRING_FLAG_DEACTIVATE))
cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time);
search = search->next;
@@ -1731,8 +1730,8 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
for (i=0; i<cloth->numverts; i++, cv++) {
copy_v3_v3(cos[i], cv->tx);
- if (cv->goal == 1.0f || len_v3v3(initial_cos[i], cv->tx) != 0.0) {
- masses[i] = 1e+10;
+ if (cv->goal == 1.0f || len_squared_v3v3(initial_cos[i], cv->tx) != 0.0f) {
+ masses[i] = 1e+10;
}
else {
masses[i] = cv->mass;
@@ -1759,18 +1758,18 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
normalize_v3(vec);
c = (len - spring->restlen);
- if (c == 0.0)
+ if (c == 0.0f)
continue;
- l = c / ((1.0/masses[v1]) + (1.0/masses[v2]));
+ l = c / ((1.0f / masses[v1]) + (1.0f / masses[v2]));
- mul_v3_fl(vec, -(1.0/masses[v1])*l);
+ mul_v3_fl(vec, -(1.0f / masses[v1]) * l);
add_v3_v3(cos[v1], vec);
sub_v3_v3v3(vec, cos[v2], cos[v1]);
normalize_v3(vec);
- mul_v3_fl(vec, -(1.0/masses[v2])*l);
+ mul_v3_fl(vec, -(1.0f / masses[v2]) * l);
add_v3_v3(cos[v2], vec);
}
}
@@ -1815,7 +1814,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase *
sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold);
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
}
- }
+ }
}
while (step < tf) {
@@ -1840,7 +1839,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase *
mul_fvector_S(tvect, tvect, step+dt);
VECADD(tvect, tvect, verts[i].xold);
copy_v3_v3(id->Xnew[i], tvect);
- }
+ }
}
copy_v3_v3(verts[i].txold, id->X[i]);
@@ -1898,7 +1897,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase *
cp_lfvector(id->V, id->Vnew, numverts);
// calculate
- cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M);
+ cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M);
simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI);
}
@@ -1947,6 +1946,6 @@ void implicit_set_positions(ClothModifierData *clmd)
copy_v3_v3(id->V[i], verts[i].v);
}
if (G.debug_value > 0)
- printf("implicit_set_positions\n");
+ printf("implicit_set_positions\n");
}
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 5216aefab58..59dd02849dd 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -569,7 +569,7 @@ static const char *material_adrcodes_to_paths(int adrcode, int *array_index)
return mtex_adrcodes_to_paths(adrcode, array_index);
}
- return NULL;
+ return NULL;
}
/* Camera Types */
@@ -727,7 +727,7 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index)
return mtex_adrcodes_to_paths(adrcode, array_index);
}
- return NULL;
+ return NULL;
}
/* Particle Types */
@@ -873,7 +873,7 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con
propname = "eval_time";
break;
- /* XXX problematic blocktypes */
+ /* XXX problematic blocktypes */
case ID_SEQ: /* sequencer strip */
//SEQ_FAC1:
switch (adrcode) {
@@ -981,21 +981,21 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con
static short adrcode_to_dtar_transchan(short adrcode)
{
switch (adrcode) {
- case OB_LOC_X:
+ case OB_LOC_X:
return DTAR_TRANSCHAN_LOCX;
case OB_LOC_Y:
return DTAR_TRANSCHAN_LOCY;
case OB_LOC_Z:
return DTAR_TRANSCHAN_LOCZ;
- case OB_ROT_X:
+ case OB_ROT_X:
return DTAR_TRANSCHAN_ROTX;
case OB_ROT_Y:
return DTAR_TRANSCHAN_ROTY;
case OB_ROT_Z:
return DTAR_TRANSCHAN_ROTZ;
- case OB_SIZE_X:
+ case OB_SIZE_X:
return DTAR_TRANSCHAN_SCALEX;
case OB_SIZE_Y:
return DTAR_TRANSCHAN_SCALEX;
@@ -1359,8 +1359,8 @@ static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *i
/* correct values for sequencer curves, that were not locked to frame */
if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
- double mul = (seq->enddisp - seq->startdisp) / 100.0f;
- double offset = seq->startdisp;
+ const float mul = (seq->enddisp - seq->startdisp) / 100.0f;
+ const float offset = seq->startdisp;
dst->vec[0][0] *= mul;
dst->vec[0][0] += offset;
@@ -1645,7 +1645,7 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
/* by default, we now always extrapolate, while in the past this was optional */
if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0)
strip->extendmode = NLASTRIP_EXTEND_NOTHING;
- }
+ }
/* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */
if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
@@ -2093,7 +2093,7 @@ void do_versions_ipos_to_animato(Main *main)
bAction *new_act;
/* add a new action for this, and convert all data into that action */
- new_act = add_empty_action(id->name+2);
+ new_act = add_empty_action(id->name + 2);
ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers);
new_act->idroot = ipo->blocktype;
}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index b9bf2fd01a3..782d796b8a7 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -389,7 +389,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
if (k1->next == NULL) k[0] = k1;
k1 = k1->next;
}
- /* k1= k[1]; */ /* UNUSED */
+ /* k1 = k[1]; */ /* UNUSED */
t[0] = k[0]->pos;
t[1] += dpos;
t[2] = k[2]->pos + dpos;
@@ -609,7 +609,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
}
}
else k1 += start * key->elemsize;
- }
+ }
if (mode == KEY_MODE_BEZTRIPLE) {
elemstr[0] = 1;
@@ -691,8 +691,8 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const
if (nu->bp) {
step = nu->pntsu * nu->pntsv;
- a1 = maxi(a, start);
- a2 = mini(a + step, end);
+ a1 = max_ii(a, start);
+ a2 = min_ii(a + step, end);
if (a1 < a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT);
}
@@ -700,8 +700,8 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const
step = 3 * nu->pntsu;
/* exception because keys prefer to work with complete blocks */
- a1 = maxi(a, start);
- a2 = mini(a + step, end);
+ a1 = max_ii(a, start);
+ a2 = min_ii(a + step, end);
if (a1 < a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE);
}
@@ -1043,7 +1043,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
/* find the group (weak loop-in-loop) */
defgrp_index = defgroup_name_index(ob, vgroup);
- if (defgrp_index >= 0) {
+ if (defgrp_index != -1) {
float *weights;
int i;
@@ -1217,7 +1217,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
remain = step;
}
- count = mini(remain, estep);
+ count = min_ii(remain, estep);
if (mode == KEY_MODE_BEZTRIPLE) {
count += 3 - count % 3;
}
@@ -1268,7 +1268,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
do_key(a, a + 1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(a, a + 1, tot, out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
- }
+ }
}
else {
if (key->type == KEY_RELATIVE) {
@@ -1584,7 +1584,7 @@ void BKE_key_convert_to_lattice(KeyBlock *kb, Lattice *lt)
fp = kb->data;
tot = lt->pntsu * lt->pntsv * lt->pntsw;
- tot = mini(kb->totelem, tot);
+ tot = min_ii(kb->totelem, tot);
for (a = 0; a < tot; a++, fp += 3, bp++) {
copy_v3_v3(bp->vec, fp);
@@ -1656,7 +1656,7 @@ void BKE_key_convert_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
tot = BKE_nurbList_verts_count(nurb);
- tot = mini(kb->totelem, tot);
+ tot = min_ii(kb->totelem, tot);
while (nu && tot > 0) {
@@ -1724,7 +1724,7 @@ void BKE_key_convert_to_mesh(KeyBlock *kb, Mesh *me)
mvert = me->mvert;
fp = kb->data;
- tot = mini(kb->totelem, me->totvert);
+ tot = min_ii(kb->totelem, me->totvert);
for (a = 0; a < tot; a++, fp += 3, mvert++) {
copy_v3_v3(mvert->co, fp);
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 4782d09a7c8..2f37db846f3 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -33,9 +33,12 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_listbase.h"
@@ -73,7 +76,7 @@ Lamp *BKE_lamp_add(const char *name)
la->soft = 3.0f;
la->compressthresh = 0.05f;
la->ray_samp = la->ray_sampy = la->ray_sampz = 1;
- la->area_size = la->area_sizey = la->area_sizez = 1.0f;
+ la->area_size = la->area_sizey = la->area_sizez = 0.1f;
la->buffers = 1;
la->buftype = LA_SHADBUF_HALFWAY;
la->ray_samp_method = LA_SAMP_HALTON;
@@ -232,3 +235,38 @@ void BKE_lamp_free(Lamp *la)
la->id.icon_id = 0;
}
+/* Calculate all drivers for lamps, see material_drivers_update for why this is a bad hack */
+
+static void lamp_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime)
+{
+ bNode *node;
+
+ /* nodetree itself */
+ if (ntree->adt && ntree->adt->drivers.first)
+ BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS);
+
+ /* nodes */
+ for (node = ntree->nodes.first; node; node = node->next)
+ if (node->id && node->type == NODE_GROUP)
+ lamp_node_drivers_update(scene, (bNodeTree *)node->id, ctime);
+}
+
+void lamp_drivers_update(Scene *scene, Lamp *la, float ctime)
+{
+ /* Prevent infinite recursion by checking (and tagging the lamp) as having been visited already
+ * (see BKE_scene_update_tagged()). This assumes la->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017] */
+ if (la->id.flag & LIB_DOIT)
+ return;
+ else
+ la->id.flag |= LIB_DOIT;
+
+ /* lamp itself */
+ if (la->adt && la->adt->drivers.first)
+ BKE_animsys_evaluate_animdata(scene, &la->id, la->adt, ctime, ADT_RECALC_DRIVERS);
+
+ /* nodes */
+ if (la->nodetree)
+ lamp_node_drivers_update(scene, la->nodetree, ctime);
+}
+
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 17e4103c7d3..a15ca7cb5ce 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -64,19 +64,19 @@
#include "BKE_deform.h"
-void calc_lat_fudu(int flag, int res, float *fu, float *du)
+void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
{
if (res == 1) {
- *fu = 0.0;
- *du = 0.0;
+ *r_fu = 0.0;
+ *r_du = 0.0;
}
else if (flag & LT_GRID) {
- *fu = -0.5f * (res - 1);
- *du = 1.0f;
+ *r_fu = -0.5f * (res - 1);
+ *r_du = 1.0f;
}
else {
- *fu = -1.0f;
- *du = 2.0f / (res - 1);
+ *r_fu = -1.0f;
+ *r_du = 2.0f / (res - 1);
}
}
@@ -348,7 +348,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
int ui, vi, wi, uu, vv, ww;
/* vgroup influence */
- int defgroup_nr = -1;
+ int defgrp_index = -1;
float co_prev[3], weight_blend = 0.0f;
MDeformVert *dvert = BKE_lattice_deform_verts_get(ob);
@@ -357,7 +357,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
if (lt->latticedata == NULL) return;
if (lt->vgroup[0] && dvert) {
- defgroup_nr = defgroup_name_index(ob, lt->vgroup);
+ defgrp_index = defgroup_name_index(ob, lt->vgroup);
copy_v3_v3(co_prev, co);
}
@@ -431,8 +431,8 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
madd_v3_v3fl(co, &lt->latticedata[idx_u * 3], u);
- if (defgroup_nr != -1)
- weight_blend += (u * defvert_find_weight(dvert + idx_u, defgroup_nr));
+ if (defgrp_index != -1)
+ weight_blend += (u * defvert_find_weight(dvert + idx_u, defgrp_index));
}
}
}
@@ -440,7 +440,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
}
}
- if (defgroup_nr != -1)
+ if (defgrp_index != -1)
interp_v3_v3v3(co, co_prev, co, weight_blend);
}
@@ -669,9 +669,9 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me = target->data;
- int index = defgroup_name_index(target, vgroup);
+ const int defgrp_index = defgroup_name_index(target, vgroup);
- if (index != -1 && (me->dvert || dm)) {
+ if (defgrp_index != -1 && (me->dvert || dm)) {
MDeformVert *dvert = me->dvert;
float vec[3];
float weight;
@@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
dvert = me->dvert;
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
- weight = defvert_find_weight(dvert, index);
+ weight = defvert_find_weight(dvert, defgrp_index);
if (weight > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
@@ -699,7 +699,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
- if (defvert_find_weight(dvert, index) > 0.0f) {
+ if (defvert_find_weight(dvert, defgrp_index) > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
minmax_v3v3_v3(cd.dmin, cd.dmax, vertexCos[a]);
}
@@ -709,7 +709,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
- weight = defvert_find_weight(dvert, index);
+ weight = defvert_find_weight(dvert, defgrp_index);
if (weight > 0.0f) {
/* already in 'cd.curvespace', prev for loop */
@@ -815,16 +815,16 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me = target->data;
- int index = defgroup_name_index(target, vgroup);
+ const int defgrp_index = defgroup_name_index(target, vgroup);
float weight;
- if (index >= 0 && (me->dvert || dm)) {
+ if (defgrp_index >= 0 && (me->dvert || dm)) {
MDeformVert *dvert = me->dvert;
for (a = 0; a < numVerts; a++, dvert++) {
if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
- weight = defvert_find_weight(dvert, index);
+ weight = defvert_find_weight(dvert, defgrp_index);
if (weight > 0.0f)
calc_latt_deform(laOb, vertexCos[a], weight * fac);
@@ -879,9 +879,10 @@ void outside_lattice(Lattice *lt)
for (v = 0; v < lt->pntsv; v++) {
for (u = 0; u < lt->pntsu; u++, bp++) {
- if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) ;
+ if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) {
+ /* pass */
+ }
else {
-
bp->hide = 1;
bp->f1 &= ~SELECT;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 45364f5aafa..9deff12f124 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -796,6 +796,18 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata
}
}
+void BKE_libblock_free_data(ID *id)
+{
+ Main *bmain = G.main; /* should eventually be an arg */
+
+ if (id->properties) {
+ IDP_FreeProperty(id->properties);
+ MEM_freeN(id->properties);
+ }
+
+ /* this ID may be a driver target! */
+ BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id);
+}
/* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */
void BKE_libblock_free(ListBase *lb, void *idv)
@@ -904,15 +916,9 @@ void BKE_libblock_free(ListBase *lb, void *idv)
break;
}
- if (id->properties) {
- IDP_FreeProperty(id->properties);
- MEM_freeN(id->properties);
- }
-
BLI_remlink(lb, id);
- /* this ID may be a driver target! */
- BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id);
+ BKE_libblock_free_data(id);
MEM_freeN(id);
}
@@ -992,7 +998,6 @@ void free_main(Main *mainvar)
#endif
}
}
- a = set_listbasepointers(mainvar, lbarray);
MEM_freeN(mainvar);
}
@@ -1200,7 +1205,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8];
/* make sure input name is terminated properly */
- /* if ( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3]= 0; */
+ /* if ( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3] = 0; */
/* removed since this is only ever called from one place - campbell */
while (1) {
@@ -1547,7 +1552,7 @@ void rename_id(ID *id, const char *name)
BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
lb = which_libbase(G.main, GS(id->name) );
- new_id(lb, id, name);
+ new_id(lb, id, name);
}
void name_uiprefix_id(char *name, ID *id)
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index aa19350c456..b7f4c4bd61e 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -378,8 +378,8 @@ float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point,
if (len_squared_v2(v1) > proj_eps_squared) {
ang1 = angle_v2v2(v1, n1);
- if (ang1 > M_PI / 2.0f)
- ang1 = M_PI - ang1;
+ if (ang1 > (float)M_PI / 2.0f)
+ ang1 = (float)M_PI - ang1;
if (ang < 0.0f || ang1 < ang) {
ang = ang1;
@@ -405,8 +405,8 @@ float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point,
if (len_squared_v2(v2) > proj_eps_squared) {
ang2 = angle_v2v2(v2, n2);
- if (ang2 > M_PI / 2.0f)
- ang2 = M_PI - ang2;
+ if (ang2 > (float)M_PI / 2.0f)
+ ang2 = (float)M_PI - ang2;
if (ang2 < ang) {
ang = ang2;
@@ -555,7 +555,7 @@ float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, c
if (!bezt_next) {
return bezt->weight;
}
- else if (u <= 0.0) {
+ else if (u <= 0.0f) {
return bezt->weight;
}
else if (u >= 1.0f) {
@@ -576,7 +576,7 @@ float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const fl
if (!bezt_next) {
return bezt->weight;
}
- else if (u <= 0.0) {
+ else if (u <= 0.0f) {
return bezt->weight;
}
else if (u >= 1.0f) {
@@ -1805,7 +1805,7 @@ static void interp_weights_uv_v2_calc(float r_uv[2], const float pt[2], const fl
float pt_on_line[2];
r_uv[0] = closest_to_line_v2(pt_on_line, pt, pt_a, pt_b);
r_uv[1] = (len_v2v2(pt_on_line, pt) / len_v2v2(pt_a, pt_b)) *
- ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0 : 1.0); /* this line only sets the sign */
+ ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0f : 1.0f); /* this line only sets the sign */
}
@@ -1955,5 +1955,5 @@ void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int coun
int BKE_mask_get_duration(Mask *mask)
{
- return maxi(1, mask->efra - mask->sfra);
+ return max_ii(1, mask->efra - mask->sfra);
}
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 4a8601df0b8..7d89678d36f 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -69,7 +69,7 @@ unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int heigh
unsigned int i, resol = 1;
if (width != 0 && height != 0) {
- max_segment = 1.0f / (float)maxi(width, height);
+ max_segment = 1.0f / (float)max_ii(width, height);
}
for (i = 0; i < spline->tot_point; i++) {
@@ -131,7 +131,7 @@ unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, i
if (u_diff > FLT_EPSILON) {
float jump = fabsf(w_diff / u_diff);
- max_jump = MAX2(max_jump, jump);
+ max_jump = max_ff(max_jump, jump);
}
prev_u = point->uw[j].u;
@@ -245,7 +245,7 @@ static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int e
}
else {
bucket->segments = MEM_reallocN(bucket->segments,
- (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments));
+ (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments));
}
bucket->alloc_segment += alloc_delta;
@@ -418,7 +418,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe
max_delta = MAX2(max_delta_x, max_delta_y);
- buckets_per_side = MIN2(512, 0.9f / max_delta);
+ buckets_per_side = min_ii(512, 0.9f / max_delta);
if (buckets_per_side == 0) {
/* happens when some segment fills the whole bounding box across some of dimension */
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 13ad9962aff..88393fab79c 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -104,7 +104,7 @@
/* for debugging add... */
#ifndef NDEBUG
-/* printf("%u %u %u %u\n", _t[0], _t[1], _t[2], _t[3]); \ */
+/* printf("%u %u %u %u\n", _t[0], _t[1], _t[2], _t[3]); \ */
# define FACE_ASSERT(face, vert_max) \
{ \
unsigned int *_t = face; \
@@ -428,7 +428,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
/* width and height of each bucket */
const float bucket_size_x = (bucket_dim_x + FLT_EPSILON) / layer->buckets_x;
const float bucket_size_y = (bucket_dim_y + FLT_EPSILON) / layer->buckets_y;
- const float bucket_max_rad = (maxf(bucket_size_x, bucket_size_y) * M_SQRT2) + FLT_EPSILON;
+ const float bucket_max_rad = (max_ff(bucket_size_x, bucket_size_y) * (float)M_SQRT2) + FLT_EPSILON;
const float bucket_max_rad_squared = bucket_max_rad * bucket_max_rad;
unsigned int *face = &layer->face_array[0][0];
@@ -451,10 +451,10 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
const float *v2 = cos[face[1]];
const float *v3 = cos[face[2]];
- xmin = minf(v1[0], minf(v2[0], v3[0]));
- xmax = maxf(v1[0], maxf(v2[0], v3[0]));
- ymin = minf(v1[1], minf(v2[1], v3[1]));
- ymax = maxf(v1[1], maxf(v2[1], v3[1]));
+ xmin = min_ff(v1[0], min_ff(v2[0], v3[0]));
+ xmax = max_ff(v1[0], max_ff(v2[0], v3[0]));
+ ymin = min_ff(v1[1], min_ff(v2[1], v3[1]));
+ ymax = max_ff(v1[1], max_ff(v2[1], v3[1]));
}
else {
const float *v1 = cos[face[0]];
@@ -462,10 +462,10 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
const float *v3 = cos[face[2]];
const float *v4 = cos[face[3]];
- xmin = minf(v1[0], minf(v2[0], minf(v3[0], v4[0])));
- xmax = maxf(v1[0], maxf(v2[0], maxf(v3[0], v4[0])));
- ymin = minf(v1[1], minf(v2[1], minf(v3[1], v4[1])));
- ymax = maxf(v1[1], maxf(v2[1], maxf(v3[1], v4[1])));
+ xmin = min_ff(v1[0], min_ff(v2[0], min_ff(v3[0], v4[0])));
+ xmax = max_ff(v1[0], max_ff(v2[0], max_ff(v3[0], v4[0])));
+ ymin = min_ff(v1[1], min_ff(v2[1], min_ff(v3[1], v4[1])));
+ ymax = max_ff(v1[1], max_ff(v2[1], max_ff(v3[1], v4[1])));
}
@@ -503,7 +503,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
BLI_assert(bucket_index < bucket_tot);
/* check if the bucket intersects with the face */
- /* note: there is a tradeoff here since checking box/tri intersections isn't
+ /* note: there is a trade off here since checking box/tri intersections isn't
* as optimal as it could be, but checking pixels against faces they will never intersect
* with is likely the greater slowdown here - so check if the cell intersects the face */
if (layer_bucket_isect_test(layer, face_index,
@@ -560,7 +560,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
const short do_feather)
{
const rctf default_bounds = {0.0f, 1.0f, 0.0f, 1.0f};
- const float pixel_size = 1.0f / MIN2(width, height);
+ const float pixel_size = 1.0f / (float)min_ii(width, height);
const float asp_xy[2] = {(do_aspect_correct && width > height) ? (float)height / (float)width : 1.0f,
(do_aspect_correct && width < height) ? (float)width / (float)height : 1.0f};
@@ -1335,10 +1335,10 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
value -= value_layer;
break;
case MASK_BLEND_LIGHTEN:
- value = maxf(value, value_layer);
+ value = max_ff(value, value_layer);
break;
case MASK_BLEND_DARKEN:
- value = minf(value, value_layer);
+ value = min_ff(value, value_layer);
break;
case MASK_BLEND_MUL:
value *= value_layer;
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index bea0e33da9a..ea317956255 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -38,6 +38,7 @@
#include "DNA_anim_types.h"
#include "DNA_curve_types.h"
+#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -214,7 +215,7 @@ Material *BKE_material_add(const char *name)
init_material(ma);
- return ma;
+ return ma;
}
/* XXX keep synced with next function */
@@ -903,7 +904,7 @@ short find_material_index(Object *ob, Material *ma)
break;
if (a < *totcolp)
return a + 1;
- return 0;
+ return 0;
}
int object_add_material_slot(Object *ob)
@@ -969,7 +970,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
ma->ambr = ma->amb * amb[0];
ma->ambg = ma->amb * amb[1];
ma->ambb = ma->amb * amb[2];
- }
+ }
/* will become or-ed result of all node modes */
ma->mode_l = ma->mode;
ma->mode_l &= ~MA_SHLESS;
@@ -980,6 +981,17 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
/* parses the geom+tex nodes */
if (ma->nodetree && ma->use_nodes)
ntreeShaderGetTexcoMode(ma->nodetree, r_mode, &ma->texco, &ma->mode_l);
+
+ /* local group override */
+ if ((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) {
+ Group *group;
+
+ for (group = G.main->group.first; group; group = group->id.next) {
+ if (!group->id.lib && strcmp(group->id.name, ma->group->id.name) == 0) {
+ ma->group = group;
+ }
+ }
+ }
}
static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode, float *amb)
@@ -1147,7 +1159,7 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
/* ****************** */
#if 0 /* UNUSED */
-static char colname_array[125][20]= {
+static char colname_array[125][20] = {
"Black", "DarkRed", "HalfRed", "Red", "Red",
"DarkGreen", "DarkOlive", "Brown", "Chocolate", "OrangeRed",
"HalfGreen", "GreenOlive", "DryOlive", "Goldenrod", "DarkOrange",
@@ -1603,7 +1615,7 @@ static int encode_tfaceflag(MTFace *tf, int convertall)
/* calculate the flag */
int flag = tf->mode;
- /* options that change the material offline render */
+ /* options that change the material offline render */
if (!convertall) {
flag &= ~TF_OBCOL;
}
@@ -1627,7 +1639,7 @@ static int encode_tfaceflag(MTFace *tf, int convertall)
/* set the material options based in the tface flag */
static void decode_tfaceflag(Material *ma, int flag, int convertall)
{
- int alphablend;
+ int alphablend;
GameSettings *game = &ma->game;
/* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */
@@ -1786,13 +1798,13 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag)
* for now store the flag into the material and change light/tex/collision
* store the flag as a negative number */
ma->game.flag = -flag;
- id_us_min((ID *)ma);
+ id_us_min((ID *)ma);
}
else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname + 2, me->id.name + 2);
}
/* set as converted, no need to go bad to this face */
- tf->mode |= TF_CONVERTED;
+ tf->mode |= TF_CONVERTED;
return mat_nr;
}
@@ -1845,7 +1857,7 @@ static void convert_tfacematerial(Main *main, Material *ma)
if (mat_new) {
/* rename the material*/
strcpy(mat_new->id.name, idname);
- id_us_min((ID *)mat_new);
+ id_us_min((ID *)mat_new);
mat_nr = mesh_addmaterial(me, mat_new);
decode_tfaceflag(mat_new, flag, 1);
@@ -2033,7 +2045,7 @@ int do_version_tface(Main *main, int fileload)
nowarning = 0;
}
else
- convert_tfacematerial(main, ma); continue;
+ convert_tfacematerial(main, ma); continue;
}
/* no conflicts in this material - 90% of cases
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 9eea075c97a..759e858cc62 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -1319,12 +1319,16 @@ static void addtovertices(VERTICES *vertices, VERTEX v)
static void vnormal(const float point[3], PROCESS *p, float r_no[3])
{
- float delta = 0.2f * p->delta;
- float f = p->function(point[0], point[1], point[2]);
+ const float delta = 0.2f * p->delta;
+ const float f = p->function(point[0], point[1], point[2]);
r_no[0] = p->function(point[0] + delta, point[1], point[2]) - f;
r_no[1] = p->function(point[0], point[1] + delta, point[2]) - f;
r_no[2] = p->function(point[0], point[1], point[2] + delta) - f;
+
+#if 1
+ normalize_v3(r_no);
+#else
f = normalize_v3(r_no);
if (0) {
@@ -1343,6 +1347,7 @@ static void vnormal(const float point[3], PROCESS *p, float r_no[3])
normalize_v3(r_no);
}
}
+#endif
}
@@ -1500,7 +1505,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
float f = 0.0f;
ml = G_mb.mainb[a];
- f = 1.0 - (mb->thresh / ml->s);
+ f = 1.0f - (mb->thresh / ml->s);
/* Skip, when Stiffness of MetaElement is too small ... MetaElement can't be
* visible alone ... but still can influence others MetaElements :-) */
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 1aaeebf5109..068059dc29a 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -469,15 +469,17 @@ void free_dverts(MDeformVert *dvert, int totvert)
static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
{
- if (free_customdata)
+ if (free_customdata) {
CustomData_free(&mesh->fdata, mesh->totface);
+ }
+ else {
+ CustomData_reset(&mesh->fdata);
+ }
mesh->mface = NULL;
mesh->mtface = NULL;
mesh->mcol = NULL;
mesh->totface = 0;
-
- memset(&mesh->fdata, 0, sizeof(mesh->fdata));
}
Mesh *BKE_mesh_add(const char *name)
@@ -491,7 +493,13 @@ Mesh *BKE_mesh_add(const char *name)
me->texflag = ME_AUTOSPACE;
me->flag = ME_TWOSIDED;
me->drawflag = ME_DRAWEDGES | ME_DRAWFACES | ME_DRAWCREASES;
-
+
+ CustomData_reset(&me->vdata);
+ CustomData_reset(&me->edata);
+ CustomData_reset(&me->fdata);
+ CustomData_reset(&me->pdata);
+ CustomData_reset(&me->ldata);
+
return me;
}
@@ -576,7 +584,7 @@ static void expand_local_mesh(Mesh *me)
for (i = 0; i < me->pdata.totlayer; i++) {
if (me->pdata.layers[i].type == CD_MTEXPOLY) {
- MTexPoly *txface = (MTexPoly *)me->fdata.layers[i].data;
+ MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
for (a = 0; a < me->totpoly; a++, txface++) {
/* special case: ima always local immediately */
@@ -735,7 +743,7 @@ float *BKE_mesh_orco_verts_get(Object *ob)
/* Get appropriate vertex coordinates */
vcos = MEM_callocN(sizeof(*vcos) * me->totvert, "orco mesh");
mvert = tme->mvert;
- totvert = MIN2(tme->totvert, me->totvert);
+ totvert = min_ii(tme->totvert, me->totvert);
for (a = 0; a < totvert; a++, mvert++) {
copy_v3_v3(vcos[a], mvert->co);
@@ -2039,7 +2047,7 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
MDisps *ld = CustomData_get(ldata, loopstart, CD_MDISPS);
MDisps *fd = CustomData_get(fdata, findex, CD_MDISPS);
float (*disps)[3] = fd->disps;
- int i, tot = mf->v4 ? 4 : 3;
+ int tot = mf->v4 ? 4 : 3;
int side, corners;
if (CustomData_external_test(fdata, CD_MDISPS)) {
@@ -2125,8 +2133,6 @@ void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData
/* just in case some of these layers are filled in (can happen with python created meshes) */
CustomData_free(ldata, totloop_i);
CustomData_free(pdata, totpoly_i);
- memset(ldata, 0, sizeof(*ldata));
- memset(pdata, 0, sizeof(*pdata));
totpoly = totface_i;
mpoly = MEM_callocN(sizeof(MPoly) * totpoly, "mpoly converted");
@@ -2163,7 +2169,7 @@ void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData
me->flag &= ~ME_FGON;
}
- polyindex = CustomData_get_layer(fdata, CD_POLYINDEX);
+ polyindex = CustomData_get_layer(fdata, CD_ORIGINDEX);
j = 0; /* current loop index */
ml = mloop;
@@ -2382,7 +2388,7 @@ void create_vert_poly_map(MeshElemMap **map, int **mem,
* of edges that use that vertex as an endpoint. The lists are allocated
* from one memory pool. */
void create_vert_edge_map(MeshElemMap **map, int **mem,
- const MEdge *medge, int totvert, int totedge)
+ const MEdge *medge, int totvert, int totedge)
{
int i, *indices;
@@ -2505,12 +2511,9 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
ScanFillContext sf_ctx;
ScanFillVert *sf_vert, *sf_vert_last, *sf_vert_first;
ScanFillFace *sf_tri;
- int *mface_orig_index = NULL;
- BLI_array_declare(mface_orig_index);
int *mface_to_poly_map = NULL;
BLI_array_declare(mface_to_poly_map);
int lindex[4]; /* only ever use 3 in this case */
- int *poly_orig_index;
int poly_index, j, mface_index;
const int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
@@ -2528,7 +2531,6 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
mface_index = 0;
mp = mpoly;
- poly_orig_index = CustomData_get_layer(pdata, CD_ORIGINDEX);
for (poly_index = 0; poly_index < totpoly; poly_index++, mp++) {
if (mp->totloop < 3) {
/* do nothing */
@@ -2548,10 +2550,6 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
mf->v4 = 0; \
mf->mat_nr = mp->mat_nr; \
mf->flag = mp->flag; \
- if (poly_orig_index) { \
- BLI_array_append(mface_orig_index, \
- poly_orig_index[poly_index]); \
- } \
(void)0
/* ALMOST IDENTICAL TO DEFINE ABOVE (see EXCEPTION) */
@@ -2567,10 +2565,6 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
mf->v4 = mp->loopstart + 3; /* EXCEPTION */ \
mf->mat_nr = mp->mat_nr; \
mf->flag = mp->flag; \
- if (poly_orig_index) { \
- BLI_array_append(mface_orig_index, \
- poly_orig_index[poly_index]); \
- } \
mf->edcode |= TESSFACE_IS_QUAD; /* EXCEPTION */ \
(void)0
@@ -2617,9 +2611,6 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
if (totfilltri) {
BLI_array_grow_items(mface_to_poly_map, totfilltri);
BLI_array_grow_items(mface, totfilltri);
- if (poly_orig_index) {
- BLI_array_grow_items(mface_orig_index, totfilltri);
- }
for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next, mf++) {
mface_to_poly_map[mface_index] = poly_index;
@@ -2638,10 +2629,6 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
mf->edcode |= TESSFACE_SCANFILL; /* tag for sorting loop indices */
#endif
- if (poly_orig_index) {
- mface_orig_index[mface_index] = poly_orig_index[poly_index];
- }
-
mface_index++;
}
}
@@ -2651,7 +2638,6 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
}
CustomData_free(fdata, totface);
- memset(fdata, 0, sizeof(CustomData));
totface = mface_index;
@@ -2659,23 +2645,13 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
if (LIKELY((MEM_allocN_len(mface) / sizeof(*mface)) != totface)) {
mface = MEM_reallocN(mface, sizeof(*mface) * totface);
mface_to_poly_map = MEM_reallocN(mface_to_poly_map, sizeof(*mface_to_poly_map) * totface);
- if (mface_orig_index) {
- mface_orig_index = MEM_reallocN(mface_orig_index, sizeof(*mface_orig_index) * totface);
- }
}
CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface);
- /* CD_POLYINDEX will contain an array of indices from tessfaces to the polygons
+ /* CD_ORIGINDEX will contain an array of indices from tessfaces to the polygons
* they are directly tessellated from */
- CustomData_add_layer(fdata, CD_POLYINDEX, CD_ASSIGN, mface_to_poly_map, totface);
- if (mface_orig_index) {
- /* If polys had a CD_ORIGINDEX layer, then the tessellated faces will get this
- * layer as well, pointing to polys from the original mesh (not the polys
- * that just got tessellated) */
- CustomData_add_layer(fdata, CD_ORIGINDEX, CD_ASSIGN, mface_orig_index, totface);
- }
-
+ CustomData_add_layer(fdata, CD_ORIGINDEX, CD_ASSIGN, mface_to_poly_map, totface);
CustomData_from_bmeshpoly(fdata, pdata, ldata, totface);
if (do_face_nor_cpy) {
@@ -2806,7 +2782,6 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
}
CustomData_free(fdata, totface);
- memset(fdata, 0, sizeof(CustomData));
totface = k;
@@ -3175,6 +3150,32 @@ int BKE_mesh_center_bounds(Mesh *me, float cent[3])
return 0;
}
+int BKE_mesh_center_centroid(Mesh *me, float cent[3])
+{
+ int i = me->totpoly;
+ MPoly *mpoly;
+ float poly_area;
+ float total_area = 0.0f;
+ float poly_cent[3];
+
+ zero_v3(cent);
+
+ /* calculate a weighted average of polygon centroids */
+ for (mpoly = me->mpoly; i--; mpoly++) {
+ BKE_mesh_calc_poly_center(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent);
+ poly_area = BKE_mesh_calc_poly_area(mpoly, me->mloop + mpoly->loopstart, me->mvert, NULL);
+
+ madd_v3_v3fl(cent, poly_cent, poly_area);
+ total_area += poly_area;
+ }
+ /* otherwise we get NAN for 0 polys */
+ if (me->totpoly) {
+ mul_v3_fl(cent, 1.0f / total_area);
+ }
+
+ return (me->totpoly != 0);
+}
+
void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys)
{
int i = me->totvert;
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 79e3fc19d20..128b9ae242e 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -228,7 +228,6 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
}
for (i = 1; i < totvert; i++, mv++) {
- int j;
int fix_normal = TRUE;
for (j = 0; j < 3; j++) {
@@ -717,7 +716,6 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
MDeformVert *dv;
for (i = 0, dv = dverts; i < totvert; i++, dv++) {
MDeformWeight *dw;
- unsigned int j;
for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
/* note, greater then max defgroups is accounted for in our code, but not < 0 */
@@ -914,7 +912,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
{
CustomData edata;
EdgeHashIterator *ehi;
- MPoly *mp = mesh->mpoly;
+ MPoly *mp;
MEdge *med, *med_orig;
EdgeHash *eh = BLI_edgehash_new();
int i, totedge, totpoly = mesh->totpoly;
@@ -932,7 +930,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
}
/* mesh loops (bmesh only) */
- for (i = 0; i < totpoly; i++, mp++) {
+ for (mp = mesh->mpoly, i = 0; i < totpoly; mp++, i++) {
MLoop *l = &mesh->mloop[mp->loopstart];
int j, l_prev = (l + (mp->totloop - 1))->v;
for (j = 0; j < mp->totloop; j++, l++) {
@@ -946,7 +944,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
totedge = BLI_edgehash_size(eh);
/* write new edges into a temporary CustomData */
- memset(&edata, 0, sizeof(edata));
+ CustomData_reset(&edata);
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
med = CustomData_get_layer(&edata, CD_MEDGE);
@@ -970,8 +968,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
if (mesh->totpoly) {
/* second pass, iterate through all loops again and assign
* the newly created edges to them. */
- MPoly *mp = mesh->mpoly;
- for (i = 0; i < mesh->totpoly; i++, mp++) {
+ for (mp = mesh->mpoly, i = 0; i < mesh->totpoly; mp++, i++) {
MLoop *l = &mesh->mloop[mp->loopstart];
MLoop *l_prev = (l + (mp->totloop - 1));
int j;
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 28de80a7157..9c7cbc42bdd 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -55,6 +55,8 @@
#include "BLI_linklist.h"
#include "BLI_string.h"
+#include "BLF_translation.h"
+
#include "BKE_cloth.h"
#include "BKE_key.h"
#include "BKE_multires.h"
@@ -259,12 +261,13 @@ int modifier_nonGeometrical(ModifierData *md)
return (mti->type == eModifierTypeType_NonGeometrical);
}
-void modifier_setError(ModifierData *md, const char *format, ...)
+void modifier_setError(ModifierData *md, const char *_format, ...)
{
char buffer[512];
va_list ap;
+ const char *format = TIP_(_format);
- va_start(ap, format);
+ va_start(ap, _format);
vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
buffer[sizeof(buffer) - 1] = '\0';
@@ -494,8 +497,8 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
return md;
}
-/* Takes an object and returns its first selected armature, else just its
- * armature
+
+/* Takes an object and returns its first selected armature, else just its armature
* This should work for multiple armatures per object
*/
Object *modifiers_isDeformedByArmature(Object *ob)
@@ -518,9 +521,8 @@ Object *modifiers_isDeformedByArmature(Object *ob)
return NULL;
}
-/* Takes an object and returns its first selected lattice, else just its
- * lattice
- * This should work for multiple lattics per object
+/* Takes an object and returns its first selected lattice, else just its lattice
+ * This should work for multiple lattices per object
*/
Object *modifiers_isDeformedByLattice(Object *ob)
{
@@ -542,7 +544,28 @@ Object *modifiers_isDeformedByLattice(Object *ob)
return NULL;
}
-
+/* Takes an object and returns its first selected curve, else just its curve
+ * This should work for multiple curves per object
+ */
+Object *modifiers_isDeformedByCurve(Object *ob)
+{
+ ModifierData *md = modifiers_getVirtualModifierList(ob);
+ CurveModifierData *cmd = NULL;
+
+ /* return the first selected curve, this lets us use multiple curves */
+ for (; md; md = md->next) {
+ if (md->type == eModifierType_Curve) {
+ cmd = (CurveModifierData *) md;
+ if (cmd->object && (cmd->object->flag & SELECT))
+ return cmd->object;
+ }
+ }
+
+ if (cmd) /* if were still here then return the last curve */
+ return cmd->object;
+
+ return NULL;
+}
int modifiers_usesArmature(Object *ob, bArmature *arm)
{
@@ -574,10 +597,12 @@ int modifiers_isCorrectableDeformed(Object *ob)
ModifierData *md = modifiers_getVirtualModifierList(ob);
for (; md; md = md->next) {
- if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) ;
- else
- if (modifier_isCorrectableDeformed(md))
+ if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) {
+ /* pass */
+ }
+ else if (modifier_isCorrectableDeformed(md)) {
return 1;
+ }
}
return 0;
}
diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c
index dc3d4a89e62..98eac9b95af 100644
--- a/source/blender/blenkernel/intern/modifiers_bmesh.c
+++ b/source/blender/blenkernel/intern/modifiers_bmesh.c
@@ -55,6 +55,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BLI_array_declare(verts);
BLI_array_declare(edges);
int i, j, k, totvert, totedge /* , totface */ /* UNUSED */ ;
+ int is_init = (bm->totvert == 0) && (bm->totedge == 0) && (bm->totface == 0);
/*merge custom data layout*/
CustomData_bmesh_merge(&dm->vertData, &bm->vdata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_VERT);
@@ -81,6 +82,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
v = BM_vert_create(bm, mv->co, NULL);
normal_short_to_float_v3(v->no, mv->no);
v->head.hflag = BM_vert_flag_from_mflag(mv->flag);
+ BM_elem_index_set(v, i); /* set_inline */
CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v->head.data);
@@ -89,13 +91,16 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
vtable[i] = v;
}
MEM_freeN(mvert);
+ if (is_init) bm->elem_index_dirty &= ~BM_VERT;
/*do edges*/
me = medge = dm->dupEdgeArray(dm);
for (i = 0; i < totedge; i++, me++) {
+ //BLI_assert(BM_edge_exists(vtable[me->v1], vtable[me->v2]) == NULL);
e = BM_edge_create(bm, vtable[me->v1], vtable[me->v2], NULL, FALSE);
e->head.hflag = BM_edge_flag_from_mflag(me->flag);
+ BM_elem_index_set(e, i); /* set_inline */
CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->head.data);
etable[i] = e;
@@ -106,8 +111,10 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BM_elem_float_data_set(&bm->edata, e, CD_BWEIGHT, (float)me->bweight / 255.0f);
}
MEM_freeN(medge);
+ if (is_init) bm->elem_index_dirty &= ~BM_EDGE;
- /*do faces*/
+ /* do faces */
+ /* note: i_alt is aligned with bmesh faces which may not always align with mpolys */
mp = dm->getPolyArray(dm);
mloop = dm->getLoopArray(dm);
face_normals = CustomData_get_layer(&dm->polyData, CD_NORMAL); /* can be NULL */
@@ -134,6 +141,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
}
f->head.hflag = BM_face_flag_from_mflag(mp->flag);
+ BM_elem_index_set(f, bm->totface - 1); /* set_inline */
f->mat_nr = mp->mat_nr;
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
@@ -151,6 +159,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BM_face_normal_update(f);
}
}
+ if (is_init) bm->elem_index_dirty &= ~BM_FACE;
MEM_freeN(vtable);
MEM_freeN(etable);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 0aa1f9e0822..4156b5b4367 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -520,6 +520,24 @@ static void movieclip_load_get_szie(MovieClip *clip)
}
}
+static void detect_clip_source(MovieClip *clip)
+{
+ ImBuf *ibuf;
+ char name[FILE_MAX];
+
+ BLI_strncpy(name, clip->name, sizeof(name));
+ BLI_path_abs(name, G.main->name);
+
+ ibuf = IMB_testiffname(name, IB_rect | IB_multilayer);
+ if (ibuf) {
+ clip->source = MCLIP_SRC_SEQUENCE;
+ IMB_freeImBuf(ibuf);
+ }
+ else {
+ clip->source = MCLIP_SRC_MOVIE;
+ }
+}
+
/* checks if image was already loaded, then returns same image
* otherwise creates new.
* does not load ibuf itself
@@ -565,10 +583,7 @@ MovieClip *BKE_movieclip_file_add(const char *name)
clip = movieclip_alloc(libname);
BLI_strncpy(clip->name, name, sizeof(clip->name));
- if (BLI_testextensie_array(name, imb_ext_movie))
- clip->source = MCLIP_SRC_MOVIE;
- else
- clip->source = MCLIP_SRC_SEQUENCE;
+ detect_clip_source(clip);
movieclip_load_get_szie(clip);
if (clip->lastsize[0]) {
@@ -616,11 +631,6 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip, struct MovieDistortion *dist
else
undistibuf = BKE_tracking_undistort_frame(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
- if (undistibuf->userflags & IB_RECT_INVALID) {
- ibuf->userflags &= ~IB_RECT_INVALID;
- IMB_rect_from_float(undistibuf);
- }
-
IMB_scaleImBuf(undistibuf, ibuf->x, ibuf->y);
return undistibuf;
@@ -1087,15 +1097,24 @@ void BKE_movieclip_reload(MovieClip *clip)
clip->tracking.stabilization.ok = FALSE;
/* update clip source */
- if (BLI_testextensie_array(clip->name, imb_ext_movie))
- clip->source = MCLIP_SRC_MOVIE;
- else
- clip->source = MCLIP_SRC_SEQUENCE;
+ detect_clip_source(clip);
clip->lastsize[0] = clip->lastsize[1] = 0;
movieclip_load_get_szie(clip);
movieclip_calc_length(clip);
+
+ /* same as for image update -- don't use notifiers because they are not 100% sure to succeeded
+ * (node trees which are not currently visible wouldn't be refreshed)
+ */
+ {
+ Scene *scene;
+ for (scene = G.main->scene.first; scene; scene = scene->id.next) {
+ if (scene->nodetree) {
+ nodeUpdateID(scene->nodetree, &clip->id);
+ }
+ }
+ }
}
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
@@ -1157,13 +1176,16 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, TRUE, TRUE);
- if (!search_ibuf->rect_float) {
- /* sampling happens in float buffer */
- IMB_float_from_rect(search_ibuf);
+ if (search_ibuf) {
+ if (!search_ibuf->rect_float) {
+ /* sampling happens in float buffer */
+ IMB_float_from_rect(search_ibuf);
+ }
+
+ scopes->track_search = search_ibuf;
}
scopes->undist_marker = undist_marker;
- scopes->track_search = search_ibuf;
scopes->frame_width = ibuf->x;
scopes->frame_height = ibuf->y;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 591524e5156..c737dccc5d2 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -984,7 +984,7 @@ static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *gri
/* Construct 3x3 tangent-space matrix in 'mat' */
static void grid_tangent_matrix(float mat[3][3], const CCGKey *key,
- int x, int y, CCGElem *grid)
+ int x, int y, CCGElem *grid)
{
grid_tangent(key, x, y, 0, grid, mat[0]);
normalize_v3(mat[0]);
@@ -1045,7 +1045,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
k = 0; /*current loop/mdisp index within the mloop array*/
- #pragma omp parallel for private(i) if (totloop*gridSize*gridSize >= CCG_OMP_LIMIT)
+ #pragma omp parallel for private(i) if (totloop * gridSize * gridSize >= CCG_OMP_LIMIT)
for (i = 0; i < totpoly; ++i) {
const int numVerts = mpoly[i].totloop;
@@ -1161,7 +1161,6 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
int totlvl = ccgdm->multires.totlvl;
if (lvl < totlvl) {
- Mesh *me = ob->data;
DerivedMesh *lowdm, *cddm, *highdm;
CCGElem **highGridData, **lowGridData, **subGridData, **gridData, *diffGrid;
CCGKey highGridKey, lowGridKey;
@@ -1326,7 +1325,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
k = 0; /*current loop/mdisp index within the mloop array*/
- //#pragma omp parallel for private(i) if (dm->numLoopData*gridSize*gridSize >= CCG_OMP_LIMIT)
+ //#pragma omp parallel for private(i) if (dm->numLoopData * gridSize * gridSize >= CCG_OMP_LIMIT)
for (i = 0; i < dm->numPolyData; ++i) {
const int numVerts = mpoly[i].totloop;
@@ -1631,7 +1630,7 @@ void multires_free(Multires *mr)
}
while (lvl) {
- multires_free_level(lvl);
+ multires_free_level(lvl);
lvl = lvl->next;
}
@@ -2086,8 +2085,8 @@ void multires_load_old(Object *ob, Mesh *me)
CustomData_add_layer(&me->vdata, l->type, CD_REFERENCE, l->data, me->totvert);
for (i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; ++i, ++l)
CustomData_add_layer(&me->fdata, l->type, CD_REFERENCE, l->data, me->totface);
- memset(&me->mr->vdata, 0, sizeof(CustomData));
- memset(&me->mr->fdata, 0, sizeof(CustomData));
+ CustomData_reset(&me->mr->vdata);
+ CustomData_reset(&me->mr->fdata);
multires_load_old_vcols(me);
multires_load_old_face_flags(me);
@@ -2201,7 +2200,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
dGridSize = multires_side_tot[high_mmd.totlvl];
dSkip = (dGridSize - 1) / (gridSize - 1);
- #pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT)
+ #pragma omp parallel for private(i) if (me->totface * gridSize * gridSize * 4 >= CCG_OMP_LIMIT)
for (i = 0; i < me->totpoly; ++i) {
const int numVerts = mpoly[i].totloop;
MDisps *mdisp = &mdisps[mpoly[i].loopstart];
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
index a21878d1d7d..3bf5f863557 100644
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ b/source/blender/blenkernel/intern/navmesh_conversion.c
@@ -36,44 +36,44 @@
#include "DNA_meshdata_types.h"
-#include "BKE_navmesh_conversion.h"
-#include "BKE_cdderivedmesh.h"
-
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BKE_navmesh_conversion.h"
+#include "BKE_cdderivedmesh.h"
+
#include "recast-capi.h"
-BLI_INLINE float area2(const float* a, const float* b, const float* c)
+BLI_INLINE float area2(const float *a, const float *b, const float *c)
{
return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);
}
-BLI_INLINE int left(const float* a, const float* b, const float* c)
+BLI_INLINE int left(const float *a, const float *b, const float *c)
{
return area2(a, b, c) < 0;
}
-int polyNumVerts(const unsigned short* p, const int vertsPerPoly)
+int polyNumVerts(const unsigned short *p, const int vertsPerPoly)
{
int i, nv = 0;
- for (i=0; i<vertsPerPoly; i++) {
- if (p[i]==0xffff)
+ for (i = 0; i < vertsPerPoly; i++) {
+ if (p[i] == 0xffff)
break;
nv++;
}
return nv;
}
-int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* verts)
+int polyIsConvex(const unsigned short *p, const int vertsPerPoly, const float *verts)
{
int j, nv = polyNumVerts(p, vertsPerPoly);
- if (nv<3)
+ if (nv < 3)
return 0;
- for (j=0; j<nv; j++) {
- const float* v = &verts[3*p[j]];
- const float* v_next = &verts[3*p[(j+1)%nv]];
- const float* v_prev = &verts[3*p[(nv+j-1)%nv]];
+ for (j = 0; j < nv; j++) {
+ const float *v = &verts[3 * p[j]];
+ const float *v_next = &verts[3 * p[(j + 1) % nv]];
+ const float *v_prev = &verts[3 * p[(nv + j - 1) % nv]];
if (!left(v_prev, v, v_next))
return 0;
@@ -81,7 +81,8 @@ int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* v
return 1;
}
-float distPointToSegmentSq(const float* point, const float* a, const float* b)
+/* XXX, could replace with #dist_to_line_segment_v3(), or add a squared version */
+float distPointToSegmentSq(const float point[3], const float a[3], const float b[3])
{
float abx[3], dx[3];
float d, t;
@@ -89,24 +90,24 @@ float distPointToSegmentSq(const float* point, const float* a, const float* b)
sub_v3_v3v3(abx, b, a);
sub_v3_v3v3(dx, point, a);
- d = abx[0]*abx[0]+abx[2]*abx[2];
- t = abx[0]*dx[0]+abx[2]*dx[2];
+ d = abx[0] * abx[0] + abx[2] * abx[2];
+ t = abx[0] * dx[0] + abx[2] * dx[2];
- if (d > 0)
+ if (d > 0.0f)
t /= d;
- if (t < 0)
- t = 0;
- else if (t > 1)
- t = 1;
- dx[0] = a[0] + t*abx[0] - point[0];
- dx[2] = a[2] + t*abx[2] - point[2];
-
- return dx[0]*dx[0] + dx[2]*dx[2];
+ if (t < 0.0f)
+ t = 0.0f;
+ else if (t > 1.0f)
+ t = 1.0f;
+ dx[0] = a[0] + t * abx[0] - point[0];
+ dx[2] = a[2] + t * abx[2] - point[2];
+
+ return dx[0] * dx[0] + dx[2] * dx[2];
}
-int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
- int *ntris_r, unsigned short **tris_r, int **trisToFacesMap_r,
- int **recastData)
+int buildRawVertIndicesData(DerivedMesh *dm, int *nverts_r, float **verts_r,
+ int *ntris_r, unsigned short **tris_r, int **trisToFacesMap_r,
+ int **recastData)
{
int vi, fi, triIdx;
int nverts, ntris;
@@ -117,49 +118,49 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
MFace *faces;
nverts = dm->getNumVerts(dm);
- if (nverts>=0xffff) {
+ if (nverts >= 0xffff) {
printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
return 0;
}
- verts = MEM_callocN(sizeof(float)*3*nverts, "buildRawVertIndicesData verts");
+ verts = MEM_callocN(sizeof(float) * 3 * nverts, "buildRawVertIndicesData verts");
dm->getVertCos(dm, (float(*)[3])verts);
- //flip coordinates
- for (vi=0; vi<nverts; vi++) {
- SWAP(float, verts[3*vi+1], verts[3*vi+2]);
+ /* flip coordinates */
+ for (vi = 0; vi < nverts; vi++) {
+ SWAP(float, verts[3 * vi + 1], verts[3 * vi + 2]);
}
- //calculate number of tris
+ /* calculate number of tris */
nfaces = dm->getNumTessFaces(dm);
faces = dm->getTessFaceArray(dm);
ntris = nfaces;
- for (fi=0; fi<nfaces; fi++) {
- MFace* face = &faces[fi];
+ for (fi = 0; fi < nfaces; fi++) {
+ MFace *face = &faces[fi];
if (face->v4)
ntris++;
}
- //copy and transform to triangles (reorder on the run)
- trisToFacesMap = MEM_callocN(sizeof(int)*ntris, "buildRawVertIndicesData trisToFacesMap");
- tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris");
+ /* copy and transform to triangles (reorder on the run) */
+ trisToFacesMap = MEM_callocN(sizeof(int) * ntris, "buildRawVertIndicesData trisToFacesMap");
+ tris = MEM_callocN(sizeof(unsigned short) * 3 * ntris, "buildRawVertIndicesData tris");
tri = tris;
triIdx = 0;
- for (fi=0; fi<nfaces; fi++) {
- MFace* face = &faces[fi];
- tri[3*triIdx+0] = (unsigned short) face->v1;
- tri[3*triIdx+1] = (unsigned short) face->v3;
- tri[3*triIdx+2] = (unsigned short) face->v2;
- trisToFacesMap[triIdx++]=fi;
+ for (fi = 0; fi < nfaces; fi++) {
+ MFace *face = &faces[fi];
+ tri[3 * triIdx + 0] = (unsigned short) face->v1;
+ tri[3 * triIdx + 1] = (unsigned short) face->v3;
+ tri[3 * triIdx + 2] = (unsigned short) face->v2;
+ trisToFacesMap[triIdx++] = fi;
if (face->v4) {
- tri[3*triIdx+0] = (unsigned short) face->v1;
- tri[3*triIdx+1] = (unsigned short) face->v4;
- tri[3*triIdx+2] = (unsigned short) face->v3;
- trisToFacesMap[triIdx++]=fi;
+ tri[3 * triIdx + 0] = (unsigned short) face->v1;
+ tri[3 * triIdx + 1] = (unsigned short) face->v4;
+ tri[3 * triIdx + 2] = (unsigned short) face->v3;
+ trisToFacesMap[triIdx++] = fi;
}
}
- //carefully, recast data is just reference to data in derived mesh
- *recastData = (int*)CustomData_get_layer(&dm->polyData, CD_RECAST);
+ /* carefully, recast data is just reference to data in derived mesh */
+ *recastData = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST);
*nverts_r = nverts;
*verts_r = verts;
@@ -170,122 +171,122 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
return 1;
}
-int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
- unsigned short* polys, const unsigned short* dmeshes,
- const float* verts, const unsigned short* dtris,
- const int* dtrisToPolysMap)
+int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
+ unsigned short *polys, const unsigned short *dmeshes,
+ const float *verts, const unsigned short *dtris,
+ const int *dtrisToPolysMap)
{
int polyidx;
int capacity = vertsPerPoly;
- unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly");
- memset(newPoly, 0xff, sizeof(unsigned short)*capacity);
+ unsigned short *newPoly = MEM_callocN(sizeof(unsigned short) * capacity, "buildPolygonsByDetailedMeshes newPoly");
+ memset(newPoly, 0xff, sizeof(unsigned short) * capacity);
- for (polyidx=0; polyidx<npolys; polyidx++) {
+ for (polyidx = 0; polyidx < npolys; polyidx++) {
size_t i;
int j, k;
int nv = 0;
- //search border
+ /* search border */
int tri, btri = -1;
int edge, bedge = -1;
- int dtrisNum = dmeshes[polyidx*4+3];
- int dtrisBase = dmeshes[polyidx*4+2];
- unsigned char *traversedTris = MEM_callocN(sizeof(unsigned char)*dtrisNum, "buildPolygonsByDetailedMeshes traversedTris");
- unsigned short* adjustedPoly;
+ int dtrisNum = dmeshes[polyidx * 4 + 3];
+ int dtrisBase = dmeshes[polyidx * 4 + 2];
+ unsigned char *traversedTris = MEM_callocN(sizeof(unsigned char) * dtrisNum, "buildPolygonsByDetailedMeshes traversedTris");
+ unsigned short *adjustedPoly;
int adjustedNv;
int allBorderTraversed;
- for (j=0; j<dtrisNum && btri==-1;j++) {
- int curpolytri = dtrisBase+j;
- for (k=0; k<3; k++) {
- unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
- if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
+ for (j = 0; j < dtrisNum && btri == -1; j++) {
+ int curpolytri = dtrisBase + j;
+ for (k = 0; k < 3; k++) {
+ unsigned short neighbortri = dtris[curpolytri * 3 * 2 + 3 + k];
+ if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
btri = curpolytri;
bedge = k;
break;
}
- }
+ }
}
- if (btri==-1 || bedge==-1) {
- //can't find triangle with border edge
+ if (btri == -1 || bedge == -1) {
+ /* can't find triangle with border edge */
MEM_freeN(traversedTris);
MEM_freeN(newPoly);
return 0;
}
- newPoly[nv++] = dtris[btri*3*2+bedge];
+ newPoly[nv++] = dtris[btri * 3 * 2 + bedge];
tri = btri;
- edge = (bedge+1)%3;
- traversedTris[tri-dtrisBase] = 1;
+ edge = (bedge + 1) % 3;
+ traversedTris[tri - dtrisBase] = 1;
while (tri != btri || edge != bedge) {
- int neighbortri = dtris[tri*3*2+3+edge];
- if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
- if (nv==capacity) {
- unsigned short* newPolyBig;
+ int neighbortri = dtris[tri * 3 * 2 + 3 + edge];
+ if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
+ if (nv == capacity) {
+ unsigned short *newPolyBig;
capacity += vertsPerPoly;
- newPolyBig = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPolyBig");
- memset(newPolyBig, 0xff, sizeof(unsigned short)*capacity);
- memcpy(newPolyBig, newPoly, sizeof(unsigned short)*nv);
+ newPolyBig = MEM_callocN(sizeof(unsigned short) * capacity, "buildPolygonsByDetailedMeshes newPolyBig");
+ memset(newPolyBig, 0xff, sizeof(unsigned short) * capacity);
+ memcpy(newPolyBig, newPoly, sizeof(unsigned short) * nv);
MEM_freeN(newPoly);
- newPoly = newPolyBig;
+ newPoly = newPolyBig;
}
- newPoly[nv++] = dtris[tri*3*2+edge];
- //move to next edge
- edge = (edge+1)%3;
+ newPoly[nv++] = dtris[tri * 3 * 2 + edge];
+ /* move to next edge */
+ edge = (edge + 1) % 3;
}
else {
- //move to next tri
+ /* move to next tri */
int twinedge = -1;
- for (k=0; k<3; k++) {
- if (dtris[neighbortri*3*2+3+k] == tri) {
+ for (k = 0; k < 3; k++) {
+ if (dtris[neighbortri * 3 * 2 + 3 + k] == tri) {
twinedge = k;
break;
}
}
- if (twinedge==-1) {
+ if (twinedge == -1) {
printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
MEM_freeN(traversedTris);
goto returnLabel;
}
tri = neighbortri;
- edge = (twinedge+1)%3;
- traversedTris[tri-dtrisBase] = 1;
+ edge = (twinedge + 1) % 3;
+ traversedTris[tri - dtrisBase] = 1;
}
}
- adjustedPoly = MEM_callocN(sizeof(unsigned short)*nv, "buildPolygonsByDetailedMeshes adjustedPoly");
+ adjustedPoly = MEM_callocN(sizeof(unsigned short) * nv, "buildPolygonsByDetailedMeshes adjustedPoly");
adjustedNv = 0;
- for (i=0; i<nv; i++) {
- unsigned short prev = newPoly[(nv+i-1)%nv];
+ for (i = 0; i < nv; i++) {
+ unsigned short prev = newPoly[(nv + i - 1) % nv];
unsigned short cur = newPoly[i];
- unsigned short next = newPoly[(i+1)%nv];
- float distSq = distPointToSegmentSq(&verts[3*cur], &verts[3*prev], &verts[3*next]);
+ unsigned short next = newPoly[(i + 1) % nv];
+ float distSq = distPointToSegmentSq(&verts[3 * cur], &verts[3 * prev], &verts[3 * next]);
static const float tolerance = 0.001f;
- if (distSq>tolerance)
+ if (distSq > tolerance)
adjustedPoly[adjustedNv++] = cur;
}
- memcpy(newPoly, adjustedPoly, adjustedNv*sizeof(unsigned short));
+ memcpy(newPoly, adjustedPoly, adjustedNv * sizeof(unsigned short));
MEM_freeN(adjustedPoly);
nv = adjustedNv;
allBorderTraversed = 1;
- for (i=0; i<dtrisNum; i++) {
- if (traversedTris[i]==0) {
- //check whether it has border edges
- int curpolytri = dtrisBase+i;
- for (k=0; k<3; k++) {
- unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
- if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
+ for (i = 0; i < dtrisNum; i++) {
+ if (traversedTris[i] == 0) {
+ /* check whether it has border edges */
+ int curpolytri = dtrisBase + i;
+ for (k = 0; k < 3; k++) {
+ unsigned short neighbortri = dtris[curpolytri * 3 * 2 + 3 + k];
+ if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
allBorderTraversed = 0;
break;
}
}
- }
+ }
}
- if (nv<=vertsPerPoly && allBorderTraversed) {
- for (i=0; i<nv; i++) {
- polys[polyidx*vertsPerPoly*2+i] = newPoly[i];
+ if (nv <= vertsPerPoly && allBorderTraversed) {
+ for (i = 0; i < nv; i++) {
+ polys[polyidx * vertsPerPoly * 2 + i] = newPoly[i];
}
}
@@ -298,21 +299,20 @@ returnLabel:
return 1;
}
-struct SortContext
-{
- const int* recastData;
- const int* trisToFacesMap;
+struct SortContext {
+ const int *recastData;
+ const int *trisToFacesMap;
};
-static int compareByData(void *ctx, const void * a, const void * b)
+static int compareByData(void *ctx, const void *a, const void *b)
{
- return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int*)a]] -
- ((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int*)b]] );
+ return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)a]] -
+ ((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)b]]);
}
-int buildNavMeshData(const int nverts, const float* verts,
+int buildNavMeshData(const int nverts, const float *verts,
const int ntris, const unsigned short *tris,
- const int* recastData, const int* trisToFacesMap,
+ const int *recastData, const int *trisToFacesMap,
int *ndtris_r, unsigned short **dtris_r,
int *npolys_r, unsigned short **dmeshes_r, unsigned short **polys_r,
int *vertsPerPoly_r, int **dtrisToPolysMap_r, int **dtrisToTrisMap_r)
@@ -333,86 +333,86 @@ int buildNavMeshData(const int nverts, const float* verts,
return 0;
}
- trisMapping = MEM_callocN(sizeof(int)*ntris, "buildNavMeshData trisMapping");
+ trisMapping = MEM_callocN(sizeof(int) * ntris, "buildNavMeshData trisMapping");
- //sort the triangles by polygon idx
- for (i=0; i<ntris; i++)
- trisMapping[i]=i;
+ /* sort the triangles by polygon idx */
+ for (i = 0; i < ntris; i++)
+ trisMapping[i] = i;
context.recastData = recastData;
context.trisToFacesMap = trisToFacesMap;
recast_qsort(trisMapping, ntris, sizeof(int), &context, compareByData);
- //search first valid triangle - triangle of convex polygon
+ /* search first valid triangle - triangle of convex polygon */
validTriStart = -1;
- for (i=0; i< ntris; i++) {
- if (recastData[trisToFacesMap[trisMapping[i]]]>0) {
+ for (i = 0; i < ntris; i++) {
+ if (recastData[trisToFacesMap[trisMapping[i]]] > 0) {
validTriStart = i;
break;
}
}
- if (validTriStart<0) {
+ if (validTriStart < 0) {
printf("Converting navmesh: Error! No valid polygons in mesh\n");
MEM_freeN(trisMapping);
return 0;
}
- ndtris = ntris-validTriStart;
- //fill dtris to faces mapping
- dtrisToTrisMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToTrisMap");
- memcpy(dtrisToTrisMap, &trisMapping[validTriStart], ndtris*sizeof(int));
+ ndtris = ntris - validTriStart;
+ /* fill dtris to faces mapping */
+ dtrisToTrisMap = MEM_callocN(sizeof(int) * ndtris, "buildNavMeshData dtrisToTrisMap");
+ memcpy(dtrisToTrisMap, &trisMapping[validTriStart], ndtris * sizeof(int));
MEM_freeN(trisMapping);
- //create detailed mesh triangles - copy only valid triangles
- //and reserve memory for adjacency info
- dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris");
- memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris);
- for (i=0; i<ndtris; i++) {
- memcpy(dtris+3*2*i, tris+3*dtrisToTrisMap[i], sizeof(unsigned short)*3);
+ /* create detailed mesh triangles - copy only valid triangles
+ * and reserve memory for adjacency info */
+ dtris = MEM_callocN(sizeof(unsigned short) * 3 * 2 * ndtris, "buildNavMeshData dtris");
+ memset(dtris, 0xffff, sizeof(unsigned short) * 3 * 2 * ndtris);
+ for (i = 0; i < ndtris; i++) {
+ memcpy(dtris + 3 * 2 * i, tris + 3 * dtrisToTrisMap[i], sizeof(unsigned short) * 3);
}
- //create new recast data corresponded to dtris and renumber for continuous indices
+ /* create new recast data corresponded to dtris and renumber for continuous indices */
prevPolyIdx = -1;
newPolyIdx = 0;
- dtrisToPolysMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToPolysMap");
- for (i=0; i<ndtris; i++) {
+ dtrisToPolysMap = MEM_callocN(sizeof(int) * ndtris, "buildNavMeshData dtrisToPolysMap");
+ for (i = 0; i < ndtris; i++) {
curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
- if (curPolyIdx!=prevPolyIdx) {
+ if (curPolyIdx != prevPolyIdx) {
newPolyIdx++;
- prevPolyIdx=curPolyIdx;
+ prevPolyIdx = curPolyIdx;
}
dtrisToPolysMap[i] = newPolyIdx;
}
- //build adjacency info for detailed mesh triangles
+ /* build adjacency info for detailed mesh triangles */
recast_buildMeshAdjacency(dtris, ndtris, nverts, 3);
- //create detailed mesh description for each navigation polygon
- npolys = dtrisToPolysMap[ndtris-1];
- dmeshes = MEM_callocN(sizeof(unsigned short)*npolys*4, "buildNavMeshData dmeshes");
- memset(dmeshes, 0, npolys*4*sizeof(unsigned short));
+ /* create detailed mesh description for each navigation polygon */
+ npolys = dtrisToPolysMap[ndtris - 1];
+ dmeshes = MEM_callocN(sizeof(unsigned short) * npolys * 4, "buildNavMeshData dmeshes");
+ memset(dmeshes, 0, npolys * 4 * sizeof(unsigned short));
dmesh = NULL;
prevpolyidx = 0;
- for (i=0; i<ndtris; i++) {
+ for (i = 0; i < ndtris; i++) {
int curpolyidx = dtrisToPolysMap[i];
- if (curpolyidx!=prevpolyidx) {
- if (curpolyidx!=prevpolyidx+1) {
+ if (curpolyidx != prevpolyidx) {
+ if (curpolyidx != prevpolyidx + 1) {
printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
return 0;
}
- dmesh = dmesh==NULL ? dmeshes : dmesh+4;
- dmesh[2] = (unsigned short)i; //tbase
- dmesh[3] = 0; //tnum
+ dmesh = dmesh == NULL ? dmeshes : dmesh + 4;
+ dmesh[2] = (unsigned short)i; /* tbase */
+ dmesh[3] = 0; /* tnum */
prevpolyidx = curpolyidx;
}
dmesh[3]++;
}
- //create navigation polygons
+ /* create navigation polygons */
vertsPerPoly = 6;
- polys = MEM_callocN(sizeof(unsigned short)*npolys*vertsPerPoly*2, "buildNavMeshData polys");
- memset(polys, 0xff, sizeof(unsigned short)*vertsPerPoly*2*npolys);
+ polys = MEM_callocN(sizeof(unsigned short) * npolys * vertsPerPoly * 2, "buildNavMeshData polys");
+ memset(polys, 0xff, sizeof(unsigned short) * vertsPerPoly * 2 * npolys);
buildPolygonsByDetailedMeshes(vertsPerPoly, npolys, polys, dmeshes, verts, dtris, dtrisToPolysMap);
@@ -429,16 +429,16 @@ int buildNavMeshData(const int nverts, const float* verts,
}
-int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
- int *nverts, float **verts,
- int *ndtris, unsigned short **dtris,
- int *npolys, unsigned short **dmeshes,
- unsigned short **polys, int **dtrisToPolysMap,
- int **dtrisToTrisMap, int **trisToFacesMap)
+int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
+ int *nverts, float **verts,
+ int *ndtris, unsigned short **dtris,
+ int *npolys, unsigned short **dmeshes,
+ unsigned short **polys, int **dtrisToPolysMap,
+ int **dtrisToTrisMap, int **trisToFacesMap)
{
int res = 1;
- int ntris = 0, *recastData=NULL;
- unsigned short *tris=NULL;
+ int ntris = 0, *recastData = NULL;
+ unsigned short *tris = NULL;
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
if (!res) {
@@ -447,8 +447,8 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
}
res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
- ndtris, dtris, npolys, dmeshes, polys, vertsPerPoly,
- dtrisToPolysMap, dtrisToTrisMap);
+ ndtris, dtris, npolys, dmeshes, polys, vertsPerPoly,
+ dtrisToPolysMap, dtrisToTrisMap);
if (!res) {
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
goto exit;
@@ -461,11 +461,11 @@ exit:
return res;
}
-int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx)
+int polyFindVertex(const unsigned short *p, const int vertsPerPoly, unsigned short vertexIdx)
{
int i, res = -1;
- for (i=0; i<vertsPerPoly; i++) {
- if (p[i]==0xffff)
+ for (i = 0; i < vertsPerPoly; i++) {
+ if (p[i] == 0xffff)
break;
if (p[i] == vertexIdx) {
res = i;
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 9590160c8f3..6f585198524 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -423,7 +423,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
return strip->actstart;
}
else {
- /* - the 'fmod(..., actlength*scale)' is needed to get the repeats working
+ /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
*/
return strip->actend - fmodf(cframe - strip->start, actlength * scale) / scale;
@@ -446,7 +446,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
return strip->actend;
}
else {
- /* - the 'fmod(..., actlength*scale)' is needed to get the repeats working
+ /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
*/
return strip->actstart + fmodf(cframe - strip->start, actlength * scale) / scale;
@@ -496,7 +496,7 @@ float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode)
case NLASTRIP_TYPE_CLIP: /* action-clip (default) */
default:
return nlastrip_get_frame_actionclip(strip, cframe, mode);
- }
+ }
}
@@ -1162,7 +1162,7 @@ static short nlastrip_is_first(AnimData *adt, NlaStrip *strip)
if (ns->start < strip->start)
return 0;
}
- }
+ }
/* should be first now */
return 1;
@@ -1491,7 +1491,7 @@ void BKE_nla_action_pushdown(AnimData *adt)
/* add a new NLA strip to the track, which references the active action */
strip = add_nlastrip_to_stack(adt, adt->action);
- /* do other necessary work on strip */
+ /* do other necessary work on strip */
if (strip) {
/* clear reference to action now that we've pushed it onto the stack */
id_us_min(&adt->action->id);
@@ -1545,7 +1545,7 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
/* now try to find active strip */
activeStrip = BKE_nlastrip_find_active(nlt);
break;
- }
+ }
}
/* There are situations where we may have multiple strips selected and we want to enter tweakmode on all
@@ -1563,7 +1563,7 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
activeStrip = BKE_nlastrip_find_active(nlt);
break;
}
- }
+ }
}
if ((activeTrack) && (activeStrip == NULL)) {
/* no active strip in active or last selected track; compromise for first selected (assuming only single)... */
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 8cede4f51a5..2d76484b60a 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -147,6 +147,7 @@ static bNodeSocket *make_socket(bNodeTree *UNUSED(ntree), int in_out, const char
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
sock->type = type;
sock->storage = NULL;
+ sock->flag |= SOCK_COLLAPSED;
sock->default_value = node_socket_make_default_value(type);
node_socket_init_default_value(type, sock->default_value);
@@ -326,10 +327,13 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp)
ntype->initfunc(ntree, node, ntemp);
/* initialize the node name with the node label.
- * note: do this after the initfunc so nodes get
- * their data set which may be used in naming
+ * note: do this after the initfunc so nodes get their data set which may be used in naming
* (node groups for example) */
- BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR);
+ /* XXX Do not use nodeLabel() here, it returns translated content, which should *only* be used
+ * in UI, *never* in data...
+ * This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
+ * than adding a "no translate" flag to this func (and labelfunc() as well). */
+ BLI_strncpy(node->name, node->typeinfo->name, NODE_MAXSTR);
nodeUniqueName(ntree, node);
ntree->update |= NTREE_UPDATE_NODES;
@@ -343,6 +347,7 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
{
bNode *nnode = MEM_callocN(sizeof(bNode), "dupli node");
bNodeSocket *sock, *oldsock;
+ bNodeLink *link, *oldlink;
*nnode = *node;
/* can be called for nodes outside a node tree (e.g. clipboard) */
@@ -382,6 +387,15 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
sock->cache = NULL;
}
+ BLI_duplicatelist(&nnode->internal_links, &node->internal_links);
+ oldlink = node->internal_links.first;
+ for (link = nnode->internal_links.first; link; link = link->next, oldlink = oldlink->next) {
+ link->fromnode = nnode;
+ link->tonode = nnode;
+ link->fromsock = link->fromsock->new_sock;
+ link->tosock = link->tosock->new_sock;
+ }
+
/* don't increase node->id users, freenode doesn't decrement either */
if (node->typeinfo->copystoragefunc)
@@ -389,7 +403,17 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
node->new_node = nnode;
nnode->new_node = NULL;
- nnode->preview = NULL;
+
+ /* only shader nodes get pleasant preview updating this way, compo uses own system */
+ if (node->preview) {
+ if (ntree->type == NTREE_SHADER) {
+ nnode->preview = MEM_dupallocN(node->preview);
+ if (node->preview->rect)
+ nnode->preview->rect = MEM_dupallocN(node->preview->rect);
+ }
+ else
+ nnode->preview = NULL;
+ }
if (ntree)
ntree->update |= NTREE_UPDATE_NODES;
@@ -520,15 +544,12 @@ void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
void nodeInternalRelink(bNodeTree *ntree, bNode *node)
{
bNodeLink *link, *link_next;
- ListBase intlinks;
- if (!node->typeinfo->internal_connect)
+ if (node->internal_links.first == NULL)
return;
- intlinks = node->typeinfo->internal_connect(ntree, node);
-
/* store link pointers in output sockets, for efficient lookup */
- for (link = intlinks.first; link; link = link->next)
+ for (link = node->internal_links.first; link; link = link->next)
link->tosock->link = link;
/* redirect downstream links */
@@ -562,8 +583,6 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
if (link->tonode == node)
nodeRemLink(ntree, link);
}
-
- BLI_freelistN(&intlinks);
}
void nodeToView(bNode *node, float x, float y, float *rx, float *ry)
@@ -710,7 +729,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_use
}
node->new_node = NULL;
- /* nnode= */ nodeCopyNode(newtree, node); /* sets node->new */
+ /* nnode = */ nodeCopyNode(newtree, node); /* sets node->new */
/* make sure we don't copy new nodes again! */
if (node == last)
@@ -815,7 +834,7 @@ void nodeFreePreview(bNode *node)
MEM_freeN(node->preview->rect);
MEM_freeN(node->preview);
node->preview = NULL;
- }
+ }
}
static void node_init_preview(bNode *node, int xsize, int ysize)
@@ -858,7 +877,7 @@ void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
node_init_preview(node, xsize, ysize);
if (node->type == NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
- }
+ }
}
static void nodeClearPreview(bNode *node)
@@ -880,13 +899,13 @@ void ntreeClearPreview(bNodeTree *ntree)
nodeClearPreview(node);
if (node->type == NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
ntreeClearPreview((bNodeTree *)node->id);
- }
+ }
}
/* hack warning! this function is only used for shader previews, and
* since it gets called multiple times per pixel for Ztransp we only
* add the color once. Preview gets cleared before it starts render though */
-void nodeAddToPreview(bNode *node, float col[4], int x, int y, int do_manage)
+void nodeAddToPreview(bNode *node, const float col[4], int x, int y, int do_manage)
{
bNodePreview *preview = node->preview;
if (preview) {
@@ -985,6 +1004,8 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
MEM_freeN(sock);
}
+ BLI_freelistN(&node->internal_links);
+
nodeFreePreview(node);
MEM_freeN(node);
@@ -996,6 +1017,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
/* do not free ntree itself here, BKE_libblock_free calls this function too */
void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
{
+ bNodeTree *tntree;
bNode *node, *next;
bNodeSocket *sock;
@@ -1052,6 +1074,14 @@ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
for (sock = ntree->outputs.first; sock; sock = sock->next)
node_socket_free_default_value(sock->type, sock->default_value);
BLI_freelistN(&ntree->outputs);
+
+ /* if ntree is not part of library, free the libblock data explicitly */
+ for (tntree = G.main->nodetree.first; tntree; tntree = tntree->id.next)
+ if (tntree == ntree)
+ break;
+ if (tntree == NULL) {
+ BKE_libblock_free_data(&ntree->id);
+ }
}
/* same as ntreeFreeTree_ex but always manage users */
void ntreeFreeTree(bNodeTree *ntree)
@@ -1554,11 +1584,11 @@ int BKE_node_clipboard_validate(void)
/* lists must be aligned */
BLI_assert(BLI_countlist(&node_clipboard.nodes) ==
- BLI_countlist(&node_clipboard.nodes_extra_info));
+ BLI_countlist(&node_clipboard.nodes_extra_info));
for (node = node_clipboard.nodes.first, node_info = node_clipboard.nodes_extra_info.first;
- node;
- node = node->next, node_info = node_info->next)
+ node;
+ node = node->next, node_info = node_info->next)
{
/* validate the node against the stored node info */
@@ -1638,21 +1668,21 @@ int BKE_node_clipboard_get_type(void)
/* ************** dependency stuff *********** */
/* node is guaranteed to be not checked before */
-static int node_get_deplist_recurs(bNode *node, bNode ***nsort)
+static int node_get_deplist_recurs(bNodeTree *ntree, bNode *node, bNode ***nsort)
{
bNode *fromnode;
- bNodeSocket *sock;
+ bNodeLink *link;
int level = 0xFFF;
node->done = TRUE;
/* check linked nodes */
- for (sock = node->inputs.first; sock; sock = sock->next) {
- if (sock->link) {
- fromnode = sock->link->fromnode;
+ for (link = ntree->links.first; link; link = link->next) {
+ if (link->tonode == node) {
+ fromnode = link->fromnode;
if (fromnode) {
if (fromnode->done == 0)
- fromnode->level = node_get_deplist_recurs(fromnode, nsort);
+ fromnode->level = node_get_deplist_recurs(ntree, fromnode, nsort);
if (fromnode->level <= level)
level = fromnode->level - 1;
}
@@ -1662,7 +1692,7 @@ static int node_get_deplist_recurs(bNode *node, bNode ***nsort)
/* check parent node */
if (node->parent) {
if (node->parent->done == 0)
- node->parent->level = node_get_deplist_recurs(node->parent, nsort);
+ node->parent->level = node_get_deplist_recurs(ntree, node->parent, nsort);
if (node->parent->level <= level)
level = node->parent->level - 1;
}
@@ -1696,7 +1726,7 @@ void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, in
/* recursive check */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->done == 0) {
- node->level = node_get_deplist_recurs(node, &nsort);
+ node->level = node_get_deplist_recurs(ntree, node, &nsort);
}
}
}
@@ -1714,7 +1744,7 @@ static void ntree_update_node_level(bNodeTree *ntree)
/* recursive check */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->done == 0) {
- node->level = node_get_deplist_recurs(node, NULL);
+ node->level = node_get_deplist_recurs(ntree, node, NULL);
}
}
}
@@ -1813,6 +1843,8 @@ void ntreeUpdateTree(bNodeTree *ntree)
ntreetype->update_node(ntree, node);
else if (node->typeinfo->updatefunc)
node->typeinfo->updatefunc(ntree, node);
+
+ nodeUpdateInternalLinks(ntree, node);
}
}
@@ -1850,6 +1882,9 @@ void nodeUpdate(bNodeTree *ntree, bNode *node)
ntreetype->update_node(ntree, node);
else if (node->typeinfo->updatefunc)
node->typeinfo->updatefunc(ntree, node);
+
+ nodeUpdateInternalLinks(ntree, node);
+
/* clear update flag */
node->update = 0;
}
@@ -1889,9 +1924,21 @@ int nodeUpdateID(bNodeTree *ntree, ID *id)
}
}
+ for (node = ntree->nodes.first; node; node = node->next) {
+ nodeUpdateInternalLinks(ntree, node);
+ }
+
return change;
}
+void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node)
+{
+ BLI_freelistN(&node->internal_links);
+
+ if (node->typeinfo && node->typeinfo->update_internal_links)
+ node->typeinfo->update_internal_links(ntree, node);
+}
+
/* ************* node type access ********** */
@@ -1964,7 +2011,7 @@ void node_type_base(bNodeTreeType *ttype, bNodeType *ntype, int type, const char
/* Default muting stuff. */
if (ttype)
- ntype->internal_connect = ttype->internal_connect;
+ ntype->update_internal_links = ttype->update_internal_links;
/* default size values */
ntype->width = 140;
@@ -2060,9 +2107,9 @@ void node_type_exec_new(struct bNodeType *ntype,
ntype->newexecfunc = newexecfunc;
}
-void node_type_internal_connect(bNodeType *ntype, ListBase (*internal_connect)(bNodeTree *, bNode *))
+void node_type_internal_links(bNodeType *ntype, void (*update_internal_links)(bNodeTree *, bNode *))
{
- ntype->internal_connect = internal_connect;
+ ntype->update_internal_links = update_internal_links;
}
void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out))
@@ -2195,6 +2242,7 @@ static void registerCompositNodes(bNodeTreeType *ttype)
register_node_type_cmp_bokehimage(ttype);
register_node_type_cmp_bokehblur(ttype);
register_node_type_cmp_switch(ttype);
+ register_node_type_cmp_pixelate(ttype);
register_node_type_cmp_mask(ttype);
register_node_type_cmp_trackpos(ttype);
@@ -2243,16 +2291,23 @@ static void registerShaderNodes(bNodeTreeType *ttype)
register_node_type_sh_layer_weight(ttype);
register_node_type_sh_tex_coord(ttype);
register_node_type_sh_particle_info(ttype);
+ register_node_type_sh_bump(ttype);
+ register_node_type_sh_script(ttype);
+ register_node_type_sh_tangent(ttype);
+ register_node_type_sh_normal_map(ttype);
register_node_type_sh_background(ttype);
+ register_node_type_sh_bsdf_anisotropic(ttype);
register_node_type_sh_bsdf_diffuse(ttype);
register_node_type_sh_bsdf_glossy(ttype);
register_node_type_sh_bsdf_glass(ttype);
+ register_node_type_sh_bsdf_refraction(ttype);
register_node_type_sh_bsdf_translucent(ttype);
register_node_type_sh_bsdf_transparent(ttype);
register_node_type_sh_bsdf_velvet(ttype);
register_node_type_sh_emission(ttype);
register_node_type_sh_holdout(ttype);
+ register_node_type_sh_ambient_occlusion(ttype);
//register_node_type_sh_volume_transparent(ttype);
//register_node_type_sh_volume_isotropic(ttype);
register_node_type_sh_mix_shader(ttype);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f72372742d0..6ec173a5908 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -300,11 +300,11 @@ void BKE_object_free(Object *ob)
BKE_object_free_display(ob);
- /* disconnect specific data */
+ /* disconnect specific data, but not for lib data (might be indirect data, can get relinked) */
if (ob->data) {
ID *id = ob->data;
id->us--;
- if (id->us == 0) {
+ if (id->us == 0 && id->lib == NULL) {
switch (ob->type) {
case OB_MESH:
BKE_mesh_unlink((Mesh *)id);
@@ -454,7 +454,7 @@ void BKE_object_unlink(Object *ob)
if (pchan->custom == ob)
pchan->custom = NULL;
}
- }
+ }
else if (ELEM(OB_MBALL, ob->type, obt->type)) {
if (BKE_mball_is_basis_for(obt, ob))
obt->recalc |= OB_RECALC_DATA;
@@ -689,8 +689,8 @@ void BKE_object_unlink(Object *ob)
if (so->treestore) {
TreeStoreElem *tselem = so->treestore->data;
- int a;
- for (a = 0; a < so->treestore->usedelem; a++, tselem++) {
+ int i;
+ for (i = 0; i < so->treestore->usedelem; i++, tselem++) {
if (tselem->id == (ID *)ob) tselem->id = NULL;
}
}
@@ -854,7 +854,9 @@ Object *BKE_object_add_only_object(int type, const char *name)
ob->step_height = 0.15f;
ob->jump_speed = 10.0f;
ob->fall_speed = 55.0f;
-
+ ob->col_group = 0x01;
+ ob->col_mask = 0xff;
+
/* NT fluid sim defaults */
ob->fluidsimSettings = NULL;
@@ -1781,7 +1783,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
/* Make sure the bone is still valid */
pchan = BKE_pose_channel_find_name(par->pose, ob->parsubstr);
- if (!pchan) {
+ if (!pchan || !pchan->bone) {
printf("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name + 2, ob->parsubstr);
unit_m4(mat);
return;
@@ -2300,11 +2302,9 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const short u
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-
- if ((use_hidden == FALSE) && (PBONE_VISIBLE(arm, pchan->bone) == FALSE)) {
- /* pass */
- }
- else {
+ /* XXX pchan->bone may be NULL for duplicated bones, see duplicateEditBoneObjects() comment
+ * (editarmature.c:2592)... Skip in this case too! */
+ if (pchan->bone && !((use_hidden == FALSE) && (PBONE_VISIBLE(arm, pchan->bone) == FALSE))) {
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
minmax_v3v3_v3(min_r, max_r, vec);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
@@ -2573,9 +2573,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
if (ob->recalc & OB_RECALC_DATA) {
ID *data_id = (ID *)ob->data;
AnimData *adt = BKE_animdata_from_id(data_id);
- float ctime = (float)scene->r.cfra; // XXX this is bad...
- ListBase pidlist;
- PTCacheID *pid;
+ float ctime = (float)scene->r.cfra; /* XXX this is bad... */
if (G.debug & G_DEBUG)
printf("recalcdata %s\n", ob->id.name + 2);
@@ -2644,18 +2642,20 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
* However, not doing anything (or trying to hack around this lack) is not an option
* anymore, especially due to Cycles [#31834]
*/
- //if (ob->totcol) {
- // int a;
- //
- // for (a = 1; a <= ob->totcol; a++) {
- // Material *ma = give_current_material(ob, a);
- //
- // if (ma) {
- // /* recursively update drivers for this material */
- // material_drivers_update(scene, ma, ctime);
- // }
- // }
- //}
+ if (ob->totcol) {
+ int a;
+
+ for (a = 1; a <= ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a);
+
+ if (ma) {
+ /* recursively update drivers for this material */
+ material_drivers_update(scene, ma, ctime);
+ }
+ }
+ }
+ else if (ob->type == OB_LAMP)
+ lamp_drivers_update(scene, ob->data, ctime);
/* particles */
if (ob->particlesystem.first) {
@@ -2698,26 +2698,8 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
}
}
-
- /* check if quick cache is needed */
- BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if ((pid->cache->flag & PTCACHE_BAKED) ||
- (pid->cache->flag & PTCACHE_QUICK_CACHE) == 0)
- {
- continue;
- }
-
- if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID) == 0) {
- scene->physics_settings.quick_cache_step =
- scene->physics_settings.quick_cache_step ?
- mini(scene->physics_settings.quick_cache_step, pid->cache->step) :
- pid->cache->step;
- }
- }
-
- BLI_freelistN(&pidlist);
+
+ /* quick cache removed */
}
/* the no-group proxy case, we call update */
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 4f3921936e8..e694a7e7eb3 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -183,7 +183,7 @@ MINLINE float catrom(float p0, float p1, float p2, float p3, float f)
MINLINE float omega(float k, float depth)
{
- return sqrt(GRAVITY * k * tanh(k * depth));
+ return sqrtf(GRAVITY * k * tanhf(k * depth));
}
// modified Phillips spectrum
@@ -256,8 +256,8 @@ static void add_comlex_c(fftw_complex res, fftw_complex cmpl1, fftw_complex cmpl
static void mul_complex_f(fftw_complex res, fftw_complex cmpl, float f)
{
- res[0] = cmpl[0] * f;
- res[1] = cmpl[1] * f;
+ res[0] = cmpl[0] * (double)f;
+ res[1] = cmpl[1] * (double)f;
}
static void mul_complex_c(fftw_complex res, fftw_complex cmpl1, fftw_complex cmpl2)
@@ -289,8 +289,8 @@ static void exp_complex(fftw_complex res, fftw_complex cmpl)
{
float r = expf(cmpl[0]);
- res[0] = cos(cmpl[1]) * r;
- res[1] = sin(cmpl[1]) * r;
+ res[0] = cosf(cmpl[1]) * r;
+ res[1] = sinf(cmpl[1]) * r;
}
float BKE_ocean_jminus_to_foam(float jminus, float coverage)
@@ -462,7 +462,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j)
i = abs(i) % oc->_M;
j = abs(j) % oc->_N;
- ocr->disp[1] = oc->_do_disp_y ? oc->_disp_y[i * oc->_N + j] : 0.0f;
+ ocr->disp[1] = oc->_do_disp_y ? (float)oc->_disp_y[i * oc->_N + j] : 0.0f;
if (oc->_do_chop) {
ocr->disp[0] = oc->_disp_x[i * oc->_N + j];
@@ -475,7 +475,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j)
if (oc->_do_normals) {
ocr->normal[0] = oc->_N_x[i * oc->_N + j];
- ocr->normal[1] = oc->_N_y /*oc->_N_y[i*oc->_N+j] (MEM01)*/;
+ ocr->normal[1] = oc->_N_y /* oc->_N_y[i * oc->_N + j] (MEM01) */;
ocr->normal[2] = oc->_N_z[i * oc->_N + j];
normalize_v3(ocr->normal);
@@ -546,7 +546,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
mul_complex_f(mul_param, mul_param, chop_amount);
mul_complex_c(mul_param, mul_param, minus_i);
mul_complex_c(mul_param, mul_param, o->_htilda[i * (1 + o->_N / 2) + j]);
- mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0 ? 0.0 : o->_kx[i] / o->_k[i * (1 + o->_N / 2) + j]));
+ mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0f ? 0.0f : o->_kx[i] / o->_k[i * (1 + o->_N / 2) + j]));
init_complex(o->_fft_in_x[i * (1 + o->_N / 2) + j], real_c(mul_param), image_c(mul_param));
}
}
@@ -568,7 +568,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
mul_complex_f(mul_param, mul_param, chop_amount);
mul_complex_c(mul_param, mul_param, minus_i);
mul_complex_c(mul_param, mul_param, o->_htilda[i * (1 + o->_N / 2) + j]);
- mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0 ? 0.0 : o->_kz[j] / o->_k[i * (1 + o->_N / 2) + j]));
+ mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0f ? 0.0f : o->_kz[j] / o->_k[i * (1 + o->_N / 2) + j]));
init_complex(o->_fft_in_z[i * (1 + o->_N / 2) + j], real_c(mul_param), image_c(mul_param));
}
}
@@ -589,7 +589,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
mul_complex_f(mul_param, mul_param, chop_amount);
mul_complex_c(mul_param, mul_param, o->_htilda[i * (1 + o->_N / 2) + j]);
- mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0 ? 0.0 : o->_kx[i] * o->_kx[i] / o->_k[i * (1 + o->_N / 2) + j]));
+ mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0f ? 0.0f : o->_kx[i] * o->_kx[i] / o->_k[i * (1 + o->_N / 2) + j]));
init_complex(o->_fft_in_jxx[i * (1 + o->_N / 2) + j], real_c(mul_param), image_c(mul_param));
}
}
@@ -616,7 +616,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
mul_complex_f(mul_param, mul_param, chop_amount);
mul_complex_c(mul_param, mul_param, o->_htilda[i * (1 + o->_N / 2) + j]);
- mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0 ? 0.0 : o->_kz[j] * o->_kz[j] / o->_k[i * (1 + o->_N / 2) + j]));
+ mul_complex_f(mul_param, mul_param, (o->_k[i * (1 + o->_N / 2) + j] == 0.0f ? 0.0f : o->_kz[j] * o->_kz[j] / o->_k[i * (1 + o->_N / 2) + j]));
init_complex(o->_fft_in_jzz[i * (1 + o->_N / 2) + j], real_c(mul_param), image_c(mul_param));
}
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 03342d0f6d1..dec49f417ae 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -201,7 +201,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
file = BLI_open(name, O_BINARY | O_RDONLY, 0);
if (file <= 0) {
- BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
+ BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", name);
}
else {
filelen = BLI_file_descriptor_size(file);
@@ -238,7 +238,8 @@ void packAll(Main *bmain, ReportList *reports)
ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
}
else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
- BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name + 2);
+ BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported",
+ ima->id.name + 2);
}
}
}
@@ -310,20 +311,20 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
if (file >= 0) {
if (write(file, pf->data, pf->size) != pf->size) {
- BKE_reportf(reports, RPT_ERROR, "Error writing file: %s", name);
+ BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", name);
ret_value = RET_ERROR;
}
close(file);
}
else {
- BKE_reportf(reports, RPT_ERROR, "Error creating file: %s", name);
+ BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name);
ret_value = RET_ERROR;
}
if (remove_tmp) {
if (ret_value == RET_ERROR) {
if (BLI_rename(tempname, name) != 0) {
- BKE_reportf(reports, RPT_ERROR, "Error restoring tempfile. Check files: '%s' '%s'", tempname, name);
+ BKE_reportf(reports, RPT_ERROR, "Error restoring temp file (check files '%s' '%s')", tempname, name);
}
}
else {
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 5a302cba2ab..36f96045ced 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -36,6 +36,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
+#include "DNA_space_types.h"
#include "BLI_bitmap.h"
#include "BLI_utildefines.h"
@@ -87,6 +88,7 @@ Paint *paint_get_active(Scene *sce)
Paint *paint_get_active_from_context(const bContext *C)
{
Scene *sce = CTX_data_scene(C);
+ SpaceImage *sima;
if (sce) {
ToolSettings *ts = sce->toolsettings;
@@ -95,12 +97,12 @@ Paint *paint_get_active_from_context(const bContext *C)
if (sce->basact && sce->basact->object)
obact = sce->basact->object;
- if (CTX_wm_space_image(C) != NULL) {
+ if ((sima = CTX_wm_space_image(C)) != NULL) {
if (obact && obact->mode == OB_MODE_EDIT) {
- if (ts->use_uv_sculpt)
- return &ts->uvsculpt->paint;
- else
+ if (sima->mode == SI_MODE_PAINT)
return &ts->imapaint.paint;
+ else if (ts->use_uv_sculpt)
+ return &ts->uvsculpt->paint;
}
else {
return &ts->imapaint.paint;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index e8af794eaea..d645204d29c 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -48,6 +48,7 @@
#include "DNA_dynamicpaint_types.h"
#include "BLI_blenlib.h"
+#include "BLI_noise.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_kdtree.h"
@@ -97,8 +98,8 @@ int count_particles(ParticleSystem *psys)
int tot = 0;
LOOP_SHOWN_PARTICLES {
- if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) ;
- else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) ;
+ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) {}
+ else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) {}
else tot++;
}
return tot;
@@ -110,8 +111,8 @@ int count_particles_mod(ParticleSystem *psys, int totgr, int cur)
int tot = 0;
LOOP_SHOWN_PARTICLES {
- if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) ;
- else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) ;
+ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) {}
+ else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) {}
else if (p % totgr == cur) tot++;
}
return tot;
@@ -335,7 +336,7 @@ void psys_check_group_weights(ParticleSettings *part)
BLI_addtail(&part->dupliweights, dw);
}
- go = go->next;
+ go = go->next;
}
dw = part->dupliweights.first;
@@ -560,7 +561,7 @@ void psys_free(Object *ob, ParticleSystem *psys)
ob->transflag &= ~OB_DUPLIPARTS;
if (psys->part) {
- psys->part->id.us--;
+ psys->part->id.us--;
psys->part = NULL;
}
@@ -617,7 +618,10 @@ typedef struct ParticleRenderData {
int do_simplify;
int timeoffset;
ParticleRenderElem *elems;
- int *origindex;
+
+ /* ORIGINDEX */
+ const int *index_mf_to_mpoly;
+ const int *index_mp_to_orig;
} ParticleRenderData;
static float psys_render_viewport_falloff(double rate, float dist, float width)
@@ -790,9 +794,13 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
float *facearea, (*facecenter)[3], size[3], fac, powrate, scaleclamp;
float co1[3], co2[3], co3[3], co4[3], lambda, arearatio, t, area, viewport;
double vprate;
- int *origindex, *facetotvert;
+ int *facetotvert;
int a, b, totorigface, totface, newtot, skipped;
+ /* double lookup */
+ const int *index_mf_to_mpoly;
+ const int *index_mp_to_orig;
+
if (part->ren_as != PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND))
return tot;
if (!ctx->sim.psys->renderdata)
@@ -806,13 +814,18 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
mvert = dm->getVertArray(dm);
mface = dm->getTessFaceArray(dm);
- origindex = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
totface = dm->getNumTessFaces(dm);
totorigface = me->totpoly;
if (totface == 0 || totorigface == 0)
return tot;
+ index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
+
facearea = MEM_callocN(sizeof(float) * totorigface, "SimplifyFaceArea");
facecenter = MEM_callocN(sizeof(float[3]) * totorigface, "SimplifyFaceCenter");
facetotvert = MEM_callocN(sizeof(int) * totorigface, "SimplifyFaceArea");
@@ -823,20 +836,22 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
data->do_simplify = TRUE;
data->elems = elems;
- data->origindex = origindex;
+ data->index_mf_to_mpoly = index_mf_to_mpoly;
+ data->index_mp_to_orig = index_mp_to_orig;
/* compute number of children per original face */
for (a = 0; a < tot; a++) {
- b = (origindex) ? origindex[ctx->index[a]] : ctx->index[a];
- if (b != -1)
+ b = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, ctx->index[a]) : ctx->index[a];
+ if (b != ORIGINDEX_NONE) {
elems[b].totchild++;
+ }
}
/* compute areas and centers of original faces */
for (mf = mface, a = 0; a < totface; a++, mf++) {
- b = (origindex) ? origindex[a] : a;
+ b = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
- if (b != -1) {
+ if (b != ORIGINDEX_NONE) {
copy_v3_v3(co1, mvert[mf->v1].co);
copy_v3_v3(co2, mvert[mf->v2].co);
copy_v3_v3(co3, mvert[mf->v3].co);
@@ -898,7 +913,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
elem->scalemax = sqrt(elem->scalemax);
/* clamp scaling */
- scaleclamp = MIN2(elem->totchild, 10.0f);
+ scaleclamp = (float)min_ii(elem->totchild, 10);
elem->scalemin = MIN2(scaleclamp, elem->scalemin);
elem->scalemax = MIN2(scaleclamp, elem->scalemax);
@@ -930,8 +945,9 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
skipped = 0;
for (a = 0, newtot = 0; a < tot; a++) {
- b = (origindex) ? origindex[ctx->index[a]] : ctx->index[a];
- if (b != -1) {
+ b = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, ctx->index[a]) : ctx->index[a];
+
+ if (b != ORIGINDEX_NONE) {
if (elems[b].curchild++ < ceil(elems[b].lambda * elems[b].totchild)) {
ctx->index[newtot] = ctx->index[a];
ctx->skip[newtot] = skipped;
@@ -962,10 +978,10 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float
data = psys->renderdata;
if (!data->do_simplify)
return 0;
-
- b = (data->origindex) ? data->origindex[cpa->num] : cpa->num;
- if (b == -1)
+ b = (data->index_mf_to_mpoly) ? DM_origindex_mface_mpoly(data->index_mf_to_mpoly, data->index_mp_to_orig, cpa->num) : cpa->num;
+ if (b == ORIGINDEX_NONE) {
return 0;
+ }
elem = &data->elems[b];
@@ -1403,7 +1419,8 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
/************************************************/
/* interpolate a location on a face based on face coordinates */
void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*orcodata)[3],
- float *w, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor)
+ float w[4], float vec[3], float nor[3], float utan[3], float vtan[3],
+ float orco[3], float ornor[3])
{
float *v1 = 0, *v2 = 0, *v3 = 0, *v4 = 0;
float e1[3], e2[3], s1, s2, t1, t2;
@@ -1622,17 +1639,22 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f
Mesh *me = (Mesh *)ob->data;
MPoly *mpoly;
OrigSpaceFace *osface;
- int *origindex;
int quad, findex, totface;
float uv[2], (*faceuv)[2];
+ /* double lookup */
+ const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
+
mpoly = dm->getPolyArray(dm);
- origindex = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
osface = dm->getTessFaceDataArray(dm, CD_ORIGSPACE);
totface = dm->getNumTessFaces(dm);
- if (osface == NULL || origindex == NULL) {
+ if (osface == NULL || index_mf_to_mpoly == NULL) {
/* Assume we don't need osface data */
if (index < totface) {
//printf("\tNO CD_ORIGSPACE, assuming not needed\n");
@@ -1666,7 +1688,8 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f
}
else { /* if we have no node, try every face */
for (findex = 0; findex < totface; findex++) {
- if (origindex[findex] == index) {
+ const int findex_orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, findex);
+ if (findex_orig == index) {
faceuv = osface[findex].uv;
quad = (mpoly[findex].totloop == 4);
@@ -1746,7 +1769,9 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_
}
/* interprets particle data to get a point on a mesh in object space */
-void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache, const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3], float ornor[3])
+void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache,
+ const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
+ float orco[3], float ornor[3])
{
float tmpnor[3], mapfw[4];
float (*orcodata)[3];
@@ -1842,7 +1867,9 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys)
/* Particles on a shape */
/************************************************/
/* ready for future use */
-static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor)
+static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index),
+ float *UNUSED(fuv), float vec[3], float nor[3], float utan[3], float vtan[3],
+ float orco[3], float ornor[3])
{
/* TODO */
float zerovec[3] = {0.0f, 0.0f, 0.0f};
@@ -1868,7 +1895,9 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *
/************************************************/
/* Particles on emitter */
/************************************************/
-void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor)
+void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache,
+ float fuv[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
+ float orco[3], float ornor[3])
{
if (psmd) {
if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
@@ -2456,7 +2485,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c
totthread = 1;
for (i = 0; i < totthread; i++) {
- threads[i].rng_path = rng_new(seed);
+ threads[i].rng_path = BLI_rng_new(seed);
threads[i].tot = totthread;
}
@@ -3298,7 +3327,7 @@ void copy_particle_key(ParticleKey *to, ParticleKey *from, int time)
to->time = to_time;
}
}
-void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, float *time)
+void psys_get_from_key(ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
{
if (loc) copy_v3_v3(loc, key->co);
if (vel) copy_v3_v3(vel, key->vel);
@@ -4319,7 +4348,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
if (pa) {
if (!always) {
if ((cfra < pa->time && (part->flag & PART_UNBORN) == 0) ||
- (cfra > pa->dietime && (part->flag & PART_DIED) == 0))
+ (cfra >= pa->dietime && (part->flag & PART_DIED) == 0))
{
return 0;
}
@@ -4414,7 +4443,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
}
}
-void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, float *uv, float *orco)
+void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
+ ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa,
+ float uv[2], float orco[3])
{
MFace *mface;
MTFace *mtface;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 154c8cca75d..a780a9e8684 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -346,7 +346,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
if (!dm->deformedOnly) {
/* Will use later to speed up subsurf/derivedmesh */
LinkNode *node, *nodedmelem, **nodearray;
- int totdmelem, totelem, i, *origindex;
+ int totdmelem, totelem, i, *origindex, *origindex_poly = NULL;
if (psys->part->from == PART_FROM_VERT) {
totdmelem= dm->getNumVerts(dm);
@@ -356,23 +356,38 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
else { /* FROM_FACE/FROM_VOLUME */
totdmelem= dm->getNumTessFaces(dm);
totelem= me->totpoly;
- origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ origindex = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ /* for face lookups we need the poly origindex too */
+ origindex_poly = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if (origindex_poly == NULL) {
+ origindex = NULL;
+ }
}
nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems");
nodearray= MEM_callocN(sizeof(LinkNode *)*totelem, "psys node array");
- for (i=0, node=nodedmelem; i<totdmelem; i++, origindex++, node++) {
- node->link= SET_INT_IN_POINTER(i);
+ for (i=0, node=nodedmelem; i<totdmelem; i++, node++) {
+ int origindex_final;
+ node->link = SET_INT_IN_POINTER(i);
+
+ /* may be vertex or face origindex */
+ origindex_final = origindex ? origindex[i] : ORIGINDEX_NONE;
- if (*origindex != -1) {
- if (nodearray[*origindex]) {
+ /* if we have a poly source, do an index lookup */
+ if (origindex_poly && origindex_final != ORIGINDEX_NONE) {
+ origindex_final = origindex_poly[origindex_final];
+ }
+
+ if (origindex_final != ORIGINDEX_NONE) {
+ if (nodearray[origindex_final]) {
/* prepend */
- node->next = nodearray[*origindex];
- nodearray[*origindex]= node;
+ node->next = nodearray[origindex_final];
+ nodearray[origindex_final] = node;
+ }
+ else {
+ nodearray[origindex_final] = node;
}
- else
- nodearray[*origindex]= node;
}
}
@@ -452,13 +467,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
mv++;
for (i=1; i<totvert; i++, mv++) {
- min[0]=MIN2(min[0],mv->co[0]);
- min[1]=MIN2(min[1],mv->co[1]);
- min[2]=MIN2(min[2],mv->co[2]);
-
- max[0]=MAX2(max[0],mv->co[0]);
- max[1]=MAX2(max[1],mv->co[1]);
- max[2]=MAX2(max[2],mv->co[2]);
+ minmax_v3v3_v3(min, max, mv->co);
}
sub_v3_v3v3(delta, max, min);
@@ -556,8 +565,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
else /* store number of intersections */
(pa+(int)(lambda*size[a])*a0mul)->hair_index++;
}
-
- if (mface->v4) {
+ else if (mface->v4) {
copy_v3_v3(v4, mvert[mface->v4].co);
if (isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) {
@@ -632,10 +640,10 @@ static void hammersley_create(float *out, int n, int seed, float amount)
double p, t, offs[2];
int k, kk;
- rng = rng_new(31415926 + n + seed);
- offs[0]= rng_getDouble(rng) + (double)amount;
- offs[1]= rng_getDouble(rng) + (double)amount;
- rng_free(rng);
+ rng = BLI_rng_new(31415926 + n + seed);
+ offs[0] = BLI_rng_get_double(rng) + (double)amount;
+ offs[1] = BLI_rng_get_double(rng) + (double)amount;
+ BLI_rng_free(rng);
for (k = 0; k < n; k++) {
t = 0;
@@ -643,8 +651,8 @@ static void hammersley_create(float *out, int n, int seed, float amount)
if (kk & 1) /* kk mod 2 = 1 */
t += p;
- out[2*k + 0]= fmod((double)k/(double)n + offs[0], 1.0);
- out[2*k + 1]= fmod(t + offs[1], 1.0);
+ out[2*k + 0] = fmod((double)k/(double)n + offs[0], 1.0);
+ out[2*k + 1] = fmod(t + offs[1], 1.0);
}
}
@@ -661,13 +669,13 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
rad2= (float)(1.0f/((float)num));
rad3= (float)sqrt((float)num)/((float)num);
- rng = rng_new(31415926 + num + seed2);
+ rng = BLI_rng_new(31415926 + num + seed2);
x= 0;
num2 = 2 * num;
for (i=0; i<num2; i+=2) {
- jit[i]= x + amount*rad1*(0.5f - rng_getFloat(rng));
- jit[i+1]= i/(2.0f*num) + amount*rad1*(0.5f - rng_getFloat(rng));
+ jit[i] = x + amount*rad1*(0.5f - BLI_rng_get_float(rng));
+ jit[i+1] = i/(2.0f*num) + amount*rad1*(0.5f - BLI_rng_get_float(rng));
jit[i]-= (float)floor(jit[i]);
jit[i+1]-= (float)floor(jit[i+1]);
@@ -684,7 +692,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
BLI_jitterate2(jit, jit2, num, rad2);
}
MEM_freeN(jit2);
- rng_free(rng);
+ BLI_rng_free(rng);
}
static void psys_uv_to_w(float u, float v, int quad, float *w)
@@ -698,21 +706,21 @@ static void psys_uv_to_w(float u, float v, int quad, float *w)
u= 1.0f-u;
}
- vert[0][0]= 0.0f; vert[0][1]= 0.0f; vert[0][2]= 0.0f;
- vert[1][0]= 1.0f; vert[1][1]= 0.0f; vert[1][2]= 0.0f;
- vert[2][0]= 1.0f; vert[2][1]= 1.0f; vert[2][2]= 0.0f;
+ vert[0][0] = 0.0f; vert[0][1] = 0.0f; vert[0][2] = 0.0f;
+ vert[1][0] = 1.0f; vert[1][1] = 0.0f; vert[1][2] = 0.0f;
+ vert[2][0] = 1.0f; vert[2][1] = 1.0f; vert[2][2] = 0.0f;
- co[0]= u;
- co[1]= v;
- co[2]= 0.0f;
+ co[0] = u;
+ co[1] = v;
+ co[2] = 0.0f;
if (quad) {
- vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f;
+ vert[3][0] = 0.0f; vert[3][1] = 1.0f; vert[3][2] = 0.0f;
interp_weights_poly_v3( w,vert, 4, co);
}
else {
interp_weights_poly_v3( w,vert, 3, co);
- w[3]= 0.0f;
+ w[3] = 0.0f;
}
}
@@ -804,8 +812,8 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
}
break;
case PART_DISTR_RAND:
- randu= rng_getFloat(thread->rng);
- randv= rng_getFloat(thread->rng);
+ randu= BLI_rng_get_float(thread->rng);
+ randv= BLI_rng_get_float(thread->rng);
rng_skip_tot -= 2;
psys_uv_to_w(randu, randv, mface->v4, pa->fuv);
@@ -881,8 +889,8 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE);
- randu= rng_getFloat(thread->rng);
- randv= rng_getFloat(thread->rng);
+ randu= BLI_rng_get_float(thread->rng);
+ randv= BLI_rng_get_float(thread->rng);
rng_skip_tot -= 2;
psys_uv_to_w(randu, randv, mf->v4, cpa->fuv);
@@ -934,7 +942,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
}
if (rng_skip_tot > 0) /* should never be below zero */
- rng_skip(thread->rng, rng_skip_tot);
+ BLI_rng_skip(thread->rng, rng_skip_tot);
}
static void *distribute_threads_exec_cb(void *data)
@@ -951,12 +959,12 @@ static void *distribute_threads_exec_cb(void *data)
for (p=0; p<totpart; p++, cpa++) {
if (thread->ctx->skip) /* simplification skip */
- rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]);
+ BLI_rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]);
if ((p+thread->num) % thread->tot == 0)
distribute_threads_exec(thread, NULL, cpa, p);
else /* thread skip */
- rng_skip(thread->rng, PSYS_RND_DIST_SKIP);
+ BLI_rng_skip(thread->rng, PSYS_RND_DIST_SKIP);
}
}
else {
@@ -973,8 +981,8 @@ static void *distribute_threads_exec_cb(void *data)
static int *COMPARE_ORIG_INDEX = NULL;
static int distribute_compare_orig_index(const void *p1, const void *p2)
{
- int index1 = COMPARE_ORIG_INDEX[*(const int*)p1];
- int index2 = COMPARE_ORIG_INDEX[*(const int*)p2];
+ int index1 = COMPARE_ORIG_INDEX[*(const int *)p1];
+ int index2 = COMPARE_ORIG_INDEX[*(const int *)p2];
if (index1 < index2)
return -1;
@@ -1000,7 +1008,7 @@ static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from)
if (psys->child && totchild) {
for (p=0,cpa=psys->child; p<totchild; p++,cpa++) {
- cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]= 0.0;
+ cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3] = 0.0;
cpa->foffset= 0.0f;
cpa->parent=0;
cpa->pa[0]=cpa->pa[1]=cpa->pa[2]=cpa->pa[3]=0;
@@ -1011,7 +1019,7 @@ static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from)
else {
PARTICLE_P;
LOOP_PARTICLES {
- pa->fuv[0]=pa->fuv[1]=pa->fuv[2]= pa->fuv[3]= 0.0;
+ pa->fuv[0] = pa->fuv[1] = pa->fuv[2] = pa->fuv[3] = 0.0;
pa->foffset= 0.0f;
pa->num= -1;
}
@@ -1113,7 +1121,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
if (from == PART_FROM_VERT) {
MVert *mv= dm->getVertDataArray(dm, CD_MVERT);
- float (*orcodata)[3]= dm->getVertDataArray(dm, CD_ORCO);
+ float (*orcodata)[3] = dm->getVertDataArray(dm, CD_ORCO);
int totvert = dm->getNumVerts(dm);
tree=BLI_kdtree_new(totvert);
@@ -1245,9 +1253,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
inv_totweight = (totweight > 0.f ? 1.f/totweight : 0.f);
/* Calculate cumulative weights */
- element_sum[0]= 0.0f;
+ element_sum[0] = 0.0f;
for (i=0; i<totelem; i++)
- element_sum[i+1]= element_sum[i] + element_weight[i] * inv_totweight;
+ element_sum[i+1] = element_sum[i] + element_weight[i] * inv_totweight;
/* Finally assign elements to particles */
if ((part->flag&PART_TRAND) || (part->simplify_flag&PART_SIMPLIFY_ENABLE)) {
@@ -1256,9 +1264,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
for (p=0; p<totpart; p++) {
/* In theory element_sum[totelem] should be 1.0, but due to float errors this is not necessarily always true, so scale pos accordingly. */
pos= BLI_frand() * element_sum[totelem];
- particle_element[p]= distribute_binary_search(element_sum, totelem, pos);
- particle_element[p]= MIN2(totelem-1, particle_element[p]);
- jitter_offset[particle_element[p]]= pos;
+ particle_element[p] = distribute_binary_search(element_sum, totelem, pos);
+ particle_element[p] = MIN2(totelem-1, particle_element[p]);
+ jitter_offset[particle_element[p]] = pos;
}
}
else {
@@ -1269,16 +1277,16 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
i= 0;
for (p=0; p<totpart; p++, pos+=step) {
- while ((i < totelem) && (pos > element_sum[i+1]))
+ while ((i < totelem) && (pos > (double)element_sum[i + 1]))
i++;
- particle_element[p]= MIN2(totelem-1, i);
+ particle_element[p] = MIN2(totelem-1, i);
/* avoid zero weight face */
if (p == totpart-1 && element_weight[particle_element[p]] == 0.0f)
- particle_element[p]= particle_element[p-1];
+ particle_element[p] = particle_element[p-1];
- jitter_offset[particle_element[p]]= pos;
+ jitter_offset[particle_element[p]] = pos;
}
}
@@ -1353,7 +1361,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
seed= 31415926 + ctx->sim.psys->seed;
for (i=0; i<totthread; i++) {
- threads[i].rng= rng_new(seed);
+ threads[i].rng= BLI_rng_new(seed);
threads[i].tot= totthread;
}
@@ -1492,9 +1500,9 @@ void psys_threads_free(ParticleThread *threads)
/* threads */
for (i=0; i<totthread; i++) {
if (threads[i].rng)
- rng_free(threads[i].rng);
+ BLI_rng_free(threads[i].rng);
if (threads[i].rng_path)
- rng_free(threads[i].rng_path);
+ BLI_rng_free(threads[i].rng_path);
}
MEM_freeN(ctx);
@@ -1583,7 +1591,7 @@ static void get_angular_velocity_vector(short avemode, ParticleKey *state, float
switch (avemode) {
case PART_AVE_VELOCITY:
copy_v3_v3(vec, state->vel);
- break;
+ break;
case PART_AVE_HORIZONTAL:
{
float zvec[3];
@@ -1622,9 +1630,9 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
ParticleSystem *psys = sim->psys;
ParticleSettings *part;
ParticleTexture ptex;
- float fac, phasefac, nor[3]={0,0,0},loc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4];
- float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3]={0.0,0.0,0.0};
- float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0};
+ float fac, phasefac, nor[3] = {0,0,0},loc[3],vel[3] = {0.0,0.0,0.0},rot[4],q2[4];
+ float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3] = {0.0,0.0,0.0};
+ float x_vec[3] = {1.0,0.0,0.0}, utan[3] = {0.0,1.0,0.0}, vtan[3] = {0.0,0.0,1.0}, rot_vec[3] = {0.0,0.0,0.0};
float q_phase[4];
int p = pa - psys->particles;
part=psys->part;
@@ -2537,7 +2545,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
madd_v3_v3fl(force, vec, -(pressure + near_pressure*q)*q);
/* Viscosity */
- if (visc > 0.f || stiff_visc > 0.f) {
+ if (visc > 0.f || stiff_visc > 0.f) {
sub_v3_v3v3(dv, vel, state->vel);
u = dot_v3v3(vec, dv);
@@ -2736,7 +2744,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
}
static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, float timestep)
{
- float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep, extrotfac;
+ float rotfac, rot1[4], rot2[4] = {1.0,0.0,0.0,0.0}, dtime=dfra*timestep, extrotfac;
if ((part->flag & PART_ROTATIONS) == 0) {
unit_qt(pa->state.rot);
@@ -3166,8 +3174,7 @@ void BKE_psys_collision_neartest_cb(void *userdata, int index, const BVHTreeRay
if (col->hit == col->current && col->pce.index == index && col->pce.tot == 3)
return;
- do
- {
+ do {
collision = collision_sphere_to_tri(col, ray->radius, &pce, &t);
if (col->pce.inside == 0) {
collision += collision_sphere_to_edges(col, ray->radius, &pce, &t);
@@ -4076,7 +4083,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(sim->ob, eModifierType_Fluidsim);
- if ( fluidmd && fluidmd->fss) {
+ if ( fluidmd && fluidmd->fss) {
FluidsimSettings *fss= fluidmd->fss;
ParticleSettings *part = psys->part;
ParticleData *pa=NULL;
@@ -4121,7 +4128,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
int ptype=0;
gzread(gzf, &ptype, sizeof( ptype ));
- if (ptype&readMask) {
+ if (ptype & readMask) {
activeParts++;
gzread(gzf, &(pa->size), sizeof(float));
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 8c0d19ba1fd..f195b3d71b0 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -249,9 +249,9 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfr
if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step))
return 0;
- times[0]= pa->time;
- times[1]= pa->dietime;
- times[2]= pa->lifetime;
+ times[0] = pa->time;
+ times[1] = pa->dietime;
+ times[2] = pa->lifetime;
PTCACHE_DATA_FROM(data, BPHYS_DATA_INDEX, &index);
PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, pa->state.co);
@@ -532,20 +532,31 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
SmokeDomainSettings *sds = smd->domain;
if (sds->fluid) {
- return sds->res[0]*sds->res[1]*sds->res[2];
+ return sds->base_res[0]*sds->base_res[1]*sds->base_res[2];
}
else
return 0;
}
+
+#define SMOKE_CACHE_VERSION "1.04"
+
static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
int ret = 0;
+ int fluid_fields = smoke_get_data_flags(sds);
+
+ /* version header */
+ ptcache_file_write(pf, SMOKE_CACHE_VERSION, 4, sizeof(char));
+ ptcache_file_write(pf, &fluid_fields, 1, sizeof(int));
+ ptcache_file_write(pf, &sds->active_fields, 1, sizeof(int));
+ ptcache_file_write(pf, &sds->res, 3, sizeof(int));
+ ptcache_file_write(pf, &sds->dx, 1, sizeof(float));
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
+ float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
unsigned char *obstacles;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
@@ -553,22 +564,40 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
int mode=1; // light
if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy
- smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
+ smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)densold, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode);
+ if (fluid_fields & SM_ACTIVE_HEAT) {
+ ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode);
+ }
+ if (fluid_fields & SM_ACTIVE_FIRE) {
+ ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)react, in_len, out, mode);
+ }
+ if (fluid_fields & SM_ACTIVE_COLORS) {
+ ptcache_file_compressed_write(pf, (unsigned char *)r, in_len, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)g, in_len, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)b, in_len, out, mode);
+ }
ptcache_file_compressed_write(pf, (unsigned char *)vx, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)vy, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)vz, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)vxold, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)vyold, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)vzold, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode);
ptcache_file_write(pf, &dt, 1, sizeof(float));
ptcache_file_write(pf, &dx, 1, sizeof(float));
+ ptcache_file_write(pf, &sds->p0, 3, sizeof(float));
+ ptcache_file_write(pf, &sds->p1, 3, sizeof(float));
+ ptcache_file_write(pf, &sds->dp0, 3, sizeof(float));
+ ptcache_file_write(pf, &sds->shift, 3, sizeof(int));
+ ptcache_file_write(pf, &sds->obj_shift_f, 3, sizeof(float));
+ ptcache_file_write(pf, &sds->obmat, 16, sizeof(float));
+ ptcache_file_write(pf, &sds->base_res, 3, sizeof(int));
+ ptcache_file_write(pf, &sds->res_min, 3, sizeof(int));
+ ptcache_file_write(pf, &sds->res_max, 3, sizeof(int));
+ ptcache_file_write(pf, &sds->active_color, 3, sizeof(float));
MEM_freeN(out);
@@ -579,7 +608,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
int res_big_array[3];
int res_big;
int res = sds->res[0]*sds->res[1]*sds->res[2];
- float *dens, *densold, *tcu, *tcv, *tcw;
+ float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned int in_len_big;
unsigned char *out;
@@ -593,11 +622,20 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
in_len_big = sizeof(float) * (unsigned int)res_big;
- smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
+ smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len_big, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)densold, in_len_big, out, mode);
+ if (fluid_fields & SM_ACTIVE_FIRE) {
+ ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len_big, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len_big, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)react, in_len_big, out, mode);
+ }
+ if (fluid_fields & SM_ACTIVE_COLORS) {
+ ptcache_file_compressed_write(pf, (unsigned char *)r, in_len_big, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)g, in_len_big, out, mode);
+ ptcache_file_compressed_write(pf, (unsigned char *)b, in_len_big, out, mode);
+ }
MEM_freeN(out);
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
@@ -615,34 +653,95 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
+ char version[4];
+ int ch_res[3];
+ float ch_dx;
+ int fluid_fields = smoke_get_data_flags(sds);
+ int cache_fields = 0;
+ int active_fields = 0;
+ int reallocate = 0;
+
+ /* version header */
+ ptcache_file_read(pf, version, 4, sizeof(char));
+ if (strncmp(version, SMOKE_CACHE_VERSION, 4)) return 0;
+ /* fluid info */
+ ptcache_file_read(pf, &cache_fields, 1, sizeof(int));
+ ptcache_file_read(pf, &active_fields, 1, sizeof(int));
+ ptcache_file_read(pf, &ch_res, 3, sizeof(int));
+ ptcache_file_read(pf, &ch_dx, 1, sizeof(float));
+
+ /* check if resolution has changed */
+ if (sds->res[0] != ch_res[0] ||
+ sds->res[1] != ch_res[1] ||
+ sds->res[2] != ch_res[2]) {
+ if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)
+ reallocate = 1;
+ else
+ return 0;
+ }
+ /* check if active fields have changed */
+ if (fluid_fields != cache_fields ||
+ active_fields != sds->active_fields)
+ reallocate = 1;
+
+ /* reallocate fluid if needed*/
+ if (reallocate) {
+ sds->active_fields = active_fields;
+ smoke_reallocate_fluid(sds, ch_dx, ch_res, 1);
+ sds->dx = ch_dx;
+ VECCOPY(sds->res, ch_res);
+ sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2];
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1);
+ }
+ }
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
+ float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
unsigned char *obstacles;
unsigned int out_len = (unsigned int)res * sizeof(float);
- smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
+ smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)densold, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vx, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vy, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vz, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vxold, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vyold, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vzold, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)obstacles, (unsigned int)res);
+ ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len);
+ if (cache_fields & SM_ACTIVE_HEAT) {
+ ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len);
+ }
+ if (cache_fields & SM_ACTIVE_FIRE) {
+ ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)react, out_len);
+ }
+ if (cache_fields & SM_ACTIVE_COLORS) {
+ ptcache_file_compressed_read(pf, (unsigned char *)r, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)g, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)b, out_len);
+ }
+ ptcache_file_compressed_read(pf, (unsigned char *)vx, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)vy, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res);
ptcache_file_read(pf, &dt, 1, sizeof(float));
ptcache_file_read(pf, &dx, 1, sizeof(float));
-
- if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
+ ptcache_file_read(pf, &sds->p0, 3, sizeof(float));
+ ptcache_file_read(pf, &sds->p1, 3, sizeof(float));
+ ptcache_file_read(pf, &sds->dp0, 3, sizeof(float));
+ ptcache_file_read(pf, &sds->shift, 3, sizeof(int));
+ ptcache_file_read(pf, &sds->obj_shift_f, 3, sizeof(float));
+ ptcache_file_read(pf, &sds->obmat, 16, sizeof(float));
+ ptcache_file_read(pf, &sds->base_res, 3, sizeof(int));
+ ptcache_file_read(pf, &sds->res_min, 3, sizeof(int));
+ ptcache_file_read(pf, &sds->res_max, 3, sizeof(int));
+ ptcache_file_read(pf, &sds->active_color, 3, sizeof(float));
+ }
+
+ if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
int res = sds->res[0]*sds->res[1]*sds->res[2];
int res_big, res_big_array[3];
- float *dens, *densold, *tcu, *tcv, *tcw;
+ float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
unsigned int out_len = sizeof(float)*(unsigned int)res;
unsigned int out_len_big;
@@ -650,16 +749,23 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
out_len_big = sizeof(float) * (unsigned int)res_big;
- smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
+ smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
- ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len_big);
- ptcache_file_compressed_read(pf, (unsigned char*)densold, out_len_big);
+ ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big);
+ if (cache_fields & SM_ACTIVE_FIRE) {
+ ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len_big);
+ ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len_big);
+ }
+ if (cache_fields & SM_ACTIVE_COLORS) {
+ ptcache_file_compressed_read(pf, (unsigned char *)r, out_len_big);
+ ptcache_file_compressed_read(pf, (unsigned char *)g, out_len_big);
+ ptcache_file_compressed_read(pf, (unsigned char *)b, out_len_big);
+ }
- ptcache_file_compressed_read(pf, (unsigned char*)tcu, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tcv, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tcw, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)tcu, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)tcv, out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len);
}
- }
return 1;
}
@@ -753,7 +859,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
return 0;
}
- ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points);
+ ptcache_file_compressed_read(pf, (unsigned char *)surface->data->type_data, data_len*surface->data->total_points);
}
return 1;
@@ -1257,7 +1363,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
if (mode == 1) {
LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
- r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
+ r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
if (!(r == LZO_E_OK) || (out_len >= in_len))
compressed = 0;
else
@@ -1593,7 +1699,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
for (i=0; i<BPHYS_TOT_DATA; i++) {
unsigned int out_len = pm->totpoint*ptcache_data_size[i];
if (pf->data_types & (1<<i))
- ptcache_file_compressed_read(pf, (unsigned char*)(pm->data[i]), out_len);
+ ptcache_file_compressed_read(pf, (unsigned char *)(pm->data[i]), out_len);
}
}
else {
@@ -1624,7 +1730,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Pointcache extradata->data");
if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS)
- ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]);
+ ptcache_file_compressed_read(pf, (unsigned char *)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]);
else
ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]);
@@ -1681,7 +1787,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
if (pm->data[i]) {
unsigned int in_len = pm->totpoint*ptcache_data_size[i];
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
- ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression);
+ ptcache_file_compressed_write(pf, (unsigned char *)(pm->data[i]), in_len, out, pid->cache->compression);
MEM_freeN(out);
}
}
@@ -1714,7 +1820,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
if (pid->cache->compression) {
unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type];
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
- ptcache_file_compressed_write(pf, (unsigned char*)(extra->data), in_len, out, pid->cache->compression);
+ ptcache_file_compressed_write(pf, (unsigned char *)(extra->data), in_len, out, pid->cache->compression);
MEM_freeN(out);
}
else {
@@ -1925,18 +2031,16 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra)
pid->cache->simframe = cfra2;
}
- if ((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) {
- cfrai = (int)cfra;
- /* clear invalid cache frames so that better stuff can be simulated */
- if (pid->cache->flag & PTCACHE_OUTDATED) {
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
- }
- else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
- if (cfra <= pid->cache->last_exact)
- pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
+ cfrai = (int)cfra;
+ /* clear invalid cache frames so that better stuff can be simulated */
+ if (pid->cache->flag & PTCACHE_OUTDATED) {
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
+ }
+ else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
+ if (cfra <= pid->cache->last_exact)
+ pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
- }
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
}
return ret;
@@ -2167,7 +2271,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
/* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */
switch (mode) {
case PTCACHE_CLEAR_ALL:
- case PTCACHE_CLEAR_BEFORE:
+ case PTCACHE_CLEAR_BEFORE:
case PTCACHE_CLEAR_AFTER:
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
ptcache_path(pid, path);
@@ -2271,7 +2375,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
}
}
- if (pid->cache->cached_frames && cfra>=sta && cfra<=end)
+ if (pid->cache->cached_frames && cfra >= sta && cfra <= end)
pid->cache->cached_frames[cfra-sta] = 0;
break;
}
@@ -2358,7 +2462,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
if (MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) {
MEM_freeN(cache->cached_frames);
cache->cached_frames = NULL;
- }
+ }
}
if (cache->cached_frames==NULL && cache->endframe > cache->startframe) {
@@ -2431,8 +2535,6 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
if (mode == PTCACHE_RESET_DEPSGRAPH) {
if (!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
- if (cache->flag & PTCACHE_QUICK_CACHE)
- clear= 1;
after= 1;
}
@@ -2466,10 +2568,10 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
sbFreeSimulation(pid->calldata);
else if (pid->type == PTCACHE_TYPE_PARTICLES)
psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH);
- else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+ /*else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
smokeModifier_reset(pid->calldata);
else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
- smokeModifier_reset_turbulence(pid->calldata);
+ smokeModifier_reset_turbulence(pid->calldata);*/
else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
}
@@ -2496,7 +2598,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
}
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- /* children or just redo can be calculated without reseting anything */
+ /* children or just redo can be calculated without resetting anything */
if (psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
skip = 1;
/* Baked cloth hair has to be checked too, because we don't want to reset */
@@ -2720,6 +2822,8 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old
return ptcaches_new->first;
}
+/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on
+ * every user action changing stuff, and then it runs a complete bake??? (ton) */
/* Baking */
void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene)
@@ -2903,7 +3007,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
}
if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) &&
- ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
+ (render || bake))
{
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
}
@@ -3222,8 +3326,9 @@ void BKE_ptcache_load_external(PTCacheID *pid)
cache->endframe = end;
cache->totpoint = 0;
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
- ; /*necessary info in every file*/
+ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
+ /* necessary info in every file */
+ }
/* read totpoint from info file (frame 0) */
else if (info) {
pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0);
@@ -3271,7 +3376,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
if (cache->flag & PTCACHE_EXTERNAL) {
int cfra = cache->startframe;
- for (; cfra<=cache->endframe; cfra++) {
+ for (; cfra <= cache->endframe; cfra++) {
if (BKE_ptcache_id_exist(pid, cfra))
totframes++;
}
@@ -3298,7 +3403,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
else {
int cfra = cache->startframe;
- for (; cfra<=cache->endframe; cfra++) {
+ for (; cfra <= cache->endframe; cfra++) {
if (BKE_ptcache_id_exist(pid, cfra))
totframes++;
}
@@ -3307,7 +3412,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
}
}
else {
- PTCacheMem *pm = cache->mem_cache.first;
+ PTCacheMem *pm = cache->mem_cache.first;
float bytes = 0.0f;
int i, mb;
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 3a66ec23412..d925d736358 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -34,6 +34,8 @@
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "BKE_report.h"
#include "BKE_global.h" /* G.background only */
@@ -44,15 +46,24 @@
static const char *report_type_str(int type)
{
switch (type) {
- case RPT_DEBUG: return "Debug";
- case RPT_INFO: return "Info";
- case RPT_OPERATOR: return "Operator";
- case RPT_WARNING: return "Warning";
- case RPT_ERROR: return "Error";
- case RPT_ERROR_INVALID_INPUT: return "Invalid Input Error";
- case RPT_ERROR_INVALID_CONTEXT: return "Invalid Context Error";
- case RPT_ERROR_OUT_OF_MEMORY: return "Out Of Memory Error";
- default: return "Undefined Type";
+ case RPT_DEBUG:
+ return TIP_("Debug");
+ case RPT_INFO:
+ return TIP_("Info");
+ case RPT_OPERATOR:
+ return TIP_("Operator");
+ case RPT_WARNING:
+ return TIP_("Warning");
+ case RPT_ERROR:
+ return TIP_("Error");
+ case RPT_ERROR_INVALID_INPUT:
+ return TIP_("Invalid Input Error");
+ case RPT_ERROR_INVALID_CONTEXT:
+ return TIP_("Invalid Context Error");
+ case RPT_ERROR_OUT_OF_MEMORY:
+ return TIP_("Out Of Memory Error");
+ default:
+ return TIP_("Undefined Type");
}
}
@@ -87,10 +98,11 @@ void BKE_reports_clear(ReportList *reports)
reports->list.first = reports->list.last = NULL;
}
-void BKE_report(ReportList *reports, ReportType type, const char *message)
+void BKE_report(ReportList *reports, ReportType type, const char *_message)
{
Report *report;
int len;
+ const char *message = TIP_(_message);
/* in background mode always print otherwise there are cases the errors wont be displayed,
* but still add to the report list since this is used for python exception handling */
@@ -114,14 +126,16 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
}
}
-void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
+void BKE_reportf(ReportList *reports, ReportType type, const char *_format, ...)
{
DynStr *ds;
Report *report;
va_list args;
+ const char *format = TIP_(_format);
if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
- va_start(args, format);
+ printf("%s: ", report_type_str(type));
+ va_start(args, _format);
vprintf(format, args);
va_end(args);
fprintf(stdout, "\n"); /* otherise each report needs to include a \n */
@@ -132,7 +146,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
report = MEM_callocN(sizeof(Report), "Report");
ds = BLI_dynstr_new();
- va_start(args, format);
+ va_start(args, _format);
BLI_dynstr_vappendf(ds, format, args);
va_end(args);
@@ -147,10 +161,11 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
}
}
-void BKE_reports_prepend(ReportList *reports, const char *prepend)
+void BKE_reports_prepend(ReportList *reports, const char *_prepend)
{
Report *report;
DynStr *ds;
+ const char *prepend = TIP_(_prepend);
if (!reports)
return;
@@ -169,18 +184,19 @@ void BKE_reports_prepend(ReportList *reports, const char *prepend)
}
}
-void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
+void BKE_reports_prependf(ReportList *reports, const char *_prepend, ...)
{
Report *report;
DynStr *ds;
va_list args;
+ const char *prepend = TIP_(_prepend);
if (!reports)
return;
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
- va_start(args, prepend);
+ va_start(args, _prepend);
BLI_dynstr_vappendf(ds, prepend, args);
va_end(args);
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 6c1fbbfa9a0..eb4e0d9c679 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -552,7 +552,7 @@ void set_sca_new_poins_ob(Object *ob)
if (sens->flag & SENS_NEW) {
for (a=0; a<sens->totlinks; a++) {
if (sens->links[a] && sens->links[a]->mynew)
- sens->links[a]= sens->links[a]->mynew;
+ sens->links[a] = sens->links[a]->mynew;
}
}
sens= sens->next;
@@ -563,7 +563,7 @@ void set_sca_new_poins_ob(Object *ob)
if (cont->flag & CONT_NEW) {
for (a=0; a<cont->totlinks; a++) {
if ( cont->links[a] && cont->links[a]->mynew)
- cont->links[a]= cont->links[a]->mynew;
+ cont->links[a] = cont->links[a]->mynew;
}
}
cont= cont->next;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index f8777f87369..4f62732f5e6 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -54,11 +54,14 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_callbacks.h"
+#include "BLI_string.h"
#include "BKE_anim.h"
#include "BKE_animsys.h"
+#include "BKE_action.h"
#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_group.h"
#include "BKE_idprop.h"
@@ -114,6 +117,24 @@ void free_qtcodecdata(QuicktimeCodecData *qcd)
}
}
+static void remove_sequencer_fcurves(Scene *sce)
+{
+ AnimData *adt = BKE_animdata_from_id(&sce->id);
+
+ if (adt && adt->action) {
+ FCurve *fcu, *nextfcu;
+
+ for (fcu = adt->action->curves.first; fcu; fcu = nextfcu) {
+ nextfcu = fcu->next;
+
+ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
+ action_groups_remove_channel(adt->action, fcu);
+ free_fcurve(fcu);
+ }
+ }
+ }
+}
+
Scene *BKE_scene_copy(Scene *sce, int type)
{
Scene *scen;
@@ -175,6 +196,13 @@ Scene *BKE_scene_copy(Scene *sce, int type)
BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings);
BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings);
BKE_color_managed_view_settings_copy(&scen->r.im_format.view_settings, &sce->r.im_format.view_settings);
+
+ BLI_strncpy(scen->sequencer_colorspace_settings.name, sce->sequencer_colorspace_settings.name,
+ sizeof(scen->sequencer_colorspace_settings.name));
+
+ /* remove animation used by sequencer */
+ if (type != SCE_COPY_FULL)
+ remove_sequencer_fcurves(scen);
}
/* tool settings */
@@ -321,7 +349,7 @@ void BKE_scene_free(Scene *sce)
BKE_paint_free(&sce->toolsettings->imapaint.paint);
MEM_freeN(sce->toolsettings);
- sce->toolsettings = NULL;
+ sce->toolsettings = NULL;
}
if (sce->theDag) {
@@ -350,6 +378,7 @@ Scene *BKE_scene_add(const char *name)
Scene *sce;
ParticleEditSettings *pset;
int a;
+ const char *colorspace_name;
sce = BKE_libblock_alloc(&bmain->scene, ID_SCE, name);
sce->lay = sce->layact = 1;
@@ -363,8 +392,8 @@ Scene *BKE_scene_add(const char *name)
sce->r.ysch = 1080;
sce->r.xasp = 1;
sce->r.yasp = 1;
- sce->r.xparts = 8;
- sce->r.yparts = 8;
+ sce->r.tilex = 256;
+ sce->r.tiley = 256;
sce->r.mblur_samples = 1;
sce->r.filtertype = R_FILTER_MITCH;
sce->r.size = 50;
@@ -431,7 +460,7 @@ Scene *BKE_scene_add(const char *name)
sce->toolsettings->cornertype = 1;
sce->toolsettings->degr = 90;
sce->toolsettings->step = 9;
- sce->toolsettings->turn = 1;
+ sce->toolsettings->turn = 1;
sce->toolsettings->extr_offs = 1;
sce->toolsettings->doublimit = 0.001;
sce->toolsettings->segments = 32;
@@ -441,6 +470,7 @@ Scene *BKE_scene_add(const char *name)
sce->toolsettings->uvcalc_cubesize = 1.0f;
sce->toolsettings->uvcalc_mapdir = 1;
sce->toolsettings->uvcalc_mapalign = 1;
+ sce->toolsettings->uvcalc_margin = 0.001f;
sce->toolsettings->unwrapper = 1;
sce->toolsettings->select_thresh = 0.01f;
sce->toolsettings->jointrilimit = 0.8f;
@@ -563,8 +593,13 @@ Scene *BKE_scene_add(const char *name)
sound_create_scene(sce);
+ /* color management */
+ colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER);
+
BKE_color_managed_display_settings_init(&sce->display_settings);
BKE_color_managed_view_settings_init(&sce->view_settings);
+ BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name,
+ sizeof(sce->sequencer_colorspace_settings.name));
return sce;
}
@@ -947,7 +982,7 @@ float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame)
{
float ctime = frame;
ctime += scene->r.subframe;
- ctime *= scene->r.framelen;
+ ctime *= scene->r.framelen;
return ctime;
}
@@ -1008,8 +1043,10 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);
- /* always update layer, so that animating layers works */
- base->lay = ob->lay;
+ /* always update layer, so that animating layers works (joshua july 2010) */
+ /* XXX commented out, this has depsgraph issues anyway - and this breaks setting scenes
+ (on scene-set, the base-lay is copied to ob-lay (ton nov 2012) */
+ // base->lay = ob->lay;
}
/* scene drivers... */
@@ -1031,12 +1068,13 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene)
/* flush recalc flags to dependencies */
DAG_ids_flush_tagged(bmain);
- scene->physics_settings.quick_cache_step = 0;
+ /* removed calls to quick_cache, see pointcache.c */
/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later
* when trying to find materials with drivers that need evaluating [#32017]
*/
tag_main_idcode(bmain, ID_MA, FALSE);
+ tag_main_idcode(bmain, ID_LA, FALSE);
/* update all objects: drivers, matrices, displists, etc. flags set
* by depgraph or manual, no layer check here, gets correct flushed
@@ -1054,10 +1092,6 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene)
BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0);
}
- /* quick point cache updates */
- if (scene->physics_settings.quick_cache_step)
- BKE_ptcache_quick_cache_all(bmain, scene);
-
/* notify editors and python about recalc */
BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST);
DAG_ids_check_recalc(bmain, scene, FALSE);
@@ -1106,6 +1140,12 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
BKE_animsys_evaluate_all_animation(bmain, sce, ctime);
/*...done with recusrive funcs */
+ /* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later
+ * when trying to find materials with drivers that need evaluating [#32017]
+ */
+ tag_main_idcode(bmain, ID_MA, FALSE);
+ tag_main_idcode(bmain, ID_LA, FALSE);
+
/* BKE_object_handle_update() on all objects, groups and sets */
scene_update_tagged_recursive(bmain, sce, sce);
@@ -1182,7 +1222,7 @@ int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *s
int get_render_subsurf_level(RenderData *r, int lvl)
{
if (r->mode & R_SIMPLIFY)
- return MIN2(r->simplify_subsurf, lvl);
+ return min_ii(r->simplify_subsurf, lvl);
else
return lvl;
}
@@ -1198,7 +1238,7 @@ int get_render_child_particle_number(RenderData *r, int num)
int get_render_shadow_samples(RenderData *r, int samples)
{
if ((r->mode & R_SIMPLIFY) && samples > 0)
- return MIN2(r->simplify_shadowsamples, samples);
+ return min_ii(r->simplify_shadowsamples, samples);
else
return samples;
}
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 33519483843..469881020c1 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -62,14 +62,14 @@ static void slice_get_byte_buffers(const SeqRenderData *context, const ImBuf *ib
{
int offset = 4 * start_line * context->rectx;
- *rect1 = (unsigned char*) ibuf1->rect + offset;
- *rect_out = (unsigned char*) out->rect + offset;
+ *rect1 = (unsigned char *)ibuf1->rect + offset;
+ *rect_out = (unsigned char *)out->rect + offset;
if (ibuf2)
- *rect2 = (unsigned char*) ibuf2->rect + offset;
+ *rect2 = (unsigned char *)ibuf2->rect + offset;
if (ibuf3)
- *rect3 = (unsigned char*) ibuf3->rect + offset;
+ *rect3 = (unsigned char *)ibuf3->rect + offset;
}
static void slice_get_float_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2,
@@ -600,7 +600,7 @@ static void makeGammaTables(float gamma)
color_step = 1.0f / RE_GAMMA_TABLE_SIZE;
inv_color_step = (float) RE_GAMMA_TABLE_SIZE;
- /* We could squeeze out the two range tables to gain some memory */
+ /* We could squeeze out the two range tables to gain some memory */
for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) {
color_domain_table[i] = i * color_step;
gamma_range_table[i] = pow(color_domain_table[i], valid_gamma);
@@ -1178,7 +1178,7 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, float *r
fac3 = facf1;
/* formula:
- * fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a
+ * fac * (a * b) + (1 - fac) * a => fac * a * (b - 1) + a
*/
while (y--) {
@@ -1353,7 +1353,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
hyp2 = fabsf(angle * x + y + (-(yo - posy * 0.5f) - angle * (xo - posx * 0.5f))) * wipezone->pythangle;
}
- hwidth = minf(hwidth, fabsf(b3 - b1) / 2.0f);
+ hwidth = min_ff(hwidth, fabsf(b3 - b1) / 2.0f);
if (b2 < b1 && b2 < b3) {
output = in_band(hwidth, hyp, 0, 1);
@@ -2373,7 +2373,7 @@ static ImBuf *do_solid_color(SeqRenderData context, Sequence *seq, float UNUSED(
rect[1] = col1[1];
rect[2] = col1[2];
rect[3] = 255;
- }
+ }
}
}
@@ -2609,7 +2609,7 @@ static void store_icu_yrange_speed(Sequence *seq, short UNUSED(adrcode), float *
*ymin = 0.0;
*ymax = seq->len;
}
- }
+ }
}
void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, int force)
diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c
index b0dcad64722..609724e802f 100644
--- a/source/blender/blenkernel/intern/seqmodifier.c
+++ b/source/blender/blenkernel/intern/seqmodifier.c
@@ -349,9 +349,9 @@ static void hue_correct_apply_threaded(int width, int height, unsigned char *rec
hsv_to_rgb(hsv[0], hsv[1], hsv[2], result, result + 1, result + 2);
if (mask_rect_float)
- copy_v3_v3(mask, mask_rect_float + pixel_index);
+ copy_v3_v3(mask, mask_rect_float + pixel_index);
else if (mask_rect)
- rgb_uchar_to_float(mask, mask_rect + pixel_index);
+ rgb_uchar_to_float(mask, mask_rect + pixel_index);
result[0] = pixel[0] * (1.0f - mask[0]) + result[0] * mask[0];
result[1] = pixel[1] * (1.0f - mask[1]) + result[1] * mask[1];
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 90c3347a1df..a947a48938e 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -53,6 +53,8 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "BKE_animsys.h"
#include "BKE_global.h"
#include "BKE_image.h"
@@ -507,8 +509,8 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene, Sequence *metase
* since sound is played outside of evaluating the imbufs, */
for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
if (seq->type == SEQ_TYPE_META) {
- seq_update_sound_bounds_recursive_rec(scene, seq, maxi(start, metaseq_start(seq)),
- mini(end, metaseq_end(seq)));
+ seq_update_sound_bounds_recursive_rec(scene, seq, max_ii(start, metaseq_start(seq)),
+ min_ii(end, metaseq_end(seq)));
}
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
if (seq->scene_sound) {
@@ -674,8 +676,8 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
if (seq->anim) IMB_free_anim(seq->anim);
- /* OCIO_TODO: support configurable input space for strips */
- seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
+ seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex, seq->strip->colorspace_settings.name);
if (!seq->anim) {
return;
@@ -717,7 +719,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
#ifdef WITH_AUDASPACE
if (!seq->sound)
return;
- seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS);
+ seq->len = ceil((double)AUD_getInfo(seq->sound->playback_handle).length * FPS);
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
if (seq->len < 0) {
@@ -991,7 +993,7 @@ static float give_stripelem_index(Sequence *seq, float cfra)
if (seq->type & SEQ_TYPE_EFFECT) {
end = seq->enddisp;
- }
+ }
if (end < sta) {
return -1;
@@ -1172,8 +1174,8 @@ static void seq_open_anim_file(Sequence *seq)
seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
- /* OCIO_TODO: support configurable input space for strips */
- seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
+ seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex, seq->strip->colorspace_settings.name);
if (seq->anim == NULL) {
return;
@@ -1299,7 +1301,6 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra)
}
if (BLI_exists(name)) {
- /* OCIO_TODO: support configurable spaces for strips */
ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
if (ibuf)
@@ -1344,7 +1345,6 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra
BLI_make_existing_file(name);
- /* OCIO_TODO: support per-strip color space settings */
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
if (ok == 0) {
perror(name);
@@ -1882,7 +1882,7 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra,
ibuf = i;
}
- }
+ }
if (seq->flag & SEQ_FLIPX) {
IMB_flipx(ibuf);
@@ -1965,17 +1965,20 @@ static ImBuf *copy_from_ibuf_still(SeqRenderData context, Sequence *seq, float n
static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, ImBuf *ibuf)
{
+ /* warning: ibuf may be NULL if the video fails to load */
if (nr == 0 || nr == seq->len - 1) {
/* we have to store a copy, since the passed ibuf
* could be preprocessed afterwards (thereby silently
* changing the cached image... */
ibuf = IMB_dupImBuf(ibuf);
- sequencer_imbuf_assign_spaces(context.scene, ibuf);
+ if (ibuf) {
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
+ }
if (nr == 0) {
BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf);
- }
+ }
if (nr == seq->len - 1) {
BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf);
@@ -2334,11 +2337,14 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
* -jahka
*/
- int rendering = G.is_rendering;
- int doseq;
- int doseq_gl = G.is_rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : /*(scene->r.seq_flag & R_SEQ_GL_PREV)*/ 1;
+ const short is_rendering = G.is_rendering;
+ const int do_seq_gl = G.is_rendering ?
+ 0 /* (context.scene->r.seq_flag & R_SEQ_GL_REND) */ :
+ (context.scene->r.seq_flag & R_SEQ_GL_PREV);
+ int do_seq;
int have_seq = FALSE;
Scene *scene;
+ int is_thread_main = BLI_thread_is_main();
/* don't refer to seq->scene above this point!, it can be NULL */
if (seq->scene == NULL) {
@@ -2353,9 +2359,10 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
oldcfra = scene->r.cfra;
scene->r.cfra = frame;
- if (seq->scene_camera)
+ if (seq->scene_camera) {
camera = seq->scene_camera;
- else {
+ }
+ else {
BKE_scene_camera_switch_update(scene);
camera = scene->camera;
}
@@ -2366,8 +2373,8 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
}
/* prevent eternal loop */
- doseq = context.scene->r.scemode & R_DOSEQ;
- context.scene->r.scemode &= ~R_DOSEQ;
+ do_seq = context.scene->r.scemode & R_DOSEQ;
+ scene->r.scemode &= ~R_DOSEQ;
#ifdef DURIAN_CAMERA_SWITCH
/* stooping to new low's in hackyness :( */
@@ -2376,8 +2383,9 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
#else
(void)oldmarkers;
#endif
-
- if (sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq == 0) && camera) {
+
+ if ((sequencer_view3d_cb && do_seq_gl && camera) && is_thread_main)
+ {
char err_out[256] = "unknown";
/* for old scened this can be uninitialized,
* should probably be added to do_versions at some point if the functionality stays */
@@ -2396,15 +2404,19 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
Render *re = RE_GetRender(scene->id.name);
RenderResult rres;
- /* XXX: this if can be removed when sequence preview rendering uses the job system */
- if (rendering || context.scene != scene) {
+ /* XXX: this if can be removed when sequence preview rendering uses the job system
+ *
+ * disable rendered preview for sequencer while rendering -- it's very much possible
+ * that preview render will went into conflict with final render
+ */
+ if (!is_thread_main || is_rendering == FALSE) {
if (re == NULL)
re = RE_NewRender(scene->id.name);
RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE);
/* restore previous state after it was toggled on & off by RE_BlenderFrame */
- G.is_rendering = rendering;
+ G.is_rendering = is_rendering;
}
RE_AcquireResultImage(re, &rres);
@@ -2431,7 +2443,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
}
/* restore */
- context.scene->r.scemode |= doseq;
+ scene->r.scemode |= do_seq;
scene->r.cfra = oldcfra;
@@ -2518,8 +2530,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
BLI_path_abs(name, G.main->name);
}
- /* OCIO_TODO: support configurable space for image strips */
- if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) {
+ if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name))) {
/* we don't need both (speed reasons)! */
if (ibuf->rect_float && ibuf->rect)
imb_freerectImBuf(ibuf);
@@ -2822,7 +2833,7 @@ ImBuf *BKE_sequencer_give_ibuf(SeqRenderData context, float cfra, int chanshown)
count = BLI_countlist(&ed->metastack);
if ((chanshown < 0) && (count > 0)) {
- count = MAX2(count + chanshown, 0);
+ count = max_ii(count + chanshown, 0);
seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep;
}
else {
@@ -3191,7 +3202,7 @@ int BKE_sequence_tx_get_final_left(Sequence *seq, int metaclip)
{
if (metaclip && seq->tmp) {
/* return the range clipped by the parents range */
- return maxi(BKE_sequence_tx_get_final_left(seq, 0), BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, TRUE));
+ return max_ii(BKE_sequence_tx_get_final_left(seq, 0), BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, TRUE));
}
else {
return (seq->start - seq->startstill) + seq->startofs;
@@ -3202,7 +3213,7 @@ int BKE_sequence_tx_get_final_right(Sequence *seq, int metaclip)
{
if (metaclip && seq->tmp) {
/* return the range clipped by the parents range */
- return mini(BKE_sequence_tx_get_final_right(seq, 0), BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, TRUE));
+ return min_ii(BKE_sequence_tx_get_final_right(seq, 0), BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, TRUE));
}
else {
return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
@@ -3454,7 +3465,7 @@ int BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_sc
for (seq = seqbasep->first; seq; seq = seq->next) {
if (seq->machine == orig_machine)
- new_frame = MAX2(new_frame, seq->enddisp);
+ new_frame = max_ii(new_frame, seq->enddisp);
}
test->machine = orig_machine;
@@ -3479,10 +3490,10 @@ static int shuffle_seq_time_offset_test(ListBase *seqbasep, char dir)
for (seq_other = seqbasep->first; seq_other; seq_other = seq_other->next) {
if (!seq_other->tmp && seq_overlap(seq, seq_other)) {
if (dir == 'L') {
- offset = MIN2(offset, seq_other->startdisp - seq->enddisp);
+ offset = min_ii(offset, seq_other->startdisp - seq->enddisp);
}
else {
- offset = MAX2(offset, seq_other->enddisp - seq->startdisp);
+ offset = max_ii(offset, seq_other->enddisp - seq->startdisp);
}
}
}
@@ -3667,26 +3678,26 @@ int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
char name[sizeof(seq_a->name)];
if (seq_a->len != seq_b->len) {
- *error_str = "Strips must be the same length";
+ *error_str = N_("Strips must be the same length");
return 0;
}
- /* type checking, could be more advanced but disalow sound vs non-sound copy */
+ /* type checking, could be more advanced but disallow sound vs non-sound copy */
if (seq_a->type != seq_b->type) {
if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) {
- *error_str = "Strips were not compatible";
+ *error_str = N_("Strips were not compatible");
return 0;
}
/* disallow effects to swap with non-effects strips */
if ((seq_a->type & SEQ_TYPE_EFFECT) != (seq_b->type & SEQ_TYPE_EFFECT)) {
- *error_str = "Strips were not compatible";
+ *error_str = N_("Strips were not compatible");
return 0;
}
if ((seq_a->type & SEQ_TYPE_EFFECT) && (seq_b->type & SEQ_TYPE_EFFECT)) {
if (BKE_sequence_effect_get_num_inputs(seq_a->type) != BKE_sequence_effect_get_num_inputs(seq_b->type)) {
- *error_str = "Strips must have the same number of inputs";
+ *error_str = N_("Strips must have the same number of inputs");
return 0;
}
}
@@ -3929,6 +3940,25 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine)
return seq;
}
+void BKE_sequence_init_colorspace(Sequence *seq)
+{
+ if (seq->strip && seq->strip->stripdata) {
+ char name[FILE_MAX];
+ ImBuf *ibuf;
+
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(name, G.main->name);
+
+ /* initialize input color space */
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name);
+
+ if (ibuf)
+ IMB_freeImBuf(ibuf);
+ }
+ }
+}
+
/* NOTE: this function doesn't fill in image names */
Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
{
@@ -3998,7 +4028,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- seq->len = ceil(info.length * FPS);
+ seq->len = (int)ceil((double)info.length * FPS);
strip->us = 1;
/* we only need 1 element to store the filename */
@@ -4035,14 +4065,14 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
Sequence *seq; /* generic strip vars */
Strip *strip;
StripElem *se;
+ char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
struct anim *an;
BLI_strncpy(path, seq_load->path, sizeof(path));
BLI_path_abs(path, G.main->name);
- /* OCIO_TODO: support configurable input space for strips */
- an = openanim(path, IB_rect, 0, NULL);
+ an = openanim(path, IB_rect, 0, colorspace);
if (an == NULL)
return NULL;
@@ -4061,6 +4091,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN);
strip->us = 1;
+ BLI_strncpy(seq->strip->colorspace_settings.name, colorspace, sizeof(seq->strip->colorspace_settings.name));
+
/* we only need 1 element for MOVIE strips */
strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 9a8bcaabe0c..72db34d339c 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -56,35 +56,18 @@
#include "BKE_mesh.h"
#include "BKE_tessmesh.h"
-/* Util macros */
-#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
-
-/* Benchmark macros */
-#if !defined(_WIN32) && 0
-
-#include <sys/time.h>
-
-#define BENCH(a) \
- do { \
- double _t1, _t2; \
- struct timeval _tstart, _tend; \
- clock_t _clock_init = clock(); \
- gettimeofday ( &_tstart, NULL); \
- (a); \
- gettimeofday ( &_tend, NULL); \
- _t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 ); \
- _t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 ); \
- printf("%s: %fs (real) %fs (cpu)\n", #a, _t2-_t1, (float)(clock()-_clock_init)/CLOCKS_PER_SEC);\
- } while (0)
-
+/* for timing... */
+#if 0
+# include "PIL_time.h"
#else
-
-#define BENCH(a) (a)
-
+# define TIMEIT_BENCH(expr, id) (expr)
#endif
+/* Util macros */
+#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
+
/* get derived mesh */
-//TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not?
+/* TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not? */
DerivedMesh *object_get_derived_final(Object *ob)
{
Mesh *me = ob->data;
@@ -143,13 +126,13 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
BVHTreeNearest nearest = NULL_BVHTreeNearest;
- BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6));
+ TIMEIT_BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6), bvhtree_verts);
if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
}
- //Setup nearest
+ /* Setup nearest */
nearest.index = -1;
nearest.dist = FLT_MAX;
#ifndef __APPLE__
@@ -159,10 +142,12 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if (weight == 0.0f) continue;
+ if (weight == 0.0f) {
+ continue;
+ }
- //Convert the vertex to tree coordinates
+ /* Convert the vertex to tree coordinates */
if (calc->vert) {
copy_v3_v3(tmp_co, calc->vert[i].co);
}
@@ -171,11 +156,11 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
}
space_transform_apply(&calc->local2target, tmp_co);
- //Use local proximity heuristics (to reduce the nearest search)
- //
- //If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
- //so we can initiate the "nearest.dist" with the expected value to that last hit.
- //This will lead in prunning of the search tree.
+ /* Use local proximity heuristics (to reduce the nearest search)
+ *
+ * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
+ * so we can initiate the "nearest.dist" with the expected value to that last hit.
+ * This will lead in prunning of the search tree. */
if (nearest.index != -1)
nearest.dist = len_squared_v3v3(tmp_co, nearest.co);
else
@@ -184,23 +169,27 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData);
- //Found the nearest vertex
+ /* Found the nearest vertex */
if (nearest.index != -1) {
- //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
- float dist = sasqrt(nearest.dist);
- if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist) / dist;
+ /* Adjusting the vertex weight,
+ * so that after interpolating it keeps a certain distance from the nearest position */
+ if (nearest.dist > FLT_EPSILON) {
+ const float dist = sqrtf(nearest.dist);
+ weight *= (dist - calc->keepDist) / dist;
+ }
- //Convert the coordinates back to mesh coordinates
+ /* Convert the coordinates back to mesh coordinates */
copy_v3_v3(tmp_co, nearest.co);
space_transform_invert(&calc->local2target, tmp_co);
- interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation
+ interp_v3_v3v3(co, co, tmp_co, weight); /* linear interpolation */
}
}
free_bvhtree_from_mesh(&treeData);
}
+
/*
* This function raycast a single vertex and updates the hit if the "hit" is considered valid.
* Returns TRUE if "hit" was updated.
@@ -209,16 +198,24 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
* MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE (front faces hits are ignored)
* MOD_SHRINKWRAP_CULL_TARGET_BACKFACE (back faces hits are ignored)
*/
-int normal_projection_project_vertex(char options, const float vert[3], const float dir[3], const SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
+int normal_projection_project_vertex(char options, const float vert[3], const float dir[3],
+ const SpaceTransform *transf,
+ BVHTree *tree, BVHTreeRayHit *hit,
+ BVHTree_RayCastCallback callback, void *userdata)
{
+ /* don't use this because this dist value could be incompatible
+ * this value used by the callback for comparing prev/new dist values.
+ * also, at the moment there is no need to have a corrected 'dist' value */
+// #define USE_DIST_CORRECT
+
float tmp_co[3], tmp_no[3];
const float *co, *no;
BVHTreeRayHit hit_tmp;
- //Copy from hit (we need to convert hit rays from one space coordinates to the other
+ /* Copy from hit (we need to convert hit rays from one space coordinates to the other */
memcpy(&hit_tmp, hit, sizeof(hit_tmp));
- //Apply space transform (TODO readjust dist)
+ /* Apply space transform (TODO readjust dist) */
if (transf) {
copy_v3_v3(tmp_co, vert);
space_transform_apply(transf, tmp_co);
@@ -228,7 +225,9 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl
space_transform_apply_normal(transf, tmp_no);
no = tmp_no;
+#ifdef USE_DIST_CORRECT
hit_tmp.dist *= mat4_to_scale(((SpaceTransform *)transf)->local2target);
+#endif
}
else {
co = vert;
@@ -249,7 +248,7 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl
/* apply backface */
const float dot = dot_v3v3(dir, hit_tmp.no);
if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) ||
- ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f))
+ ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f))
{
return FALSE; /* Ignore hit */
}
@@ -258,9 +257,13 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl
if (transf) {
/* Inverting space transform (TODO make coeherent with the initial dist readjust) */
space_transform_invert(transf, hit_tmp.co);
- hit_tmp.dist = len_v3v3((float *)vert, hit_tmp.co);
+#ifdef USE_DIST_CORRECT
+ hit_tmp.dist = len_v3v3(vert, hit_tmp.co);
+#endif
}
+ BLI_assert(hit_tmp.dist <= hit->dist);
+
memcpy(hit, &hit_tmp, sizeof(hit_tmp));
return TRUE;
}
@@ -272,41 +275,47 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
{
int i;
- //Options about projection direction
+ /* Options about projection direction */
const char use_normal = calc->smd->shrinkOpts;
+ const float proj_limit_squared = calc->smd->projLimit * calc->smd->projLimit;
float proj_axis[3] = {0.0f, 0.0f, 0.0f};
- //Raycast and tree stuff
+ /* Raycast and tree stuff */
+
+ /** \note 'hit.dist' is kept in the targets space, this is only used
+ * for finding the best hit, to get the real dist,
+ * measure the len_v3v3() from the input coord to hit.co */
BVHTreeRayHit hit;
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
- //auxiliary target
+ /* auxiliary target */
DerivedMesh *auxMesh = NULL;
BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh;
SpaceTransform local2aux;
- //If the user doesn't allows to project in any direction of projection axis
- //then theres nothing todo.
+ /* If the user doesn't allows to project in any direction of projection axis
+ * then theres nothing todo. */
if ((use_normal & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0)
return;
- //Prepare data to retrieve the direction in which we should project each vertex
+ /* Prepare data to retrieve the direction in which we should project each vertex */
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
if (calc->vert == NULL) return;
}
else {
- //The code supports any axis that is a combination of X,Y,Z
- //although currently UI only allows to set the 3 different axis
+ /* The code supports any axis that is a combination of X,Y,Z
+ * although currently UI only allows to set the 3 different axis */
if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) proj_axis[0] = 1.0f;
if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f;
if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f;
normalize_v3(proj_axis);
- //Invalid projection direction
- if (dot_v3v3(proj_axis, proj_axis) < FLT_EPSILON)
- return;
+ /* Invalid projection direction */
+ if (len_squared_v3(proj_axis) < FLT_EPSILON) {
+ return;
+ }
}
if (calc->smd->auxTarget) {
@@ -316,7 +325,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->smd->auxTarget);
}
- //After sucessufuly build the trees, start projection vertexs
+ /* After sucessufuly build the trees, start projection vertexs */
if (bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6) &&
(auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6)))
{
@@ -327,9 +336,11 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
float tmp_co[3], tmp_no[3];
- float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
+ const float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if (weight == 0.0f) continue;
+ if (weight == 0.0f) {
+ continue;
+ }
if (calc->vert) {
/* calc->vert contains verts from derivedMesh */
@@ -351,28 +362,45 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
hit.index = -1;
- hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that
+ hit.dist = 10000.0f; /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
- //Project over positive direction of axis
+ /* Project over positive direction of axis */
if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
- if (auxData.tree)
- normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
+ if (auxData.tree) {
+ normal_projection_project_vertex(0, tmp_co, tmp_no,
+ &local2aux, auxData.tree, &hit,
+ auxData.raycast_callback, &auxData);
+ }
- normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
+ normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no,
+ &calc->local2target, treeData.tree, &hit,
+ treeData.raycast_callback, &treeData);
}
- //Project over negative direction of axis
- if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) {
+ /* Project over negative direction of axis */
+ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) {
float inv_no[3];
negate_v3_v3(inv_no, tmp_no);
- if (auxData.tree)
- normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
+ if (auxData.tree) {
+ normal_projection_project_vertex(0, tmp_co, inv_no,
+ &local2aux, auxData.tree, &hit,
+ auxData.raycast_callback, &auxData);
+ }
- normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
+ normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no,
+ &calc->local2target, treeData.tree, &hit,
+ treeData.raycast_callback, &treeData);
}
+ /* don't set the initial dist (which is more efficient),
+ * because its calculated in the targets space, we want the dist in our own space */
+ if (proj_limit_squared != 0.0f) {
+ if (len_squared_v3v3(hit.co, co) > proj_limit_squared) {
+ hit.index = -1;
+ }
+ }
if (hit.index != -1) {
madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
@@ -381,7 +409,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
}
}
- //free data structures
+ /* free data structures */
free_bvhtree_from_mesh(&treeData);
free_bvhtree_from_mesh(&auxData);
}
@@ -399,19 +427,19 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest;
- //Create a bvh-tree of the given target
- BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6));
+ /* Create a bvh-tree of the given target */
+ TIMEIT_BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6), bvhtree_faces);
if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
}
- //Setup nearest
+ /* Setup nearest */
nearest.index = -1;
nearest.dist = FLT_MAX;
- //Find the nearest vertex
+ /* Find the nearest vertex */
#ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
#endif
@@ -421,7 +449,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
if (weight == 0.0f) continue;
- //Convert the vertex to tree coordinates
+ /* Convert the vertex to tree coordinates */
if (calc->vert) {
copy_v3_v3(tmp_co, calc->vert[i].co);
}
@@ -430,11 +458,11 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
space_transform_apply(&calc->local2target, tmp_co);
- //Use local proximity heuristics (to reduce the nearest search)
- //
- //If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
- //so we can initiate the "nearest.dist" with the expected value to that last hit.
- //This will lead in prunning of the search tree.
+ /* Use local proximity heuristics (to reduce the nearest search)
+ *
+ * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
+ * so we can initiate the "nearest.dist" with the expected value to that last hit.
+ * This will lead in prunning of the search tree. */
if (nearest.index != -1)
nearest.dist = len_squared_v3v3(tmp_co, nearest.co);
else
@@ -442,24 +470,28 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData);
- //Found the nearest vertex
+ /* Found the nearest vertex */
if (nearest.index != -1) {
if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
- //Make the vertex stay on the front side of the face
+ /* Make the vertex stay on the front side of the face */
madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist);
}
else {
- //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
+ /* Adjusting the vertex weight,
+ * so that after interpolating it keeps a certain distance from the nearest position */
float dist = sasqrt(nearest.dist);
- if (dist > FLT_EPSILON)
- interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist); //linear interpolation
- else
+ if (dist > FLT_EPSILON) {
+ /* linear interpolation */
+ interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist);
+ }
+ else {
copy_v3_v3(tmp_co, nearest.co);
+ }
}
- //Convert the coordinates back to mesh coordinates
+ /* Convert the coordinates back to mesh coordinates */
space_transform_invert(&calc->local2target, tmp_co);
- interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation
+ interp_v3_v3v3(co, co, tmp_co, weight); /* linear interpolation */
}
}
@@ -467,24 +499,25 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
/* Main shrinkwrap function */
-void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts)
+void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts)
{
DerivedMesh *ss_mesh = NULL;
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
- //remove loop dependencies on derived meshs (TODO should this be done elsewhere?)
+ /* remove loop dependencies on derived meshs (TODO should this be done elsewhere?) */
if (smd->target == ob) smd->target = NULL;
if (smd->auxTarget == ob) smd->auxTarget = NULL;
- //Configure Shrinkwrap calc data
+ /* Configure Shrinkwrap calc data */
calc.smd = smd;
calc.ob = ob;
calc.numVerts = numVerts;
calc.vertexCos = vertexCos;
- //DeformVertex
+ /* DeformVertex */
calc.vgroup = defgroup_name_index(calc.ob, calc.smd->vgroup_name);
if (dm) {
calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
@@ -497,12 +530,12 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
if (smd->target) {
calc.target = object_get_derived_final(smd->target);
- //TODO there might be several "bugs" on non-uniform scales matrixs
- //because it will no longer be nearest surface, not sphere projection
- //because space has been deformed
+ /* TODO there might be several "bugs" on non-uniform scales matrixs
+ * because it will no longer be nearest surface, not sphere projection
+ * because space has been deformed */
SPACE_TRANSFORM_SETUP(&calc.local2target, ob, smd->target);
- //TODO: smd->keepDist is in global units.. must change to local
+ /* TODO: smd->keepDist is in global units.. must change to local */
calc.keepDist = smd->keepDist;
}
@@ -511,15 +544,15 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name);
if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
- //Setup arrays to get vertexs positions, normals and deform weights
+ /* Setup arrays to get vertexs positions, normals and deform weights */
calc.vert = dm->getVertDataArray(dm, CD_MVERT);
calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
- //Using vertexs positions/normals as if a subsurface was applied
+ /* Using vertexs positions/normals as if a subsurface was applied */
if (smd->subsurfLevels) {
SubsurfModifierData ssmd = {{NULL}};
- ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
- ssmd.levels = smd->subsurfLevels; //levels
+ ssmd.subdivType = ME_CC_SUBSURF; /* catmull clark */
+ ssmd.levels = smd->subsurfLevels; /* levels */
ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0);
@@ -532,31 +565,30 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
}
}
- //Just to make sure we are not leaving any memory behind
+ /* Just to make sure we are not leaving any memory behind */
assert(ssmd.emCache == NULL);
assert(ssmd.mCache == NULL);
}
}
- //Projecting target defined - lets work!
+ /* Projecting target defined - lets work! */
if (calc.target) {
switch (smd->shrinkType) {
case MOD_SHRINKWRAP_NEAREST_SURFACE:
- BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
+ TIMEIT_BENCH(shrinkwrap_calc_nearest_surface_point(&calc), deform_surface);
break;
case MOD_SHRINKWRAP_PROJECT:
- BENCH(shrinkwrap_calc_normal_projection(&calc));
+ TIMEIT_BENCH(shrinkwrap_calc_normal_projection(&calc), deform_project);
break;
case MOD_SHRINKWRAP_NEAREST_VERTEX:
- BENCH(shrinkwrap_calc_nearest_vertex(&calc));
+ TIMEIT_BENCH(shrinkwrap_calc_nearest_vertex(&calc), deform_vertex);
break;
}
}
- //free memory
+ /* free memory */
if (ss_mesh)
ss_mesh->release(ss_mesh);
}
-
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 1909e65d0ab..0c440c6f968 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -49,18 +49,7 @@
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
#include "BLI_utildefines.h"
-
-#include "BKE_bvhutils.h"
-#include "BKE_cdderivedmesh.h"
-#include "BKE_collision.h"
-#include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_effect.h"
-#include "BKE_modifier.h"
-#include "BKE_particle.h"
-#include "BKE_pointcache.h"
-#include "BKE_smoke.h"
-
+#include "BLI_voxel.h"
#include "DNA_customdata_types.h"
#include "DNA_group_types.h"
@@ -73,10 +62,22 @@
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
+#include "BKE_bvhutils.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_collision.h"
+#include "BKE_customdata.h"
+#include "BKE_deform.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_effect.h"
+#include "BKE_modifier.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
#include "BKE_smoke.h"
#include "GPU_compatibility.h"
+#include "RE_shader_ext.h"
+
/* UNUSED so far, may be enabled later */
/* #define USE_SMOKE_COLLISION_DM */
@@ -94,38 +95,38 @@ static LARGE_INTEGER liFrequency;
static LARGE_INTEGER liStartTime;
static LARGE_INTEGER liCurrentTime;
-static void tstart ( void )
+static void tstart(void)
{
- QueryPerformanceFrequency ( &liFrequency );
- QueryPerformanceCounter ( &liStartTime );
+ QueryPerformanceFrequency(&liFrequency);
+ QueryPerformanceCounter(&liStartTime);
}
-static void tend ( void )
+static void tend(void)
{
- QueryPerformanceCounter ( &liCurrentTime );
+ QueryPerformanceCounter(&liCurrentTime);
}
-static double UNUSED_FUNCTION(tval)( void )
+static double tval(void)
{
- return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart ));
+ return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart) * (double)1000.0 / (double)liFrequency.QuadPart));
}
#else
#include <sys/time.h>
static struct timeval _tstart, _tend;
static struct timezone tz;
-static void tstart ( void )
+static void tstart(void)
{
- gettimeofday ( &_tstart, &tz );
+ gettimeofday(&_tstart, &tz);
}
-static void tend ( void )
+static void tend(void)
{
- gettimeofday ( &_tend,&tz );
+ gettimeofday(&_tend, &tz);
}
-static double UNUSED_FUNCTION(tval)( void )
+static double UNUSED_FUNCTION(tval) (void)
{
double t1, t2;
- t1 = ( double ) _tstart.tv_sec*1000 + ( double ) _tstart.tv_usec/ ( 1000 );
- t2 = ( double ) _tend.tv_sec*1000 + ( double ) _tend.tv_usec/ ( 1000 );
- return t2-t1;
+ t1 = ( double ) _tstart.tv_sec * 1000 + ( double ) _tstart.tv_usec / (1000);
+ t2 = ( double ) _tend.tv_sec * 1000 + ( double ) _tend.tv_usec / (1000);
+ return t2 - t1;
}
#endif
@@ -134,608 +135,238 @@ struct Scene;
struct DerivedMesh;
struct SmokeModifierData;
-#define TRI_UVOFFSET (1./4.)
-
// timestep default value for nice appearance 0.1f
#define DT_DEFAULT 0.1f
-/* forward declerations */
-static void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len);
-static void get_cell(const float p0[3], const int res[3], float dx, const float pos[3], int cell[3], int correct);
-static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs);
+#define ADD_IF_LOWER_POS(a, b) (MIN2((a) + (b), MAX2((a), (b))))
+#define ADD_IF_LOWER_NEG(a, b) (MAX2((a) + (b), MIN2((a), (b))))
+#define ADD_IF_LOWER(a, b) (((b) > 0) ? ADD_IF_LOWER_POS((a), (b)) : ADD_IF_LOWER_NEG((a), (b)))
#else /* WITH_SMOKE */
/* Stubs to use when smoke is disabled */
-struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; }
-// struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; }
+struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
+//struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(dx), float *UNUSED(dtdef), int UNUSED(use_heat), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
void smoke_free(struct FLUID_3D *UNUSED(fluid)) {}
float *smoke_get_density(struct FLUID_3D *UNUSED(fluid)) { return NULL; }
void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {}
void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(strength)) {}
-void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity), int *UNUSED(border_colli)) {}
-long long smoke_get_mem_req(int UNUSED(xres), int UNUSED(yres), int UNUSED(zres), int UNUSED(amplify)) { return 0; }
-void smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) {}
+void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity),
+ int *UNUSED(border_colli), float *UNUSED(burning_rate), float *UNUSED(flame_smoke), float *UNUSED(flame_smoke_color),
+ float *UNUSED(flame_vorticity), float *UNUSED(flame_ignition_temp), float *UNUSED(flame_max_temp)) {}
+struct DerivedMesh *smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) { return NULL; }
+float smoke_get_velocity_at(struct Object *UNUSED(ob), float UNUSED(position[3]), float UNUSED(velocity[3])) { return 0.0f; }
+void flame_get_spectrum(unsigned char *UNUSED(spec), int UNUSED(width), float UNUSED(t1), float UNUSED(t2)) {}
#endif /* WITH_SMOKE */
#ifdef WITH_SMOKE
-static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm)
+void smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3], int free_old)
{
- if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid)
- {
- size_t i;
- float min[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
- float size[3];
- MVert *verts = dm->getVertArray(dm);
- float scale = 0.0;
- int res;
-
- res = smd->domain->maxres;
-
- // get BB of domain
- for(i = 0; i < dm->getNumVerts(dm); i++)
- {
- float tmp[3];
-
- copy_v3_v3(tmp, verts[i].co);
- mul_m4_v3(ob->obmat, tmp);
-
- // min BB
- min[0] = MIN2(min[0], tmp[0]);
- min[1] = MIN2(min[1], tmp[1]);
- min[2] = MIN2(min[2], tmp[2]);
-
- // max BB
- max[0] = MAX2(max[0], tmp[0]);
- max[1] = MAX2(max[1], tmp[1]);
- max[2] = MAX2(max[2], tmp[2]);
- }
-
- copy_v3_v3(smd->domain->p0, min);
- copy_v3_v3(smd->domain->p1, max);
-
- // calc other res with max_res provided
- sub_v3_v3v3(size, max, min);
-
- // prevent crash when initializing a plane as domain
- if((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON))
- return 0;
-
- if(size[0] > size[1])
- {
- if(size[0] > size[2])
- {
- scale = res / size[0];
- smd->domain->scale = size[0];
- smd->domain->dx = 1.0f / res;
- smd->domain->res[0] = res;
- smd->domain->res[1] = (int)(size[1] * scale + 0.5);
- smd->domain->res[2] = (int)(size[2] * scale + 0.5);
- }
- else {
- scale = res / size[2];
- smd->domain->scale = size[2];
- smd->domain->dx = 1.0f / res;
- smd->domain->res[2] = res;
- smd->domain->res[0] = (int)(size[0] * scale + 0.5);
- smd->domain->res[1] = (int)(size[1] * scale + 0.5);
- }
- }
- else {
- if(size[1] > size[2])
- {
- scale = res / size[1];
- smd->domain->scale = size[1];
- smd->domain->dx = 1.0f / res;
- smd->domain->res[1] = res;
- smd->domain->res[0] = (int)(size[0] * scale + 0.5);
- smd->domain->res[2] = (int)(size[2] * scale + 0.5);
- }
- else {
- scale = res / size[2];
- smd->domain->scale = size[2];
- smd->domain->dx = 1.0f / res;
- smd->domain->res[2] = res;
- smd->domain->res[0] = (int)(size[0] * scale + 0.5);
- smd->domain->res[1] = (int)(size[1] * scale + 0.5);
- }
- }
-
- // TODO: put in failsafe if res<=0 - dg
-
- // dt max is 0.1
- smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0, DT_DEFAULT);
- smd->time = scene->r.cfra;
-
- if(smd->domain->flags & MOD_SMOKE_HIGHRES)
- {
- smd->domain->wt = smoke_turbulence_init(smd->domain->res, smd->domain->amplify + 1, smd->domain->noise);
- smd->domain->res_wt[0] = smd->domain->res[0] * (smd->domain->amplify + 1);
- smd->domain->res_wt[1] = smd->domain->res[1] * (smd->domain->amplify + 1);
- smd->domain->res_wt[2] = smd->domain->res[2] * (smd->domain->amplify + 1);
- smd->domain->dx_wt = smd->domain->dx / (smd->domain->amplify + 1);
- }
-
- if(!smd->domain->shadow)
- smd->domain->shadow = MEM_callocN(sizeof(float) * smd->domain->res[0] * smd->domain->res[1] * smd->domain->res[2], "SmokeDomainShadow");
-
- smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta), &(smd->domain->time_scale), &(smd->domain->vorticity), &(smd->domain->border_collisions));
-
- if(smd->domain->wt)
- {
- smoke_initWaveletBlenderRNA(smd->domain->wt, &(smd->domain->strength));
- }
- return 1;
- }
- else if((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow)
- {
- // handle flow object here
- // XXX TODO
-
- smd->time = scene->r.cfra;
-
- return 1;
- }
- else if((smd->type & MOD_SMOKE_TYPE_COLL))
- {
- // todo: delete this when loading colls work -dg
-
- if(!smd->coll)
- {
- smokeModifier_createType(smd);
- }
-
- if(!smd->coll->points)
- {
- // init collision points
- SmokeCollSettings *scs = smd->coll;
-
- smd->time = scene->r.cfra;
-
- // copy obmat
- copy_m4_m4(scs->mat, ob->obmat);
- copy_m4_m4(scs->mat_old, ob->obmat);
-
- DM_ensure_tessface(dm);
- fill_scs_points(ob, dm, scs);
- }
-
- if(!smd->coll->bvhtree)
- {
- smd->coll->bvhtree = NULL; // bvhtree_build_from_smoke ( ob->obmat, dm->getTessFaceArray(dm), dm->getNumTessFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 );
- }
- return 1;
+ int use_heat = (sds->active_fields & SM_ACTIVE_HEAT);
+ int use_fire = (sds->active_fields & (SM_ACTIVE_HEAT | SM_ACTIVE_FIRE));
+ int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
+
+ if (free_old && sds->fluid)
+ smoke_free(sds->fluid);
+ if (!MIN3(res[0], res[1], res[2])) {
+ sds->fluid = NULL;
+ return;
}
-
- return 2;
+ sds->fluid = smoke_init(res, dx, DT_DEFAULT, use_heat, use_fire, use_colors);
+ smoke_initBlenderRNA(sds->fluid, &(sds->alpha), &(sds->beta), &(sds->time_scale), &(sds->vorticity), &(sds->border_collisions),
+ &(sds->burning_rate), &(sds->flame_smoke), sds->flame_smoke_color, &(sds->flame_vorticity), &(sds->flame_ignition), &(sds->flame_max_temp));
+
+ /* reallocate shadow buffer */
+ if (sds->shadow)
+ MEM_freeN(sds->shadow);
+ sds->shadow = MEM_callocN(sizeof(float) * res[0] * res[1] * res[2], "SmokeDomainShadow");
}
-static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
+void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int res[3], int free_old)
{
- MVert *mvert = dm->getVertArray(dm);
- MFace *mface = dm->getTessFaceArray(dm);
- int i = 0, divs = 0;
-
- // DG TODO: need to do this dynamically according to the domain object!
- float cell_len = scs->dx;
- int newdivs = 0;
- int quads = 0, facecounter = 0;
+ int use_fire = (sds->active_fields & (SM_ACTIVE_HEAT | SM_ACTIVE_FIRE));
+ int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
- // count quads
- for(i = 0; i < dm->getNumTessFaces(dm); i++)
- {
- if(mface[i].v4)
- quads++;
+ if (free_old && sds->wt)
+ smoke_turbulence_free(sds->wt);
+ if (!MIN3(res[0], res[1], res[2])) {
+ sds->wt = NULL;
+ return;
}
+ sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, use_fire, use_colors);
+ sds->res_wt[0] = res[0] * (sds->amplify + 1);
+ sds->res_wt[1] = res[1] * (sds->amplify + 1);
+ sds->res_wt[2] = res[2] * (sds->amplify + 1);
+ sds->dx_wt = dx / (sds->amplify + 1);
+ smoke_initWaveletBlenderRNA(sds->wt, &(sds->strength));
+}
- scs->numtris = dm->getNumTessFaces(dm) + quads;
- scs->tridivs = NULL;
- calcTriangleDivs(ob, mvert, dm->getNumVerts(dm), mface, dm->getNumTessFaces(dm), scs->numtris, &(scs->tridivs), cell_len);
+/* convert global position to domain cell space */
+static void smoke_pos_to_cell(SmokeDomainSettings *sds, float pos[3])
+{
+ mul_m4_v3(sds->imat, pos);
+ sub_v3_v3(pos, sds->p0);
+ pos[0] *= 1.0f / sds->cell_size[0];
+ pos[1] *= 1.0f / sds->cell_size[1];
+ pos[2] *= 1.0f / sds->cell_size[2];
+}
- // count triangle divisions
- for(i = 0; i < dm->getNumTessFaces(dm) + quads; i++)
- {
- divs += (scs->tridivs[3 * i] + 1) * (scs->tridivs[3 * i + 1] + 1) * (scs->tridivs[3 * i + 2] + 1);
- }
+/* set domain resolution and dimensions from object derivedmesh */
+static void smoke_set_domain_from_derivedmesh(SmokeDomainSettings *sds, Object *ob, DerivedMesh *dm)
+{
+ size_t i;
+ float min[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
+ float size[3];
+ MVert *verts = dm->getVertArray(dm);
+ float scale = 0.0;
+ int res;
- scs->points = MEM_callocN(sizeof(float) * (dm->getNumVerts(dm) + divs) * 3, "SmokeCollPoints");
- scs->points_old = MEM_callocN(sizeof(float) * (dm->getNumVerts(dm) + divs) * 3, "SmokeCollPointsOld");
+ res = sds->maxres;
- for(i = 0; i < dm->getNumVerts(dm); i++)
+ // get BB of domain
+ for (i = 0; i < dm->getNumVerts(dm); i++)
{
- float tmpvec[3];
- copy_v3_v3(tmpvec, mvert[i].co);
- // mul_m4_v3(ob->obmat, tmpvec); // DG: use local coordinates, we save MAT anyway
- copy_v3_v3(&scs->points[i * 3], tmpvec);
+ // min BB
+ min[0] = MIN2(min[0], verts[i].co[0]);
+ min[1] = MIN2(min[1], verts[i].co[1]);
+ min[2] = MIN2(min[2], verts[i].co[2]);
+
+ // max BB
+ max[0] = MAX2(max[0], verts[i].co[0]);
+ max[1] = MAX2(max[1], verts[i].co[1]);
+ max[2] = MAX2(max[2], verts[i].co[2]);
}
-
- for(i = 0, facecounter = 0; i < dm->getNumTessFaces(dm); i++)
- {
- int again = 0;
- do
- {
- int j, k;
- int divs1 = scs->tridivs[3 * facecounter + 0];
- int divs2 = scs->tridivs[3 * facecounter + 1];
- //int divs3 = scs->tridivs[3 * facecounter + 2];
- float side1[3], side2[3], trinormorg[3], trinorm[3];
-
- if(again == 1 && mface[i].v4)
- {
- sub_v3_v3v3(side1, mvert[ mface[i].v3 ].co, mvert[ mface[i].v1 ].co);
- sub_v3_v3v3(side2, mvert[ mface[i].v4 ].co, mvert[ mface[i].v1 ].co);
- }
- else {
- sub_v3_v3v3(side1, mvert[ mface[i].v2 ].co, mvert[ mface[i].v1 ].co);
- sub_v3_v3v3(side2, mvert[ mface[i].v3 ].co, mvert[ mface[i].v1 ].co);
- }
- cross_v3_v3v3(trinormorg, side1, side2);
- normalize_v3(trinormorg);
- copy_v3_v3(trinorm, trinormorg);
- mul_v3_fl(trinorm, 0.25 * cell_len);
+ /* set domain bounds */
+ copy_v3_v3(sds->p0, min);
+ copy_v3_v3(sds->p1, max);
+ sds->dx = 1.0f / res;
- for(j = 0; j <= divs1; j++)
- {
- for(k = 0; k <= divs2; k++)
- {
- float p1[3], p2[3], p3[3], p[3]={0,0,0};
- const float uf = (float)(j + TRI_UVOFFSET) / (float)(divs1 + 0.0);
- const float vf = (float)(k + TRI_UVOFFSET) / (float)(divs2 + 0.0);
- float tmpvec[3];
-
- if(uf+vf > 1.0)
- {
- // printf("bigger - divs1: %d, divs2: %d\n", divs1, divs2);
- continue;
- }
+ /* calculate domain dimensions */
+ sub_v3_v3v3(size, max, min);
+ copy_v3_v3(sds->cell_size, size);
+ mul_v3_v3(size, ob->size);
+ copy_v3_v3(sds->global_size, size);
+ copy_v3_v3(sds->dp0, min);
- copy_v3_v3(p1, mvert[ mface[i].v1 ].co);
- if(again == 1 && mface[i].v4)
- {
- copy_v3_v3(p2, mvert[ mface[i].v3 ].co);
- copy_v3_v3(p3, mvert[ mface[i].v4 ].co);
- }
- else {
- copy_v3_v3(p2, mvert[ mface[i].v2 ].co);
- copy_v3_v3(p3, mvert[ mface[i].v3 ].co);
- }
+ invert_m4_m4(sds->imat, ob->obmat);
- mul_v3_fl(p1, (1.0-uf-vf));
- mul_v3_fl(p2, uf);
- mul_v3_fl(p3, vf);
-
- add_v3_v3v3(p, p1, p2);
- add_v3_v3(p, p3);
-
- if(newdivs > divs)
- printf("mem problem\n");
-
- // mMovPoints.push_back(p + trinorm);
- add_v3_v3v3(tmpvec, p, trinorm);
- // mul_m4_v3(ob->obmat, tmpvec); // DG: use local coordinates, we save MAT anyway
- copy_v3_v3(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec);
- newdivs++;
-
- if(newdivs > divs)
- printf("mem problem\n");
-
- // mMovPoints.push_back(p - trinorm);
- copy_v3_v3(tmpvec, p);
- sub_v3_v3(tmpvec, trinorm);
- // mul_m4_v3(ob->obmat, tmpvec); // DG: use local coordinates, we save MAT anyway
- copy_v3_v3(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec);
- newdivs++;
- }
- }
-
- if(again == 0 && mface[i].v4)
- again++;
- else
- again = 0;
-
- facecounter++;
+ // prevent crash when initializing a plane as domain
+ if ((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON))
+ return;
- } while(again!=0);
+ /* define grid resolutions from longest domain side */
+ if (size[0] > MAX2(size[1], size[2])) {
+ scale = res / size[0];
+ sds->scale = size[0] / ob->size[0];
+ sds->base_res[0] = res;
+ sds->base_res[1] = (int)(size[1] * scale + 0.5f);
+ sds->base_res[2] = (int)(size[2] * scale + 0.5f);
}
-
- scs->numverts = dm->getNumVerts(dm);
- // DG TODO: also save triangle count?
-
- scs->numpoints = dm->getNumVerts(dm) + newdivs;
-
- for(i = 0; i < scs->numpoints * 3; i++)
- {
- scs->points_old[i] = scs->points[i];
+ else if (size[1] > MAX2(size[0], size[2])) {
+ scale = res / size[1];
+ sds->scale = size[1] / ob->size[1];
+ sds->base_res[0] = (int)(size[0] * scale + 0.5f);
+ sds->base_res[1] = res;
+ sds->base_res[2] = (int)(size[2] * scale + 0.5f);
+ }
+ else {
+ scale = res / size[2];
+ sds->scale = size[2] / ob->size[2];
+ sds->base_res[0] = (int)(size[0] * scale + 0.5f);
+ sds->base_res[1] = (int)(size[1] * scale + 0.5f);
+ sds->base_res[2] = res;
}
-}
+ /* set cell size */
+ sds->cell_size[0] /= (float)sds->base_res[0];
+ sds->cell_size[1] /= (float)sds->base_res[1];
+ sds->cell_size[2] /= (float)sds->base_res[2];
+}
-static void fill_scs_points_anim(Object *UNUSED(ob), DerivedMesh *dm, SmokeCollSettings *scs)
+static int smokeModifier_init(SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm)
{
- MVert *mvert = dm->getVertArray(dm);
- MFace *mface = dm->getTessFaceArray(dm);
- int quads = 0, numtris = 0, facecounter = 0;
- unsigned int i = 0;
- int divs = 0, newdivs = 0;
-
- // DG TODO: need to do this dynamically according to the domain object!
- float cell_len = scs->dx;
-
- // count quads
- for(i = 0; i < dm->getNumTessFaces(dm); i++)
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid)
{
- if(mface[i].v4)
- quads++;
- }
+ SmokeDomainSettings *sds = smd->domain;
+ int res[3];
+ /* set domain dimensions from derivedmesh */
+ smoke_set_domain_from_derivedmesh(sds, ob, dm);
+ /* reset domain values */
+ zero_v3_int(sds->shift);
+ zero_v3(sds->shift_f);
+ add_v3_fl(sds->shift_f, 0.5f);
+ zero_v3(sds->prev_loc);
+ mul_m4_v3(ob->obmat, sds->prev_loc);
+
+ /* set resolutions */
+ if (smd->domain->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
+ res[0] = res[1] = res[2] = 1; /* use minimum res for adaptive init */
+ }
+ else {
+ VECCOPY(res, sds->base_res);
+ }
+ VECCOPY(sds->res, res);
+ sds->total_cells = sds->res[0] * sds->res[1] * sds->res[2];
+ sds->res_min[0] = sds->res_min[1] = sds->res_min[2] = 0;
+ VECCOPY(sds->res_max, res);
- numtris = dm->getNumTessFaces(dm) + quads;
+ /* allocate fluid */
+ smoke_reallocate_fluid(sds, sds->dx, sds->res, 0);
- // check if mesh changed topology
- if(scs->numtris != numtris)
- return;
- if(scs->numverts != dm->getNumVerts(dm))
- return;
+ smd->time = scene->r.cfra;
- // update new positions
- for(i = 0; i < dm->getNumVerts(dm); i++)
- {
- float tmpvec[3];
- copy_v3_v3(tmpvec, mvert[i].co);
- copy_v3_v3(&scs->points[i * 3], tmpvec);
- }
+ /* allocate highres fluid */
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ smoke_reallocate_highres_fluid(sds, sds->dx, sds->res, 0);
+ }
+ /* allocate shadow buffer */
+ if (!sds->shadow)
+ sds->shadow = MEM_callocN(sizeof(float) * sds->res[0] * sds->res[1] * sds->res[2], "SmokeDomainShadow");
- // for every triangle // update div points
- for(i = 0, facecounter = 0; i < dm->getNumTessFaces(dm); i++)
+ return 1;
+ }
+ else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow)
{
- int again = 0;
- do
- {
- int j, k;
- int divs1 = scs->tridivs[3 * facecounter + 0];
- int divs2 = scs->tridivs[3 * facecounter + 1];
- float srcside1[3], srcside2[3], destside1[3], destside2[3], src_trinormorg[3], dest_trinormorg[3], src_trinorm[3], dest_trinorm[3];
-
- if(again == 1 && mface[i].v4)
- {
- sub_v3_v3v3(srcside1, &scs->points_old[mface[i].v3 * 3], &scs->points_old[mface[i].v1 * 3]);
- sub_v3_v3v3(destside1, &scs->points[mface[i].v3 * 3], &scs->points[mface[i].v1 * 3]);
-
- sub_v3_v3v3(srcside2, &scs->points_old[mface[i].v4 * 3], &scs->points_old[mface[i].v1 * 3]);
- sub_v3_v3v3(destside2, &scs->points[mface[i].v4 * 3], &scs->points[mface[i].v1 * 3]);
- }
- else {
- sub_v3_v3v3(srcside1, &scs->points_old[mface[i].v2 * 3], &scs->points_old[mface[i].v1 * 3]);
- sub_v3_v3v3(destside1, &scs->points[mface[i].v2 * 3], &scs->points[mface[i].v1 * 3]);
-
- sub_v3_v3v3(srcside2, &scs->points_old[mface[i].v3 * 3], &scs->points_old[mface[i].v1 * 3]);
- sub_v3_v3v3(destside2, &scs->points[mface[i].v3 * 3], &scs->points[mface[i].v1 * 3]);
- }
-
- cross_v3_v3v3(src_trinormorg, srcside1, srcside2);
- cross_v3_v3v3(dest_trinormorg, destside1, destside2);
-
- normalize_v3(src_trinormorg);
- normalize_v3(dest_trinormorg);
-
- copy_v3_v3(src_trinorm, src_trinormorg);
- copy_v3_v3(dest_trinorm, dest_trinormorg);
-
- mul_v3_fl(src_trinorm, 0.25 * cell_len);
- mul_v3_fl(dest_trinorm, 0.25 * cell_len);
-
- for(j = 0; j <= divs1; j++)
- {
- for(k = 0; k <= divs2; k++)
- {
- float src_p1[3], src_p2[3], src_p3[3], src_p[3]={0,0,0};
- float dest_p1[3], dest_p2[3], dest_p3[3], dest_p[3]={0,0,0};
- const float uf = (float)(j + TRI_UVOFFSET) / (float)(divs1 + 0.0);
- const float vf = (float)(k + TRI_UVOFFSET) / (float)(divs2 + 0.0);
- float src_tmpvec[3], dest_tmpvec[3];
-
- if(uf+vf > 1.0)
- {
- // printf("bigger - divs1: %d, divs2: %d\n", divs1, divs2);
- continue;
- }
-
- copy_v3_v3(src_p1, &scs->points_old[mface[i].v1 * 3]);
- copy_v3_v3(dest_p1, &scs->points[mface[i].v1 * 3]);
- if(again == 1 && mface[i].v4)
- {
- copy_v3_v3(src_p2, &scs->points_old[mface[i].v3 * 3]);
- copy_v3_v3(dest_p2, &scs->points[mface[i].v3 * 3]);
-
- copy_v3_v3(src_p3,&scs->points_old[mface[i].v4 * 3]);
- copy_v3_v3(dest_p3, &scs->points[mface[i].v4 * 3]);
- }
- else {
- copy_v3_v3(src_p2, &scs->points_old[mface[i].v2 * 3]);
- copy_v3_v3(dest_p2, &scs->points[mface[i].v2 * 3]);
- copy_v3_v3(src_p3, &scs->points_old[mface[i].v3 * 3]);
- copy_v3_v3(dest_p3, &scs->points[mface[i].v3 * 3]);
- }
-
- mul_v3_fl(src_p1, (1.0-uf-vf));
- mul_v3_fl(dest_p1, (1.0-uf-vf));
-
- mul_v3_fl(src_p2, uf);
- mul_v3_fl(dest_p2, uf);
-
- mul_v3_fl(src_p3, vf);
- mul_v3_fl(dest_p3, vf);
-
- add_v3_v3v3(src_p, src_p1, src_p2);
- add_v3_v3v3(dest_p, dest_p1, dest_p2);
-
- add_v3_v3(src_p, src_p3);
- add_v3_v3(dest_p, dest_p3);
-
- if(newdivs > divs)
- printf("mem problem\n");
-
- // mMovPoints.push_back(p + trinorm);
- add_v3_v3v3(src_tmpvec, src_p, src_trinorm);
- add_v3_v3v3(dest_tmpvec, dest_p, dest_trinorm);
-
- // mul_m4_v3(ob->obmat, tmpvec); // DG: use local coordinates, we save MAT anyway
- copy_v3_v3(&scs->points_old[3 * (dm->getNumVerts(dm) + newdivs)], src_tmpvec);
- copy_v3_v3(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], dest_tmpvec);
- newdivs++;
-
- if(newdivs > divs)
- printf("mem problem\n");
-
- // mMovPoints.push_back(p - trinorm);
- copy_v3_v3(src_tmpvec, src_p);
- copy_v3_v3(dest_tmpvec, dest_p);
-
- sub_v3_v3(src_tmpvec, src_trinorm);
- sub_v3_v3(dest_tmpvec, dest_trinorm);
-
- // mul_m4_v3(ob->obmat, tmpvec); // DG: use local coordinates, we save MAT anyway
- copy_v3_v3(&scs->points_old[3 * (dm->getNumVerts(dm) + newdivs)], src_tmpvec);
- copy_v3_v3(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], dest_tmpvec);
- newdivs++;
- }
- }
-
- if(again == 0 && mface[i].v4)
- again++;
- else
- again = 0;
-
- facecounter++;
+ smd->time = scene->r.cfra;
- } while(again!=0);
+ return 1;
}
-
- // scs->numpoints = dm->getNumVerts(dm) + newdivs;
-
-}
-
-/*! init triangle divisions */
-static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFace *faces, int numfaces, int numtris, int **tridivs, float cell_len)
-{
- // mTriangleDivs1.resize( faces.size() );
- // mTriangleDivs2.resize( faces.size() );
- // mTriangleDivs3.resize( faces.size() );
-
- size_t i = 0, facecounter = 0;
- float maxscale[3] = {1,1,1}; // = channelFindMaxVf(mcScale); get max scale value
- float maxpart = ABS(maxscale[0]);
- float scaleFac = 0;
- float fsTri = 0;
- if(ABS(maxscale[1])>maxpart) maxpart = ABS(maxscale[1]);
- if(ABS(maxscale[2])>maxpart) maxpart = ABS(maxscale[2]);
- scaleFac = 1.0 / maxpart;
- // featureSize = mLevel[mMaxRefine].nodeSize
- fsTri = cell_len * 0.75 * scaleFac; // fsTri = cell_len * 0.9;
-
- if(*tridivs)
- MEM_freeN(*tridivs);
-
- *tridivs = MEM_callocN(sizeof(int) * numtris * 3, "Smoke_Tridivs");
-
- for(i = 0, facecounter = 0; i < numfaces; i++)
+ else if ((smd->type & MOD_SMOKE_TYPE_COLL))
{
- float p0[3], p1[3], p2[3];
- float side1[3];
- float side2[3];
- float side3[3];
- int divs1=0, divs2=0, divs3=0;
-
- copy_v3_v3(p0, verts[faces[i].v1].co);
- mul_m4_v3(ob->obmat, p0);
- copy_v3_v3(p1, verts[faces[i].v2].co);
- mul_m4_v3(ob->obmat, p1);
- copy_v3_v3(p2, verts[faces[i].v3].co);
- mul_m4_v3(ob->obmat, p2);
-
- sub_v3_v3v3(side1, p1, p0);
- sub_v3_v3v3(side2, p2, p0);
- sub_v3_v3v3(side3, p1, p2);
-
- if(dot_v3v3(side1, side1) > fsTri*fsTri)
- {
- float tmp = normalize_v3(side1);
- divs1 = (int)ceil(tmp/fsTri);
- }
- if(dot_v3v3(side2, side2) > fsTri*fsTri)
- {
- float tmp = normalize_v3(side2);
- divs2 = (int)ceil(tmp/fsTri);
-
- /*
- // debug
- if(i==0)
- printf("b tmp: %f, fsTri: %f, divs2: %d\n", tmp, fsTri, divs2);
- */
-
+ if (!smd->coll)
+ {
+ smokeModifier_createType(smd);
}
- (*tridivs)[3 * facecounter + 0] = divs1;
- (*tridivs)[3 * facecounter + 1] = divs2;
- (*tridivs)[3 * facecounter + 2] = divs3;
-
- // TODO quad case
- if(faces[i].v4)
- {
- divs1=0, divs2=0, divs3=0;
-
- facecounter++;
-
- copy_v3_v3(p0, verts[faces[i].v3].co);
- mul_m4_v3(ob->obmat, p0);
- copy_v3_v3(p1, verts[faces[i].v4].co);
- mul_m4_v3(ob->obmat, p1);
- copy_v3_v3(p2, verts[faces[i].v1].co);
- mul_m4_v3(ob->obmat, p2);
-
- sub_v3_v3v3(side1, p1, p0);
- sub_v3_v3v3(side2, p2, p0);
- sub_v3_v3v3(side3, p1, p2);
-
- if(dot_v3v3(side1, side1) > fsTri*fsTri)
- {
- float tmp = normalize_v3(side1);
- divs1 = (int)ceil(tmp/fsTri);
- }
- if(dot_v3v3(side2, side2) > fsTri*fsTri)
- {
- float tmp = normalize_v3(side2);
- divs2 = (int)ceil(tmp/fsTri);
- }
+ smd->time = scene->r.cfra;
- (*tridivs)[3 * facecounter + 0] = divs1;
- (*tridivs)[3 * facecounter + 1] = divs2;
- (*tridivs)[3 * facecounter + 2] = divs3;
- }
- facecounter++;
+ return 1;
}
+
+ return 2;
}
#endif /* WITH_SMOKE */
static void smokeModifier_freeDomain(SmokeModifierData *smd)
{
- if(smd->domain)
+ if (smd->domain)
{
- if(smd->domain->shadow)
- MEM_freeN(smd->domain->shadow);
- smd->domain->shadow = NULL;
+ if (smd->domain->shadow)
+ MEM_freeN(smd->domain->shadow);
+ smd->domain->shadow = NULL;
- if(smd->domain->fluid)
+ if (smd->domain->fluid)
smoke_free(smd->domain->fluid);
- if(smd->domain->wt)
+ if (smd->domain->wt)
smoke_turbulence_free(smd->domain->wt);
- if(smd->domain->effector_weights)
- MEM_freeN(smd->domain->effector_weights);
+ if (smd->domain->effector_weights)
+ MEM_freeN(smd->domain->effector_weights);
smd->domain->effector_weights = NULL;
BKE_ptcache_free_list(&(smd->domain->ptcaches[0]));
@@ -748,16 +379,10 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
static void smokeModifier_freeFlow(SmokeModifierData *smd)
{
- if(smd->flow)
+ if (smd->flow)
{
-/*
- if(smd->flow->bvh)
- {
- free_bvhtree_from_mesh(smd->flow->bvh);
- MEM_freeN(smd->flow->bvh);
- }
- smd->flow->bvh = NULL;
-*/
+ if (smd->flow->dm) smd->flow->dm->release(smd->flow->dm);
+ if (smd->flow->verts_old) MEM_freeN(smd->flow->verts_old);
MEM_freeN(smd->flow);
smd->flow = NULL;
}
@@ -765,40 +390,22 @@ static void smokeModifier_freeFlow(SmokeModifierData *smd)
static void smokeModifier_freeCollision(SmokeModifierData *smd)
{
- if(smd->coll)
+ if (smd->coll)
{
SmokeCollSettings *scs = smd->coll;
- if(scs->numpoints)
+ if (scs->numverts)
{
- if(scs->points)
+ if (scs->verts_old)
{
- MEM_freeN(scs->points);
- scs->points = NULL;
- }
- if(scs->points_old)
- {
- MEM_freeN(scs->points_old);
- scs->points_old = NULL;
- }
- if(scs->tridivs)
- {
- MEM_freeN(scs->tridivs);
- scs->tridivs = NULL;
+ MEM_freeN(scs->verts_old);
+ scs->verts_old = NULL;
}
}
- if(scs->bvhtree)
- {
- BLI_bvhtree_free(scs->bvhtree);
- scs->bvhtree = NULL;
- }
-
-#ifdef USE_SMOKE_COLLISION_DM
- if(smd->coll->dm)
+ if (smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = NULL;
-#endif
MEM_freeN(smd->coll);
smd->coll = NULL;
@@ -807,7 +414,7 @@ static void smokeModifier_freeCollision(SmokeModifierData *smd)
void smokeModifier_reset_turbulence(struct SmokeModifierData *smd)
{
- if(smd && smd->domain && smd->domain->wt)
+ if (smd && smd->domain && smd->domain->wt)
{
smoke_turbulence_free(smd->domain->wt);
smd->domain->wt = NULL;
@@ -816,15 +423,15 @@ void smokeModifier_reset_turbulence(struct SmokeModifierData *smd)
void smokeModifier_reset(struct SmokeModifierData *smd)
{
- if(smd)
+ if (smd)
{
- if(smd->domain)
+ if (smd->domain)
{
- if(smd->domain->shadow)
+ if (smd->domain->shadow)
MEM_freeN(smd->domain->shadow);
smd->domain->shadow = NULL;
- if(smd->domain->fluid)
+ if (smd->domain->fluid)
{
smoke_free(smd->domain->fluid);
smd->domain->fluid = NULL;
@@ -833,39 +440,23 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
smokeModifier_reset_turbulence(smd);
smd->time = -1;
-
- // printf("reset domain end\n");
+ smd->domain->total_cells = 0;
+ smd->domain->active_fields = 0;
}
- else if(smd->flow)
+ else if (smd->flow)
{
- /*
- if(smd->flow->bvh)
- {
- free_bvhtree_from_mesh(smd->flow->bvh);
- MEM_freeN(smd->flow->bvh);
- }
- smd->flow->bvh = NULL;
- */
+ if (smd->flow->verts_old) MEM_freeN(smd->flow->verts_old);
+ smd->flow->verts_old = NULL;
+ smd->flow->numverts = 0;
}
- else if(smd->coll)
+ else if (smd->coll)
{
SmokeCollSettings *scs = smd->coll;
- if(scs->numpoints && scs->points)
+ if (scs->numverts && scs->verts_old)
{
- MEM_freeN(scs->points);
- scs->points = NULL;
-
- if(scs->points_old)
- {
- MEM_freeN(scs->points_old);
- scs->points_old = NULL;
- }
- if(scs->tridivs)
- {
- MEM_freeN(scs->tridivs);
- scs->tridivs = NULL;
- }
+ MEM_freeN(scs->verts_old);
+ scs->verts_old = NULL;
}
}
}
@@ -873,7 +464,7 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
void smokeModifier_free(SmokeModifierData *smd)
{
- if(smd)
+ if (smd)
{
smokeModifier_freeDomain(smd);
smokeModifier_freeFlow(smd);
@@ -883,11 +474,11 @@ void smokeModifier_free(SmokeModifierData *smd)
void smokeModifier_createType(struct SmokeModifierData *smd)
{
- if(smd)
+ if (smd)
{
- if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
- if(smd->domain)
+ if (smd->domain)
smokeModifier_freeDomain(smd);
smd->domain = MEM_callocN(sizeof(SmokeDomainSettings), "SmokeDomain");
@@ -903,13 +494,12 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->ptcaches[1].first = smd->domain->ptcaches[1].last = NULL;
/* set some standard values */
smd->domain->fluid = NULL;
- smd->domain->wt = NULL;
+ smd->domain->wt = NULL;
smd->domain->eff_group = NULL;
smd->domain->fluid_group = NULL;
smd->domain->coll_group = NULL;
smd->domain->maxres = 32;
- smd->domain->amplify = 1;
- smd->domain->omega = 1.0;
+ smd->domain->amplify = 1;
smd->domain->alpha = -0.001;
smd->domain->beta = 0.1;
smd->domain->time_scale = 1.0;
@@ -919,14 +509,28 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->strength = 2.0;
smd->domain->noise = MOD_SMOKE_NOISEWAVE;
smd->domain->diss_speed = 5;
- // init 3dview buffer
+ smd->domain->active_fields = 0;
+
+ smd->domain->adapt_margin = 4;
+ smd->domain->adapt_res = 0;
+ smd->domain->adapt_threshold = 0.02f;
+
+ smd->domain->burning_rate = 0.75f;
+ smd->domain->flame_smoke = 1.0f;
+ smd->domain->flame_vorticity = 0.5f;
+ smd->domain->flame_ignition = 1.25f;
+ smd->domain->flame_max_temp = 1.75f;
+ /* color */
+ smd->domain->flame_smoke_color[0] = 0.7f;
+ smd->domain->flame_smoke_color[1] = 0.7f;
+ smd->domain->flame_smoke_color[2] = 0.7f;
smd->domain->viewsettings = MOD_SMOKE_VIEW_SHOWBIG;
smd->domain->effector_weights = BKE_add_effector_weights(NULL);
}
- else if(smd->type & MOD_SMOKE_TYPE_FLOW)
+ else if (smd->type & MOD_SMOKE_TYPE_FLOW)
{
- if(smd->flow)
+ if (smd->flow)
smokeModifier_freeFlow(smd);
smd->flow = MEM_callocN(sizeof(SmokeFlowSettings), "SmokeFlow");
@@ -934,31 +538,35 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->flow->smd = smd;
/* set some standard values */
- smd->flow->density = 1.0;
- smd->flow->temp = 1.0;
+ smd->flow->density = 1.0f;
+ smd->flow->fuel_amount = 1.0f;
+ smd->flow->temp = 1.0f;
smd->flow->flags = MOD_SMOKE_FLOW_ABSOLUTE;
- smd->flow->vel_multi = 1.0;
+ smd->flow->vel_multi = 1.0f;
+ smd->flow->surface_distance = 1.5f;
+ smd->flow->source = MOD_SMOKE_FLOW_SOURCE_MESH;
+ smd->flow->texture_size = 1.0f;
+
+ smd->flow->color[0] = 0.7f;
+ smd->flow->color[1] = 0.7f;
+ smd->flow->color[2] = 0.7f;
+ smd->flow->dm = NULL;
smd->flow->psys = NULL;
}
- else if(smd->type & MOD_SMOKE_TYPE_COLL)
+ else if (smd->type & MOD_SMOKE_TYPE_COLL)
{
- if(smd->coll)
+ if (smd->coll)
smokeModifier_freeCollision(smd);
smd->coll = MEM_callocN(sizeof(SmokeCollSettings), "SmokeColl");
smd->coll->smd = smd;
- smd->coll->points = NULL;
- smd->coll->points_old = NULL;
- smd->coll->tridivs = NULL;
- smd->coll->vel = NULL;
- smd->coll->numpoints = 0;
- smd->coll->numtris = 0;
- smd->coll->bvhtree = NULL;
+ smd->coll->verts_old = NULL;
+ smd->coll->numverts = 0;
smd->coll->type = 0; // static obstacle
- smd->coll->dx = 1.0f / 50.0f;
+ smd->coll->dm = NULL;
#ifdef USE_SMOKE_COLLISION_DM
smd->coll->dm = NULL;
@@ -971,39 +579,67 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
{
tsmd->type = smd->type;
tsmd->time = smd->time;
-
+
smokeModifier_createType(tsmd);
if (tsmd->domain) {
- tsmd->domain->maxres = smd->domain->maxres;
- tsmd->domain->amplify = smd->domain->amplify;
- tsmd->domain->omega = smd->domain->omega;
+ tsmd->domain->fluid_group = smd->domain->fluid_group;
+ tsmd->domain->coll_group = smd->domain->coll_group;
+
+ tsmd->domain->adapt_margin = smd->domain->adapt_margin;
+ tsmd->domain->adapt_res = smd->domain->adapt_res;
+ tsmd->domain->adapt_threshold = smd->domain->adapt_threshold;
+
tsmd->domain->alpha = smd->domain->alpha;
tsmd->domain->beta = smd->domain->beta;
+ tsmd->domain->amplify = smd->domain->amplify;
+ tsmd->domain->maxres = smd->domain->maxres;
tsmd->domain->flags = smd->domain->flags;
- tsmd->domain->strength = smd->domain->strength;
+ tsmd->domain->viewsettings = smd->domain->viewsettings;
tsmd->domain->noise = smd->domain->noise;
tsmd->domain->diss_speed = smd->domain->diss_speed;
- tsmd->domain->viewsettings = smd->domain->viewsettings;
- tsmd->domain->fluid_group = smd->domain->fluid_group;
- tsmd->domain->coll_group = smd->domain->coll_group;
+ tsmd->domain->strength = smd->domain->strength;
+
+ tsmd->domain->border_collisions = smd->domain->border_collisions;
tsmd->domain->vorticity = smd->domain->vorticity;
tsmd->domain->time_scale = smd->domain->time_scale;
- tsmd->domain->border_collisions = smd->domain->border_collisions;
-
+
+ tsmd->domain->burning_rate = smd->domain->burning_rate;
+ tsmd->domain->flame_smoke = smd->domain->flame_smoke;
+ tsmd->domain->flame_vorticity = smd->domain->flame_vorticity;
+ tsmd->domain->flame_ignition = smd->domain->flame_ignition;
+ tsmd->domain->flame_max_temp = smd->domain->flame_max_temp;
+ copy_v3_v3(tsmd->domain->flame_smoke_color, smd->domain->flame_smoke_color);
+
MEM_freeN(tsmd->domain->effector_weights);
tsmd->domain->effector_weights = MEM_dupallocN(smd->domain->effector_weights);
- }
+ }
else if (tsmd->flow) {
+ tsmd->flow->psys = smd->flow->psys;
+ tsmd->flow->noise_texture = smd->flow->noise_texture;
+
+ tsmd->flow->vel_multi = smd->flow->vel_multi;
+ tsmd->flow->vel_normal = smd->flow->vel_normal;
+ tsmd->flow->vel_random = smd->flow->vel_random;
+
tsmd->flow->density = smd->flow->density;
+ copy_v3_v3(tsmd->flow->color, smd->flow->color);
+ tsmd->flow->fuel_amount = smd->flow->fuel_amount;
tsmd->flow->temp = smd->flow->temp;
- tsmd->flow->psys = smd->flow->psys;
+ tsmd->flow->volume_density = smd->flow->volume_density;
+ tsmd->flow->surface_distance = smd->flow->surface_distance;
+
+ tsmd->flow->texture_size = smd->flow->texture_size;
+ tsmd->flow->texture_offset = smd->flow->texture_offset;
+ BLI_strncpy(tsmd->flow->uvlayer_name, tsmd->flow->uvlayer_name, sizeof(tsmd->flow->uvlayer_name));
+ tsmd->flow->vgroup_density = smd->flow->vgroup_density;
+
tsmd->flow->type = smd->flow->type;
+ tsmd->flow->source = smd->flow->source;
+ tsmd->flow->texture_type = smd->flow->texture_type;
tsmd->flow->flags = smd->flow->flags;
- tsmd->flow->vel_multi = smd->flow->vel_multi;
}
else if (tsmd->coll) {
- ;
/* leave it as initialized, collision settings is mostly caches */
}
}
@@ -1011,24 +647,24 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
#ifdef WITH_SMOKE
// forward decleration
-static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct);
+static void smoke_calc_transparency(SmokeDomainSettings *sds, Scene *scene);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
static int get_lamp(Scene *scene, float *light)
-{
- Base *base_tmp = NULL;
+{
+ Base *base_tmp = NULL;
int found_lamp = 0;
// try to find a lamp, preferably local
- for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) {
- if(base_tmp->object->type == OB_LAMP) {
+ for (base_tmp = scene->base.first; base_tmp; base_tmp = base_tmp->next) {
+ if (base_tmp->object->type == OB_LAMP) {
Lamp *la = base_tmp->object->data;
- if(la->type == LA_LOCAL) {
+ if (la->type == LA_LOCAL) {
copy_v3_v3(light, base_tmp->object->obmat[3]);
return 1;
}
- else if(!found_lamp) {
+ else if (!found_lamp) {
copy_v3_v3(light, base_tmp->object->obmat[3]);
found_lamp = 1;
}
@@ -1038,48 +674,131 @@ static int get_lamp(Scene *scene, float *light)
return found_lamp;
}
-static void smoke_calc_domain(Scene *UNUSED(scene), Object *UNUSED(ob), SmokeModifierData *UNUSED(smd))
+static void obstacles_from_derivedmesh(Object *coll_ob, SmokeDomainSettings *sds, SmokeCollSettings *scs, unsigned char *obstacle_map, float *velocityX, float *velocityY, float *velocityZ, float dt)
{
-#if 0
- SmokeDomainSettings *sds = smd->domain;
- GroupObject *go = NULL;
- Base *base = NULL;
-
- /* do collisions, needs to be done before emission, so that smoke isn't emitted inside collision cells */
- if(1)
+ if (!scs->dm) return;
{
- unsigned int i;
- Object **collobjs = NULL;
- unsigned int numcollobj = 0;
- collobjs = get_collisionobjects(scene, ob, sds->coll_group, &numcollobj);
+ DerivedMesh *dm = NULL;
+ MVert *mvert = NULL;
+ MFace *mface = NULL;
+ BVHTreeFromMesh treeData = {0};
+ int numverts, i, z;
+
+ float surface_distance = 0.6;
+
+ float *vert_vel = NULL;
+ int has_velocity = 0;
+
+ tstart();
+
+ dm = CDDM_copy(scs->dm);
+ CDDM_calc_normals(dm);
+ mvert = dm->getVertArray(dm);
+ mface = dm->getTessFaceArray(dm);
+ numverts = dm->getNumVerts(dm);
+
+ // DG TODO
+ // if (scs->type > SM_COLL_STATIC)
+ // if line above is used, the code is in trouble if the object moves but is declared as "does not move"
- for(i = 0; i < numcollobj; i++)
{
- Object *collob= collobjs[i];
- SmokeModifierData *smd2 = (SmokeModifierData*)modifiers_findByType(collob, eModifierType_Smoke);
-
- // check for active smoke modifier
- // if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
- // SmokeModifierData *smd2 = (SmokeModifierData *)md;
-
- if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points && smd2->coll->points_old)
+ vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "smoke_obs_velocity");
+
+ if (scs->numverts != numverts || !scs->verts_old) {
+ if (scs->verts_old) MEM_freeN(scs->verts_old);
+
+ scs->verts_old = MEM_callocN(sizeof(float) * numverts * 3, "smoke_obs_verts_old");
+ scs->numverts = numverts;
+ }
+ else {
+ has_velocity = 1;
+ }
+ }
+
+ /* Transform collider vertices to
+ * domain grid space for fast lookups */
+ for (i = 0; i < numverts; i++) {
+ float n[3];
+ float co[3];
+
+ /* vert pos */
+ mul_m4_v3(coll_ob->obmat, mvert[i].co);
+ smoke_pos_to_cell(sds, mvert[i].co);
+
+ /* vert normal */
+ normal_short_to_float_v3(n, mvert[i].no);
+ mul_mat3_m4_v3(coll_ob->obmat, n);
+ mul_mat3_m4_v3(sds->imat, n);
+ normalize_v3(n);
+ normal_float_to_short_v3(mvert[i].no, n);
+
+ /* vert velocity */
+ VECADD(co, mvert[i].co, sds->shift);
+ if (has_velocity)
{
- // ??? anything to do here?
+ sub_v3_v3v3(&vert_vel[i * 3], co, &scs->verts_old[i * 3]);
+ mul_v3_fl(&vert_vel[i * 3], sds->dx / dt);
+ }
+ copy_v3_v3(&scs->verts_old[i * 3], co);
+ }
+
+ if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6)) {
+ #pragma omp parallel for schedule(static)
+ for (z = sds->res_min[2]; z < sds->res_max[2]; z++) {
+ int x, y;
+ for (x = sds->res_min[0]; x < sds->res_max[0]; x++)
+ for (y = sds->res_min[1]; y < sds->res_max[1]; y++) {
+ int index = smoke_get_index(x - sds->res_min[0], sds->res[0], y - sds->res_min[1], sds->res[1], z - sds->res_min[2]);
+
+ float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f};
+ BVHTreeNearest nearest = {0};
+ nearest.index = -1;
+ nearest.dist = surface_distance * surface_distance; /* find_nearest uses squared distance */
+
+ /* find the nearest point on the mesh */
+ if (BLI_bvhtree_find_nearest(treeData.tree, ray_start, &nearest, treeData.nearest_callback, &treeData) != -1) {
+ float weights[4];
+ int v1, v2, v3, f_index = nearest.index;
+
+ /* calculate barycentric weights for nearest point */
+ v1 = mface[f_index].v1;
+ v2 = (nearest.flags & BVH_ONQUAD) ? mface[f_index].v3 : mface[f_index].v2;
+ v3 = (nearest.flags & BVH_ONQUAD) ? mface[f_index].v4 : mface[f_index].v3;
+ interp_weights_face_v3(weights, mvert[v1].co, mvert[v2].co, mvert[v3].co, NULL, nearest.co);
+
+ // DG TODO
+ if (has_velocity)
+ {
+ /* apply object velocity */
+ {
+ float hit_vel[3];
+ interp_v3_v3v3v3(hit_vel, &vert_vel[v1 * 3], &vert_vel[v2 * 3], &vert_vel[v3 * 3], weights);
+ velocityX[index] += hit_vel[0];
+ velocityY[index] += hit_vel[1];
+ velocityZ[index] += hit_vel[2];
+ }
+ }
- // TODO: only something to do for ANIMATED obstacles: need to update positions
+ /* tag obstacle cells */
+ obstacle_map[index] = 1;
+ if (has_velocity)
+ obstacle_map[index] |= 8;
+ }
+ }
}
}
+ /* free bvh tree */
+ free_bvhtree_from_mesh(&treeData);
+ dm->release(dm);
- if(collobjs)
- MEM_freeN(collobjs);
+ if (vert_vel) MEM_freeN(vert_vel);
}
-
-#endif
}
/* Animated obstacles: dx_step = ((x_new - x_old) / totalsteps) * substep */
-static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt, int substep, int totalsteps)
+static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt,
+ int UNUSED(substep), int UNUSED(totalsteps))
{
Object **collobjs = NULL;
unsigned int numcollobj = 0;
@@ -1092,24 +811,20 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds,
float *velxOrig = smoke_get_velocity_x(sds->fluid);
float *velyOrig = smoke_get_velocity_y(sds->fluid);
float *velzOrig = smoke_get_velocity_z(sds->fluid);
- // float *density = smoke_get_density(sds->fluid);
+ float *density = smoke_get_density(sds->fluid);
+ float *fuel = smoke_get_fuel(sds->fluid);
+ float *flame = smoke_get_flame(sds->fluid);
+ float *r = smoke_get_color_r(sds->fluid);
+ float *g = smoke_get_color_g(sds->fluid);
+ float *b = smoke_get_color_b(sds->fluid);
unsigned int z;
smoke_get_ob_velocity(sds->fluid, &velx, &vely, &velz);
// TODO: delete old obstacle flags
- for(z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
+ for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
{
- if(obstacles[z])
- {
- // density[z] = 0;
-
- velxOrig[z] = 0;
- velyOrig[z] = 0;
- velzOrig[z] = 0;
- }
-
- if(obstacles[z] & 8) // Do not delete static obstacles
+ if (obstacles[z] & 8) // Do not delete static obstacles
{
obstacles[z] = 0;
}
@@ -1119,410 +834,1064 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds,
velz[z] = 0;
}
+
collobjs = get_collisionobjects(scene, ob, sds->coll_group, &numcollobj, eModifierType_Smoke);
// update obstacle tags in cells
- for(collIndex = 0; collIndex < numcollobj; collIndex++)
+ for (collIndex = 0; collIndex < numcollobj; collIndex++)
{
- Object *collob= collobjs[collIndex];
- SmokeModifierData *smd2 = (SmokeModifierData*)modifiers_findByType(collob, eModifierType_Smoke);
+ Object *collob = collobjs[collIndex];
+ SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(collob, eModifierType_Smoke);
// DG TODO: check if modifier is active?
-
- if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points && smd2->coll->points_old)
+
+ if ((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll)
{
SmokeCollSettings *scs = smd2->coll;
- unsigned int i;
+ obstacles_from_derivedmesh(collob, sds, scs, obstacles, velx, vely, velz, dt);
+ }
+ }
+
+ if (collobjs)
+ MEM_freeN(collobjs);
+
+ /* obstacle cells should not contain any velocity from the smoke simulation */
+ for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
+ {
+ if (obstacles[z])
+ {
+ velxOrig[z] = 0;
+ velyOrig[z] = 0;
+ velzOrig[z] = 0;
+ density[z] = 0;
+ if (fuel) {
+ fuel[z] = 0;
+ flame[z] = 0;
+ }
+ if (r) {
+ r[z] = 0;
+ g[z] = 0;
+ b[z] = 0;
+ }
+ }
+ }
+}
- /*
- // DG TODO: support static cobstacles, but basicly we could even support static + rigid with one set of code
- if(scs->type > SM_COLL_STATIC)
- */
- /* Handle collisions */
- for(i = 0; i < scs->numpoints; i++)
+typedef struct EmissionMap {
+ float *influence;
+ float *velocity;
+ int min[3], max[3], res[3];
+ int total_cells, valid;
+} EmissionMap;
+
+static void em_boundInsert(EmissionMap *em, float point[3])
+{
+ int i = 0;
+ if (!em->valid) {
+ VECCOPY(em->min, point);
+ VECCOPY(em->max, point);
+ em->valid = 1;
+ }
+ else {
+ for (; i < 3; i++) {
+ if (point[i] < em->min[i]) em->min[i] = (int)floor(point[i]);
+ if (point[i] > em->max[i]) em->max[i] = (int)ceil(point[i]);
+ }
+ }
+}
+
+static void clampBoundsInDomain(SmokeDomainSettings *sds, int min[3], int max[3], float *min_vel, float *max_vel, int margin, float dt)
+{
+ int i;
+ for (i = 0; i < 3; i++) {
+ int adapt = (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) ? sds->adapt_res : 0;
+ /* add margin */
+ min[i] -= margin;
+ max[i] += margin;
+
+ /* adapt to velocity */
+ if (min_vel && min_vel[i] < 0.0f) {
+ min[i] += (int)ceil(min_vel[i] * dt);
+ }
+ if (max_vel && max_vel[i] > 0.0f) {
+ max[i] += (int)ceil(max_vel[i] * dt);
+ }
+
+ /* clamp within domain max size */
+ CLAMP(min[i], -adapt, sds->base_res[i] + adapt);
+ CLAMP(max[i], -adapt, sds->base_res[i] + adapt);
+ }
+}
+
+static void em_allocateData(EmissionMap *em, int use_velocity) {
+ int i, res[3];
+
+ for (i = 0; i < 3; i++) {
+ res[i] = em->max[i] - em->min[i];
+ if (res[i] <= 0)
+ return;
+ }
+ em->total_cells = res[0] * res[1] * res[2];
+ copy_v3_v3_int(em->res, res);
+
+
+ em->influence = MEM_callocN(sizeof(float) * em->total_cells, "smoke_flow_influence");
+ if (use_velocity)
+ em->velocity = MEM_callocN(sizeof(float) * em->total_cells * 3, "smoke_flow_velocity");
+}
+
+static void em_freeData(EmissionMap *em) {
+ if (em->influence)
+ MEM_freeN(em->influence);
+ if (em->velocity)
+ MEM_freeN(em->velocity);
+}
+
+
+static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, SmokeFlowSettings *sfs, EmissionMap *em, Scene *scene, float time, float dt)
+{
+ if (sfs && sfs->psys && sfs->psys->part && ELEM(sfs->psys->part->type, PART_EMITTER, PART_FLUID)) // is particle system selected
+ {
+ ParticleSimulationData sim;
+ ParticleSystem *psys = sfs->psys;
+ float *particle_pos;
+ float *particle_vel;
+ int totpart = psys->totpart, totchild;
+ int p = 0;
+ int valid_particles = 0;
+
+ sim.scene = scene;
+ sim.ob = flow_ob;
+ sim.psys = psys;
+
+ if (psys->part->type == PART_HAIR)
+ {
+ // TODO: PART_HAIR not supported whatsoever
+ totchild = 0;
+ }
+ else
+ totchild = psys->totchild * psys->part->disp / 100;
+
+ particle_pos = MEM_callocN(sizeof(float) * (totpart + totchild) * 3, "smoke_flow_particles");
+ particle_vel = MEM_callocN(sizeof(float) * (totpart + totchild) * 3, "smoke_flow_particles");
+
+ /* calculate local position for each particle */
+ for (p = 0; p < totpart + totchild; p++)
+ {
+ ParticleKey state;
+ float *pos;
+ if (p < totpart) {
+ if (psys->particles[p].flag & (PARS_NO_DISP | PARS_UNEXIST))
+ continue;
+ }
+ else {
+ /* handle child particle */
+ ChildParticle *cpa = &psys->child[p - totpart];
+ if (psys->particles[cpa->parent].flag & (PARS_NO_DISP | PARS_UNEXIST))
+ continue;
+ }
+
+ state.time = time;
+ if (psys_get_particle_state(&sim, p, &state, 0) == 0)
+ continue;
+
+ /* location */
+ pos = &particle_pos[valid_particles * 3];
+ copy_v3_v3(pos, state.co);
+ smoke_pos_to_cell(sds, pos);
+
+ /* velocity */
+ copy_v3_v3(&particle_vel[valid_particles * 3], state.vel);
+ mul_mat3_m4_v3(sds->imat, &particle_vel[valid_particles * 3]);
+
+ /* calculate emission map bounds */
+ em_boundInsert(em, pos);
+ valid_particles++;
+ }
+
+ /* set emission map */
+ clampBoundsInDomain(sds, em->min, em->max, NULL, NULL, 1, dt);
+ em_allocateData(em, sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY);
+
+ for (p = 0; p < valid_particles; p++)
+ {
+ int cell[3];
+ size_t i = 0;
+ size_t index = 0;
+ int badcell = 0;
+
+ /* 1. get corresponding cell */
+ cell[0] = floor(particle_pos[p * 3]) - em->min[0];
+ cell[1] = floor(particle_pos[p * 3 + 1]) - em->min[1];
+ cell[2] = floor(particle_pos[p * 3 + 2]) - em->min[2];
+ /* check if cell is valid (in the domain boundary) */
+ for (i = 0; i < 3; i++) {
+ if ((cell[i] > em->res[i] - 1) || (cell[i] < 0)) {
+ badcell = 1;
+ break;
+ }
+ }
+ if (badcell)
+ continue;
+ /* get cell index */
+ index = smoke_get_index(cell[0], em->res[0], cell[1], em->res[1], cell[2]);
+ /* Add influence to emission map */
+ em->influence[index] = 1.0f;
+ /* Uses particle velocity as initial velocity for smoke */
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO))
{
- // 1. get corresponding cell
- int cell[3];
- float pos[3], oldpos[3], vel[3];
- float cPos[3], cOldpos[3]; /* current position in substeps */
- int badcell = 0;
- size_t index;
- int j;
-
- // translate local points into global positions
- copy_v3_v3(cPos, &scs->points[3 * i]);
- mul_m4_v3(scs->mat, cPos);
- copy_v3_v3(pos, cPos);
-
- copy_v3_v3(cOldpos, &scs->points_old[3 * i]);
- mul_m4_v3(scs->mat_old, cOldpos);
- copy_v3_v3(oldpos, cOldpos);
-
- /* support for rigid bodies, armatures etc */
- {
- float tmp[3];
+ VECADDFAC(&em->velocity[index * 3], &em->velocity[index * 3], &particle_vel[p * 3], sfs->vel_multi);
+ }
+ } // particles loop
+
+ /* free data */
+ if (particle_pos)
+ MEM_freeN(particle_pos);
+ if (particle_vel)
+ MEM_freeN(particle_vel);
+ }
+}
+
+static void get_texture_value(Tex *texture, float tex_co[3], TexResult *texres)
+{
+ int result_type;
- /* x_current = x_old + (x_new - x_old) * step_current / steps_total */
- float mulStep = (float)(((float)substep) / ((float)totalsteps));
+ /* no node textures for now */
+ result_type = multitex_ext_safe(texture, tex_co, texres);
+
+ /* if the texture gave an RGB value, we assume it didn't give a valid
+ * intensity, since this is in the context of modifiers don't use perceptual color conversion.
+ * if the texture didn't give an RGB value, copy the intensity across
+ */
+ if (result_type & TEX_RGB) {
+ texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
+ }
+ else {
+ copy_v3_fl(&texres->tr, texres->tin);
+ }
+}
+
+static void emit_from_derivedmesh(Object *flow_ob, SmokeDomainSettings *sds, SmokeFlowSettings *sfs, EmissionMap *em, float dt)
+{
+ if (!sfs->dm) return;
+ {
+ DerivedMesh *dm = sfs->dm;
+ int defgrp_index = sfs->vgroup_density - 1;
+ MDeformVert *dvert = NULL;
+ MVert *mvert = NULL;
+ MVert *mvert_orig = NULL;
+ MFace *mface = NULL;
+ MTFace *tface = NULL;
+ BVHTreeFromMesh treeData = {0};
+ int numOfVerts, i, z;
+ float flow_center[3] = {0};
+
+ float *vert_vel = NULL;
+ int has_velocity = 0;
+
+ CDDM_calc_normals(dm);
+ mvert = dm->getVertArray(dm);
+ mvert_orig = dm->dupVertArray(dm); /* copy original mvert and restore when done */
+ mface = dm->getTessFaceArray(dm);
+ numOfVerts = dm->getNumVerts(dm);
+ dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+ tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, sfs->uvlayer_name);
+
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
+ vert_vel = MEM_callocN(sizeof(float) * numOfVerts * 3, "smoke_flow_velocity");
+
+ if (sfs->numverts != numOfVerts || !sfs->verts_old) {
+ if (sfs->verts_old) MEM_freeN(sfs->verts_old);
+ sfs->verts_old = MEM_callocN(sizeof(float) * numOfVerts * 3, "smoke_flow_verts_old");
+ sfs->numverts = numOfVerts;
+ }
+ else {
+ has_velocity = 1;
+ }
+ }
- sub_v3_v3v3(tmp, cPos, cOldpos);
- mul_v3_fl(tmp, mulStep);
- add_v3_v3(cOldpos, tmp);
+ /* Transform dm vertices to
+ * domain grid space for fast lookups */
+ for (i = 0; i < numOfVerts; i++) {
+ float n[3];
+ /* vert pos */
+ mul_m4_v3(flow_ob->obmat, mvert[i].co);
+ smoke_pos_to_cell(sds, mvert[i].co);
+ /* vert normal */
+ normal_short_to_float_v3(n, mvert[i].no);
+ mul_mat3_m4_v3(flow_ob->obmat, n);
+ mul_mat3_m4_v3(sds->imat, n);
+ normalize_v3(n);
+ normal_float_to_short_v3(mvert[i].no, n);
+ /* vert velocity */
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
+ float co[3];
+ VECADD(co, mvert[i].co, sds->shift);
+ if (has_velocity) {
+ sub_v3_v3v3(&vert_vel[i * 3], co, &sfs->verts_old[i * 3]);
+ mul_v3_fl(&vert_vel[i * 3], sds->dx / dt);
}
+ copy_v3_v3(&sfs->verts_old[i * 3], co);
+ }
- sub_v3_v3v3(vel, pos, oldpos);
- /* Scale velocity to incorperate the object movement during this step */
- mul_v3_fl(vel, 1.0 / (totalsteps * dt * sds->scale));
- // mul_v3_fl(vel, 1.0 / dt);
+ /* calculate emission map bounds */
+ em_boundInsert(em, mvert[i].co);
+ }
+ mul_m4_v3(flow_ob->obmat, flow_center);
+ smoke_pos_to_cell(sds, flow_center);
+
+ /* set emission map */
+ clampBoundsInDomain(sds, em->min, em->max, NULL, NULL, sfs->surface_distance, dt);
+ em_allocateData(em, sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY);
+
+ if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6)) {
+ #pragma omp parallel for schedule(static)
+ for (z = em->min[2]; z < em->max[2]; z++) {
+ int x, y;
+ for (x = em->min[0]; x < em->max[0]; x++)
+ for (y = em->min[1]; y < em->max[1]; y++) {
+ int index = smoke_get_index(x - em->min[0], em->res[0], y - em->min[1], em->res[1], z - em->min[2]);
+
+ float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f};
+ float ray_dir[3] = {1.0f, 0.0f, 0.0f};
+
+ BVHTreeRayHit hit = {0};
+ BVHTreeNearest nearest = {0};
+
+ float volume_factor = 0.0f;
+ float sample_str = 0.0f;
+
+ hit.index = -1;
+ hit.dist = 9999;
+ nearest.index = -1;
+ nearest.dist = sfs->surface_distance * sfs->surface_distance; /* find_nearest uses squared distance */
+
+ /* Check volume collision */
+ if (sfs->volume_density) {
+ if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) {
+ float dot = ray_dir[0] * hit.no[0] + ray_dir[1] * hit.no[1] + ray_dir[2] * hit.no[2];
+ /* If ray and hit face normal are facing same direction
+ * hit point is inside a closed mesh. */
+ if (dot >= 0) {
+ /* Also cast a ray in opposite direction to make sure
+ * point is at least surrounded by two faces */
+ negate_v3(ray_dir);
+ hit.index = -1;
+ hit.dist = 9999;
+
+ BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, treeData.raycast_callback, &treeData);
+ if (hit.index != -1) {
+ volume_factor = sfs->volume_density;
+ nearest.dist = hit.dist * hit.dist;
+ }
+ }
+ }
+ }
- // DG TODO: cap velocity to maxVelMag (or maxvel)
+ /* find the nearest point on the mesh */
+ if (BLI_bvhtree_find_nearest(treeData.tree, ray_start, &nearest, treeData.nearest_callback, &treeData) != -1) {
+ float weights[4];
+ int v1, v2, v3, f_index = nearest.index;
+ float n1[3], n2[3], n3[3], hit_normal[3];
+
+ /* emit from surface based on distance */
+ if (sfs->surface_distance) {
+ sample_str = sqrtf(nearest.dist) / sfs->surface_distance;
+ CLAMP(sample_str, 0.0f, 1.0f);
+ sample_str = pow(1.0f - sample_str, 0.5f);
+ }
+ else
+ sample_str = 0.0f;
+
+ /* calculate barycentric weights for nearest point */
+ v1 = mface[f_index].v1;
+ v2 = (nearest.flags & BVH_ONQUAD) ? mface[f_index].v3 : mface[f_index].v2;
+ v3 = (nearest.flags & BVH_ONQUAD) ? mface[f_index].v4 : mface[f_index].v3;
+ interp_weights_face_v3(weights, mvert[v1].co, mvert[v2].co, mvert[v3].co, NULL, nearest.co);
+
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
+ /* apply normal directional velocity */
+ if (sfs->vel_normal) {
+ /* interpolate vertex normal vectors to get nearest point normal */
+ normal_short_to_float_v3(n1, mvert[v1].no);
+ normal_short_to_float_v3(n2, mvert[v2].no);
+ normal_short_to_float_v3(n3, mvert[v3].no);
+ interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
+ normalize_v3(hit_normal);
+ /* apply normal directional and random velocity
+ * - TODO: random disabled for now since it doesnt really work well as pressure calc smoothens it out... */
+ em->velocity[index * 3] += hit_normal[0] * sfs->vel_normal * 0.25f;
+ em->velocity[index * 3 + 1] += hit_normal[1] * sfs->vel_normal * 0.25f;
+ em->velocity[index * 3 + 2] += hit_normal[2] * sfs->vel_normal * 0.25f;
+ /* TODO: for fire emitted from mesh surface we can use
+ * Vf = Vs + (Ps/Pf - 1)*S to model gaseous expansion from solid to fuel */
+ }
+ /* apply object velocity */
+ if (has_velocity && sfs->vel_multi) {
+ float hit_vel[3];
+ interp_v3_v3v3v3(hit_vel, &vert_vel[v1 * 3], &vert_vel[v2 * 3], &vert_vel[v3 * 3], weights);
+ em->velocity[index * 3] += hit_vel[0] * sfs->vel_multi;
+ em->velocity[index * 3 + 1] += hit_vel[1] * sfs->vel_multi;
+ em->velocity[index * 3 + 2] += hit_vel[2] * sfs->vel_multi;
+ }
+ }
+
+ /* apply vertex group influence if used */
+ if (defgrp_index != -1 && dvert) {
+ float weight_mask = defvert_find_weight(&dvert[v1], defgrp_index) * weights[0] +
+ defvert_find_weight(&dvert[v2], defgrp_index) * weights[1] +
+ defvert_find_weight(&dvert[v3], defgrp_index) * weights[2];
+ sample_str *= weight_mask;
+ }
+
+ /* apply emission texture */
+ if ((sfs->flags & MOD_SMOKE_FLOW_TEXTUREEMIT) && sfs->noise_texture) {
+ float tex_co[3] = {0};
+ TexResult texres;
+
+ if (sfs->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_AUTO) {
+ tex_co[0] = ((float)(x - flow_center[0]) / sds->base_res[0]) / sfs->texture_size;
+ tex_co[1] = ((float)(y - flow_center[1]) / sds->base_res[1]) / sfs->texture_size;
+ tex_co[2] = ((float)(z - flow_center[2]) / sds->base_res[2] - sfs->texture_offset) / sfs->texture_size;
+ }
+ else if (tface) {
+ interp_v2_v2v2v2(tex_co, tface[f_index].uv[0], tface[f_index].uv[(nearest.flags & BVH_ONQUAD) ? 2 : 1],
+ tface[f_index].uv[(nearest.flags & BVH_ONQUAD) ? 3 : 2], weights);
+ /* map between -1.0f and 1.0f */
+ tex_co[0] = tex_co[0] * 2.0f - 1.0f;
+ tex_co[1] = tex_co[1] * 2.0f - 1.0f;
+ tex_co[2] = sfs->texture_offset;
+ }
+ texres.nor = NULL;
+ get_texture_value(sfs->noise_texture, tex_co, &texres);
+ sample_str *= texres.tin;
+ }
+ }
- // oldpos + velocity * dt = newpos
- get_cell(sds->p0, sds->res, sds->dx*sds->scale, cOldpos /* use current position here instead of "pos" */, cell, 0);
+ /* multiply initial velocity by emitter influence */
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
+ mul_v3_fl(&em->velocity[index * 3], sample_str);
+ }
- // check if cell is valid (in the domain boundary)
- for(j = 0; j < 3; j++)
- if((cell[j] > sds->res[j] - 1) || (cell[j] < 0))
- {
- badcell = 1;
- break;
+ /* apply final influence based on volume factor */
+ em->influence[index] = MAX2(volume_factor, sample_str);
}
-
- if(badcell)
- continue;
+ }
+ }
+ /* free bvh tree */
+ free_bvhtree_from_mesh(&treeData);
+ /* restore original mverts */
+ CustomData_set_layer(&dm->vertData, CD_MVERT, mvert_orig);
+ if (mvert)
+ MEM_freeN(mvert);
+
+ if (vert_vel) MEM_freeN(vert_vel);
+ }
+}
- // 2. set cell values (heat, density and velocity)
- index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
+static void adjustDomainResolution(SmokeDomainSettings *sds, int new_shift[3], EmissionMap *emaps, unsigned int numflowobj, float dt)
+{
+ int min[3] = {32767, 32767, 32767}, max[3] = {-32767, -32767, -32767}, res[3];
+ int total_cells = 1, res_changed = 0, shift_changed = 0;
+ float min_vel[3], max_vel[3];
+ int x, y, z, i;
+ float *density = smoke_get_density(sds->fluid);
+ float *fuel = smoke_get_fuel(sds->fluid);
+ float *vx = smoke_get_velocity_x(sds->fluid);
+ float *vy = smoke_get_velocity_y(sds->fluid);
+ float *vz = smoke_get_velocity_z(sds->fluid);
+
+ INIT_MINMAX(min_vel, max_vel);
+
+ /* Calculate bounds for current domain content */
+ for (x = sds->res_min[0]; x < sds->res_max[0]; x++)
+ for (y = sds->res_min[1]; y < sds->res_max[1]; y++)
+ for (z = sds->res_min[2]; z < sds->res_max[2]; z++)
+ {
+ int xn = x - new_shift[0];
+ int yn = y - new_shift[1];
+ int zn = z - new_shift[2];
+ int index = smoke_get_index(x - sds->res_min[0], sds->res[0], y - sds->res_min[1], sds->res[1], z - sds->res_min[2]);
+ float max_den = (fuel) ? MAX2(density[index], fuel[index]) : density[index];
+
+ /* content bounds (use shifted coordinates) */
+ if (max_den >= sds->adapt_threshold) {
+ if (min[0] > xn) min[0] = xn;
+ if (min[1] > yn) min[1] = yn;
+ if (min[2] > zn) min[2] = zn;
+ if (max[0] < xn) max[0] = xn;
+ if (max[1] < yn) max[1] = yn;
+ if (max[2] < zn) max[2] = zn;
+ }
+ /* velocity bounds */
+ if (min_vel[0] > vx[index]) min_vel[0] = vx[index];
+ if (min_vel[1] > vy[index]) min_vel[1] = vy[index];
+ if (min_vel[2] > vz[index]) min_vel[2] = vz[index];
+ if (max_vel[0] < vx[index]) max_vel[0] = vx[index];
+ if (max_vel[1] < vy[index]) max_vel[1] = vy[index];
+ if (max_vel[2] < vz[index]) max_vel[2] = vz[index];
+ }
- // Don't overwrite existing obstacles
- if(obstacles[index])
- continue;
-
- // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]);
- // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index);
- obstacles[index] = 1 | 8 /* ANIMATED */;
+ /* also apply emission maps */
+ for (i = 0; i < numflowobj; i++)
+ {
+ EmissionMap *em = &emaps[i];
- if(len_v3(vel) > FLT_EPSILON)
+ for (x = em->min[0]; x < em->max[0]; x++)
+ for (y = em->min[1]; y < em->max[1]; y++)
+ for (z = em->min[2]; z < em->max[2]; z++)
{
- // Collision object is moving
-
- velx[index] = vel[0]; // use "+="?
- vely[index] = vel[1];
- velz[index] = vel[2];
+ int index = smoke_get_index(x - em->min[0], em->res[0], y - em->min[1], em->res[1], z - em->min[2]);
+ float max_den = em->influence[index];
+
+ /* density bounds */
+ if (max_den >= sds->adapt_threshold) {
+ if (min[0] > x) min[0] = x;
+ if (min[1] > y) min[1] = y;
+ if (min[2] > z) min[2] = z;
+ if (max[0] < x) max[0] = x;
+ if (max[1] < y) max[1] = y;
+ if (max[2] < z) max[2] = z;
+ }
+ /* velocity bounds */
+ if (em->velocity) {
+ if (min_vel[0] > em->velocity[index * 3]) min_vel[0] = em->velocity[index * 3];
+ if (min_vel[1] > em->velocity[index * 3 + 1]) min_vel[1] = em->velocity[index * 3 + 1];
+ if (min_vel[2] > em->velocity[index * 3 + 2]) min_vel[2] = em->velocity[index * 3 + 2];
+ if (max_vel[0] < em->velocity[index * 3]) max_vel[0] = em->velocity[index * 3];
+ if (max_vel[1] < em->velocity[index * 3 + 1]) max_vel[1] = em->velocity[index * 3 + 1];
+ if (max_vel[2] < em->velocity[index * 3 + 2]) max_vel[2] = em->velocity[index * 3 + 2];
+ }
}
+ }
+
+ /* calculate new bounds based on these values */
+ clampBoundsInDomain(sds, min, max, min_vel, max_vel, sds->adapt_margin + 1, dt);
+
+ for (i = 0; i < 3; i++) {
+ /* calculate new resolution */
+ res[i] = max[i] - min[i];
+ total_cells *= res[i];
+
+ if (new_shift[i])
+ shift_changed = 1;
+
+ /* if no content set minimum dimensions */
+ if (res[i] <= 0) {
+ int j;
+ for (j = 0; j < 3; j++) {
+ min[j] = 0;
+ max[j] = 1;
+ res[j] = 1;
}
+ res_changed = 1;
+ total_cells = 1;
+ break;
}
+ if (min[i] != sds->res_min[i] || max[i] != sds->res_max[i])
+ res_changed = 1;
}
- if(collobjs)
- MEM_freeN(collobjs);
+ if (res_changed || shift_changed) {
+ struct FLUID_3D *fluid_old = sds->fluid;
+ struct WTURBULENCE *turb_old = sds->wt;
+ /* allocate new fluid data */
+ smoke_reallocate_fluid(sds, sds->dx, res, 0);
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ smoke_reallocate_highres_fluid(sds, sds->dx, res, 0);
+ }
+
+ /* copy values from old fluid to new */
+ if (sds->total_cells > 1 && total_cells > 1) {
+ /* low res smoke */
+ float *o_dens, *o_react, *o_flame, *o_fuel, *o_heat, *o_heatold, *o_vx, *o_vy, *o_vz, *o_r, *o_g, *o_b;
+ float *n_dens, *n_react, *n_flame, *n_fuel, *n_heat, *n_heatold, *n_vx, *n_vy, *n_vz, *n_r, *n_g, *n_b;
+ float dummy;
+ unsigned char *dummy_p;
+ /* high res smoke */
+ int wt_res_old[3];
+ float *o_wt_dens, *o_wt_react, *o_wt_flame, *o_wt_fuel, *o_wt_tcu, *o_wt_tcv, *o_wt_tcw, *o_wt_r, *o_wt_g, *o_wt_b;
+ float *n_wt_dens, *n_wt_react, *n_wt_flame, *n_wt_fuel, *n_wt_tcu, *n_wt_tcv, *n_wt_tcw, *n_wt_r, *n_wt_g, *n_wt_b;
+
+ smoke_export(fluid_old, &dummy, &dummy, &o_dens, &o_react, &o_flame, &o_fuel, &o_heat, &o_heatold, &o_vx, &o_vy, &o_vz, &o_r, &o_g, &o_b, &dummy_p);
+ smoke_export(sds->fluid, &dummy, &dummy, &n_dens, &n_react, &n_flame, &n_fuel, &n_heat, &n_heatold, &n_vx, &n_vy, &n_vz, &n_r, &n_g, &n_b, &dummy_p);
+
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ smoke_turbulence_export(turb_old, &o_wt_dens, &o_wt_react, &o_wt_flame, &o_wt_fuel, &o_wt_r, &o_wt_g, &o_wt_b, &o_wt_tcu, &o_wt_tcv, &o_wt_tcw);
+ smoke_turbulence_get_res(turb_old, wt_res_old);
+ smoke_turbulence_export(sds->wt, &n_wt_dens, &n_wt_react, &n_wt_flame, &n_wt_fuel, &n_wt_r, &n_wt_g, &n_wt_b, &n_wt_tcu, &n_wt_tcv, &n_wt_tcw);
+ }
+
+
+ for (x = sds->res_min[0]; x < sds->res_max[0]; x++)
+ for (y = sds->res_min[1]; y < sds->res_max[1]; y++)
+ for (z = sds->res_min[2]; z < sds->res_max[2]; z++)
+ {
+ /* old grid index */
+ int xo = x - sds->res_min[0];
+ int yo = y - sds->res_min[1];
+ int zo = z - sds->res_min[2];
+ int index_old = smoke_get_index(xo, sds->res[0], yo, sds->res[1], zo);
+ /* new grid index */
+ int xn = x - min[0] - new_shift[0];
+ int yn = y - min[1] - new_shift[1];
+ int zn = z - min[2] - new_shift[2];
+ int index_new = smoke_get_index(xn, res[0], yn, res[1], zn);
+
+ /* skip if outside new domain */
+ if (xn < 0 || xn >= res[0] ||
+ yn < 0 || yn >= res[1] ||
+ zn < 0 || zn >= res[2])
+ continue;
+
+ /* copy data */
+ n_dens[index_new] = o_dens[index_old];
+ /* heat */
+ if (n_heat && o_heat) {
+ n_heat[index_new] = o_heat[index_old];
+ n_heatold[index_new] = o_heatold[index_old];
+ }
+ /* fuel */
+ if (n_fuel && o_fuel) {
+ n_flame[index_new] = o_flame[index_old];
+ n_fuel[index_new] = o_fuel[index_old];
+ n_react[index_new] = o_react[index_old];
+ }
+ /* color */
+ if (o_r && n_r) {
+ n_r[index_new] = o_r[index_old];
+ n_g[index_new] = o_g[index_old];
+ n_b[index_new] = o_b[index_old];
+ }
+ n_vx[index_new] = o_vx[index_old];
+ n_vy[index_new] = o_vy[index_old];
+ n_vz[index_new] = o_vz[index_old];
+
+ if (sds->flags & MOD_SMOKE_HIGHRES && turb_old) {
+ int block_size = sds->amplify + 1;
+ int i, j, k;
+ /* old grid index */
+ int xx_o = xo * block_size;
+ int yy_o = yo * block_size;
+ int zz_o = zo * block_size;
+ /* new grid index */
+ int xx_n = xn * block_size;
+ int yy_n = yn * block_size;
+ int zz_n = zn * block_size;
+
+ n_wt_tcu[index_new] = o_wt_tcu[index_old];
+ n_wt_tcv[index_new] = o_wt_tcv[index_old];
+ n_wt_tcw[index_new] = o_wt_tcw[index_old];
+
+ for (i = 0; i < block_size; i++)
+ for (j = 0; j < block_size; j++)
+ for (k = 0; k < block_size; k++)
+ {
+ int big_index_old = smoke_get_index(xx_o + i, wt_res_old[0], yy_o + j, wt_res_old[1], zz_o + k);
+ int big_index_new = smoke_get_index(xx_n + i, sds->res_wt[0], yy_n + j, sds->res_wt[1], zz_n + k);
+ /* copy data */
+ n_wt_dens[big_index_new] = o_wt_dens[big_index_old];
+ if (n_wt_flame && o_wt_flame) {
+ n_wt_flame[big_index_new] = o_wt_flame[big_index_old];
+ n_wt_fuel[big_index_new] = o_wt_fuel[big_index_old];
+ n_wt_react[big_index_new] = o_wt_react[big_index_old];
+ }
+ if (n_wt_r && o_wt_r) {
+ n_wt_r[big_index_new] = o_wt_r[big_index_old];
+ n_wt_g[big_index_new] = o_wt_g[big_index_old];
+ n_wt_b[big_index_new] = o_wt_b[big_index_old];
+ }
+ }
+ }
+ }
+ }
+ smoke_free(fluid_old);
+ if (turb_old)
+ smoke_turbulence_free(turb_old);
+
+ /* set new domain dimensions */
+ VECCOPY(sds->res_min, min);
+ VECCOPY(sds->res_max, max);
+ VECCOPY(sds->res, res);
+ sds->total_cells = total_cells;
+ }
+}
+
+BLI_INLINE void apply_outflow_fields(int index, float *density, float *heat, float *fuel, float *react, float *color_r, float *color_g, float *color_b)
+{
+ density[index] = 0.f;
+ if (heat) {
+ heat[index] = 0.f;
+ }
+ if (fuel) {
+ fuel[index] = 0.f;
+ react[index] = 0.f;
+ }
+ if (color_r) {
+ color_r[index] = 0.f;
+ color_g[index] = 0.f;
+ color_b[index] = 0.f;
+ }
+}
+
+BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value, int index, float *density, float *heat, float *fuel, float *react, float *color_r, float *color_g, float *color_b)
+{
+ int absolute_flow = (sfs->flags & MOD_SMOKE_FLOW_ABSOLUTE);
+ float dens_old = density[index];
+ // float fuel_old = (fuel) ? fuel[index] : 0.0f; /* UNUSED */
+ float dens_flow = (sfs->type == MOD_SMOKE_FLOW_TYPE_FIRE) ? 0.0f : emission_value * sfs->density;
+ float fuel_flow = emission_value * sfs->fuel_amount;
+ /* add heat */
+ if (heat) {
+ heat[index] = MAX2(emission_value * sfs->temp, heat[index]);
+ }
+ /* absolute */
+ if (absolute_flow) {
+ if (sfs->type != MOD_SMOKE_FLOW_TYPE_FIRE) {
+ if (dens_flow > density[index])
+ density[index] = dens_flow;
+ }
+ if (sfs->type != MOD_SMOKE_FLOW_TYPE_SMOKE && fuel && fuel_flow) {
+ if (fuel_flow > fuel[index])
+ fuel[index] = fuel_flow;
+ }
+ }
+ /* additive */
+ else {
+ if (sfs->type != MOD_SMOKE_FLOW_TYPE_FIRE) {
+ density[index] += dens_flow;
+ CLAMP(density[index], 0.0f, 1.0f);
+ }
+ if (sfs->type != MOD_SMOKE_FLOW_TYPE_SMOKE && fuel && sfs->fuel_amount) {
+ fuel[index] += fuel_flow;
+ CLAMP(fuel[index], 0.0f, 10.0f);
+ }
+ }
+
+ /* set color */
+ if (color_r && dens_flow) {
+ float total_dens = density[index] / (dens_old + dens_flow);
+ color_r[index] = (color_r[index] + sfs->color[0] * dens_flow) * total_dens;
+ color_g[index] = (color_g[index] + sfs->color[1] * dens_flow) * total_dens;
+ color_b[index] = (color_b[index] + sfs->color[2] * dens_flow) * total_dens;
+ }
+
+ /* set fire reaction coordinate */
+ if (fuel && fuel[index]) {
+ /* instead of using 1.0 for all new fuel add slight falloff
+ * to reduce flow blockiness */
+ float value = 1.0f - powf(1.0f - emission_value, 2.0f);
+
+ if (value > react[index]) {
+ float f = fuel_flow / fuel[index];
+ react[index] = value * f + (1.0f - f) * react[index];
+ }
+ }
}
-static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float time)
+static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float time, float dt)
{
Object **flowobjs = NULL;
+ EmissionMap *emaps = NULL;
unsigned int numflowobj = 0;
unsigned int flowIndex;
+ int new_shift[3] = {0};
+ int active_fields = sds->active_fields;
+
+ /* calculate domain shift for current frame if using adaptive domain */
+ if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
+ int total_shift[3];
+ float frame_shift_f[3];
+ float ob_loc[3] = {0};
+
+ mul_m4_v3(ob->obmat, ob_loc);
+
+ VECSUB(frame_shift_f, ob_loc, sds->prev_loc);
+ copy_v3_v3(sds->prev_loc, ob_loc);
+ /* convert global space shift to local "cell" space */
+ mul_mat3_m4_v3(sds->imat, frame_shift_f);
+ frame_shift_f[0] = frame_shift_f[0] / sds->cell_size[0];
+ frame_shift_f[1] = frame_shift_f[1] / sds->cell_size[1];
+ frame_shift_f[2] = frame_shift_f[2] / sds->cell_size[2];
+ /* add to total shift */
+ VECADD(sds->shift_f, sds->shift_f, frame_shift_f);
+ /* convert to integer */
+ total_shift[0] = floor(sds->shift_f[0]);
+ total_shift[1] = floor(sds->shift_f[1]);
+ total_shift[2] = floor(sds->shift_f[2]);
+ VECSUB(new_shift, total_shift, sds->shift);
+ copy_v3_v3_int(sds->shift, total_shift);
+
+ /* calculate new domain boundary points so that smoke doesnt slide on sub-cell movement */
+ sds->p0[0] = sds->dp0[0] - sds->cell_size[0] * (sds->shift_f[0] - total_shift[0] - 0.5f);
+ sds->p0[1] = sds->dp0[1] - sds->cell_size[1] * (sds->shift_f[1] - total_shift[1] - 0.5f);
+ sds->p0[2] = sds->dp0[2] - sds->cell_size[2] * (sds->shift_f[2] - total_shift[2] - 0.5f);
+ sds->p1[0] = sds->p0[0] + sds->cell_size[0] * sds->base_res[0];
+ sds->p1[1] = sds->p0[1] + sds->cell_size[1] * sds->base_res[1];
+ sds->p1[2] = sds->p0[2] + sds->cell_size[2] * sds->base_res[2];
+ }
flowobjs = get_collisionobjects(scene, ob, sds->fluid_group, &numflowobj, eModifierType_Smoke);
- // update obstacle tags in cells
- for(flowIndex = 0; flowIndex < numflowobj; flowIndex++)
+ /* init emission maps for each flow */
+ emaps = MEM_callocN(sizeof(struct EmissionMap) * numflowobj, "smoke_flow_maps");
+
+ /* Prepare flow emission maps */
+ for (flowIndex = 0; flowIndex < numflowobj; flowIndex++)
{
- Object *collob= flowobjs[flowIndex];
- SmokeModifierData *smd2 = (SmokeModifierData*)modifiers_findByType(collob, eModifierType_Smoke);
+ Object *collob = flowobjs[flowIndex];
+ SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(collob, eModifierType_Smoke);
// check for initialized smoke object
- if((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow)
+ if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow)
{
// we got nice flow object
SmokeFlowSettings *sfs = smd2->flow;
+ EmissionMap *em = &emaps[flowIndex];
- if(sfs && sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected
- {
- ParticleSimulationData sim;
- ParticleSystem *psys = sfs->psys;
- int totpart=psys->totpart, totchild;
- int p = 0;
- float *density = smoke_get_density(sds->fluid);
- float *bigdensity = smoke_turbulence_get_density(sds->wt);
- float *heat = smoke_get_heat(sds->fluid);
- float *velocity_x = smoke_get_velocity_x(sds->fluid);
- float *velocity_y = smoke_get_velocity_y(sds->fluid);
- float *velocity_z = smoke_get_velocity_z(sds->fluid);
- unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
- // DG TODO UNUSED unsigned char *obstacleAnim = smoke_get_obstacle_anim(sds->fluid);
- int bigres[3];
- short absolute_flow = (sfs->flags & MOD_SMOKE_FLOW_ABSOLUTE);
- short high_emission_smoothing = bigdensity ? (sds->flags & MOD_SMOKE_HIGH_SMOOTH) : 0;
-
- /*
- * A temporary volume map used to store whole emissive
- * area to be added to smoke density and interpolated
- * for high resolution smoke.
- */
- float *temp_emission_map = NULL;
-
- sim.scene = scene;
- sim.ob = collob;
- sim.psys = psys;
-
- // initialize temp emission map
- if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW))
- {
- int i;
- temp_emission_map = MEM_callocN(sizeof(float) * sds->res[0]*sds->res[1]*sds->res[2], "SmokeTempEmission");
- // set whole volume to 0.0f
- for (i=0; i<sds->res[0]*sds->res[1]*sds->res[2]; i++) {
- temp_emission_map[i] = 0.0f;
- }
- }
+ if (sfs->source == MOD_SMOKE_FLOW_SOURCE_PARTICLES) {
+ emit_from_particles(collob, sds, sfs, em, scene, time, dt);
+ }
+ else {
+ emit_from_derivedmesh(collob, sds, sfs, em, dt);
+ }
- // mostly copied from particle code
- if(psys->part->type==PART_HAIR)
- {
- /*
- if(psys->childcache)
- {
- totchild = psys->totchildcache;
+ /* update required data fields */
+ if (em->total_cells && sfs->type != MOD_SMOKE_FLOW_TYPE_OUTFLOW) {
+ /* activate heat field if flow produces any heat */
+ if (sfs->temp) {
+ active_fields |= SM_ACTIVE_HEAT;
+ }
+ /* activate fuel field if flow adds any fuel */
+ if (sfs->type != MOD_SMOKE_FLOW_TYPE_SMOKE && sfs->fuel_amount) {
+ active_fields |= SM_ACTIVE_FIRE;
+ }
+ /* activate color field if flows add smoke with varying colors */
+ if (sfs->type != MOD_SMOKE_FLOW_TYPE_FIRE && sfs->density) {
+ if (!(active_fields & SM_ACTIVE_COLOR_SET)) {
+ copy_v3_v3(sds->active_color, sfs->color);
+ active_fields |= SM_ACTIVE_COLOR_SET;
+ }
+ else if (!equals_v3v3(sds->active_color, sfs->color)) {
+ active_fields |= SM_ACTIVE_COLORS;
}
- else
- */
-
- // TODO: PART_HAIR not supported whatsoever
- totchild=0;
}
- else
- totchild=psys->totchild*psys->part->disp/100;
+ }
+ }
+ }
- for(p=0; p<totpart+totchild; p++)
- {
- int cell[3];
- size_t i = 0;
- size_t index = 0;
- int badcell = 0;
- ParticleKey state;
+ /* monitor active fields based on domain settings */
+ /* if domain has fire, activate new fields if required */
+ if (active_fields & SM_ACTIVE_FIRE) {
+ /* heat is always needed for fire */
+ active_fields |= SM_ACTIVE_HEAT;
+ /* also activate colors if domain smoke color differs from active color */
+ if (!(active_fields & SM_ACTIVE_COLOR_SET)) {
+ copy_v3_v3(sds->active_color, sds->flame_smoke_color);
+ active_fields |= SM_ACTIVE_COLOR_SET;
+ }
+ else if (!equals_v3v3(sds->active_color, sds->flame_smoke_color)) {
+ active_fields |= SM_ACTIVE_COLORS;
+ }
+ }
- if(p < totpart)
- {
- if(psys->particles[p].flag & (PARS_NO_DISP|PARS_UNEXIST))
- continue;
- }
- else {
- /* handle child particle */
- ChildParticle *cpa = &psys->child[p - totpart];
+ /* Adjust domain size if needed */
+ if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
+ adjustDomainResolution(sds, new_shift, emaps, numflowobj, dt);
+ }
- if(psys->particles[cpa->parent].flag & (PARS_NO_DISP|PARS_UNEXIST))
- continue;
- }
+ /* Initialize new data fields if any */
+ if (active_fields & SM_ACTIVE_HEAT) {
+ smoke_ensure_heat(sds->fluid);
+ }
+ if (active_fields & SM_ACTIVE_FIRE) {
+ smoke_ensure_fire(sds->fluid, sds->wt);
+ }
+ if (active_fields & SM_ACTIVE_COLORS) {
+ /* initialize all smoke with "active_color" */
+ smoke_ensure_colors(sds->fluid, sds->wt, sds->active_color[0], sds->active_color[1], sds->active_color[2]);
+ }
+ sds->active_fields = active_fields;
- state.time = time;
- if(psys_get_particle_state(&sim, p, &state, 0) == 0)
- continue;
+ /* Apply emission data */
+ if (sds->fluid) {
+ for (flowIndex = 0; flowIndex < numflowobj; flowIndex++)
+ {
+ Object *collob = flowobjs[flowIndex];
+ SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(collob, eModifierType_Smoke);
- // copy_v3_v3(pos, pa->state.co);
- // mul_m4_v3(ob->imat, pos);
- // 1. get corresponding cell
- get_cell(sds->p0, sds->res, sds->dx*sds->scale, state.co, cell, 0);
- // check if cell is valid (in the domain boundary)
- for(i = 0; i < 3; i++)
- {
- if((cell[i] > sds->res[i] - 1) || (cell[i] < 0))
- {
- badcell = 1;
- break;
- }
- }
- if(badcell)
- continue;
- // 2. set cell values (heat, density and velocity)
- index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
- if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index])) // this is inflow
- {
- // heat[index] += sfs->temp * 0.1;
- // density[index] += sfs->density * 0.1;
- heat[index] = sfs->temp;
-
- // Add emitter density to temp emission map
- temp_emission_map[index] = sfs->density;
-
- // Uses particle velocity as initial velocity for smoke
- if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO))
- {
- velocity_x[index] = state.vel[0]*sfs->vel_multi;
- velocity_y[index] = state.vel[1]*sfs->vel_multi;
- velocity_z[index] = state.vel[2]*sfs->vel_multi;
- }
- }
- else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow
- {
- heat[index] = 0.f;
- density[index] = 0.f;
- velocity_x[index] = 0.f;
- velocity_y[index] = 0.f;
- velocity_z[index] = 0.f;
- // we need different handling for the high-res feature
- if(bigdensity)
- {
- // init all surrounding cells according to amplification, too
- int i, j, k;
- smoke_turbulence_get_res(sds->wt, bigres);
-
- for(i = 0; i < sds->amplify + 1; i++)
- for(j = 0; j < sds->amplify + 1; j++)
- for(k = 0; k < sds->amplify + 1; k++)
- {
- index = smoke_get_index((sds->amplify + 1)* cell[0] + i, bigres[0], (sds->amplify + 1)* cell[1] + j, bigres[1], (sds->amplify + 1)* cell[2] + k);
- bigdensity[index] = 0.f;
- }
- }
- }
- } // particles loop
+ // check for initialized smoke object
+ if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow)
+ {
+ // we got nice flow object
+ SmokeFlowSettings *sfs = smd2->flow;
+ EmissionMap *em = &emaps[flowIndex];
+
+ float *density = smoke_get_density(sds->fluid);
+ float *color_r = smoke_get_color_r(sds->fluid);
+ float *color_g = smoke_get_color_g(sds->fluid);
+ float *color_b = smoke_get_color_b(sds->fluid);
+ float *fuel = smoke_get_fuel(sds->fluid);
+ float *react = smoke_get_react(sds->fluid);
+ float *bigdensity = smoke_turbulence_get_density(sds->wt);
+ float *bigfuel = smoke_turbulence_get_fuel(sds->wt);
+ float *bigreact = smoke_turbulence_get_react(sds->wt);
+ float *bigcolor_r = smoke_turbulence_get_color_r(sds->wt);
+ float *bigcolor_g = smoke_turbulence_get_color_g(sds->wt);
+ float *bigcolor_b = smoke_turbulence_get_color_b(sds->wt);
+ float *heat = smoke_get_heat(sds->fluid);
+ float *velocity_x = smoke_get_velocity_x(sds->fluid);
+ float *velocity_y = smoke_get_velocity_y(sds->fluid);
+ float *velocity_z = smoke_get_velocity_z(sds->fluid);
+ //unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
+ // DG TODO UNUSED unsigned char *obstacleAnim = smoke_get_obstacle_anim(sds->fluid);
+ int bigres[3];
+ short high_emission_smoothing = (sds->flags & MOD_SMOKE_HIGH_SMOOTH);
+ float *velocity_map = em->velocity;
+ float *emission_map = em->influence;
- // apply emission values
- if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW))
- {
- // initialize variables
- int ii, jj, kk, x, y, z, block_size;
- size_t index, index_big;
+ int ii, jj, kk, gx, gy, gz, ex, ey, ez, dx, dy, dz, block_size;
+ size_t e_index, d_index, index_big;
- smoke_turbulence_get_res(sds->wt, bigres);
- block_size = sds->amplify + 1; // high res block size
+ // loop through every emission map cell
+ for (gx = em->min[0]; gx < em->max[0]; gx++)
+ for (gy = em->min[1]; gy < em->max[1]; gy++)
+ for (gz = em->min[2]; gz < em->max[2]; gz++)
+ {
+ /* get emission map index */
+ ex = gx - em->min[0];
+ ey = gy - em->min[1];
+ ez = gz - em->min[2];
+ e_index = smoke_get_index(ex, em->res[0], ey, em->res[1], ez);
+ if (!emission_map[e_index]) continue;
+ /* get domain index */
+ dx = gx - sds->res_min[0];
+ dy = gy - sds->res_min[1];
+ dz = gz - sds->res_min[2];
+ d_index = smoke_get_index(dx, sds->res[0], dy, sds->res[1], dz);
+
+ if (sfs->type == MOD_SMOKE_FLOW_TYPE_OUTFLOW) { // outflow
+ apply_outflow_fields(d_index, density, heat, fuel, react, color_r, color_g, color_b);
+ }
+ else { // inflow
+ apply_inflow_fields(sfs, emission_map[e_index], d_index, density, heat, fuel, react, color_r, color_g, color_b);
+
+ /* initial velocity */
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
+ velocity_x[d_index] = ADD_IF_LOWER(velocity_x[d_index], velocity_map[e_index * 3]);
+ velocity_y[d_index] = ADD_IF_LOWER(velocity_y[d_index], velocity_map[e_index * 3 + 1]);
+ velocity_z[d_index] = ADD_IF_LOWER(velocity_z[d_index], velocity_map[e_index * 3 + 2]);
+ }
+ }
- // loop through every low res cell
- for(x = 0; x < sds->res[0]; x++)
- for(y = 0; y < sds->res[1]; y++)
- for(z = 0; z < sds->res[2]; z++)
- {
+ /* loop through high res blocks if high res enabled */
+ if (bigdensity) {
// neighbor cell emission densities (for high resolution smoke smooth interpolation)
float c000, c001, c010, c011, c100, c101, c110, c111;
- c000 = (x>0 && y>0 && z>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y-1, sds->res[1], z-1)] : 0;
- c001 = (x>0 && y>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y-1, sds->res[1], z)] : 0;
- c010 = (x>0 && z>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y, sds->res[1], z-1)] : 0;
- c011 = (x>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y, sds->res[1], z)] : 0;
+ smoke_turbulence_get_res(sds->wt, bigres);
+ block_size = sds->amplify + 1; // high res block size
- c100 = (y>0 && z>0) ? temp_emission_map[smoke_get_index(x, sds->res[0], y-1, sds->res[1], z-1)] : 0;
- c101 = (y>0) ? temp_emission_map[smoke_get_index(x, sds->res[0], y-1, sds->res[1], z)] : 0;
- c110 = (z>0) ? temp_emission_map[smoke_get_index(x, sds->res[0], y, sds->res[1], z-1)] : 0;
- c111 = temp_emission_map[smoke_get_index(x, sds->res[0], y, sds->res[1], z)]; // this cell
+ c000 = (ex > 0 && ey > 0 && ez > 0) ? emission_map[smoke_get_index(ex - 1, em->res[0], ey - 1, em->res[1], ez - 1)] : 0;
+ c001 = (ex > 0 && ey > 0) ? emission_map[smoke_get_index(ex - 1, em->res[0], ey - 1, em->res[1], ez)] : 0;
+ c010 = (ex > 0 && ez > 0) ? emission_map[smoke_get_index(ex - 1, em->res[0], ey, em->res[1], ez - 1)] : 0;
+ c011 = (ex > 0) ? emission_map[smoke_get_index(ex - 1, em->res[0], ey, em->res[1], ez)] : 0;
- // get cell index
- index = smoke_get_index(x, sds->res[0], y, sds->res[1], z);
+ c100 = (ey > 0 && ez > 0) ? emission_map[smoke_get_index(ex, em->res[0], ey - 1, em->res[1], ez - 1)] : 0;
+ c101 = (ey > 0) ? emission_map[smoke_get_index(ex, em->res[0], ey - 1, em->res[1], ez)] : 0;
+ c110 = (ez > 0) ? emission_map[smoke_get_index(ex, em->res[0], ey, em->res[1], ez - 1)] : 0;
+ c111 = emission_map[smoke_get_index(ex, em->res[0], ey, em->res[1], ez)]; // this cell
- // add emission to low resolution density
- if (absolute_flow)
- {
- if (temp_emission_map[index]>0)
- density[index] = temp_emission_map[index];
- }
- else
- {
- density[index] += temp_emission_map[index];
+ for (ii = 0; ii < block_size; ii++)
+ for (jj = 0; jj < block_size; jj++)
+ for (kk = 0; kk < block_size; kk++)
+ {
- if (density[index]>1)
- density[index]=1.0f;
- }
+ float fx, fy, fz, interpolated_value;
+ int shift_x, shift_y, shift_z;
- smoke_turbulence_get_res(sds->wt, bigres);
- /* loop through high res blocks if high res enabled */
- if (bigdensity)
- for(ii = 0; ii < block_size; ii++)
- for(jj = 0; jj < block_size; jj++)
- for(kk = 0; kk < block_size; kk++)
+ /*
+ * Do volume interpolation if emitter smoothing
+ * is enabled
+ */
+ if (high_emission_smoothing)
{
-
- float fx,fy,fz, interpolated_value;
- int shift_x, shift_y, shift_z;
-
-
- /*
- * Do volume interpolation if emitter smoothing
- * is enabled
- */
- if (high_emission_smoothing)
- {
- // convert block position to relative
- // for interpolation smoothing
- fx = (float)ii/block_size + 0.5f/block_size;
- fy = (float)jj/block_size + 0.5f/block_size;
- fz = (float)kk/block_size + 0.5f/block_size;
-
- // calculate trilinear interpolation
- interpolated_value = c000 * (1-fx) * (1-fy) * (1-fz) +
- c100 * fx * (1-fy) * (1-fz) +
- c010 * (1-fx) * fy * (1-fz) +
- c001 * (1-fx) * (1-fy) * fz +
- c101 * fx * (1-fy) * fz +
- c011 * (1-fx) * fy * fz +
- c110 * fx * fy * (1-fz) +
- c111 * fx * fy * fz;
-
-
- // add some contrast / sharpness
- // depending on hi-res block size
-
- interpolated_value = (interpolated_value-0.4f*sfs->density)*(block_size/2) + 0.4f*sfs->density;
- if (interpolated_value<0.0f) interpolated_value = 0.0f;
- if (interpolated_value>1.0f) interpolated_value = 1.0f;
-
- // shift smoke block index
- // (because pixel center is actually
- // in halfway of the low res block)
- shift_x = (x < 1) ? 0 : block_size/2;
- shift_y = (y < 1) ? 0 : block_size/2;
- shift_z = (z < 1) ? 0 : block_size/2;
- }
- else
- {
- // without interpolation use same low resolution
- // block value for all hi-res blocks
- interpolated_value = c111;
- shift_x = 0;
- shift_y = 0;
- shift_z = 0;
- }
-
- // get shifted index for current high resolution block
- index_big = smoke_get_index(block_size * x + ii - shift_x, bigres[0], block_size * y + jj - shift_y, bigres[1], block_size * z + kk - shift_z);
-
- // add emission data to high resolution density
- if (absolute_flow)
- {
- if (interpolated_value > 0)
- bigdensity[index_big] = interpolated_value;
- }
- else
- {
- bigdensity[index_big] += interpolated_value;
-
- if (bigdensity[index_big]>1)
- bigdensity[index_big]=1.0f;
+ /* get relative block position
+ * for interpolation smoothing */
+ fx = (float)ii / block_size + 0.5f / block_size;
+ fy = (float)jj / block_size + 0.5f / block_size;
+ fz = (float)kk / block_size + 0.5f / block_size;
+
+ /* calculate trilinear interpolation */
+ interpolated_value = c000 * (1 - fx) * (1 - fy) * (1 - fz) +
+ c100 * fx * (1 - fy) * (1 - fz) +
+ c010 * (1 - fx) * fy * (1 - fz) +
+ c001 * (1 - fx) * (1 - fy) * fz +
+ c101 * fx * (1 - fy) * fz +
+ c011 * (1 - fx) * fy * fz +
+ c110 * fx * fy * (1 - fz) +
+ c111 * fx * fy * fz;
+
+
+ /* add some contrast / sharpness
+ * depending on hi-res block size */
+ interpolated_value = (interpolated_value - 0.4f) * (block_size / 2) + 0.4f;
+ CLAMP(interpolated_value, 0.0f, 1.0f);
+
+ /* shift smoke block index
+ * (because pixel center is actually
+ * in halfway of the low res block) */
+ shift_x = (dx < 1) ? 0 : block_size / 2;
+ shift_y = (dy < 1) ? 0 : block_size / 2;
+ shift_z = (dz < 1) ? 0 : block_size / 2;
+ }
+ else {
+ /* without interpolation use same low resolution
+ * block value for all hi-res blocks */
+ interpolated_value = c111;
+ shift_x = 0;
+ shift_y = 0;
+ shift_z = 0;
+ }
+
+ /* get shifted index for current high resolution block */
+ index_big = smoke_get_index(block_size * dx + ii - shift_x, bigres[0], block_size * dy + jj - shift_y, bigres[1], block_size * dz + kk - shift_z);
+
+ if (sfs->type == MOD_SMOKE_FLOW_TYPE_OUTFLOW) { // outflow
+ if (interpolated_value) {
+ apply_outflow_fields(index_big, bigdensity, NULL, bigfuel, bigreact, bigcolor_r, bigcolor_g, bigcolor_b);
}
- } // end of hires loop
-
- } // end of low res loop
-
- // free temporary emission map
- if (temp_emission_map)
- MEM_freeN(temp_emission_map);
-
- } // end emission
- }
+ }
+ else { // inflow
+ apply_inflow_fields(sfs, interpolated_value, index_big, bigdensity, NULL, bigfuel, bigreact, bigcolor_r, bigcolor_g, bigcolor_b);
+ }
+ } // hires loop
+ } // bigdensity
+ } // low res loop
+
+ // free emission maps
+ em_freeData(em);
+
+ } // end emission
}
}
- if(flowobjs)
+ if (flowobjs)
MEM_freeN(flowobjs);
+ if (emaps)
+ MEM_freeN(emaps);
}
static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt))
{
- ListBase *effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights);
+ ListBase *effectors;
+ /* make sure smoke flow influence is 0.0f */
+ sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
+ effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights);
- if(effectors)
+ if (effectors)
{
float *density = smoke_get_density(sds->fluid);
float *force_x = smoke_get_force_x(sds->fluid);
@@ -1532,223 +1901,269 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds,
float *velocity_y = smoke_get_velocity_y(sds->fluid);
float *velocity_z = smoke_get_velocity_z(sds->fluid);
unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
- int x, y, z;
+ int x;
// precalculate wind forces
- for(x = 0; x < sds->res[0]; x++)
- for(y = 0; y < sds->res[1]; y++)
- for(z = 0; z < sds->res[2]; z++)
- {
- EffectedPoint epoint;
- float voxelCenter[3] = {0,0,0}, vel[3] = {0,0,0}, retvel[3] = {0,0,0};
- unsigned int index = smoke_get_index(x, sds->res[0], y, sds->res[1], z);
-
- if((density[index] < FLT_EPSILON) || obstacle[index])
- continue;
-
- vel[0] = velocity_x[index];
- vel[1] = velocity_y[index];
- vel[2] = velocity_z[index];
-
- voxelCenter[0] = sds->p0[0] + sds->dx * sds->scale * x + sds->dx * sds->scale * 0.5;
- voxelCenter[1] = sds->p0[1] + sds->dx * sds->scale * y + sds->dx * sds->scale * 0.5;
- voxelCenter[2] = sds->p0[2] + sds->dx * sds->scale * z + sds->dx * sds->scale * 0.5;
-
- pd_point_from_loc(scene, voxelCenter, vel, index, &epoint);
- pdDoEffectors(effectors, NULL, sds->effector_weights, &epoint, retvel, NULL);
-
- // TODO dg - do in force!
- force_x[index] = MIN2(MAX2(-1.0, retvel[0] * 0.2), 1.0);
- force_y[index] = MIN2(MAX2(-1.0, retvel[1] * 0.2), 1.0);
- force_z[index] = MIN2(MAX2(-1.0, retvel[2] * 0.2), 1.0);
+ #pragma omp parallel for schedule(static)
+ for (x = 0; x < sds->res[0]; x++)
+ {
+ int y, z;
+ for (y = 0; y < sds->res[1]; y++)
+ for (z = 0; z < sds->res[2]; z++)
+ {
+ EffectedPoint epoint;
+ float mag;
+ float voxelCenter[3] = {0, 0, 0}, vel[3] = {0, 0, 0}, retvel[3] = {0, 0, 0};
+ unsigned int index = smoke_get_index(x, sds->res[0], y, sds->res[1], z);
+
+ if ((density[index] < FLT_EPSILON) || obstacle[index])
+ continue;
+
+ vel[0] = velocity_x[index];
+ vel[1] = velocity_y[index];
+ vel[2] = velocity_z[index];
+
+ /* convert vel to global space */
+ mag = len_v3(vel);
+ mul_mat3_m4_v3(sds->obmat, vel);
+ normalize_v3(vel);
+ mul_v3_fl(vel, mag);
+
+ voxelCenter[0] = sds->p0[0] + sds->cell_size[0] * ((float)(x + sds->res_min[0]) + 0.5f);
+ voxelCenter[1] = sds->p0[1] + sds->cell_size[1] * ((float)(y + sds->res_min[1]) + 0.5f);
+ voxelCenter[2] = sds->p0[2] + sds->cell_size[2] * ((float)(z + sds->res_min[2]) + 0.5f);
+ mul_m4_v3(sds->obmat, voxelCenter);
+
+ pd_point_from_loc(scene, voxelCenter, vel, index, &epoint);
+ pdDoEffectors(effectors, NULL, sds->effector_weights, &epoint, retvel, NULL);
+
+ /* convert retvel to local space */
+ mag = len_v3(retvel);
+ mul_mat3_m4_v3(sds->imat, retvel);
+ normalize_v3(retvel);
+ mul_v3_fl(retvel, mag);
+
+ // TODO dg - do in force!
+ force_x[index] = min_ff(max_ff(-1.0f, retvel[0] * 0.2f), 1.0f);
+ force_y[index] = min_ff(max_ff(-1.0f, retvel[1] * 0.2f), 1.0f);
+ force_z[index] = min_ff(max_ff(-1.0f, retvel[2] * 0.2f), 1.0f);
+ }
}
}
pdEndEffectors(&effectors);
}
-static void step(Scene *scene, Object *ob, SmokeModifierData *smd, float fps)
+static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
{
+ SmokeDomainSettings *sds = smd->domain;
/* stability values copied from wturbulence.cpp */
const int maxSubSteps = 25;
float maxVel;
// maxVel should be 1.5 (1.5 cell max movement) * dx (cell size)
- float dt = DT_DEFAULT;
+ float dt;
float maxVelMag = 0.0f;
int totalSubsteps;
int substep = 0;
float dtSubdiv;
+ float gravity[3] = {0.0f, 0.0f, -1.0f};
+ float gravity_mag;
- SmokeDomainSettings *sds = smd->domain;
-
- /* get max velocity and lower the dt value if it is too high */
- size_t size= sds->res[0] * sds->res[1] * sds->res[2];
-
+#if 0 /* UNUSED */
+ /* get max velocity and lower the dt value if it is too high */
+ size_t size = sds->res[0] * sds->res[1] * sds->res[2];
float *velX = smoke_get_velocity_x(sds->fluid);
float *velY = smoke_get_velocity_y(sds->fluid);
float *velZ = smoke_get_velocity_z(sds->fluid);
size_t i;
+#endif
- /* adapt timestep for different framerates, dt = 0.1 is at 25fps */
- dt *= (25.0f / fps);
+ /* update object state */
+ invert_m4_m4(sds->imat, ob->obmat);
+ copy_m4_m4(sds->obmat, ob->obmat);
+ smoke_set_domain_from_derivedmesh(sds, ob, domain_dm);
+
+ /* use global gravity if enabled */
+ if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
+ copy_v3_v3(gravity, scene->physics_settings.gravity);
+ /* map default value to 1.0 */
+ mul_v3_fl(gravity, 1.0f / 9.810f);
+ }
+ /* convert gravity to domain space */
+ gravity_mag = len_v3(gravity);
+ mul_mat3_m4_v3(sds->imat, gravity);
+ normalize_v3(gravity);
+ mul_v3_fl(gravity, gravity_mag);
+ /* adapt timestep for different framerates, dt = 0.1 is at 25fps */
+ dt = DT_DEFAULT * (25.0f / fps);
// maximum timestep/"CFL" constraint: dt < 5.0 *dx / maxVel
- maxVel = (sds->dx * 5.0);
+ maxVel = (sds->dx * 5.0f);
- for(i = 0; i < size; i++)
- {
- float vtemp = (velX[i]*velX[i]+velY[i]*velY[i]+velZ[i]*velZ[i]);
- if(vtemp > maxVelMag)
+#if 0
+ for (i = 0; i < size; i++) {
+ float vtemp = (velX[i] * velX[i] + velY[i] * velY[i] + velZ[i] * velZ[i]);
+ if (vtemp > maxVelMag)
maxVelMag = vtemp;
}
+#endif
- maxVelMag = sqrt(maxVelMag) * dt * sds->time_scale;
+ maxVelMag = sqrtf(maxVelMag) * dt * sds->time_scale;
totalSubsteps = (int)((maxVelMag / maxVel) + 1.0f); /* always round up */
totalSubsteps = (totalSubsteps < 1) ? 1 : totalSubsteps;
totalSubsteps = (totalSubsteps > maxSubSteps) ? maxSubSteps : totalSubsteps;
/* Disable substeps for now, since it results in numerical instability */
- totalSubsteps = 1.0f;
+ totalSubsteps = 1.0f;
dtSubdiv = (float)dt / (float)totalSubsteps;
// printf("totalSubsteps: %d, maxVelMag: %f, dt: %f\n", totalSubsteps, maxVelMag, dt);
- for(substep = 0; substep < totalSubsteps; substep++)
+ for (substep = 0; substep < totalSubsteps; substep++)
{
// calc animated obstacle velocities
+ update_flowsfluids(scene, ob, sds, smd->time, dtSubdiv);
update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps);
- update_flowsfluids(scene, ob, sds, smd->time);
- update_effectors(scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
- smoke_step(sds->fluid, dtSubdiv);
+ if (sds->total_cells > 1) {
+ update_effectors(scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
+ smoke_step(sds->fluid, gravity, dtSubdiv);
+ }
+ }
+}
- // move animated obstacle: Done in update_obstacles() */
+static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
+{
+ DerivedMesh *result;
+ MVert *mverts;
+ MPoly *mpolys;
+ MLoop *mloops;
+ float min[3];
+ float max[3];
+ float *co;
+ MPoly *mp;
+ MLoop *ml;
+
+ int num_verts = 8;
+ int num_faces = 6;
+ int i;
+ float ob_loc[3] = {0};
+ float ob_cache_loc[3] = {0};
+
+ /* dont generate any mesh if there isnt any content */
+ if (sds->total_cells <= 1) {
+ num_verts = 0;
+ num_faces = 0;
+ }
- // where to delete old obstacles from array? Done in update_obstacles() */
+ result = CDDM_new(num_verts, 0, 0, num_faces * 4, num_faces);
+ mverts = CDDM_get_verts(result);
+ mpolys = CDDM_get_polys(result);
+ mloops = CDDM_get_loops(result);
+
+
+ if (num_verts) {
+ /* volume bounds */
+ VECMADD(min, sds->p0, sds->cell_size, sds->res_min);
+ VECMADD(max, sds->p0, sds->cell_size, sds->res_max);
+
+ /* set vertices */
+ /* top slab */
+ co = mverts[0].co; co[0] = min[0]; co[1] = min[1]; co[2] = max[2];
+ co = mverts[1].co; co[0] = max[0]; co[1] = min[1]; co[2] = max[2];
+ co = mverts[2].co; co[0] = max[0]; co[1] = max[1]; co[2] = max[2];
+ co = mverts[3].co; co[0] = min[0]; co[1] = max[1]; co[2] = max[2];
+ /* bottom slab */
+ co = mverts[4].co; co[0] = min[0]; co[1] = min[1]; co[2] = min[2];
+ co = mverts[5].co; co[0] = max[0]; co[1] = min[1]; co[2] = min[2];
+ co = mverts[6].co; co[0] = max[0]; co[1] = max[1]; co[2] = min[2];
+ co = mverts[7].co; co[0] = min[0]; co[1] = max[1]; co[2] = min[2];
+
+ /* create faces */
+ /* top */
+ mp = &mpolys[0]; ml = &mloops[0 * 4]; mp->loopstart = 0 * 4; mp->totloop = 4;
+ ml[0].v = 0; ml[1].v = 1; ml[2].v = 2; ml[3].v = 3;
+ /* right */
+ mp = &mpolys[1]; ml = &mloops[1 * 4]; mp->loopstart = 1 * 4; mp->totloop = 4;
+ ml[0].v = 2; ml[1].v = 1; ml[2].v = 5; ml[3].v = 6;
+ /* bottom */
+ mp = &mpolys[2]; ml = &mloops[2 * 4]; mp->loopstart = 2 * 4; mp->totloop = 4;
+ ml[0].v = 7; ml[1].v = 6; ml[2].v = 5; ml[3].v = 4;
+ /* left */
+ mp = &mpolys[3]; ml = &mloops[3 * 4]; mp->loopstart = 3 * 4; mp->totloop = 4;
+ ml[0].v = 0; ml[1].v = 3; ml[2].v = 7; ml[3].v = 4;
+ /* front */
+ mp = &mpolys[4]; ml = &mloops[4 * 4]; mp->loopstart = 4 * 4; mp->totloop = 4;
+ ml[0].v = 3; ml[1].v = 2; ml[2].v = 6; ml[3].v = 7;
+ /* back */
+ mp = &mpolys[5]; ml = &mloops[5 * 4]; mp->loopstart = 5 * 4; mp->totloop = 4;
+ ml[0].v = 1; ml[1].v = 0; ml[2].v = 4; ml[3].v = 5;
+
+ /* calculate required shift to match domain's global position
+ * it was originally simulated at (if object moves without smoke step) */
+ invert_m4_m4(ob->imat, ob->obmat);
+ mul_m4_v3(ob->obmat, ob_loc);
+ mul_m4_v3(sds->obmat, ob_cache_loc);
+ VECSUB(sds->obj_shift_f, ob_cache_loc, ob_loc);
+ /* convert shift to local space and apply to vertices */
+ mul_mat3_m4_v3(ob->imat, sds->obj_shift_f);
+ /* apply */
+ for (i = 0; i < num_verts; i++) {
+ add_v3_v3(mverts[i].co, sds->obj_shift_f);
+ }
}
+
+
+ CDDM_calc_edges(result);
+ return result;
}
-void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
-{
- if((smd->type & MOD_SMOKE_TYPE_FLOW))
+static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
+{
+ if ((smd->type & MOD_SMOKE_TYPE_FLOW))
{
- if(scene->r.cfra >= smd->time)
+ if (scene->r.cfra >= smd->time)
smokeModifier_init(smd, ob, scene, dm);
- if(scene->r.cfra > smd->time)
+ if (smd->flow->dm) smd->flow->dm->release(smd->flow->dm);
+ smd->flow->dm = CDDM_copy(dm);
+ DM_ensure_tessface(smd->flow->dm);
+
+ if (scene->r.cfra > smd->time)
{
- // XXX TODO
smd->time = scene->r.cfra;
-
- // rigid movement support
- /*
- copy_m4_m4(smd->flow->mat_old, smd->flow->mat);
- copy_m4_m4(smd->flow->mat, ob->obmat);
- */
}
- else if(scene->r.cfra < smd->time)
+ else if (scene->r.cfra < smd->time)
{
smd->time = scene->r.cfra;
smokeModifier_reset(smd);
}
}
- else if(smd->type & MOD_SMOKE_TYPE_COLL)
+ else if (smd->type & MOD_SMOKE_TYPE_COLL)
{
- /* Check if domain resolution changed */
- /* DG TODO: can this be solved more elegant using dependancy graph? */
- {
- SmokeCollSettings *scs = smd->coll;
- Base *base = scene->base.first;
- int changed = 0;
- float dx = FLT_MAX;
- float scale = 1.0f;
- int haveDomain = 0;
-
- for ( ; base; base = base->next)
- {
- SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(base->object, eModifierType_Smoke);
-
- if (smd2 && (smd2->type & MOD_SMOKE_TYPE_DOMAIN) && smd2->domain)
- {
- SmokeDomainSettings *sds = smd2->domain;
-
- if(sds->dx * sds->scale < dx)
- {
- dx = sds->dx;
- scale = sds->scale;
- changed = 1;
- }
-
- haveDomain = 1;
- }
- }
-
- if(!haveDomain)
- return;
-
- if(changed)
- {
- if(dx*scale != scs->dx)
- {
- scs->dx = dx*scale;
- smokeModifier_reset(smd);
- }
- }
- }
-
- if(scene->r.cfra >= smd->time)
+ if (scene->r.cfra >= smd->time)
smokeModifier_init(smd, ob, scene, dm);
- if(scene->r.cfra > smd->time)
+ if (smd->coll)
{
- unsigned int i;
- SmokeCollSettings *scs = smd->coll;
- float *points_old = scs->points_old;
- float *points = scs->points;
- unsigned int numpoints = scs->numpoints;
-
- // XXX TODO <-- DG: what is TODO here?
- smd->time = scene->r.cfra;
-
- // rigid movement support
- copy_m4_m4(scs->mat_old, scs->mat);
- copy_m4_m4(scs->mat, ob->obmat);
-
- if(scs->type != SM_COLL_ANIMATED) // if(not_animated)
- {
- // nothing to do, "mat" is already up to date
- }
- else
- {
- // XXX TODO: need to update positions + divs
-
- if(scs->numverts != dm->getNumVerts(dm))
- {
- // DG TODO: reset modifier?
- return;
- }
+ if (smd->coll->dm)
+ smd->coll->dm->release(smd->coll->dm);
- for(i = 0; i < numpoints * 3; i++)
- {
- points_old[i] = points[i];
- }
-
- DM_ensure_tessface(dm);
- fill_scs_points_anim(ob, dm, scs);
- }
+ smd->coll->dm = CDDM_copy(dm);
+ DM_ensure_tessface(smd->coll->dm);
}
- else if(scene->r.cfra < smd->time)
+
+ smd->time = scene->r.cfra;
+ if (scene->r.cfra < smd->time)
{
- smd->time = scene->r.cfra;
smokeModifier_reset(smd);
}
}
- else if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
+ else if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
SmokeDomainSettings *sds = smd->domain;
- float light[3];
PointCache *cache = NULL;
PTCacheID pid;
int startframe, endframe, framenr;
@@ -1762,41 +2177,39 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
BKE_ptcache_id_from_smoke(&pid, ob, smd);
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
- if(!smd->domain->fluid || framenr == startframe)
+ if (!smd->domain->fluid || framenr == startframe)
{
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+ smokeModifier_reset(smd);
BKE_ptcache_validate(cache, framenr);
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
- if(!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD)==0 && (cache->flag & PTCACHE_BAKED)==0)
+ if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0 && (cache->flag & PTCACHE_BAKED) == 0)
return;
smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
-
CLAMP(framenr, startframe, endframe);
/* If already viewing a pre/after frame, no need to reload */
if ((smd->time == framenr) && (framenr != scene->r.cfra))
return;
- // printf("startframe: %d, framenr: %d\n", startframe, framenr);
-
- if(smokeModifier_init(smd, ob, scene, dm)==0)
+ if (smokeModifier_init(smd, ob, scene, dm) == 0)
{
printf("bad smokeModifier_init\n");
return;
}
/* try to read from cache */
- if(BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) {
+ if (BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) {
BKE_ptcache_validate(cache, framenr);
smd->time = framenr;
return;
}
-
+
/* only calculate something when we advanced a single frame */
- if(framenr != (int)smd->time+1)
+ if (framenr != (int)smd->time + 1)
return;
/* don't simulate if viewing start frame, but scene frame is not real start frame */
@@ -1805,54 +2218,48 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
tstart();
- smoke_calc_domain(scene, ob, smd);
-
/* if on second frame, write cache for first frame */
- if((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) {
+ if ((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
// create shadows straight after domain initialization so we get nice shadows for startframe, too
- if(get_lamp(scene, light))
- smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx);
+ smoke_calc_transparency(sds, scene);
- if(sds->wt)
+ if (sds->wt && sds->total_cells > 1)
{
- if(sds->flags & MOD_SMOKE_DISSOLVE)
+ if (sds->flags & MOD_SMOKE_DISSOLVE)
smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
smoke_turbulence_step(sds->wt, sds->fluid);
}
BKE_ptcache_write(&pid, startframe);
}
-
+
// set new time
smd->time = scene->r.cfra;
/* do simulation */
- // low res
-
// simulate the actual smoke (c++ code in intern/smoke)
// DG: interesting commenting this line + deactivating loading of noise files
- if(framenr!=startframe)
+ if (framenr != startframe)
{
- if(sds->flags & MOD_SMOKE_DISSOLVE)
+ if (sds->flags & MOD_SMOKE_DISSOLVE)
smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
-
- step(scene, ob, smd, scene->r.frs_sec / scene->r.frs_sec_base);
+
+ step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
}
// create shadows before writing cache so they get stored
- if(get_lamp(scene, light))
- smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx);
+ smoke_calc_transparency(sds, scene);
- if(sds->wt)
+ if (sds->wt)
{
- if(sds->flags & MOD_SMOKE_DISSOLVE)
+ if (sds->flags & MOD_SMOKE_DISSOLVE)
smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
smoke_turbulence_step(sds->wt, sds->fluid);
}
-
+
BKE_ptcache_validate(cache, framenr);
- if(framenr != startframe)
+ if (framenr != startframe)
BKE_ptcache_write(&pid, framenr);
tend();
@@ -1860,38 +2267,34 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
}
}
-static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct)
+struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
{
- const size_t index = smoke_get_index(pixel[0], res[0], pixel[1], res[1], pixel[2]);
+ smokeModifier_process(smd, scene, ob, dm);
- // T_ray *= T_vox
- *tRay *= exp(input[index]*correct);
-
- if(result[index] < 0.0f)
+ /* return generated geometry for adaptive domain */
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain &&
+ smd->domain->flags & MOD_SMOKE_ADAPTIVE_DOMAIN &&
+ smd->domain->base_res[0])
{
-// #pragma omp critical
- result[index] = *tRay;
- }
-
- return *tRay;
+ return createDomainGeometry(smd->domain, ob);
+ }
+ else return CDDM_copy(dm);
}
-long long smoke_get_mem_req(int xres, int yres, int zres, int amplify)
+static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct)
{
- int totalCells = xres * yres * zres;
- int amplifiedCells = totalCells * amplify * amplify * amplify;
-
- // print out memory requirements
- long long int coarseSize = sizeof(float) * totalCells * 22 +
- sizeof(unsigned char) * totalCells;
+ const size_t index = smoke_get_index(pixel[0], res[0], pixel[1], res[1], pixel[2]);
- long long int fineSize = sizeof(float) * amplifiedCells * 7 + // big grids
- sizeof(float) * totalCells * 8 + // small grids
- sizeof(float) * 128 * 128 * 128; // noise tile
+ // T_ray *= T_vox
+ *tRay *= expf(input[index] * correct);
- long long int totalMB = (coarseSize + fineSize) / (1024 * 1024);
+ if (result[index] < 0.0f)
+ {
+// #pragma omp critical
+ result[index] = *tRay;
+ }
- return totalMB;
+ return *tRay;
}
static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, bresenham_callback cb, float *result, float *input, int res[3], float correct)
@@ -1921,7 +2324,7 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
err_1 = dy2 - l;
err_2 = dz2 - l;
for (i = 0; i < l; i++) {
- if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
break;
if (err_1 > 0) {
pixel[1] += y_inc;
@@ -1935,12 +2338,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
err_2 += dz2;
pixel[0] += x_inc;
}
- }
+ }
else if ((m >= l) && (m >= n)) {
err_1 = dx2 - m;
err_2 = dz2 - m;
for (i = 0; i < m; i++) {
- if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
break;
if (err_1 > 0) {
pixel[0] += x_inc;
@@ -1954,12 +2357,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
err_2 += dz2;
pixel[1] += y_inc;
}
- }
+ }
else {
err_1 = dy2 - n;
err_2 = dx2 - n;
for (i = 0; i < n; i++) {
- if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
break;
if (err_1 > 0) {
pixel[1] += y_inc;
@@ -1977,80 +2380,142 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
cb(result, input, res, pixel, tRay, correct);
}
-static void get_cell(const float p0[3], const int res[3], float dx, const float pos[3], int cell[3], int correct)
+static void smoke_calc_transparency(SmokeDomainSettings *sds, Scene *scene)
{
- float tmp[3];
+ float bv[6] = {0};
+ float light[3];
+ int a, z, slabsize = sds->res[0] * sds->res[1], size = sds->res[0] * sds->res[1] * sds->res[2];
+ float *density = smoke_get_density(sds->fluid);
+ float correct = -7.0f * sds->dx;
- sub_v3_v3v3(tmp, pos, p0);
- mul_v3_fl(tmp, 1.0 / dx);
+ if (!get_lamp(scene, light)) return;
- if (correct) {
- cell[0] = MIN2(res[0] - 1, MAX2(0, (int)floor(tmp[0])));
- cell[1] = MIN2(res[1] - 1, MAX2(0, (int)floor(tmp[1])));
- cell[2] = MIN2(res[2] - 1, MAX2(0, (int)floor(tmp[2])));
- }
- else {
- cell[0] = (int)floor(tmp[0]);
- cell[1] = (int)floor(tmp[1]);
- cell[2] = (int)floor(tmp[2]);
- }
-}
-
-static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct)
-{
- float bv[6];
- int a, z, slabsize=res[0]*res[1], size= res[0]*res[1]*res[2];
+ /* convert light pos to sim cell space */
+ mul_m4_v3(sds->imat, light);
+ light[0] = (light[0] - sds->p0[0]) / sds->cell_size[0] - 0.5f - (float)sds->res_min[0];
+ light[1] = (light[1] - sds->p0[1]) / sds->cell_size[1] - 0.5f - (float)sds->res_min[1];
+ light[2] = (light[2] - sds->p0[2]) / sds->cell_size[2] - 0.5f - (float)sds->res_min[2];
- for(a=0; a<size; a++)
- result[a]= -1.0f;
+ for (a = 0; a < size; a++)
+ sds->shadow[a] = -1.0f;
- bv[0] = p0[0];
- bv[1] = p1[0];
- // y
- bv[2] = p0[1];
- bv[3] = p1[1];
- // z
- bv[4] = p0[2];
- bv[5] = p1[2];
+ /* calculate domain bounds in sim cell space */
+ // 0,2,4 = 0.0f
+ bv[1] = (float)sds->res[0]; // x
+ bv[3] = (float)sds->res[1]; // y
+ bv[5] = (float)sds->res[2]; // z
// #pragma omp parallel for schedule(static,1)
- for(z = 0; z < res[2]; z++)
+ for (z = 0; z < sds->res[2]; z++)
{
- size_t index = z*slabsize;
- int x,y;
+ size_t index = z * slabsize;
+ int x, y;
- for(y = 0; y < res[1]; y++)
- for(x = 0; x < res[0]; x++, index++)
+ for (y = 0; y < sds->res[1]; y++)
+ for (x = 0; x < sds->res[0]; x++, index++)
{
float voxelCenter[3];
float pos[3];
int cell[3];
float tRay = 1.0;
- if(result[index] >= 0.0f)
- continue;
- voxelCenter[0] = p0[0] + dx * x + dx * 0.5;
- voxelCenter[1] = p0[1] + dx * y + dx * 0.5;
- voxelCenter[2] = p0[2] + dx * z + dx * 0.5;
+ if (sds->shadow[index] >= 0.0f)
+ continue;
+ voxelCenter[0] = (float)x;
+ voxelCenter[1] = (float)y;
+ voxelCenter[2] = (float)z;
- // get starting position (in voxel coords)
- if(BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON)
+ // get starting cell (light pos)
+ if (BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON)
{
- // we're ouside
- get_cell(p0, res, dx, pos, cell, 1);
+ // we're ouside -> use point on side of domain
+ cell[0] = (int)floor(pos[0]);
+ cell[1] = (int)floor(pos[1]);
+ cell[2] = (int)floor(pos[2]);
}
else {
- // we're inside
- get_cell(p0, res, dx, light, cell, 1);
+ // we're inside -> use light itself
+ cell[0] = (int)floor(light[0]);
+ cell[1] = (int)floor(light[1]);
+ cell[2] = (int)floor(light[2]);
}
+ /* clamp within grid bounds */
+ CLAMP(cell[0], 0, sds->res[0] - 1);
+ CLAMP(cell[1], 0, sds->res[1] - 1);
+ CLAMP(cell[2], 0, sds->res[2] - 1);
- bresenham_linie_3D(cell[0], cell[1], cell[2], x, y, z, &tRay, cb, result, input, res, correct);
+ bresenham_linie_3D(cell[0], cell[1], cell[2], x, y, z, &tRay, calc_voxel_transp, sds->shadow, density, sds->res, correct);
// convention -> from a RGBA float array, use G value for tRay
// #pragma omp critical
- result[index] = tRay;
+ sds->shadow[index] = tRay;
}
}
}
+/* get smoke velocity and density at given coordinates
+ * returns fluid density or -1.0f if outside domain*/
+float smoke_get_velocity_at(struct Object *ob, float position[3], float velocity[3])
+{
+ SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
+ zero_v3(velocity);
+
+ if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && smd->domain->fluid) {
+ SmokeDomainSettings *sds = smd->domain;
+ float time_mult = 25.f * DT_DEFAULT;
+ float vel_mag;
+ float *velX = smoke_get_velocity_x(sds->fluid);
+ float *velY = smoke_get_velocity_y(sds->fluid);
+ float *velZ = smoke_get_velocity_z(sds->fluid);
+ float density = 0.0f, fuel = 0.0f;
+ float pos[3];
+ copy_v3_v3(pos, position);
+ smoke_pos_to_cell(sds, pos);
+
+ /* check if point is outside domain max bounds */
+ if (pos[0] < sds->res_min[0] || pos[1] < sds->res_min[1] || pos[2] < sds->res_min[2]) return -1.0f;
+ if (pos[0] > sds->res_max[0] || pos[1] > sds->res_max[1] || pos[2] > sds->res_max[2]) return -1.0f;
+
+ /* map pos between 0.0 - 1.0 */
+ pos[0] = (pos[0] - sds->res_min[0]) / ((float)sds->res[0]);
+ pos[1] = (pos[1] - sds->res_min[1]) / ((float)sds->res[1]);
+ pos[2] = (pos[2] - sds->res_min[2]) / ((float)sds->res[2]);
+
+
+ /* check if point is outside active area */
+ if (smd->domain->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
+ if (pos[0] < 0.0f || pos[1] < 0.0f || pos[2] < 0.0f) return 0.0f;
+ if (pos[0] > 1.0f || pos[1] > 1.0f || pos[2] > 1.0f) return 0.0f;
+ }
+
+ /* get interpolated velocity */
+ velocity[0] = BLI_voxel_sample_trilinear(velX, sds->res, pos) * sds->global_size[0] * time_mult;
+ velocity[1] = BLI_voxel_sample_trilinear(velY, sds->res, pos) * sds->global_size[1] * time_mult;
+ velocity[2] = BLI_voxel_sample_trilinear(velZ, sds->res, pos) * sds->global_size[2] * time_mult;
+
+ /* convert velocity direction to global space */
+ vel_mag = len_v3(velocity);
+ mul_mat3_m4_v3(sds->obmat, velocity);
+ normalize_v3(velocity);
+ mul_v3_fl(velocity, vel_mag);
+
+ /* use max value of fuel or smoke density */
+ density = BLI_voxel_sample_trilinear(smoke_get_density(sds->fluid), sds->res, pos);
+ if (smoke_has_fuel(sds->fluid)) {
+ fuel = BLI_voxel_sample_trilinear(smoke_get_fuel(sds->fluid), sds->res, pos);
+ }
+ return MAX2(density, fuel);
+ }
+ return -1.0f;
+}
+
+int smoke_get_data_flags(SmokeDomainSettings *sds) {
+ int flags = 0;
+ if (smoke_has_heat(sds->fluid)) flags |= SM_ACTIVE_HEAT;
+ if (smoke_has_fuel(sds->fluid)) flags |= SM_ACTIVE_FIRE;
+ if (smoke_has_colors(sds->fluid)) flags |= SM_ACTIVE_COLORS;
+
+ return flags;
+}
+
#endif /* WITH_SMOKE */
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index f47c931e309..bb0cfe1a5c6 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -1170,7 +1170,7 @@ static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float
*damp=df*tune*ob->pd->pdef_sbdamp;
- df = 0.01f*exp(- 100.0f*df);
+ df = 0.01f * expf(-100.0f * df);
Vec3PlusStVec(force, -df, d_nvect);
deflected = 3;
}
@@ -1598,7 +1598,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
/*see if we have wind*/
if (do_effector) {
EffectedPoint epoint;
- float speed[3]={0.0f, 0.0f, 0.0f};
+ float speed[3] = {0.0f, 0.0f, 0.0f};
float pos[3];
mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos);
mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec);
@@ -1749,8 +1749,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
Object *ob= NULL;
GHash *hash;
GHashIterator *ihash;
- float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], dv1[3], ve[3], avel[3]={0.0, 0.0, 0.0},
- vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f,
+ float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], dv1[3], ve[3], avel[3] = {0.0, 0.0, 0.0},
+ vv1[3], vv2[3], vv3[3], vv4[3], coledge[3] = {0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f,
outerforceaccu[3], innerforceaccu[3],
facedist, /* n_mag, */ /* UNUSED */ force_mag_norm, minx, miny, minz, maxx, maxy, maxz,
innerfacethickness = -0.5f, outerfacethickness = 0.2f,
@@ -2209,7 +2209,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
bp = &sb->bpoint[ifirst];
for (bb=number_of_points_here; bb>0; bb--, bp++) {
/* clear forces accumulator */
- bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
+ bp->force[0] = bp->force[1] = bp->force[2] = 0.0;
/* naive ball self collision */
/* needs to be done if goal snaps or not */
if (do_selfcollision) {
@@ -2304,8 +2304,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
if (do_effector) {
EffectedPoint epoint;
float kd;
- float force[3]= {0.0f, 0.0f, 0.0f};
- float speed[3]= {0.0f, 0.0f, 0.0f};
+ float force[3] = {0.0f, 0.0f, 0.0f};
+ float speed[3] = {0.0f, 0.0f, 0.0f};
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint);
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
@@ -2557,7 +2557,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* clear forces accumulator */
- bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
+ bp->force[0] = bp->force[1] = bp->force[2] = 0.0;
if (nl_flags & NLF_BUILD) {
//int ia =3*(sb->totpoint-a);
//int op =3*sb->totpoint;
@@ -2712,8 +2712,8 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* particle field & vortex */
if (do_effector) {
EffectedPoint epoint;
- float force[3]= {0.0f, 0.0f, 0.0f};
- float speed[3]= {0.0f, 0.0f, 0.0f};
+ float force[3] = {0.0f, 0.0f, 0.0f};
+ float speed[3] = {0.0f, 0.0f, 0.0f};
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint);
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
@@ -2905,7 +2905,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* or heun ~ 2nd order runge-kutta steps, mode 1, 2 */
SoftBody *sb= ob->soft; /* is supposed to be there */
BodyPoint *bp;
- float dx[3]={0}, dv[3], aabbmin[3], aabbmax[3], cm[3]={0.0f, 0.0f, 0.0f};
+ float dx[3] = {0}, dv[3], aabbmin[3], aabbmax[3], cm[3] = {0.0f, 0.0f, 0.0f};
float timeovermass/*, freezeloc=0.00001f, freezeforce=0.00000000001f*/;
float maxerrpos= 0.0f, maxerrvel = 0.0f;
int a, fuzzy=0;
@@ -3194,7 +3194,7 @@ static void interpolate_exciter(Object *ob, int timescale, int time)
- xxxx_to_softbody(Object *ob) : a full (new) copy, creates SB geometry
*/
-static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex, float *target)
+static void get_scalar_from_vertexgroup(Object *ob, int vertID, int groupindex, float *target)
/* result 0 on success, else indicates error number
-- kind of *inverse* result defintion,
-- but this way we can signal error condition to caller
@@ -3297,7 +3297,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */
/* I'd like to have it .. if (sb->namedVG_Goal[0]) */
- get_scalar_from_vertexgroup(ob, a, (short) (sb->vertgroup-1), &bp->goal);
+ get_scalar_from_vertexgroup(ob, a, sb->vertgroup - 1, &bp->goal);
/* do this always, regardless successful read from vertex group */
/* this is where '2.5 every thing is animatable' goes wrong in the first place jow_go_for2_5 */
/* 1st coding action to take : move this to frame level */
@@ -3316,10 +3316,10 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
*/
if (sb->namedVG_Mass[0]) {
- int grp= defgroup_name_index (ob, sb->namedVG_Mass);
- /* printf("VGN %s %d\n", sb->namedVG_Mass, grp); */
- if (grp > -1) {
- get_scalar_from_vertexgroup(ob, a, (short) (grp), &bp->mass);
+ int defgrp_index = defgroup_name_index (ob, sb->namedVG_Mass);
+ /* printf("VGN %s %d\n", sb->namedVG_Mass, defgrp_index); */
+ if (defgrp_index != -1) {
+ get_scalar_from_vertexgroup(ob, a, defgrp_index, &bp->mass);
/* 2.5 bp->mass = bp->mass * sb->nodemass; */
/* printf("bp->mass %f\n", bp->mass); */
@@ -3329,10 +3329,10 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
bp->springweight = 1.0f;
if (sb->namedVG_Spring_K[0]) {
- int grp= defgroup_name_index (ob, sb->namedVG_Spring_K);
- //printf("VGN %s %d\n", sb->namedVG_Spring_K, grp);
- if (grp > -1) {
- get_scalar_from_vertexgroup(ob, a, (short) (grp), &bp->springweight);
+ int defgrp_index = defgroup_name_index (ob, sb->namedVG_Spring_K);
+ //printf("VGN %s %d\n", sb->namedVG_Spring_K, defgrp_index);
+ if (defgrp_index != -1) {
+ get_scalar_from_vertexgroup(ob, a, defgrp_index , &bp->springweight);
//printf("bp->springweight %f\n", bp->springweight);
}
@@ -3865,7 +3865,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
copy_v3_v3(bp->origS, bp->pos);
copy_v3_v3(bp->origE, bp->pos);
copy_v3_v3(bp->origT, bp->pos);
- bp->vec[0]= bp->vec[1]= bp->vec[2]= 0.0f;
+ bp->vec[0] = bp->vec[1] = bp->vec[2] = 0.0f;
/* the bp->prev*'s are for rolling back from a canceled try to propagate in time
* adaptive step size algo in a nutshell:
@@ -4008,8 +4008,8 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
}
loops++;
if (sb->solverflags & SBSO_MONITOR ) {
- sct=PIL_check_seconds_timer();
- if (sct-sst > 0.5f) printf("%3.0f%% \r", 100.0f*timedone/dtime);
+ sct = PIL_check_seconds_timer();
+ if (sct - sst > 0.5) printf("%3.0f%% \r", 100.0f * timedone / dtime);
}
/* ask for user break */
if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break;
@@ -4045,7 +4045,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
if (sb->solverflags & SBSO_MONITOR ) {
sct=PIL_check_seconds_timer();
- if ((sct-sst > 0.5f) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n", sct-sst, ob->id.name);
+ if ((sct - sst > 0.5) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n", sct-sst, ob->id.name);
}
}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 385d1bb6fc5..af9d21d8cbc 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -353,17 +353,17 @@ void sound_load(struct Main *bmain, bSound *sound)
}
// XXX unused currently
#if 0
- break;
+ break;
+ }
+ case SOUND_TYPE_BUFFER:
+ if (sound->child_sound && sound->child_sound->handle)
+ sound->handle = AUD_bufferSound(sound->child_sound->handle);
+ break;
+ case SOUND_TYPE_LIMITER:
+ if (sound->child_sound && sound->child_sound->handle)
+ sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
+ break;
}
- case SOUND_TYPE_BUFFER:
- if (sound->child_sound && sound->child_sound->handle)
- sound->handle = AUD_bufferSound(sound->child_sound->handle);
- break;
- case SOUND_TYPE_LIMITER:
- if (sound->child_sound && sound->child_sound->handle)
- sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
- break;
-}
#endif
if (sound->flags & SOUND_FLAGS_MONO) {
void *handle = AUD_monoSound(sound->handle);
@@ -701,7 +701,7 @@ void sound_update_scene(struct Scene *scene)
if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
if (speaker->sound)
- AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
+ AUD_moveSequence(strip->speaker_handle, (double)strip->start / FPS, -1, 0);
else {
AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
strip->speaker_handle = NULL;
@@ -709,7 +709,9 @@ void sound_update_scene(struct Scene *scene)
}
else {
if (speaker->sound) {
- strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0);
+ strip->speaker_handle = AUD_addSequence(scene->sound_scene,
+ speaker->sound->playback_handle,
+ (double)strip->start / FPS, -1, 0);
AUD_setRelativeSequence(strip->speaker_handle, 0);
}
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index e1a7bb792f8..ff975535cf6 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -602,7 +602,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
}
mp = mpoly;
- index = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
+ index = (int *)dm->getPolyDataArray(dm, CD_ORIGINDEX);
for (i = 0; i < dm->numPolyData; i++, mp++) {
CCGFace *f;
@@ -2802,6 +2802,30 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
{
if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
+ int *origindex;
+
+ /* Avoid re-creation if the layer exists already */
+ origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ if (origindex) {
+ return origindex;
+ }
+
+ DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
+ origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+
+ /* silly loop counting up */
+ range_vn_i(origindex, dm->getNumTessFaces(dm), 0);
+
+ return origindex;
+ }
+
+ return DM_get_tessface_data_layer(dm, type);
+}
+
+static void *ccgDM_get_poly_data_layer(DerivedMesh *dm, int type)
+{
+ if (type == CD_ORIGINDEX) {
+ /* create origindex on demand to save memory */
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
CCGSubSurf *ss = ccgdm->ss;
int *origindex;
@@ -2809,13 +2833,13 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
int gridFaces = ccgSubSurf_getGridSize(ss) - 1;
/* Avoid re-creation if the layer exists already */
- origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ origindex = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
if (origindex) {
return origindex;
}
- DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
- origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ DM_add_poly_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
+ origindex = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
totface = ccgSubSurf_getNumFaces(ss);
@@ -2831,7 +2855,7 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
return origindex;
}
- return DM_get_tessface_data_layer(dm, type);
+ return DM_get_poly_data_layer(dm, type);
}
static void *ccgDM_get_vert_data(DerivedMesh *dm, int index, int type)
@@ -2864,6 +2888,16 @@ static void *ccgDM_get_tessface_data(DerivedMesh *dm, int index, int type)
return DM_get_tessface_data(dm, index, type);
}
+static void *ccgDM_get_poly_data(DerivedMesh *dm, int index, int type)
+{
+ if (type == CD_ORIGINDEX) {
+ /* ensure creation of CD_ORIGINDEX layer */
+ ccgDM_get_tessface_data_layer(dm, type);
+ }
+
+ return DM_get_poly_data(dm, index, type);
+}
+
static int ccgDM_getNumGrids(DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
@@ -3087,7 +3121,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
* when the ccgdm gets remade, the assumption is that the topology
* does not change. */
ccgdm_create_grids(dm);
- BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void **)ccgdm->gridFaces);
+ BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void **)ccgdm->gridFaces,
+ ccgdm->gridFlagMats, ccgdm->gridHidden);
}
ccgdm->pbvh = ob->sculpt->pbvh;
@@ -3116,6 +3151,9 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
me->totface, me->totvert, &me->vdata);
}
+ if (ccgdm->pbvh)
+ pbvh_show_diffuse_color_set(ccgdm->pbvh, ob->sculpt->show_diffuse_color);
+
return ccgdm->pbvh;
}
@@ -3191,7 +3229,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
}
/* We absolutely need that layer, else it's no valid tessellated data! */
- polyidx = CustomData_add_layer(&ccgdm->dm.faceData, CD_POLYINDEX, CD_CALLOC,
+ polyidx = CustomData_add_layer(&ccgdm->dm.faceData, CD_ORIGINDEX, CD_CALLOC,
NULL, ccgSubSurf_getNumFinalFaces(ss));
ccgdm->dm.getMinMax = ccgDM_getMinMax;
@@ -3219,9 +3257,11 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->dm.getVertData = ccgDM_get_vert_data;
ccgdm->dm.getEdgeData = ccgDM_get_edge_data;
ccgdm->dm.getTessFaceData = ccgDM_get_tessface_data;
+ ccgdm->dm.getPolyData = ccgDM_get_poly_data;
ccgdm->dm.getVertDataArray = ccgDM_get_vert_data_layer;
ccgdm->dm.getEdgeDataArray = ccgDM_get_edge_data_layer;
ccgdm->dm.getTessFaceDataArray = ccgDM_get_tessface_data_layer;
+ ccgdm->dm.getPolyDataArray = ccgDM_get_poly_data_layer;
ccgdm->dm.getNumGrids = ccgDM_getNumGrids;
ccgdm->dm.getGridSize = ccgDM_getGridSize;
ccgdm->dm.getGridData = ccgDM_getGridData;
@@ -3320,8 +3360,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
vertOrigIndex = DM_get_vert_data_layer(&ccgdm->dm, CD_ORIGINDEX);
/*edgeOrigIndex = DM_get_edge_data_layer(&ccgdm->dm, CD_ORIGINDEX);*/
- faceOrigIndex = DM_get_tessface_data_layer(&ccgdm->dm, CD_ORIGINDEX);
+ faceOrigIndex = DM_get_tessface_data_layer(&ccgdm->dm, CD_ORIGINDEX);
polyOrigIndex = DM_get_poly_data_layer(&ccgdm->dm, CD_ORIGINDEX);
#if 0
@@ -3459,7 +3499,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
/*set original index data*/
if (faceOrigIndex) {
- *faceOrigIndex = origIndex;
+ /* reference the index in 'polyOrigIndex' */
+ *faceOrigIndex = faceNum;
faceOrigIndex++;
}
if (polyOrigIndex) {
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 05d0705107d..d230cf8f1fe 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -55,12 +55,15 @@
#include "DNA_text_types.h"
#include "DNA_userdef_types.h"
#include "DNA_object_types.h"
+#include "DNA_node_types.h"
+#include "DNA_material_types.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_text.h"
+#include "BKE_node.h"
#ifdef WITH_PYTHON
@@ -314,7 +317,7 @@ int BKE_text_reload(Text *text)
fseek(fp, 0L, SEEK_END);
len = ftell(fp);
- fseek(fp, 0L, SEEK_SET);
+ fseek(fp, 0L, SEEK_SET);
text->undo_pos = -1;
@@ -370,7 +373,7 @@ int BKE_text_reload(Text *text)
text->curl = text->sell = text->lines.first;
text->curc = text->selc = 0;
- MEM_freeN(buffer);
+ MEM_freeN(buffer);
return 1;
}
@@ -404,7 +407,7 @@ Text *BKE_text_load(const char *file, const char *relpath)
fseek(fp, 0L, SEEK_END);
len = ftell(fp);
- fseek(fp, 0L, SEEK_SET);
+ fseek(fp, 0L, SEEK_SET);
ta->name = MEM_mallocN(strlen(file) + 1, "text_name");
strcpy(ta->name, file);
@@ -469,7 +472,7 @@ Text *BKE_text_load(const char *file, const char *relpath)
ta->curl = ta->sell = ta->lines.first;
ta->curc = ta->selc = 0;
- MEM_freeN(buffer);
+ MEM_freeN(buffer);
return ta;
}
@@ -531,6 +534,9 @@ void BKE_text_unlink(Main *bmain, Text *text)
bController *cont;
bActuator *act;
bConstraint *con;
+ bNodeTree *ntree;
+ bNode *node;
+ Material *mat;
short update;
for (ob = bmain->object.first; ob; ob = ob->id.next) {
@@ -582,6 +588,28 @@ void BKE_text_unlink(Main *bmain, Text *text)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
+ /* nodes */
+ for (mat = bmain->mat.first; mat; mat = mat->id.next) {
+ ntree = mat->nodetree;
+ if (!ntree)
+ continue;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_SCRIPT) {
+ Text *ntext = (Text *)node->id;
+ if (ntext == text) node->id = NULL;
+ }
+ }
+ }
+
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_SCRIPT) {
+ Text *ntext = (Text *)node->id;
+ if (ntext == text) node->id = NULL;
+ }
+ }
+ }
+
/* text space */
for (scr = bmain->screen.first; scr; scr = scr->id.next) {
for (area = scr->areabase.first; area; area = area->next) {
@@ -683,7 +711,7 @@ void txt_clean_text(Text *text)
if (!text->lines.first) {
if (text->lines.last) text->lines.first = text->lines.last;
else text->lines.first = text->lines.last = txt_new_line(NULL);
- }
+ }
if (!text->lines.last) text->lines.last = text->lines.first;
@@ -732,7 +760,7 @@ int txt_get_span(TextLine *from, TextLine *to)
if (!tmp) ret = 0;
}
- return ret;
+ return ret;
}
static void txt_make_dirty(Text *text)
@@ -934,7 +962,7 @@ void txt_move_right(Text *text, short sel)
txt_move_down(text, sel);
*charp = 0;
}
- }
+ }
else {
// do nice right only if there are only spaces
// spaces hardcoded in DNA_text_types.h
@@ -1376,7 +1404,7 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
int newc = (int)(s - tl->line);
txt_move_to(text, newl, newc, 0);
txt_move_to(text, newl, newc + strlen(findstr), 1);
- return 1;
+ return 1;
}
else
return 0;
@@ -1458,7 +1486,7 @@ char *txt_sel_to_buf(Text *text)
length += charl;
buf[length] = 0;
- }
+ }
return buf;
}
@@ -2078,7 +2106,7 @@ void txt_do_undo(Text *text)
charp = op - UNDO_BS_1 + 1;
txt_add_char(text, txt_undo_read_unicode(text->undo_buf, &text->undo_pos, charp));
text->undo_pos--;
- break;
+ break;
case UNDO_DEL_1: case UNDO_DEL_2: case UNDO_DEL_3: case UNDO_DEL_4:
charp = op - UNDO_DEL_1 + 1;
@@ -2104,7 +2132,7 @@ void txt_do_undo(Text *text)
txt_curs_first(text, &holdl, &holdc);
holdln = txt_get_span(text->lines.first, holdl);
- txt_insert_buf(text, buf);
+ txt_insert_buf(text, buf);
MEM_freeN(buf);
text->curl = text->lines.first;
@@ -2235,7 +2263,7 @@ void txt_do_redo(Text *text)
unsigned short charp;
char *buf;
- text->undo_pos++;
+ text->undo_pos++;
op = text->undo_buf[text->undo_pos];
if (!op) {
@@ -2351,7 +2379,7 @@ void txt_do_redo(Text *text)
text->undo_pos += linep;
buf[linep] = 0;
- txt_insert_buf(text, buf);
+ txt_insert_buf(text, buf);
MEM_freeN(buf);
text->undo_pos++;
@@ -2369,7 +2397,7 @@ void txt_do_redo(Text *text)
//charp is the first char selected or 0
linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos);
- //linep is now the first line of the selection
+ //linep is now the first line of the selection
//set the selcetion for this now
text->curc = charp;
text->curl = text->lines.first;
@@ -2476,7 +2504,7 @@ void txt_split_curline(Text *text)
text->curl->format = NULL;
text->curl->len = text->curl->len - text->curc;
- BLI_insertlinkbefore(&text->lines, text->curl, ins);
+ BLI_insertlinkbefore(&text->lines, text->curl, ins);
text->curc = 0;
@@ -2834,7 +2862,7 @@ int txt_replace_char(Text *text, unsigned int add)
void txt_indent(Text *text)
{
- int len, num;
+ int len, num, curc_old;
char *tmp;
const char *add = "\t";
@@ -2857,6 +2885,8 @@ void txt_indent(Text *text)
indentlen = spaceslen;
}
+ curc_old = text->curc;
+
num = 0;
while (TRUE) {
tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string");
@@ -2877,7 +2907,7 @@ void txt_indent(Text *text)
txt_clean_text(text);
if (text->curl == text->sell) {
- text->selc = text->sell->len;
+ text->selc += indentlen;
break;
}
else {
@@ -2885,7 +2915,9 @@ void txt_indent(Text *text)
num++;
}
}
- text->curc = 0;
+ if (!curc_old) text->curc = 0;
+ else text->curc = curc_old + indentlen;
+
while (num > 0) {
text->curl = text->curl->prev;
num--;
@@ -2900,7 +2932,8 @@ void txt_unindent(Text *text)
{
int num = 0;
const char *remove = "\t";
- int indent = 1;
+ int indentlen = 1;
+ int unindented_first = FALSE;
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
@@ -2912,25 +2945,26 @@ void txt_unindent(Text *text)
/* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES) {
remove = tab_to_spaces;
- indent = spaceslen;
+ indentlen = spaceslen;
}
while (TRUE) {
int i = 0;
- if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) {
+ if (BLI_strncasecmp(text->curl->line, remove, indentlen) == 0) {
+ if (num == 0) unindented_first = TRUE;
while (i < text->curl->len) {
- text->curl->line[i] = text->curl->line[i + indent];
+ text->curl->line[i] = text->curl->line[i + indentlen];
i++;
}
- text->curl->len -= indent;
+ text->curl->len -= indentlen;
}
txt_make_dirty(text);
txt_clean_text(text);
if (text->curl == text->sell) {
- text->selc = text->sell->len;
+ if (i > 0) text->selc = MAX2(text->selc - indentlen, 0);
break;
}
else {
@@ -2939,7 +2973,9 @@ void txt_unindent(Text *text)
}
}
- text->curc = 0;
+
+ if (unindented_first) text->curc = MAX2(text->curc - indentlen, 0);
+
while (num > 0) {
text->curl = text->curl->prev;
num--;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 9dd83181521..6d0313f6334 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -571,7 +571,7 @@ void default_mtex(MTex *mtex)
mtex->size[1] = 1.0;
mtex->size[2] = 1.0;
mtex->tex = NULL;
- mtex->texflag = MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE;
+ mtex->texflag = MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE | MTEX_MAPTO_BOUNDS;
mtex->colormodel = 0;
mtex->r = 1.0;
mtex->g = 0.0;
@@ -646,7 +646,7 @@ MTex *add_mtex_id(ID *id, int slot)
if (slot == -1) {
/* find first free */
- int i;
+ int i;
for (i = 0; i < MAX_MTEX; i++) {
if (!mtex_ar[i]) {
slot = i;
@@ -909,8 +909,7 @@ void autotexname(Tex *tex)
if (tex->use_nodes) {
new_id(&bmain->tex, (ID *)tex, "Noddy");
}
- else
- if (tex->type == TEX_IMAGE) {
+ else if (tex->type == TEX_IMAGE) {
ima = tex->ima;
if (ima) {
BLI_strncpy(di, ima->name, sizeof(di));
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index c9d7ec3964f..b174f27b7e1 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -51,6 +51,8 @@
#include "BLI_string.h"
#include "BLI_threads.h"
+#include "BLF_translation.h"
+
#include "BKE_global.h"
#include "BKE_tracking.h"
#include "BKE_movieclip.h"
@@ -169,10 +171,9 @@ void BKE_tracking_settings_init(MovieTracking *tracking)
tracking->settings.default_minimum_correlation = 0.75;
tracking->settings.default_pattern_size = 11;
tracking->settings.default_search_size = 61;
- tracking->settings.keyframe1 = 1;
- tracking->settings.keyframe2 = 30;
tracking->settings.dist = 1;
tracking->settings.object_distance = 1;
+ tracking->settings.reconstruction_success_threshold = 1e-3;
tracking->stabilization.scaleinf = 1.0f;
tracking->stabilization.locinf = 1.0f;
@@ -223,7 +224,7 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingOb
float viewfac, pixsize, left, right, bottom, top, clipsta, clipend;
float winmat[4][4];
float ycor = 1.0f / tracking->camera.pixel_aspect;
- float shiftx, shifty, winside = MAX2(winx, winy);
+ float shiftx, shifty, winside = (float)min_ii(winx, winy);
BKE_tracking_camera_shift_get(tracking, winx, winy, &shiftx, &shifty);
@@ -633,7 +634,7 @@ void BKE_tracking_track_path_clear(MovieTrackingTrack *track, int ref_frame, int
}
}
-void BKE_tracking_tracks_join(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
+void BKE_tracking_tracks_join(MovieTracking *tracking, MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
{
int i = 0, a = 0, b = 0, tot;
MovieTrackingMarker *markers;
@@ -736,6 +737,8 @@ void BKE_tracking_tracks_join(MovieTrackingTrack *dst_track, MovieTrackingTrack
dst_track->markersnr = i;
MEM_freeN(markers);
+
+ BKE_tracking_dopesheet_tag_update(tracking);
}
MovieTrackingTrack *BKE_tracking_track_get_named(MovieTracking *tracking, MovieTrackingObject *object, const char *name)
@@ -997,8 +1000,8 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event)
if (event == CLAMP_PAT_DIM) {
for (a = 0; a < 2; a++) {
/* search shouldn't be resized smaller than pattern */
- marker->search_min[a] = minf(pat_min[a], marker->search_min[a]);
- marker->search_max[a] = maxf(pat_max[a], marker->search_max[a]);
+ marker->search_min[a] = min_ff(pat_min[a], marker->search_min[a]);
+ marker->search_max[a] = max_ff(pat_max[a], marker->search_max[a]);
}
}
else if (event == CLAMP_PAT_POS) {
@@ -1022,8 +1025,8 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event)
else if (event == CLAMP_SEARCH_DIM) {
for (a = 0; a < 2; a++) {
/* search shouldn't be resized smaller than pattern */
- marker->search_min[a] = minf(pat_min[a], marker->search_min[a]);
- marker->search_max[a] = maxf(pat_max[a], marker->search_max[a]);
+ marker->search_min[a] = min_ff(pat_min[a], marker->search_min[a]);
+ marker->search_max[a] = max_ff(pat_max[a], marker->search_max[a]);
}
}
else if (event == CLAMP_SEARCH_POS) {
@@ -1179,23 +1182,25 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char
tracking->objectnr = BLI_countlist(&tracking->objects) - 1;
object->scale = 1.0f;
+ object->keyframe1 = 1;
+ object->keyframe2 = 30;
BKE_tracking_object_unique_name(tracking, object);
return object;
}
-void BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *object)
+int BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *object)
{
MovieTrackingTrack *track;
int index = BLI_findindex(&tracking->objects, object);
- if (index < 0)
- return;
+ if (index == -1)
+ return FALSE;
if (object->flag & TRACKING_OBJECT_CAMERA) {
/* object used for camera solving can't be deleted */
- return;
+ return FALSE;
}
track = object->tracks.first;
@@ -1211,10 +1216,11 @@ void BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *ob
tracking->tot_object--;
- if (index > 0)
+ if (index != 0)
tracking->objectnr = index - 1;
else
tracking->objectnr = 0;
+ return TRUE;
}
void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object)
@@ -1494,7 +1500,8 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
ibuf->x, ibuf->y, overscan, ibuf->channels);
}
- resibuf->userflags |= IB_RECT_INVALID;
+ if (ibuf->rect)
+ imb_freerectImBuf(ibuf);
}
else {
if (undistort) {
@@ -1512,9 +1519,8 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
(void) overscan;
(void) undistort;
- if (ibuf->rect_float) {
- resibuf->userflags |= IB_RECT_INVALID;
- }
+ if (ibuf->rect_float && ibuf->rect)
+ imb_freerectImBuf(ibuf);
#endif
return resibuf;
@@ -1618,6 +1624,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
double warped_position_x, warped_position_y;
float *mask = NULL;
+ if (num_samples_x <= 0 || num_samples_y <= 0)
+ return NULL;
+
pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
if (!search_ibuf->rect_float) {
@@ -1684,10 +1693,15 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo
search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels);
- pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker,
- FALSE, num_samples_x, num_samples_y, NULL);
+ if (search_ibuf) {
+ pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker,
+ FALSE, num_samples_x, num_samples_y, NULL);
- IMB_freeImBuf(search_ibuf);
+ IMB_freeImBuf(search_ibuf);
+ }
+ else {
+ pattern_ibuf = NULL;
+ }
return pattern_ibuf;
}
@@ -1712,6 +1726,9 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov
w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
+ if (w <= 0 || h <= 0)
+ return NULL;
+
searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
@@ -2136,7 +2153,7 @@ void BKE_tracking_context_sync(MovieTrackingContext *context)
context->sync_frame = newframe;
- tracking->dopesheet.ok = FALSE;
+ BKE_tracking_dopesheet_tag_update(tracking);
}
void BKE_tracking_context_sync_user(const MovieTrackingContext *context, MovieClipUser *user)
@@ -2181,6 +2198,12 @@ static float *track_get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track,
searchibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, FALSE, TRUE);
+ if (!searchibuf) {
+ *width_r = 0;
+ *height_r = 0;
+ return NULL;
+ }
+
width = searchibuf->x;
height = searchibuf->y;
@@ -2343,10 +2366,10 @@ static int tracking_check_marker_margin(MovieTrackingTrack *track, MovieTracking
/* margin from frame boundaries */
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
sub_v2_v2v2(dim, pat_max, pat_min);
- margin[0] = margin[1] = maxf(dim[0], dim[1]) / 2.0f;
+ margin[0] = margin[1] = max_ff(dim[0], dim[1]) / 2.0f;
- margin[0] = maxf(margin[0], (float)track->margin / frame_width);
- margin[1] = maxf(margin[1], (float)track->margin / frame_height);
+ margin[0] = max_ff(margin[0], (float)track->margin / frame_width);
+ margin[1] = max_ff(margin[1], (float)track->margin / frame_height);
/* do not track markers which are too close to boundary */
if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] ||
@@ -2500,6 +2523,9 @@ int BKE_tracking_context_step(MovieTrackingContext *context)
get_marker_coords_for_tracking(frame_width, frame_height, &track_context->marker, src_pixel_x, src_pixel_y);
get_marker_coords_for_tracking(frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
+ if (!patch_new || !track_context->search_area)
+ continue;
+
/* run the tracker! */
tracked = libmv_trackRegion(&options,
track_context->search_area,
@@ -2556,6 +2582,9 @@ typedef struct MovieReconstructContext {
TracksMap *tracks_map;
+ float success_threshold;
+ int use_fallback_reconstruction;
+
int sfra, efra;
} MovieReconstructContext;
@@ -2755,10 +2784,11 @@ static int reconstruct_refine_intrinsics_get_flags(MovieTracking *tracking, Movi
return flags;
}
-static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase)
+static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, MovieTrackingObject *object)
{
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
int tot = 0;
- int frame1 = tracking->settings.keyframe1, frame2 = tracking->settings.keyframe2;
+ int frame1 = object->keyframe1, frame2 = object->keyframe2;
MovieTrackingTrack *track;
track = tracksbase->first;
@@ -2779,14 +2809,12 @@ static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, L
int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObject *object, char *error_msg, int error_size)
{
#ifdef WITH_LIBMV
- ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
-
if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) {
/* TODO: check for number of tracks? */
return TRUE;
}
- else if (reconstruct_count_tracks_on_both_keyframes(tracking, tracksbase) < 8) {
- BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction",
+ else if (reconstruct_count_tracks_on_both_keyframes(tracking, object) < 8) {
+ BLI_strncpy(error_msg, N_("At least 8 common tracks on both of keyframes are needed for reconstruction"),
error_size);
return FALSE;
@@ -2794,7 +2822,7 @@ int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObje
return TRUE;
#else
- BLI_strncpy(error_msg, "Blender is compiled without motion tracking library", error_size);
+ BLI_strncpy(error_msg, N_("Blender is compiled without motion tracking library"), error_size);
(void) tracking;
(void) object;
@@ -2826,6 +2854,9 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
context->k2 = camera->k2;
context->k3 = camera->k3;
+ context->success_threshold = tracking->settings.reconstruction_success_threshold;
+ context->use_fallback_reconstruction = tracking->settings.reconstruction_flag & TRACKING_USE_FALLBACK_RECONSTRUCTION;
+
context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
track = tracksbase->first;
@@ -2847,10 +2878,10 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
}
if (first < track->markersnr - 1)
- sfra = MIN2(sfra, first_marker->framenr);
+ sfra = min_ii(sfra, first_marker->framenr);
if (last >= 0)
- efra = MAX2(efra, last_marker->framenr);
+ efra = max_ii(efra, last_marker->framenr);
tracks_map_insert(context->tracks_map, track, NULL);
@@ -2925,12 +2956,18 @@ void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *
reconstruct_update_solve_cb, &progressdata);
}
else {
+ struct libmv_reconstructionOptions options;
+
+ options.success_threshold = context->success_threshold;
+ options.use_fallback_reconstruction = context->use_fallback_reconstruction;
+
context->reconstruction = libmv_solveReconstruction(context->tracks,
context->keyframe1, context->keyframe2,
context->refine_flags,
context->focal_length,
context->principal_point[0], context->principal_point[1],
context->k1, context->k2, context->k3,
+ &options,
reconstruct_update_solve_cb, &progressdata);
}
@@ -2952,6 +2989,7 @@ int BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieTr
MovieTrackingReconstruction *reconstruction;
tracks_map_merge(context->tracks_map, tracking);
+ BKE_tracking_dopesheet_tag_update(tracking);
if (context->is_camera) {
reconstruction = &tracking->reconstruction;
@@ -3197,8 +3235,8 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i
if (track->flag & TRACK_USE_2D_STAB ||
((stab->flag & TRACKING_STABILIZE_ROTATION) && track == stab->rot_track))
{
- sfra = MIN2(sfra, track->markers[0].framenr);
- efra = MAX2(efra, track->markers[track->markersnr - 1].framenr);
+ sfra = min_ii(sfra, track->markers[0].framenr);
+ efra = max_ii(efra, track->markers[track->markersnr - 1].framenr);
}
track = track->next;
@@ -3274,7 +3312,7 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i
S = (-w * I - h * J) / (dx * I + dy * J + K);
- scale = maxf(scale, S);
+ scale = max_ff(scale, S);
}
}
}
@@ -3283,7 +3321,7 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i
stab->scale = scale;
if (stab->maxscale > 0.0f)
- stab->scale = minf(stab->scale, stab->maxscale);
+ stab->scale = min_ff(stab->scale, stab->maxscale);
}
else {
stab->scale = 1.0f;
@@ -3642,7 +3680,7 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel)
channel->segments[2 * segment] = start_marker->framenr;
channel->segments[2 * segment + 1] = start_marker->framenr + len;
- channel->max_segment = MAX2(channel->max_segment, len);
+ channel->max_segment = max_ii(channel->max_segment, len);
segment++;
}
@@ -3650,7 +3688,7 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel)
}
}
-static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse)
+static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse)
{
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 46836b1f8d1..84e1f29f6c0 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -259,7 +259,7 @@ static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0,
static struct bUnitDef buNaturalRotDef[] = {
- {"degree", "degrees", "°", NULL, "Degrees", M_PI/180.0, 0.0, B_UNIT_DEF_NONE},
+ {"degree", "degrees", "°", NULL, "Degrees", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE},
// {"radian", "radians", "r", NULL, "Radians", 1.0, 0.0, B_UNIT_DEF_NONE},
// {"turn", "turns", "t", NULL, "Turns", 1.0/(M_PI*2.0), 0.0,B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 434bfe19c1f..4bde895cf7d 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -107,7 +107,7 @@ World *add_world(const char *name)
wrld->ao_indirect_energy = 1.0f;
wrld->ao_indirect_bounces = 1;
wrld->aobias = 0.05f;
- wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
+ wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
wrld->ao_approx_error = 0.25f;
wrld->preview = NULL;
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index dab44b5463c..d4428be3faf 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -47,7 +47,11 @@
#include "BKE_report.h"
#include "BKE_writeavi.h"
-#include "AVI_avi.h"
+
+/* ********************** general blender movie support ***************************** */
+
+#ifdef WITH_AVI
+# include "AVI_avi.h"
/* callbacks */
static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports);
@@ -55,30 +59,31 @@ static void end_avi(void);
static int append_avi(RenderData *rd, int start_frame, int frame, int *pixels,
int rectx, int recty, ReportList *reports);
static void filepath_avi(char *string, RenderData *rd);
-
-/* ********************** general blender movie support ***************************** */
+#endif /* WITH_AVI */
#ifdef WITH_QUICKTIME
-#include "quicktime_export.h"
+# include "quicktime_export.h"
#endif
#ifdef WITH_FFMPEG
-#include "BKE_writeffmpeg.h"
+# include "BKE_writeffmpeg.h"
#endif
#include "BKE_writeframeserver.h"
bMovieHandle *BKE_movie_handle_get(const char imtype)
{
- static bMovieHandle mh;
+ static bMovieHandle mh = {0};
/* set the default handle, as builtin */
+#ifdef WITH_AVI
mh.start_movie = start_avi;
mh.append_movie = append_avi;
mh.end_movie = end_avi;
mh.get_next_frame = NULL;
mh.get_movie_path = filepath_avi;
-
+#endif
+
/* do the platform specific handles */
#ifdef WITH_QUICKTIME
if (imtype == R_IMF_IMTYPE_QUICKTIME) {
@@ -114,6 +119,8 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
/* ****************************************************************** */
+#ifdef WITH_AVI
+
static AviMovie *avi = NULL;
static void filepath_avi(char *string, RenderData *rd)
@@ -155,7 +162,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL
else format = AVI_FORMAT_MJPEG;
if (AVI_open_compress(name, avi, 1, format) != AVI_ERROR_NONE) {
- BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file.");
+ BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file");
MEM_freeN(avi);
avi = NULL;
return 0;
@@ -168,8 +175,8 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL
avi->interlace = 0;
avi->odd_fields = 0;
-/* avi->interlace= rd->mode & R_FIELDS; */
-/* avi->odd_fields= (rd->mode & R_ODDFIELD)?1:0; */
+/* avi->interlace = rd->mode & R_FIELDS; */
+/* avi->odd_fields = (rd->mode & R_ODDFIELD) ? 1 : 0; */
printf("Created avi: %s\n", name);
return 1;
@@ -219,6 +226,7 @@ static void end_avi(void)
MEM_freeN(avi);
avi = NULL;
}
+#endif /* WITH_AVI */
/* similar to BKE_makepicstring() */
void BKE_movie_filepath_get(char *string, RenderData *rd)
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index ff1fdebb728..da9c919c109 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -289,7 +289,7 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame *frame, ReportLis
}
if (!success)
- BKE_report(reports, RPT_ERROR, "Error writing frame.");
+ BKE_report(reports, RPT_ERROR, "Error writing frame");
return success;
}
@@ -307,7 +307,7 @@ static AVFrame *generate_video_frame(uint8_t *pixels, ReportList *reports)
if (c->pix_fmt != PIX_FMT_BGR32) {
rgb_frame = alloc_picture(PIX_FMT_BGR32, width, height);
if (!rgb_frame) {
- BKE_report(reports, RPT_ERROR, "Couldn't allocate temporary frame.");
+ BKE_report(reports, RPT_ERROR, "Could not allocate temporary frame");
return NULL;
}
}
@@ -478,9 +478,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->time_base.den = 2997;
c->time_base.num = 100;
}
- else if ((double) ((int) rd->frs_sec_base) ==
- rd->frs_sec_base)
- {
+ else if ((float) ((int) rd->frs_sec_base) == rd->frs_sec_base) {
c->time_base.den = rd->frs_sec;
c->time_base.num = (int) rd->frs_sec_base;
}
@@ -695,12 +693,12 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
exts = get_file_extensions(ffmpeg_type);
if (!exts) {
- BKE_report(reports, RPT_ERROR, "No valid formats found.");
+ BKE_report(reports, RPT_ERROR, "No valid formats found");
return 0;
}
fmt = av_guess_format(NULL, exts[0], NULL);
if (!fmt) {
- BKE_report(reports, RPT_ERROR, "No valid formats found.");
+ BKE_report(reports, RPT_ERROR, "No valid formats found");
return 0;
}
@@ -795,7 +793,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
if (error[0])
BKE_report(reports, RPT_ERROR, error);
else
- BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
+ BKE_report(reports, RPT_ERROR, "Error initializing video stream");
av_dict_free(&opts);
return 0;
@@ -805,20 +803,20 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of);
if (!audio_stream) {
- BKE_report(reports, RPT_ERROR, "Error initializing audio stream.");
+ BKE_report(reports, RPT_ERROR, "Error initializing audio stream");
av_dict_free(&opts);
return 0;
}
}
if (!(fmt->flags & AVFMT_NOFILE)) {
if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) {
- BKE_report(reports, RPT_ERROR, "Could not open file for writing.");
+ BKE_report(reports, RPT_ERROR, "Could not open file for writing");
av_dict_free(&opts);
return 0;
}
}
if (avformat_write_header(of, NULL) < 0) {
- BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination.");
+ BKE_report(reports, RPT_ERROR, "Could not initialize streams, probably unsupported codec combination");
av_dict_free(&opts);
return 0;
}
@@ -982,7 +980,7 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i
PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, recty);
-// why is this done before writing the video frame and again at end_ffmpeg?
+/* why is this done before writing the video frame and again at end_ffmpeg? */
// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
if (video_stream) {
@@ -999,7 +997,7 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i
}
#ifdef WITH_AUDASPACE
- write_audio_frames((frame - rd->sfra) / (((double)rd->frs_sec) / rd->frs_sec_base));
+ write_audio_frames((frame - rd->sfra) / (((double)rd->frs_sec) / (double)rd->frs_sec_base));
#endif
return success;
}
@@ -1225,7 +1223,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
while (*param == ' ') param++;
}
- o = my_av_find_opt(&c, name, NULL, 0, 0);
+ o = my_av_find_opt(&c, name, NULL, 0, 0);
if (!o) {
return 0;
}
@@ -1233,7 +1231,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
return 0;
}
if (param && o->type != FF_OPT_TYPE_CONST && o->unit) {
- p = my_av_find_opt(&c, param, o->unit, 0, 0);
+ p = my_av_find_opt(&c, param, o->unit, 0, 0);
if (p) {
prop = BKE_ffmpeg_property_add(rd, (char *) type, p - c.av_class->option, o - c.av_class->option);
}
diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c
index d8fddb9851a..acbbcb0b043 100644
--- a/source/blender/blenkernel/intern/writeframeserver.c
+++ b/source/blender/blenkernel/intern/writeframeserver.c
@@ -118,13 +118,13 @@ int BKE_frameserver_start(struct Scene *scene, RenderData *UNUSED(rd), int rectx
(void)scene; /* unused */
if (!startup_socket_system()) {
- BKE_report(reports, RPT_ERROR, "Can't startup socket system");
+ BKE_report(reports, RPT_ERROR, "Cannot startup socket system");
return 0;
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
shutdown_socket_system();
- BKE_report(reports, RPT_ERROR, "Can't open socket");
+ BKE_report(reports, RPT_ERROR, "Cannot open socket");
return 0;
}
@@ -136,13 +136,13 @@ int BKE_frameserver_start(struct Scene *scene, RenderData *UNUSED(rd), int rectx
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
shutdown_socket_system();
- BKE_report(reports, RPT_ERROR, "Can't bind to socket");
+ BKE_report(reports, RPT_ERROR, "Cannot bind to socket");
return 0;
}
if (listen(sock, SOMAXCONN) < 0) {
shutdown_socket_system();
- BKE_report(reports, RPT_ERROR, "Can't establish listen backlog");
+ BKE_report(reports, RPT_ERROR, "Cannot establish listen backlog");
return 0;
}
connsock = -1;
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index 941a74ec2ab..f068c4c58f0 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -85,4 +85,4 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short
void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes);
void nladata_flush_channels(ListBase *channels);
-#endif // __NLA_PRIVATE_H__
+#endif /* __NLA_PRIVATE_H__ */
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index 74b477bacaf..03b75975af4 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -78,8 +78,6 @@ extern "C" {
#include "BLI_rect.h"
-#include "BLI_noise.h"
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h
index 52b839d11a9..438bffb2fc5 100644
--- a/source/blender/blenlib/BLI_bpath.h
+++ b/source/blender/blenlib/BLI_bpath.h
@@ -48,6 +48,11 @@ void BLI_bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVi
void BLI_bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata);
int BLI_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src);
+/* Functions for temp backup/restore of paths, path count must NOT change */
+void *BLI_bpath_list_backup(struct Main *bmain, const int flag);
+void BLI_bpath_list_restore(struct Main *bmain, const int flag, void *ls_handle);
+void BLI_bpath_list_free(void *ls_handle);
+
#define BLI_BPATH_TRAVERSE_ABS (1 << 0) /* convert paths to absolute */
#define BLI_BPATH_TRAVERSE_SKIP_LIBRARY (1 << 2) /* skip library paths */
#define BLI_BPATH_TRAVERSE_SKIP_PACKED (1 << 3) /* skip packed data */
@@ -64,4 +69,4 @@ void BLI_bpath_missing_files_find(struct Main *bmain, const char *searchpath, st
void BLI_bpath_relative_convert(struct Main *bmain, const char *basedir, struct ReportList *reports);
void BLI_bpath_absolute_convert(struct Main *bmain, const char *basedir, struct ReportList *reports);
-#endif // __BLI_BPATH_H__
+#endif /* __BLI_BPATH_H__ */
diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h
index 92356b24403..bdde8dbd597 100644
--- a/source/blender/blenlib/BLI_dlrbTree.h
+++ b/source/blender/blenlib/BLI_dlrbTree.h
@@ -46,7 +46,7 @@
/* Basic Layout for a Node */
typedef struct DLRBT_Node {
/* ListBase capabilities */
- struct DLRBT_Node *next, *prev;
+ struct DLRBT_Node *next, *prev;
/* Tree Associativity settings */
struct DLRBT_Node *left, *right;
@@ -158,4 +158,4 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node);
/* ********************************************** */
-#endif // __BLI_DLRBTREE_H__
+#endif /* __BLI_DLRBTREE_H__ */
diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h
index 948d462fde4..4bc6d3828b9 100644
--- a/source/blender/blenlib/BLI_endian_switch_inline.h
+++ b/source/blender/blenlib/BLI_endian_switch_inline.h
@@ -74,12 +74,12 @@ BLI_INLINE void BLI_endian_switch_int64(int64_t *val)
{
int64_t tval = *val;
*val = ((tval >> 56)) |
- ((tval << 40) & 0x00ff000000000000) |
- ((tval << 24) & 0x0000ff0000000000) |
- ((tval << 8) & 0x000000ff00000000) |
- ((tval >> 8) & 0x00000000ff000000) |
- ((tval >> 24) & 0x0000000000ff0000) |
- ((tval >> 40) & 0x000000000000ff00) |
+ ((tval << 40) & 0x00ff000000000000ll) |
+ ((tval << 24) & 0x0000ff0000000000ll) |
+ ((tval << 8) & 0x000000ff00000000ll) |
+ ((tval >> 8) & 0x00000000ff000000ll) |
+ ((tval >> 24) & 0x0000000000ff0000ll) |
+ ((tval >> 40) & 0x000000000000ff00ll) |
((tval << 56));
}
BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val)
diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h
index b378f2bb365..c0941e00c9b 100644
--- a/source/blender/blenlib/BLI_heap.h
+++ b/source/blender/blenlib/BLI_heap.h
@@ -42,6 +42,7 @@ typedef void (*HeapFreeFP)(void *ptr);
/* Creates a new heap. BLI_memarena is used for allocating nodes. Removed nodes
* are recycled, so memory usage will not shrink. */
+Heap *BLI_heap_new_ex(unsigned int tot_reserve);
Heap *BLI_heap_new(void);
void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp);
@@ -53,10 +54,10 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr);
void BLI_heap_remove(Heap *heap, HeapNode *node);
/* Return 0 if the heap is empty, 1 otherwise. */
-int BLI_heap_empty(Heap *heap);
+int BLI_heap_is_empty(Heap *heap);
/* Return the size of the heap. */
-int BLI_heap_size(Heap *heap);
+unsigned int BLI_heap_size(Heap *heap);
/* Return the top node of the heap. This is the node with the lowest value. */
HeapNode *BLI_heap_top(Heap *heap);
@@ -68,5 +69,4 @@ void *BLI_heap_popmin(Heap *heap);
float BLI_heap_node_value(HeapNode *heap);
void *BLI_heap_node_ptr(HeapNode *heap);
-#endif
-
+#endif /* __BLI_HEAP_H__ */
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index 985b5af3b94..8441413fba9 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -75,7 +75,7 @@ typedef struct BVHTreeRayHit {
} BVHTreeRayHit;
/* callback must update nearest in case it finds a nearest result */
-typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const float *co, BVHTreeNearest *nearest);
+typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const float co[3], BVHTreeNearest *nearest);
/* callback must update hit in case it finds a nearest successful hit */
typedef void (*BVHTree_RayCastCallback)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit);
@@ -87,31 +87,34 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis);
void BLI_bvhtree_free(BVHTree *tree);
/* construct: first insert points, then call balance */
-int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints);
+int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints);
void BLI_bvhtree_balance(BVHTree *tree);
/* update: first update points/nodes, then call update_tree to refit the bounding volumes */
-int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints);
+int BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const float co_moving[3], int numpoints);
void BLI_bvhtree_update_tree(BVHTree *tree);
/* collision/overlap: check two trees if they overlap, alloc's *overlap with length of the int return value */
BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int *result);
-float BLI_bvhtree_getepsilon(BVHTree *tree);
+float BLI_bvhtree_getepsilon(const BVHTree *tree);
-/* find nearest node to the given coordinates (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */
-int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata);
+/* find nearest node to the given coordinates
+ * (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */
+int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest,
+ BVHTree_NearestPointCallback callback, void *userdata);
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
+int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
+ BVHTree_RayCastCallback callback, void *userdata);
-float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const float light_end[3], float pos[3]);
+float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], const float light_end[3], float pos[3]);
/* range query */
-int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata);
+int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius,
+ BVHTree_RangeQuery callback, void *userdata);
#ifdef __cplusplus
}
#endif
-#endif // __BLI_KDOPBVH_H__
-
+#endif /* __BLI_KDOPBVH_H__ */
diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h
index e90566408d4..f9b52f34102 100644
--- a/source/blender/blenlib/BLI_kdtree.h
+++ b/source/blender/blenlib/BLI_kdtree.h
@@ -56,7 +56,7 @@ void BLI_kdtree_balance(KDTree *tree);
/* Find nearest returns index, and -1 if no node is found.
* 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. */
-int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *nearest);
+int BLI_kdtree_find_nearest(KDTree *tree, const float co[3], const float nor[3], KDTreeNearest *nearest);
int BLI_kdtree_find_n_nearest(KDTree *tree, int n, const float co[3], const float nor[3], KDTreeNearest *nearest);
/* Range search returns number of points found, with results in nearest */
diff --git a/source/blender/blenlib/BLI_math.h b/source/blender/blenlib/BLI_math.h
index 89c37daae84..db2fed433da 100644
--- a/source/blender/blenlib/BLI_math.h
+++ b/source/blender/blenlib/BLI_math.h
@@ -58,6 +58,7 @@
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_math_geom.h"
+#include "BLI_math_interp.h"
#endif /* __BLI_MATH_H__ */
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 6ee1498c855..2b513cbec41 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -188,8 +188,11 @@ MINLINE float sasqrt(float fac);
MINLINE float interpf(float a, float b, float t);
-MINLINE float minf(float a, float b);
-MINLINE float maxf(float a, float b);
+MINLINE float min_ff(float a, float b);
+MINLINE float max_ff(float a, float b);
+
+MINLINE int min_ii(int a, int b);
+MINLINE int max_ii(int a, int b);
MINLINE float signf(float f);
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 107b688b36a..80169e952bf 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -95,12 +95,6 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2]
int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]);
int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
-/* Returns the number of point of interests
- * 0 - lines are colinear
- * 1 - lines are coplanar, i1 is set to intersection
- * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively
- * */
-
int isect_line_line_v3(const float v1[3], const float v2[3],
const float v3[3], const float v4[3],
float i1[3], float i2[3]);
@@ -108,35 +102,13 @@ int isect_line_line_strict_v3(const float v1[3], const float v2[3],
const float v3[3], const float v4[3],
float vi[3], float *r_lambda);
-/* if clip is nonzero, will only return true if lambda is >= 0.0
- * (i.e. intersection point is along positive d)*/
int isect_ray_plane_v3(const float p1[3], const float d[3],
const float v0[3], const float v1[3], const float v2[3],
float *r_lambda, const int clip);
-/**
- * Intersect line/plane, optionally treat line as directional (like a ray) with the no_flip argument.
- * \param out The intersection point.
- * \param l1 The first point of the line.
- * \param l2 The second point of the line.
- * \param plane_co A point on the plane to intersect with.
- * \param plane_no The direction of the plane (does not need to be normalized).
- * \param no_flip When true, the intersection point will always be from l1 to l2, even if this is not on the plane.
- */
int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3],
const float plane_co[3], const float plane_no[3], const short no_flip);
-/**
- * Intersect two planes, return a point on the intersection and a vector
- * that runs on the direction of the intersection.
- * Return error code is the same as 'isect_line_line_v3'.
- * \param r_isect_co The resulting intersection point.
- * \param r_isect_no The resulting vector of the intersection.
- * \param plane_a_co The point on the first plane.
- * \param plane_a_no The normal of the first plane.
- * \param plane_b_co The point on the second plane.
- * \param plane_b_no The normal of the second plane.
- */
void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
const float plane_a_co[3], const float plane_a_no[3],
const float plane_b_co[3], const float plane_b_no[3]);
@@ -250,14 +222,6 @@ void accumulate_vertex_normals_poly(float **vertnos, float polyno[3],
/********************************* Tangents **********************************/
-typedef struct VertexTangent {
- struct VertexTangent *next;
- float tang[3], uv[2];
-} VertexTangent;
-
-float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]);
-void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang,
- const float tang[3], const float uv[2]);
void tangent_from_uv(float uv1[2], float uv2[2], float uv3[2],
float co1[3], float co2[3], float co3[3], float n[3], float tang[3]);
@@ -291,6 +255,9 @@ float form_factor_hemi_poly(float p[3], float n[3],
void axis_dominant_v3(int *axis_a, int *axis_b, const float axis[3]);
+MINLINE int max_axis_v3(const float vec[3]);
+MINLINE int min_axis_v3(const float vec[3]);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_math_interp.h b/source/blender/blenlib/BLI_math_interp.h
new file mode 100644
index 00000000000..3a107be32bd
--- /dev/null
+++ b/source/blender/blenlib/BLI_math_interp.h
@@ -0,0 +1,35 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#ifndef BLI_MATH_INTERP
+#define BLI_MATH_INTERP
+
+void BLI_bicubic_interpolation(const float *buffer, float *output, int width, int height, int components, float u, float v);
+void BLI_bilinear_interpolation(const float *buffer, float *output, int width, int height, int components, float u, float v);
+
+#endif
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 4d0f67b6c6a..698074af38a 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -36,14 +36,18 @@ extern "C" {
/********************************* Init **************************************/
-#define MAT4_UNITY {{ 1.0, 0.0, 0.0, 0.0}, \
- { 0.0, 1.0, 0.0, 0.0}, \
- { 0.0, 0.0, 1.0, 0.0}, \
- { 0.0, 0.0, 0.0, 1.0}}
+#define MAT4_UNITY { \
+ { 1.0, 0.0, 0.0, 0.0}, \
+ { 0.0, 1.0, 0.0, 0.0}, \
+ { 0.0, 0.0, 1.0, 0.0}, \
+ { 0.0, 0.0, 0.0, 1.0} \
+}
-#define MAT3_UNITY {{ 1.0, 0.0, 0.0}, \
- { 0.0, 1.0, 0.0}, \
- { 0.0, 0.0, 1.0}}
+#define MAT3_UNITY { \
+ { 1.0, 0.0, 0.0}, \
+ { 0.0, 1.0, 0.0}, \
+ { 0.0, 0.0, 1.0} \
+}
void zero_m3(float R[3][3]);
void zero_m4(float R[4][4]);
@@ -102,6 +106,9 @@ void mul_m3_fl(float R[3][3], float f);
void mul_m4_fl(float R[4][4], float f);
void mul_mat3_m4_fl(float R[4][4], float f);
+int invert_m3_ex(float m[3][3], const float epsilon);
+int invert_m3_m3_ex(float m1[3][3], float m2[3][3], const float epsilon);
+
int invert_m3(float R[3][3]);
int invert_m3_m3(float R[3][3], float A[3][3]);
int invert_m4(float R[4][4]);
@@ -132,6 +139,7 @@ int is_orthonormal_m4(float mat[4][4]);
int is_uniform_scaled_m3(float mat[3][3]);
+void adjoint_m2_m2(float R[2][2], float A[2][2]);
void adjoint_m3_m3(float R[3][3], float A[3][3]);
void adjoint_m4_m4(float R[4][4], float A[4][4]);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index de1d423bfad..77c0ec0a88f 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -67,6 +67,7 @@ MINLINE void copy_v2_v2_short(short r[2], const short a[2]);
MINLINE void copy_v3_v3_short(short r[3], const short a[3]);
MINLINE void copy_v4_v4_short(short r[4], const short a[4]);
/* int */
+MINLINE void zero_v3_int(int r[3]);
MINLINE void copy_v2_v2_int(int r[2], const int a[2]);
MINLINE void copy_v3_v3_int(int r[3], const int a[3]);
MINLINE void copy_v4_v4_int(int r[4], const int a[4]);
@@ -139,12 +140,16 @@ MINLINE void star_m3_v3(float rmat[3][3], float a[3]);
MINLINE float len_squared_v2(const float v[2]);
MINLINE float len_squared_v3(const float v[3]);
+MINLINE float len_manhattan_v2(const float v[2]);
+MINLINE float len_manhattan_v3(const float v[3]);
MINLINE float len_v2(const float a[2]);
MINLINE float len_v2v2(const float a[2], const float b[2]);
MINLINE float len_squared_v2v2(const float a[2], const float b[2]);
+MINLINE float len_squared_v3v3(const float a[3], const float b[3]);
+MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]);
+MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]);
MINLINE float len_v3(const float a[3]);
MINLINE float len_v3v3(const float a[3], const float b[3]);
-MINLINE float len_squared_v3v3(const float a[3], const float b[3]);
MINLINE float normalize_v2(float r[2]);
MINLINE float normalize_v2_v2(float r[2], const float a[2]);
@@ -221,6 +226,7 @@ MINLINE void normal_short_to_float_v3(float r[3], const short n[3]);
MINLINE void normal_float_to_short_v3(short r[3], const float n[3]);
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]);
+void minmax_v2v2_v2(float min[2], float max[2], const float vec[2]);
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist);
void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist);
diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h
index 810b3b56386..59ecdb359c9 100644
--- a/source/blender/blenlib/BLI_pbvh.h
+++ b/source/blender/blenlib/BLI_pbvh.h
@@ -153,7 +153,8 @@ void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BLI_pbvh_redraw_BB(PBVH * bvh, float bb_min[3], float bb_max[3]);
void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface);
void BLI_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems,
- struct DMGridAdjacency *gridadj, void **gridfaces);
+ struct DMGridAdjacency *gridadj, void **gridfaces,
+ struct DMFlagMat *flagmats, unsigned int **grid_hidden);
/* vertex deformer */
float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3];
@@ -263,5 +264,7 @@ void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode);
//void BLI_pbvh_node_BB_reset(PBVHNode *node);
//void BLI_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
+void pbvh_show_diffuse_color_set(PBVH *bvh, int show_diffuse_color);
+
#endif /* __BLI_PBVH_H__ */
diff --git a/source/blender/blenlib/BLI_quadric.h b/source/blender/blenlib/BLI_quadric.h
new file mode 100644
index 00000000000..e71a6473852
--- /dev/null
+++ b/source/blender/blenlib/BLI_quadric.h
@@ -0,0 +1,56 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Laurence Bourn, Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_QUADRIC_H__
+#define __BLI_QUADRIC_H__
+
+/** \file BLI_quadric.h
+ * \ingroup bli
+ */
+
+typedef struct Quadric {
+ float a2, ab, ac, ad,
+ b2, bc, bd,
+ c2, cd,
+ d2;
+} Quadric;
+
+/* conversion */
+void BLI_quadric_from_v3_dist(Quadric *q, const float v[3], const float offset);
+void BLI_quadric_to_tensor_m3(const Quadric *q, float m[3][3]);
+void BLI_quadric_to_vector_v3(const Quadric *q, float v[3]);
+
+void BLI_quadric_clear(Quadric *q);
+
+/* math */
+void BLI_quadric_add_qu_qu(Quadric *a, const Quadric *b);
+void BLI_quadric_add_qu_ququ(Quadric *r, const Quadric *a, const Quadric *b);
+void BLI_quadric_mul(Quadric *a, const float scalar);
+
+/* solve */
+float BLI_quadric_evaluate(const Quadric *q, const float v[3]);
+int BLI_quadric_optimize(const Quadric *q, float v[3], const float epsilon);
+
+#endif /* __BLI_QUADRIC_H__ */
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index 7dd6c8575c9..3bc9a3bdb32 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -40,18 +40,18 @@
struct RNG;
typedef struct RNG RNG;
-struct RNG *rng_new(unsigned int seed);
-void rng_free(struct RNG *rng);
+struct RNG *BLI_rng_new(unsigned int seed);
+void BLI_rng_free(struct RNG *rng);
-void rng_seed(struct RNG *rng, unsigned int seed);
-void rng_srandom(struct RNG *rng, unsigned int seed);
-int rng_getInt(struct RNG *rng);
-double rng_getDouble(struct RNG *rng);
-float rng_getFloat(struct RNG *rng);
-void rng_shuffleArray(struct RNG *rng, void *data, int elemSize, int numElems);
+void BLI_rng_seed(struct RNG *rng, unsigned int seed);
+void BLI_rng_srandom(struct RNG *rng, unsigned int seed);
+int BLI_rng_get_int(struct RNG *rng);
+double BLI_rng_get_double(struct RNG *rng);
+float BLI_rng_get_float(struct RNG *rng);
+void BLI_rng_shuffle_array(struct RNG *rng, void *data, int elemSize, int numElems);
/** Note that skipping is as slow as generating n numbers! */
-void rng_skip(struct RNG *rng, int n);
+void BLI_rng_skip(struct RNG *rng, int n);
/** Seed the random number generator */
void BLI_srand(unsigned int seed);
@@ -94,7 +94,4 @@ int BLI_thread_rand(int thread);
/** Allows up to BLENDER_MAX_THREADS threads to address */
float BLI_thread_frand(int thread);
-
-
-#endif
-
+#endif /* __BLI_RAND_H__ */
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index de4c2cf3a86..f84820e94f3 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -66,9 +66,7 @@ int BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]);
int BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y);
int BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]);
int BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
-#if 0 /* NOT NEEDED YET */
-int BLI_rctf_isect_segment(struct rcti *rect, int s1[2], int s2[2]);
-#endif
+int BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]);
void BLI_rctf_union(struct rctf *rctf1, const struct rctf *rctf2);
void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2);
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src);
diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h
index a6b1943cb4d..892afdd0b27 100644
--- a/source/blender/blenlib/BLI_scanfill.h
+++ b/source/blender/blenlib/BLI_scanfill.h
@@ -103,7 +103,7 @@ void BLI_scanfill_end(ScanFillContext *sf_ctx);
/* These callbacks are needed to make the lib finction properly */
/**
- * Set a function taking a char* as argument to flag errors. If the
+ * Set a function taking a (char *) as argument to flag errors. If the
* callback is not set, the error is discarded.
* \param f The function to use as callback
* \attention used in creator.c
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 666c74ca36f..70c89773f02 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -74,7 +74,7 @@ __attribute__((nonnull))
* \param str2 second string for append
* \retval Returns dst
*/
-char *BLI_strdupcat(const char *str1, const char *str2)
+char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
#ifdef __GNUC__
__attribute__((warn_unused_result))
__attribute__((nonnull))
@@ -91,7 +91,7 @@ __attribute__((nonnull))
* the size of dst)
* \retval Returns dst
*/
-char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
+char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
@@ -107,7 +107,7 @@ __attribute__((nonnull))
* Assume that the strings returned must be freed afterwards, and that the inputs will contain
* data we want...
*/
-char *BLI_str_quoted_substrN(const char *str, const char *prefix)
+char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
#ifdef __GNUC__
__attribute__((warn_unused_result))
__attribute__((nonnull))
@@ -124,7 +124,7 @@ __attribute__((nonnull))
* \param newText The text in the string to find and replace
* \retval Returns the duplicated string
*/
-char *BLI_replacestr(char *str, const char *oldText, const char *newText)
+char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const char *__restrict newText)
#ifdef __GNUC__
__attribute__((warn_unused_result))
__attribute__((nonnull))
@@ -134,7 +134,7 @@ __attribute__((nonnull))
/*
* Replacement for snprintf
*/
-size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
+size_t BLI_snprintf(char *__restrict buffer, size_t len, const char *__restrict format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 4)))
__attribute__((nonnull))
@@ -144,7 +144,7 @@ __attribute__((nonnull))
/*
* Replacement for vsnprintf
*/
-size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg)
+size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 0)))
#endif
@@ -154,7 +154,7 @@ __attribute__ ((format(printf, 3, 0)))
* Print formatted string into a newly mallocN'd string
* and return it.
*/
-char *BLI_sprintfN(const char *format, ...)
+char *BLI_sprintfN(const char *__restrict format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 1, 2)))
__attribute__((warn_unused_result))
@@ -162,7 +162,7 @@ __attribute__((nonnull))
#endif
;
-size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
+size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
@@ -204,7 +204,7 @@ __attribute__((warn_unused_result))
__attribute__((nonnull))
#endif
;
-size_t BLI_strnlen(const char *str, size_t maxlen)
+size_t BLI_strnlen(const char *str, const size_t maxlen)
#ifdef __GNUC__
__attribute__((warn_unused_result))
__attribute__((nonnull))
@@ -216,12 +216,12 @@ __attribute__((nonnull))
#endif
; /* time var is global */
-void BLI_ascii_strtolower(char *str, int len)
+void BLI_ascii_strtolower(char *str, const size_t len)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
;
-void BLI_ascii_strtoupper(char *str, int len)
+void BLI_ascii_strtoupper(char *str, const size_t len)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index 56ed4beba53..ecbc4cb1cd4 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -31,16 +31,17 @@
extern "C" {
#endif
-char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy);
-char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy);
+char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy);
+char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy);
int BLI_utf8_invalid_byte(const char *str, int length);
int BLI_utf8_invalid_strip(char *str, int length);
int BLI_str_utf8_size(const char *p); /* warning, can return -1 on bad chars */
+int BLI_str_utf8_size_safe(const char *p);
/* copied from glib */
unsigned int BLI_str_utf8_as_unicode(const char *p);
-unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index);
-unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index);
+unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index);
+unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index);
size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf);
char *BLI_str_find_prev_char_utf8(const char *str, const char *p);
@@ -50,8 +51,9 @@ char *BLI_str_prev_char_utf8(const char *p);
/* wchar_t functions, copied from blenders own font.c originally */
size_t BLI_wstrlen_utf8(const wchar_t *src);
size_t BLI_strlen_utf8(const char *strc);
-size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy);
-size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst, const char *src, const size_t maxcpy);
+size_t BLI_strnlen_utf8(const char *start, const size_t maxlen);
+size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy);
+size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy);
#define BLI_UTF8_MAX 6
#define BLI_UTF8_ERR ((unsigned int)-1)
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 0be87249e31..fb064b5403f 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -46,43 +46,22 @@
# define TRUE 1
#endif
-
-#define ELEM(a, b, c) ((a) == (b) || (a) == (c))
-#define ELEM3(a, b, c, d) (ELEM(a, b, c) || (a) == (d) )
-#define ELEM4(a, b, c, d, e) (ELEM(a, b, c) || ELEM(a, d, e) )
-#define ELEM5(a, b, c, d, e, f) (ELEM(a, b, c) || ELEM3(a, d, e, f) )
-#define ELEM6(a, b, c, d, e, f, g) (ELEM(a, b, c) || ELEM4(a, d, e, f, g) )
-#define ELEM7(a, b, c, d, e, f, g, h) (ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) )
-#define ELEM8(a, b, c, d, e, f, g, h, i) (ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) )
-#define ELEM9(a, b, c, d, e, f, g, h, i, j) (ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) )
-#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) (ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) )
-#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) (ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) )
-
-/* shift around elements */
-#define SHIFT3(type, a, b, c) { \
- type tmp; \
- tmp = a; \
- a = c; \
- c = b; \
- b = tmp; \
-} (void)0
-#define SHIFT4(type, a, b, c, d) { \
- type tmp; \
- tmp = a; \
- a = d; \
- d = c; \
- c = b; \
- b = tmp; \
-} (void)0
+/* useful for finding bad use of min/max */
+#if 0
+/* gcc only */
+# define _TYPECHECK(a, b) ((void)(((typeof(a) *)0) == ((typeof(b) *)0)))
+# define MIN2(x, y) (_TYPECHECK(x, y), (((x) < (y) ? (x) : (y))))
+# define MAX2(x, y) (_TYPECHECK(x, y), (((x) > (y) ? (x) : (y))))
+#endif
/* min/max */
-#define MIN2(x, y) ( (x) < (y) ? (x) : (y) )
-#define MIN3(x, y, z) MIN2(MIN2((x), (y)), (z) )
-#define MIN4(x, y, z, a) MIN2(MIN2((x), (y)), MIN2((z), (a)) )
+#define MIN2(x, y) ((x) < (y) ? (x) : (y))
+#define MIN3(x, y, z) (MIN2(MIN2((x), (y)), (z)))
+#define MIN4(x, y, z, a) (MIN2(MIN2((x), (y)), MIN2((z), (a))))
-#define MAX2(x, y) ( (x) > (y) ? (x) : (y) )
-#define MAX3(x, y, z) MAX2(MAX2((x), (y)), (z) )
-#define MAX4(x, y, z, a) MAX2(MAX2((x), (y)), MAX2((z), (a)) )
+#define MAX2(x, y) ((x) > (y) ? (x) : (y))
+#define MAX3(x, y, z) (MAX2(MAX2((x), (y)), (z)))
+#define MAX4(x, y, z, a) (MAX2(MAX2((x), (y)), MAX2((z), (a))))
#define INIT_MINMAX(min, max) { \
(min)[0] = (min)[1] = (min)[2] = 1.0e30f; \
@@ -122,24 +101,28 @@
/* Causes warning:
* incompatible types when assigning to type 'Foo' from type 'Bar'
* ... the compiler optimizes away the temp var */
-#ifndef CHECK_TYPE
#ifdef __GNUC__
#define CHECK_TYPE(var, type) { \
__typeof(var) *__tmp; \
__tmp = (type *)NULL; \
(void)__tmp; \
} (void)0
+
+#define CHECK_TYPE_PAIR(var_a, var_b) { \
+ __typeof(var_a) *__tmp; \
+ __tmp = (__typeof(var_b) *)NULL; \
+ (void)__tmp; \
+} (void)0
#else
-#define CHECK_TYPE(var, type)
-#endif
+# define CHECK_TYPE(var, type)
+# define CHECK_TYPE_PAIR(var_a, var_b)
#endif
/* can be used in simple macros */
#define CHECK_TYPE_INLINE(val, type) \
- ((void)(((type *)0) == (val)))
+ ((void)(((type *)0) != (val)))
-#ifndef SWAP
-# define SWAP(type, a, b) { \
+#define SWAP(type, a, b) { \
type sw_ap; \
CHECK_TYPE(a, type); \
CHECK_TYPE(b, type); \
@@ -147,7 +130,53 @@
(a) = (b); \
(b) = sw_ap; \
} (void)0
-#endif
+
+/* swap with a temp value */
+#define SWAP_TVAL(tval, a, b) { \
+ CHECK_TYPE_PAIR(tval, a); \
+ CHECK_TYPE_PAIR(tval, b); \
+ (tval) = (a); \
+ (a) = (b); \
+ (b) = (tval); \
+} (void)0
+
+
+#define ELEM(a, b, c) ((a) == (b) || (a) == (c))
+#define ELEM3(a, b, c, d) (ELEM(a, b, c) || (a) == (d) )
+#define ELEM4(a, b, c, d, e) (ELEM(a, b, c) || ELEM(a, d, e) )
+#define ELEM5(a, b, c, d, e, f) (ELEM(a, b, c) || ELEM3(a, d, e, f) )
+#define ELEM6(a, b, c, d, e, f, g) (ELEM(a, b, c) || ELEM4(a, d, e, f, g) )
+#define ELEM7(a, b, c, d, e, f, g, h) (ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) )
+#define ELEM8(a, b, c, d, e, f, g, h, i) (ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) )
+#define ELEM9(a, b, c, d, e, f, g, h, i, j) (ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) )
+#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) (ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) )
+#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) (ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) )
+
+/* 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
+
#define ABS(a) ( (a) < 0 ? (-(a)) : (a) )
@@ -199,6 +228,11 @@
*(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (fac); \
*(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (fac); \
} (void)0
+#define VECMADD(v1, v2, v3, v4) { \
+ *(v1) = *(v2) + *(v3) * (*(v4)); \
+ *(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (*(v4 + 1)); \
+ *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (*(v4 + 2)); \
+} (void)0
#define VECSUBFAC(v1, v2, v3, fac) { \
*(v1) = *(v2) - *(v3) * (fac); \
*(v1 + 1) = *(v2 + 1) - *(v3 + 1) * (fac); \
@@ -327,6 +361,13 @@
# define BLI_assert(a) (void)0
#endif
+#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) /* gcc4.6+ only */
+# define BLI_STATIC_ASSERT(a, msg) _Static_assert(a, msg);
+#else
+ /* TODO msvc, clang */
+# define BLI_STATIC_ASSERT(a, msg)
+#endif
+
/* hints for branch pradiction, only use in code that runs a _lot_ where */
#ifdef __GNUC__
# define LIKELY(x) __builtin_expect(!!(x), 1)
@@ -346,4 +387,4 @@
#endif
#endif
-#endif // __BLI_UTILDEFINES_H__
+#endif /* __BLI_UTILDEFINES_H__ */
diff --git a/source/blender/blenlib/BLI_voronoi.h b/source/blender/blenlib/BLI_voronoi.h
index a67b01c5175..68d7398d89b 100644
--- a/source/blender/blenlib/BLI_voronoi.h
+++ b/source/blender/blenlib/BLI_voronoi.h
@@ -49,7 +49,7 @@ typedef struct VoronoiEdge {
float left[2]; /* point on Voronoi place on the left side of edge */
float right[2]; /* point on Voronoi place on the right side of edge */
- float f, g; /* directional coeffitients satisfying equation y = f*x + g (edge lies on this line) */
+ float f, g; /* directional coeffitients satisfying equation y = f * x + g (edge lies on this line) */
/* some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm */
struct VoronoiEdge *neighbour;
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 2836174be73..a6435bcbd50 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -70,6 +70,7 @@ set(SRC
intern/math_color_inline.c
intern/math_geom.c
intern/math_geom_inline.c
+ intern/math_interp.c
intern/math_matrix.c
intern/math_rotation.c
intern/math_vector.c
@@ -78,6 +79,7 @@ set(SRC
intern/noise.c
intern/path_util.c
intern/pbvh.c
+ intern/quadric.c
intern/rand.c
intern/rct.c
intern/scanfill.c
@@ -90,8 +92,8 @@ set(SRC
intern/threads.c
intern/time.c
intern/uvproject.c
- intern/voxel.c
intern/voronoi.c
+ intern/voxel.c
intern/winstuff.c
BLI_args.h
@@ -135,6 +137,7 @@ set(SRC
BLI_noise.h
BLI_path_util.h
BLI_pbvh.h
+ BLI_quadric.h
BLI_rand.h
BLI_rect.h
BLI_scanfill.h
diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h
index 288d2fe78e5..c3e7e8486d9 100644
--- a/source/blender/blenlib/PIL_time.h
+++ b/source/blender/blenlib/PIL_time.h
@@ -20,7 +20,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -30,7 +30,6 @@
* \brief Platform independent time functions.
*/
-
#ifndef __PIL_TIME_H__
#define __PIL_TIME_H__
@@ -61,20 +60,35 @@ void PIL_sleep_ms(int ms);
double _timeit_##var = PIL_check_seconds_timer(); \
printf("time start (" #var "): " AT "\n"); \
fflush(stdout); \
- { (void)0 \
-
+ { (void)0
#define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var)
+#define TIMEIT_VALUE_PRINT(var) \
+ { \
+ printf("time update(" #var "): %.6f" " " AT "\n", TIMEIT_VALUE(var));\
+ fflush(stdout); \
+ } (void)0
#define TIMEIT_END(var) \
} \
- printf("time end (" #var "): %.6f" " " AT "\n", TIMEIT_VALUE(var)); \
+ printf("time end (" #var "): %.6f" " " AT "\n", TIMEIT_VALUE(var)); \
fflush(stdout); \
-} (void)0 \
+} (void)0
+
+/**
+ * Given some function/expression:
+ * TIMEIT_BENCH(some_function(), some_unique_description);
+ */
+#define TIMEIT_BENCH(expr, id) \
+ { \
+ TIMEIT_START(id); \
+ (expr); \
+ TIMEIT_END(id); \
+ } (void)0
#ifdef __cplusplus
}
#endif
-#endif /* !__PIL_TIME_H__ */
+#endif /* !__PIL_TIME_H__ */
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 844407f9e06..0cae9bab531 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -135,7 +135,7 @@ int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFre
BLI_mempool_free(gh->entrypool, e);
/* correct but 'e' isn't used before return */
- /* e= n; *//*UNUSED*/
+ /* e = n; *//*UNUSED*/
if (p) p->next = n;
else gh->buckets[hash] = n;
@@ -165,7 +165,7 @@ void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp)
BLI_mempool_free(gh->entrypool, e);
/* correct but 'e' isn't used before return */
- /* e= n; *//*UNUSED*/
+ /* e = n; *//*UNUSED*/
if (p) p->next = n;
else gh->buckets[hash] = n;
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index ee7d93ea1a9..dcc028630e2 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -40,9 +40,9 @@
/***/
struct HeapNode {
- void *ptr;
- float value;
- int index;
+ void *ptr;
+ float value;
+ unsigned int index;
};
struct Heap {
@@ -54,48 +54,43 @@ struct Heap {
HeapNode **tree;
};
+/* internal functions */
+
#define HEAP_PARENT(i) ((i - 1) >> 1)
#define HEAP_LEFT(i) ((i << 1) + 1)
#define HEAP_RIGHT(i) ((i << 1) + 2)
#define HEAP_COMPARE(a, b) (a->value < b->value)
-// #define HEAP_EQUALS(a, b) (a->value == b->value) // UNUSED
-#define HEAP_SWAP(heap, i, j) \
- { \
- SWAP(int, heap->tree[i]->index, heap->tree[j]->index); \
- SWAP(HeapNode *, heap->tree[i], heap->tree[j]); \
- } (void)0
-/***/
+#if 0 /* UNUSED */
+#define HEAP_EQUALS(a, b) (a->value == b->value)
+#endif
-Heap *BLI_heap_new(void)
+BLI_INLINE void heap_swap(Heap *heap, const unsigned int i, const unsigned int j)
{
- Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__);
- heap->bufsize = 1;
- heap->tree = (HeapNode **)MEM_mallocN(sizeof(HeapNode *), "BLIHeapTree");
- heap->arena = BLI_memarena_new(1 << 16, "heap arena");
- return heap;
+#if 0
+ SWAP(unsigned int, heap->tree[i]->index, heap->tree[j]->index);
+ SWAP(HeapNode *, heap->tree[i], heap->tree[j]);
+#else
+ HeapNode **tree = heap->tree;
+ union {
+ unsigned int index;
+ HeapNode *node;
+ } tmp;
+ SWAP_TVAL(tmp.index, tree[i]->index, tree[j]->index);
+ SWAP_TVAL(tmp.node, tree[i], tree[j]);
+#endif
}
-void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
+static void heap_down(Heap *heap, unsigned int i)
{
- int i;
-
- if (ptrfreefp)
- for (i = 0; i < heap->size; i++)
- ptrfreefp(heap->tree[i]->ptr);
+ /* size won't change in the loop */
+ const unsigned int size = heap->size;
- MEM_freeN(heap->tree);
- BLI_memarena_free(heap->arena);
- MEM_freeN(heap);
-}
-
-static void BLI_heap_down(Heap *heap, int i)
-{
while (1) {
- int size = heap->size, smallest;
- int l = HEAP_LEFT(i);
- int r = HEAP_RIGHT(i);
+ const unsigned int l = HEAP_LEFT(i);
+ const unsigned int r = HEAP_RIGHT(i);
+ unsigned int smallest;
smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], heap->tree[i])) ? l : i;
@@ -105,46 +100,75 @@ static void BLI_heap_down(Heap *heap, int i)
if (smallest == i)
break;
- HEAP_SWAP(heap, i, smallest);
+ heap_swap(heap, i, smallest);
i = smallest;
}
}
-static void BLI_heap_up(Heap *heap, int i)
+static void heap_up(Heap *heap, unsigned int i)
{
while (i > 0) {
- int p = HEAP_PARENT(i);
+ const unsigned int p = HEAP_PARENT(i);
if (HEAP_COMPARE(heap->tree[p], heap->tree[i]))
break;
- HEAP_SWAP(heap, p, i);
+ heap_swap(heap, p, i);
i = p;
}
}
-HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
+
+/***/
+
+/* use when the size of the heap is known in advance */
+Heap *BLI_heap_new_ex(unsigned int tot_reserve)
{
- HeapNode *node;
+ Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__);
+ /* ensure we have at least one so we can keep doubling it */
+ heap->bufsize = MAX2(1, tot_reserve);
+ heap->tree = (HeapNode **)MEM_mallocN(heap->bufsize * sizeof(HeapNode *), "BLIHeapTree");
+ heap->arena = BLI_memarena_new(1 << 16, "heap arena");
- if ((heap->size + 1) > heap->bufsize) {
- int newsize = heap->bufsize * 2;
- HeapNode **newtree;
+ return heap;
+}
+
+Heap *BLI_heap_new(void)
+{
+ return BLI_heap_new_ex(1);
+}
+
+void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
+{
+ unsigned int i;
+
+ if (ptrfreefp) {
+ for (i = 0; i < heap->size; i++) {
+ ptrfreefp(heap->tree[i]->ptr);
+ }
+ }
- newtree = (HeapNode **)MEM_mallocN(newsize * sizeof(*newtree), __func__);
- memcpy(newtree, heap->tree, sizeof(HeapNode *) * heap->size);
- MEM_freeN(heap->tree);
+ MEM_freeN(heap->tree);
+ BLI_memarena_free(heap->arena);
+ MEM_freeN(heap);
+}
- heap->tree = newtree;
- heap->bufsize = newsize;
+HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
+{
+ HeapNode *node;
+
+ if (UNLIKELY((heap->size + 1) > heap->bufsize)) {
+ heap->bufsize *= 2;
+ heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree));
}
if (heap->freenodes) {
node = heap->freenodes;
heap->freenodes = (HeapNode *)(((HeapNode *)heap->freenodes)->ptr);
}
- else
+ else {
node = (HeapNode *)BLI_memarena_alloc(heap->arena, sizeof *node);
+ }
node->value = value;
node->ptr = ptr;
@@ -154,17 +178,17 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
heap->size++;
- BLI_heap_up(heap, heap->size - 1);
+ heap_up(heap, heap->size - 1);
return node;
}
-int BLI_heap_empty(Heap *heap)
+int BLI_heap_is_empty(Heap *heap)
{
return (heap->size == 0);
}
-int BLI_heap_size(Heap *heap)
+unsigned int BLI_heap_size(Heap *heap)
{
return heap->size;
}
@@ -181,13 +205,14 @@ void *BLI_heap_popmin(Heap *heap)
heap->tree[0]->ptr = heap->freenodes;
heap->freenodes = heap->tree[0];
- if (heap->size == 1)
+ if (UNLIKELY(heap->size == 1)) {
heap->size--;
+ }
else {
- HEAP_SWAP(heap, 0, heap->size - 1);
+ heap_swap(heap, 0, heap->size - 1);
heap->size--;
- BLI_heap_down(heap, 0);
+ heap_down(heap, 0);
}
return ptr;
@@ -195,12 +220,12 @@ void *BLI_heap_popmin(Heap *heap)
void BLI_heap_remove(Heap *heap, HeapNode *node)
{
- int i = node->index;
+ unsigned int i = node->index;
while (i > 0) {
- int p = HEAP_PARENT(i);
+ unsigned int p = HEAP_PARENT(i);
- HEAP_SWAP(heap, p, i);
+ heap_swap(heap, p, i);
i = p;
}
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index a86783f3450..7968fcabda6 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -43,6 +43,8 @@
#define MAX_TREETYPE 32
+typedef unsigned char axis_t;
+
typedef struct BVHNode {
struct BVHNode **children;
struct BVHNode *parent; /* some user defined traversed need that */
@@ -53,6 +55,7 @@ typedef struct BVHNode {
char main_axis; /* Axis used to split this node */
} BVHNode;
+/* keep under 26 bytes for speed purposes */
struct BVHTree {
BVHNode **nodes;
BVHNode *nodearray; /* pre-alloc branch nodes */
@@ -61,16 +64,21 @@ struct BVHTree {
float epsilon; /* epslion is used for inflation of the k-dop */
int totleaf; /* leafs */
int totbranch;
+ axis_t start_axis, stop_axis; /* KDOP_AXES array indices according to axis */
+ axis_t axis; /* kdop type (6 => OBB, 7 => AABB, ...) */
char tree_type; /* type of tree (4 => quadtree) */
- char axis; /* kdop type (6 => OBB, 7 => AABB, ...) */
- char start_axis, stop_axis; /* KDOP_AXES array indices according to axis */
};
+/* optimization, ensure we stay small */
+BLI_STATIC_ASSERT((sizeof(void *) == 8 && sizeof(BVHTree) <= 48) ||
+ (sizeof(void *) == 4 && sizeof(BVHTree) <= 32),
+ "over sized");
+
typedef struct BVHOverlapData {
BVHTree *tree1, *tree2;
BVHTreeOverlap *overlap;
int i, max_overlap; /* i is number of overlaps */
- int start_axis, stop_axis;
+ axis_t start_axis, stop_axis;
} BVHOverlapData;
typedef struct BVHNearestData {
@@ -113,6 +121,15 @@ static float KDOP_AXES[13][3] = {
{0, 1.0, -1.0}
};
+MINLINE axis_t min_axis(axis_t a, axis_t b)
+{
+ return (a < b) ? a : b;
+}
+MINLINE axis_t max_axis(axis_t a, axis_t b)
+{
+ return (b < a) ? a : b;
+}
+
#if 0
/*
@@ -269,7 +286,7 @@ static void bvh_heapsort(BVHNode **a, int lo, int hi, int axis)
}
#endif
-static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) // returns Sortable
+static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) /* returns Sortable */
{
if ((a[mid])->bv[axis] < (a[lo])->bv[axis]) {
if ((a[hi])->bv[axis] < (a[mid])->bv[axis])
@@ -374,24 +391,25 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int
{
float newminmax;
float *bv = node->bv;
- int i, k;
+ int k;
+ axis_t axis_iter;
/* don't init boudings for the moving case */
if (!moving) {
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- bv[2 * i] = FLT_MAX;
- bv[2 * i + 1] = -FLT_MAX;
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ bv[2 * axis_iter] = FLT_MAX;
+ bv[2 * axis_iter + 1] = -FLT_MAX;
}
}
for (k = 0; k < numpoints; k++) {
/* for all Axes. */
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- newminmax = dot_v3v3(&co[k * 3], KDOP_AXES[i]);
- if (newminmax < bv[2 * i])
- bv[2 * i] = newminmax;
- if (newminmax > bv[(2 * i) + 1])
- bv[(2 * i) + 1] = newminmax;
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ newminmax = dot_v3v3(&co[k * 3], KDOP_AXES[axis_iter]);
+ if (newminmax < bv[2 * axis_iter])
+ bv[2 * axis_iter] = newminmax;
+ if (newminmax > bv[(2 * axis_iter) + 1])
+ bv[(2 * axis_iter) + 1] = newminmax;
}
}
}
@@ -400,25 +418,25 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int
static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end)
{
float newmin, newmax;
- int i, j;
float *bv = node->bv;
+ int j;
+ axis_t axis_iter;
-
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- bv[2 * i] = FLT_MAX;
- bv[2 * i + 1] = -FLT_MAX;
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ bv[(2 * axis_iter)] = FLT_MAX;
+ bv[(2 * axis_iter) + 1] = -FLT_MAX;
}
for (j = start; j < end; j++) {
/* for all Axes. */
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- newmin = tree->nodes[j]->bv[(2 * i)];
- if ((newmin < bv[(2 * i)]))
- bv[(2 * i)] = newmin;
-
- newmax = tree->nodes[j]->bv[(2 * i) + 1];
- if ((newmax > bv[(2 * i) + 1]))
- bv[(2 * i) + 1] = newmax;
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ newmin = tree->nodes[j]->bv[(2 * axis_iter)];
+ if ((newmin < bv[(2 * axis_iter)]))
+ bv[(2 * axis_iter)] = newmin;
+
+ newmax = tree->nodes[j]->bv[(2 * axis_iter) + 1];
+ if ((newmax > bv[(2 * axis_iter) + 1]))
+ bv[(2 * axis_iter) + 1] = newmax;
}
}
@@ -451,23 +469,24 @@ static char get_largest_axis(float *bv)
* join the children on the parent BV */
static void node_join(BVHTree *tree, BVHNode *node)
{
- int i, j;
-
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- node->bv[2 * i] = FLT_MAX;
- node->bv[2 * i + 1] = -FLT_MAX;
+ int i;
+ axis_t axis_iter;
+
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ node->bv[(2 * axis_iter)] = FLT_MAX;
+ node->bv[(2 * axis_iter) + 1] = -FLT_MAX;
}
for (i = 0; i < tree->tree_type; i++) {
if (node->children[i]) {
- for (j = tree->start_axis; j < tree->stop_axis; j++) {
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
/* update minimum */
- if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)])
- node->bv[(2 * j)] = node->children[i]->bv[(2 * j)];
+ 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 * j) + 1] > node->bv[(2 * j) + 1])
- node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 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
@@ -482,10 +501,12 @@ static void node_join(BVHTree *tree, BVHNode *node)
static void bvhtree_print_tree(BVHTree *tree, BVHNode *node, int depth)
{
int i;
+ axis_t axis_iter;
+
for (i = 0; i < depth; i++) printf(" ");
printf(" - %d (%ld): ", node->index, node - tree->nodearray);
- for (i = 2 * tree->start_axis; i < 2 * tree->stop_axis; i++)
- printf("%.3f ", node->bv[i]);
+ for (axis_iter = 2 * tree->start_axis; axis_iter < 2 * tree->stop_axis; axis_iter++)
+ printf("%.3f ", node->bv[axis_iter]);
printf("\n");
for (i = 0; i < tree->tree_type; i++)
@@ -645,10 +666,10 @@ static int implicit_leafs_index(BVHBuildHelper *data, int depth, int child_index
* (looping elements, knowing if its a leaf or not.. etc...)
*/
-// This functions returns the number of branches needed to have the requested number of leafs.
+/* This functions returns the number of branches needed to have the requested number of leafs. */
static int implicit_needed_branches(int tree_type, int leafs)
{
- return maxi(1, (leafs + tree_type - 3) / (tree_type - 1) );
+ return max_ii(1, (leafs + tree_type - 3) / (tree_type - 1) );
}
/*
@@ -724,7 +745,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array,
/* Loop tree levels (log N) loops */
for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) {
const int first_of_next_level = i * tree_type + tree_offset;
- const int end_j = MIN2(first_of_next_level, num_branches + 1); /* index of last branch on this level */
+ const int end_j = min_ii(first_of_next_level, num_branches + 1); /* index of last branch on this level */
int j;
/* Loop all branches on this level */
@@ -810,7 +831,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
/* tree epsilon must be >= FLT_EPSILON
* so that tangent rays can still hit a bounding volume..
* this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */
- epsilon = MAX2(FLT_EPSILON, epsilon);
+ epsilon = max_ff(FLT_EPSILON, epsilon);
if (tree) {
tree->epsilon = epsilon;
@@ -843,7 +864,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
}
- //Allocate arrays
+ /* Allocate arrays */
numnodes = maxsize + implicit_needed_branches(tree_type, maxsize) + tree_type;
tree->nodes = (BVHNode **)MEM_callocN(sizeof(BVHNode *) * numnodes, "BVHNodes");
@@ -876,7 +897,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
return NULL;
}
- //link the dynamic bv and child links
+ /* link the dynamic bv and child links */
for (i = 0; i < numnodes; i++) {
tree->nodearray[i].bv = tree->nodebv + i * axis;
tree->nodearray[i].children = tree->nodechild + i * tree_type;
@@ -921,9 +942,9 @@ void BLI_bvhtree_balance(BVHTree *tree)
/* bvhtree_info(tree); */
}
-int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints)
+int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
{
- int i;
+ axis_t axis_iter;
BVHNode *node = NULL;
/* insert should only possible as long as tree->totbranch is 0 */
@@ -942,9 +963,9 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints)
node->index = index;
/* inflate the bv with some epsilon */
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- node->bv[(2 * i)] -= tree->epsilon; /* minimum */
- node->bv[(2 * i) + 1] += tree->epsilon; /* maximum */
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ node->bv[(2 * axis_iter)] -= tree->epsilon; /* minimum */
+ node->bv[(2 * axis_iter) + 1] += tree->epsilon; /* maximum */
}
return 1;
@@ -952,10 +973,10 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints)
/* call before BLI_bvhtree_update_tree() */
-int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints)
+int BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const float co_moving[3], int numpoints)
{
- int i;
BVHNode *node = NULL;
+ axis_t axis_iter;
/* check if index exists */
if (index > tree->totleaf)
@@ -968,10 +989,10 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const flo
if (co_moving)
create_kdop_hull(tree, node, co_moving, numpoints, 1);
- // inflate the bv with some epsilon
- for (i = tree->start_axis; i < tree->stop_axis; i++) {
- node->bv[(2 * i)] -= tree->epsilon; // minimum
- node->bv[(2 * i) + 1] += tree->epsilon; // maximum
+ /* inflate the bv with some epsilon */
+ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
+ node->bv[(2 * axis_iter)] -= tree->epsilon; /* minimum */
+ node->bv[(2 * axis_iter) + 1] += tree->epsilon; /* maximum */
}
return 1;
@@ -991,7 +1012,7 @@ void BLI_bvhtree_update_tree(BVHTree *tree)
node_join(tree, *index);
}
-float BLI_bvhtree_getepsilon(BVHTree *tree)
+float BLI_bvhtree_getepsilon(const BVHTree *tree)
{
return tree->epsilon;
}
@@ -1001,7 +1022,7 @@ float BLI_bvhtree_getepsilon(BVHTree *tree)
* BLI_bvhtree_overlap
*
* overlap - is it possible for 2 bv's to collide ? */
-static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop_axis)
+static int tree_overlap(BVHNode *node1, BVHNode *node2, axis_t start_axis, axis_t stop_axis)
{
float *bv1 = node1->bv;
float *bv2 = node2->bv;
@@ -1045,7 +1066,7 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2)
data->max_overlap *= 2;
}
- // both leafs, insert overlap!
+ /* both leafs, insert overlap! */
data->overlap[data->i].indexA = node1->index;
data->overlap[data->i].indexB = node2->index;
@@ -1075,27 +1096,31 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
BVHTreeOverlap *overlap = NULL, *to = NULL;
BVHOverlapData **data;
- // check for compatibility of both trees (can't compare 14-DOP with 18-DOP)
+ /* check for compatibility of both trees (can't compare 14-DOP with 18-DOP) */
if ((tree1->axis != tree2->axis) && (tree1->axis == 14 || tree2->axis == 14) && (tree1->axis == 18 || tree2->axis == 18))
return NULL;
- // fast check root nodes for collision before doing big splitting + traversal
- if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], MIN2(tree1->start_axis, tree2->start_axis), MIN2(tree1->stop_axis, tree2->stop_axis)))
+ /* fast check root nodes for collision before doing big splitting + traversal */
+ if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf],
+ min_axis(tree1->start_axis, tree2->start_axis),
+ min_axis(tree1->stop_axis, tree2->stop_axis)))
+ {
return NULL;
+ }
data = MEM_callocN(sizeof(BVHOverlapData *) * tree1->tree_type, "BVHOverlapData_star");
for (j = 0; j < tree1->tree_type; j++) {
data[j] = (BVHOverlapData *)MEM_callocN(sizeof(BVHOverlapData), "BVHOverlapData");
- // init BVHOverlapData
- data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * MAX2(tree1->totleaf, tree2->totleaf));
+ /* init BVHOverlapData */
+ data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * max_ii(tree1->totleaf, tree2->totleaf));
data[j]->tree1 = tree1;
data[j]->tree2 = tree2;
- data[j]->max_overlap = MAX2(tree1->totleaf, tree2->totleaf);
+ data[j]->max_overlap = max_ii(tree1->totleaf, tree2->totleaf);
data[j]->i = 0;
- data[j]->start_axis = MIN2(tree1->start_axis, tree2->start_axis);
- data[j]->stop_axis = MIN2(tree1->stop_axis, tree2->stop_axis);
+ data[j]->start_axis = min_axis(tree1->start_axis, tree2->start_axis);
+ data[j]->stop_axis = min_axis(tree1->stop_axis, tree2->stop_axis);
}
#pragma omp parallel for private(j) schedule(static)
@@ -1123,13 +1148,13 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
return overlap;
}
-//Determines the nearest point of the given node BV. Returns the squared distance to that point.
+/* Determines the nearest point of the given node BV. Returns the squared distance to that point. */
static float calc_nearest_point(const float proj[3], BVHNode *node, float *nearest)
{
int i;
const float *bv = node->bv;
- //nearest on AABB hull
+ /* nearest on AABB hull */
for (i = 0; i != 3; i++, bv += 2) {
if (bv[0] > proj[i])
nearest[i] = bv[0];
@@ -1140,7 +1165,7 @@ static float calc_nearest_point(const float proj[3], BVHNode *node, float *neare
}
#if 0
- //nearest on a general hull
+ /* nearest on a general hull */
copy_v3_v3(nearest, data->co);
for (i = data->tree->start_axis; i != data->tree->stop_axis; i++, bv += 2)
{
@@ -1167,7 +1192,7 @@ typedef struct NodeDistance {
} NodeDistance;
-// TODO: use a priority queue to reduce the number of nodes looked on
+/* TODO: use a priority queue to reduce the number of nodes looked on */
static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node)
{
if (node->totnode == 0) {
@@ -1179,7 +1204,7 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node)
}
}
else {
- //Better heuristic to pick the closest node to dive on
+ /* Better heuristic to pick the closest node to dive on */
int i;
float nearest[3];
@@ -1259,7 +1284,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node)
dfs_find_nearest_dfs(data, child);
}
else {
- //adjust heap size
+ /* adjust heap size */
if ((heap_size >= max_heap_size) &&
ADJUST_MEMORY(default_heap, (void **)&heap, heap_size + 1, &max_heap_size, sizeof(heap[0])) == FALSE)
{
@@ -1299,22 +1324,23 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node)
#endif
-int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
+int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest,
+ BVHTree_NearestPointCallback callback, void *userdata)
{
- int i;
+ axis_t axis_iter;
BVHNearestData data;
BVHNode *root = tree->nodes[tree->totleaf];
- //init data to search
+ /* init data to search */
data.tree = tree;
data.co = co;
data.callback = callback;
data.userdata = userdata;
- for (i = data.tree->start_axis; i != data.tree->stop_axis; i++) {
- data.proj[i] = dot_v3v3(data.co, KDOP_AXES[i]);
+ for (axis_iter = data.tree->start_axis; axis_iter != data.tree->stop_axis; axis_iter++) {
+ data.proj[axis_iter] = dot_v3v3(data.co, KDOP_AXES[axis_iter]);
}
if (nearest) {
@@ -1346,7 +1372,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n
/* Determines the distance that the ray must travel to hit the bounding volume of the given node */
-static float ray_nearest_hit(BVHRayCastData *data, const float *bv)
+static float ray_nearest_hit(BVHRayCastData *data, const float bv[6])
{
int i;
@@ -1354,7 +1380,7 @@ static float ray_nearest_hit(BVHRayCastData *data, const float *bv)
for (i = 0; i != 3; i++, bv += 2) {
if (data->ray_dot_axis[i] == 0.0f) {
- //axis aligned ray
+ /* axis aligned ray */
if (data->ray.origin[i] < bv[0] - data->ray.radius ||
data->ray.origin[i] > bv[1] + data->ray.radius)
{
@@ -1469,12 +1495,13 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node)
}
else {
node = node->children[0];
- }
+ }
}
}
#endif
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
+int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
+ BVHTree_RayCastCallback callback, void *userdata)
{
int i;
BVHRayCastData data;
@@ -1524,14 +1551,14 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f
return data.hit.index;
}
-float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const float light_end[3], float pos[3])
+float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], const float light_end[3], float pos[3])
{
BVHRayCastData data;
float dist = 0.0;
data.hit.dist = FLT_MAX;
- // get light direction
+ /* get light direction */
data.ray.direction[0] = light_end[0] - light_start[0];
data.ray.direction[1] = light_end[1] - light_start[1];
data.ray.direction[2] = light_end[2] - light_start[2];
@@ -1563,7 +1590,7 @@ float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const
typedef struct RangeQueryData {
BVHTree *tree;
const float *center;
- float radius; //squared radius
+ float radius; /* squared radius */
int hits;
@@ -1578,7 +1605,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node)
{
if (node->totnode == 0) {
#if 0 /*UNUSED*/
- //Calculate the node min-coords (if the node was a point then this is the point coordinates)
+ /* Calculate the node min-coords (if the node was a point then this is the point coordinates) */
float co[3];
co[0] = node->bv[0];
co[1] = node->bv[2];
@@ -1591,7 +1618,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node)
float nearest[3];
float dist = calc_nearest_point(data->center, node->children[i], nearest);
if (dist < data->radius) {
- //Its a leaf.. call the callback
+ /* Its a leaf.. call the callback */
if (node->children[i]->totnode == 0) {
data->hits++;
data->callback(data->userdata, node->children[i]->index, dist);
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
index 19985c56b84..dd6c25ab6ad 100644
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ b/source/blender/blenlib/intern/BLI_kdtree.c
@@ -30,16 +30,12 @@
* \ingroup bli
*/
-
-
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_kdtree.h"
+#include "BLI_utildefines.h"
-#ifndef SWAP
-# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0
-#endif
typedef struct KDTreeNode {
struct KDTreeNode *left, *right;
@@ -132,7 +128,7 @@ void BLI_kdtree_balance(KDTree *tree)
tree->root = kdtree_balance(tree->nodes, tree->totnode, 0);
}
-static float squared_distance(const float v2[3], const float v1[3], const float *UNUSED(n1), const float *n2)
+static float squared_distance(const float v2[3], const float v1[3], const float UNUSED(n1[3]), const float n2[3])
{
float d[3], dist;
@@ -152,7 +148,7 @@ static float squared_distance(const float v2[3], const float v1[3], const float
return dist;
}
-int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *nearest)
+int BLI_kdtree_find_nearest(KDTree *tree, const float co[3], const float nor[3], KDTreeNearest *nearest)
{
KDTreeNode *root, *node, *min_node;
KDTreeNode **stack, *defaultstack[100];
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index 858eef0b2df..688372b3a28 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -502,7 +502,7 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node)
/* ----- */
/* Add the given data to the tree, and return the node added */
-// NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned
+/* NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned */
DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
DLRBT_NAlloc_FP new_cb, DLRBT_NUpdate_FP update_cb, void *data)
{
diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c
index 1c70a612c4f..8a97fdcab67 100644
--- a/source/blender/blenlib/intern/boxpack2d.c
+++ b/source/blender/blenlib/intern/boxpack2d.c
@@ -73,7 +73,7 @@ typedef struct BoxVert {
((b)->v[BR]->x = (b)->v[TR]->x)
#define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \
((b)->v[BR]->y = (b)->v[BL]->y)
-
+
/* UNUSED */
// #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b)
@@ -96,7 +96,7 @@ typedef struct BoxVert {
BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2))
/* compiler should inline */
-static float maxf(const float a, const float b) { return b > a ? b : a; }
+static float max_ff(const float a, const float b) { return b > a ? b : a; }
#if 0
#define BOXDEBUG(b) \
@@ -133,8 +133,8 @@ static int vertex_sort(const void *p1, const void *p2)
v1 = vertarray + ((int *)p1)[0];
v2 = vertarray + ((int *)p2)[0];
- a1 = maxf(v1->x + box_width, v1->y + box_height);
- a2 = maxf(v2->x + box_width, v2->y + box_height);
+ a1 = max_ff(v1->x + box_width, v1->y + box_height);
+ a2 = max_ff(v2->x + box_width, v2->y + box_height);
/* sort largest to smallest */
if (a1 > a2) return 1;
@@ -314,8 +314,8 @@ void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float *
if (!isect) {
/* maintain the total width and height */
- (*tot_width) = maxf(BOXRIGHT(box), (*tot_width));
- (*tot_height) = maxf(BOXTOP(box), (*tot_height));
+ (*tot_width) = max_ff(BOXRIGHT(box), (*tot_width));
+ (*tot_height) = max_ff(BOXTOP(box), (*tot_height));
/* Place the box */
vert->free &= ~quad_flags[j];
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index f72b5882f22..be9f5f97a6e 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -85,7 +85,7 @@ static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), co
ReportList *reports = (ReportList *)userdata;
if (!BLI_exists(path_src)) {
- BKE_reportf(reports, RPT_WARNING, "Path Not Found \"%s\"", path_src);
+ BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src);
}
return FALSE;
@@ -122,7 +122,7 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char
data->count_changed++;
}
else {
- BKE_reportf(data->reports, RPT_WARNING, "Path cant be made relative \"%s\"", path_src);
+ BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made relative", path_src);
data->count_failed++;
}
return TRUE;
@@ -144,7 +144,7 @@ void BLI_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *re
BLI_bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data);
BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
- "Total files %d|Changed %d|Failed %d",
+ "Total files %d | Changed %d | Failed %d",
data.count_tot, data.count_changed, data.count_failed);
}
@@ -164,7 +164,7 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char
data->count_changed++;
}
else {
- BKE_reportf(data->reports, RPT_WARNING, "Path cant be made absolute \"%s\"", path_src);
+ BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src);
data->count_failed++;
}
return TRUE;
@@ -187,13 +187,13 @@ void BLI_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *re
BLI_bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data);
BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
- "Total files %d|Changed %d|Failed %d",
+ "Total files %d | Changed %d | Failed %d",
data.count_tot, data.count_changed, data.count_failed);
}
/**
* find this file recursively, use the biggest file so thumbnails don't get used by mistake
- * \param filename_new: the path will be copied here, caller must initialize as empyu string.
+ * \param filename_new: the path will be copied here, caller must initialize as empty string.
* \param dirname: subdir to search
* \param filename: set this filename
* \param filesize: filesize for the file
@@ -279,13 +279,13 @@ static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char
if (filesize == -1) { /* could not open dir */
BKE_reportf(data->reports, RPT_WARNING,
- "Could open directory \"%s\"",
+ "Could not open directory '%s'",
BLI_path_basename(data->searchdir));
return FALSE;
}
else if (found == FALSE) {
BKE_reportf(data->reports, RPT_WARNING,
- "Could not find \"%s\" in \"%s\"",
+ "Could not find '%s' in '%s'",
BLI_path_basename((char *)path_src), data->searchdir);
return FALSE;
}
@@ -618,3 +618,73 @@ int BLI_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat
return FALSE;
}
}
+
+
+/* -------------------------------------------------------------------- */
+/**
+ * Backup/Restore/Free functions,
+ * \note These functions assume the data won't chane order.
+ */
+
+struct PathStore {
+ struct PathStore *next, *prev;
+} PathStore;
+
+static int bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
+{
+ /* store the path and string in a single alloc */
+ ListBase *ls = userdata;
+ size_t path_size = strlen(path_src) + 1;
+ struct PathStore *path_store = MEM_mallocN(sizeof(PathStore) + path_size, __func__);
+ char *filepath = (char *)(path_store + 1);
+
+ memcpy(filepath, path_src, path_size);
+ BLI_addtail(ls, path_store);
+ return FALSE;
+}
+
+static int bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
+{
+ /* assume ls->first wont be NULL because the number of paths can't change!
+ * (if they do caller is wrong) */
+ ListBase *ls = userdata;
+ struct PathStore *path_store = ls->first;
+ const char *filepath = (char *)(path_store + 1);
+ int ret;
+
+ if (strcmp(path_src, filepath) == 0) {
+ ret = FALSE;
+ }
+ else {
+ BLI_strncpy(path_dst, filepath, FILE_MAX);
+ ret = TRUE;
+ }
+
+ BLI_freelinkN(ls, path_store);
+ return ret;
+}
+
+/* return ls_handle */
+void *BLI_bpath_list_backup(Main *bmain, const int flag)
+{
+ ListBase *ls = MEM_callocN(sizeof(ListBase), __func__);
+
+ BLI_bpath_traverse_main(bmain, bpath_list_append, flag, ls);
+
+ return ls;
+}
+
+void BLI_bpath_list_restore(Main *bmain, const int flag, void *ls_handle)
+{
+ ListBase *ls = ls_handle;
+
+ BLI_bpath_traverse_main(bmain, bpath_list_restore, flag, ls);
+}
+
+void BLI_bpath_list_free(void *ls_handle)
+{
+ ListBase *ls = ls_handle;
+ BLI_assert(ls->first == NULL); /* assumes we were used */
+ BLI_freelistN(ls);
+ MEM_freeN(ls);
+}
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index d58ccbbd48e..4fb48d19239 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -108,7 +108,7 @@ void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *v
eh->buckets[hash] = e;
if (++eh->nentries > eh->nbuckets * 3) {
- EdgeEntry *e, **old = eh->buckets;
+ EdgeEntry **old = eh->buckets;
int i, nold = eh->nbuckets;
eh->nbuckets = _ehash_hashsizes[++eh->cursize];
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 1df904f617a..883cdfde426 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -140,6 +140,8 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r)
}
else break;
}
+
+ gzclose(gzfile);
if (size == 0) {
MEM_freeN(mem);
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 85239270541..0a87316aa81 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -33,8 +33,8 @@
*/
-#ifdef WIN32
-#pragma warning (disable:4244)
+#ifdef _MSC_VER
+# pragma warning (disable:4244)
#endif
#include <ft2build.h>
@@ -271,7 +271,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
(len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001f * 0.0001f) &&
(len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002f * 0.0001f) &&
(len_squared_v2v2(bezt->vec[0], bezt->vec[2]) >
- maxf(len_squared_v2v2(bezt->vec[0], bezt->vec[1]),
+ max_ff(len_squared_v2v2(bezt->vec[0], bezt->vec[1]),
len_squared_v2v2(bezt->vec[1], bezt->vec[2]))))
{
bezt->h1 = bezt->h2 = HD_ALIGN;
@@ -282,7 +282,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
}
}
if (npoints) MEM_freeN(npoints);
- if (onpoints) MEM_freeN(onpoints);
+ if (onpoints) MEM_freeN(onpoints);
}
}
@@ -404,7 +404,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
lcode = charcode;
}
- return vfd;
+ return vfd;
}
@@ -473,10 +473,10 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf)
VFontData *vfd = NULL;
int success = 0;
- //init Freetype
+ /* init Freetype */
err = FT_Init_FreeType(&library);
if (err) {
- //XXX error("Failed to load the Freetype font library");
+ /* XXX error("Failed to load the Freetype font library"); */
return NULL;
}
@@ -486,7 +486,7 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf)
vfd = objfnt_to_ftvfontdata(pf);
}
- //free Freetype
+ /* free Freetype */
FT_Done_FreeType(library);
return vfd;
@@ -518,16 +518,16 @@ int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character)
#if 0
-// Freetype2 Outline struct
+/* Freetype2 Outline struct */
typedef struct FT_Outline_
- {
+{
short n_contours; /* number of contours in glyph */
short n_points; /* number of points in the glyph */
- FT_Vector* points; /* the outline's points */
- char* tags; /* the points flags */
- short* contours; /* the contour end points */
+ FT_Vector *points; /* the outline's points */
+ char *tags; /* the points flags */
+ short *contours; /* the contour end points */
int flags; /* outline masks */
} FT_Outline;
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c
index 51d7cb58b00..a93bbd97b51 100644
--- a/source/blender/blenlib/intern/graph.c
+++ b/source/blender/blenlib/intern/graph.c
@@ -353,12 +353,12 @@ int BLI_isGraphCyclic(BGraph *graph)
/* Mark all nodes as not visited */
BLI_flagNodes(graph, 0);
- /* detectCycles in subgraphs */
+ /* detectCycles in subgraphs */
for (node = graph->nodes.first; node && value == 0; node = node->next) {
/* only for nodes in subgraphs that haven't been visited yet */
if (node->flag == 0) {
value = value || detectCycle(node, NULL);
- }
+ }
}
return value;
@@ -639,11 +639,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
/* if not dispatching already and on last arc
* Dispatch using current arc as last
- * */
+ */
if (dispatch == 0 && i == total - 1) {
last = i;
dispatch = 1;
- }
+ }
if (dispatch) {
int sub_total = last - first + 1;
@@ -796,7 +796,7 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
/* count the number of branches in this symmetry group
* and determinate the axis of symmetry
- * */
+ */
for (i = 0; i < node->degree; i++) {
BArc *connectedArc = node->arcs[i];
@@ -821,7 +821,7 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
handleRadialSymmetry(graph, node, depth, axis, limit);
}
- /* markdown secondary symetries */
+ /* markdown secondary symetries */
for (i = 0; i < node->degree; i++) {
BArc *connectedArc = node->arcs[i];
@@ -836,7 +836,7 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
{
int i;
- /* if arc is null, we start straight from a node */
+ /* if arc is null, we start straight from a node */
if (arc) {
arc->symmetry_level = level;
@@ -875,7 +875,7 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
/* not on the symmetry axis */
issymmetryAxis = 0;
break;
- }
+ }
}
}
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index ad718ed8e11..9f6f409c473 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -141,7 +141,7 @@ void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink)
if (listbase == NULL) return;
/* empty list */
- if (listbase->first == NULL) {
+ if (listbase->first == NULL) {
listbase->first = newlink;
listbase->last = newlink;
@@ -149,7 +149,7 @@ void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink)
}
/* insert before first element */
- if (prevlink == NULL) {
+ if (prevlink == NULL) {
newlink->next = listbase->first;
newlink->prev = NULL;
newlink->next->prev = newlink;
@@ -203,14 +203,14 @@ void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink)
if (listbase == NULL) return;
/* empty list */
- if (listbase->first == NULL) {
+ if (listbase->first == NULL) {
listbase->first = newlink;
listbase->last = newlink;
return;
}
/* insert at head of list */
- if (prevlink == NULL) {
+ if (prevlink == NULL) {
newlink->prev = NULL;
newlink->next = listbase->first;
((Link *)listbase->first)->prev = newlink;
@@ -238,14 +238,14 @@ void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
if (listbase == NULL) return;
/* empty list */
- if (listbase->first == NULL) {
+ if (listbase->first == NULL) {
listbase->first = newlink;
listbase->last = newlink;
return;
}
/* insert at end of list */
- if (nextlink == NULL) {
+ if (nextlink == NULL) {
newlink->prev = listbase->last;
newlink->next = NULL;
((Link *)listbase->last)->next = newlink;
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 97fc431d8fa..f27da759482 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -59,34 +59,34 @@ MINLINE float saacos(float fac)
{
if (fac <= -1.0f) return (float)M_PI;
else if (fac >= 1.0f) return 0.0;
- else return (float)acos(fac);
+ else return acosf(fac);
}
MINLINE float saasin(float fac)
{
if (fac <= -1.0f) return (float)-M_PI / 2.0f;
else if (fac >= 1.0f) return (float)M_PI / 2.0f;
- else return (float)asin(fac);
+ else return asinf(fac);
}
MINLINE float sasqrt(float fac)
{
if (fac <= 0.0f) return 0.0f;
- return (float)sqrt(fac);
+ return sqrtf(fac);
}
MINLINE float saacosf(float fac)
{
if (fac <= -1.0f) return (float)M_PI;
else if (fac >= 1.0f) return 0.0f;
- else return (float)acosf(fac);
+ else return acosf(fac);
}
MINLINE float saasinf(float fac)
{
if (fac <= -1.0f) return (float)-M_PI / 2.0f;
else if (fac >= 1.0f) return (float)M_PI / 2.0f;
- else return (float)asinf(fac);
+ else return asinf(fac);
}
MINLINE float sasqrtf(float fac)
@@ -139,20 +139,20 @@ MINLINE int power_of_2_min_i(int n)
return n;
}
-MINLINE float minf(float a, float b)
+MINLINE float min_ff(float a, float b)
{
return (a < b) ? a : b;
}
-MINLINE float maxf(float a, float b)
+MINLINE float max_ff(float a, float b)
{
return (a > b) ? a : b;
}
-MINLINE int mini(int a, int b)
+MINLINE int min_ii(int a, int b)
{
return (a < b) ? a : b;
}
-MINLINE int maxi(int a, int b)
+MINLINE int max_ii(int a, int b)
{
return (b < a) ? a : b;
}
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index f520b2318e5..4c8bd43ef73 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -164,7 +164,11 @@ MINLINE void linearrgb_to_srgb_ushort4_predivide(unsigned short srgb[4], const f
for (i = 0; i < 3; ++i) {
t = linear[i] * inv_alpha;
- srgb[i] = (t < 1.0f) ? (unsigned short) (to_srgb_table_lookup(t) * alpha) : FTOUSHORT(linearrgb_to_srgb(t) * alpha);
+ srgb[i] = (t <= 1.0f) ?
+ /* warning - converts: float -> short -> float -> short */
+ (unsigned short) (to_srgb_table_lookup(t) * alpha) :
+ /* if FTOUSHORT was an inline function this could be done less confusingly */
+ ((t = linearrgb_to_srgb(t) * alpha), FTOUSHORT(t));
}
srgb[3] = FTOUSHORT(linear[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 50cef039acf..e10229f11da 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -404,8 +404,8 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[
if (u > u2) SWAP(float, u, u2);
if (u > 1.0f + eps || u2 < -eps) return -1; /* non-ovlerlapping segments */
- else if (maxf(0.0f, u) == minf(1.0f, u2)) { /* one common point: can return result */
- interp_v2_v2v2(vi, v1, v2, maxf(0, u));
+ else if (max_ff(0.0f, u) == min_ff(1.0f, u2)) { /* one common point: can return result */
+ interp_v2_v2v2(vi, v1, v2, max_ff(0, u));
return 1;
}
}
@@ -560,7 +560,8 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2],
}
}
-/*
+/**
+ * \return
* -1: collinear
* 1: intersection
*/
@@ -758,6 +759,10 @@ int isect_ray_tri_v3(const float p1[3], const float d[3],
return 1;
}
+/**
+ * if clip is nonzero, will only return true if lambda is >= 0.0
+ * (i.e. intersection point is along positive d)
+ */
int isect_ray_plane_v3(const float p1[3], const float d[3],
const float v0[3], const float v1[3], const float v2[3],
float *r_lambda, const int clip)
@@ -876,6 +881,16 @@ int isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
return 1;
}
+/**
+ * Intersect line/plane, optionally treat line as directional (like a ray) with the no_flip argument.
+ *
+ * \param out The intersection point.
+ * \param l1 The first point of the line.
+ * \param l2 The second point of the line.
+ * \param plane_co A point on the plane to intersect with.
+ * \param plane_no The direction of the plane (does not need to be normalized).
+ * \param no_flip When true, the intersection point will always be from l1 to l2, even if this is not on the plane.
+ */
int isect_line_plane_v3(float out[3],
const float l1[3], const float l2[3],
const float plane_co[3], const float plane_no[3], const short no_flip)
@@ -921,7 +936,20 @@ int isect_line_plane_v3(float out[3],
}
}
-/* note: return normal isn't unit length */
+/**
+ * Intersect two planes, return a point on the intersection and a vector
+ * that runs on the direction of the intersection.
+ * Return error code is the same as 'isect_line_line_v3'.
+ *
+ * \param r_isect_co The resulting intersection point.
+ * \param r_isect_no The resulting vector of the intersection.
+ * \param plane_a_co The point on the first plane.
+ * \param plane_a_no The normal of the first plane.
+ * \param plane_b_co The point on the second plane.
+ * \param plane_b_no The normal of the second plane.
+ *
+ * \note return normal isn't unit length
+ */
void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
const float plane_a_co[3], const float plane_a_no[3],
const float plane_b_co[3], const float plane_b_no[3])
@@ -939,10 +967,10 @@ void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
/* "Improved Collision detection and Response" */
static int getLowestRoot(const float a, const float b, const float c, const float maxR, float *root)
{
- // Check if a solution exists
+ /* Check if a solution exists */
float determinant = b * b - 4.0f * a * c;
- // If determinant is negative it means no solutions.
+ /* If determinant is negative it means no solutions. */
if (determinant >= 0.0f) {
/* calculate the two roots: (if determinant == 0 then
* x1==x2 but lets disregard that slight optimization) */
@@ -950,24 +978,24 @@ static int getLowestRoot(const float a, const float b, const float c, const floa
float r1 = (-b - sqrtD) / (2.0f * a);
float r2 = (-b + sqrtD) / (2.0f * a);
- // Sort so x1 <= x2
+ /* Sort so x1 <= x2 */
if (r1 > r2)
SWAP(float, r1, r2);
- // Get lowest root:
+ /* Get lowest root: */
if (r1 > 0.0f && r1 < maxR) {
*root = r1;
return 1;
}
- // It is possible that we want x2 - this can happen
- // if x1 < 0
+ /* It is possible that we want x2 - this can happen */
+ /* if x1 < 0 */
if (r2 > 0.0f && r2 < maxR) {
*root = r2;
return 1;
}
}
- // No (valid) solutions
+ /* No (valid) solutions */
return 0;
}
@@ -1080,7 +1108,7 @@ int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const flo
}
/*---test edges---*/
- sub_v3_v3v3(e3, v2, v1); //wasnt yet calculated
+ sub_v3_v3v3(e3, v2, v1); /* wasnt yet calculated */
/*e1*/
@@ -1206,11 +1234,12 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3]
return 1;
}
-/* Returns the number of point of interests
+/**
+ * \return The number of point of interests
* 0 - lines are colinear
* 1 - lines are coplanar, i1 is set to intersection
* 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively
- * */
+ */
int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float i1[3], float i2[3])
{
float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3];
@@ -1344,7 +1373,7 @@ void isect_ray_aabb_initialize(IsectRayAABBData *data, const float ray_start[3],
/* Adapted from http://www.gamedev.net/community/forums/topic.asp?topic_id=459973 */
int isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3],
- const float bb_max[3], float *tmin_out)
+ const float bb_max[3], float *tmin_out)
{
float bbox[2][3];
float tmin, tmax, tymin, tymax, tzmin, tzmax;
@@ -1587,7 +1616,7 @@ void isect_point_face_uv_v2(const int isquad,
}
}
-#if 0 // XXX this version used to be used in isect_point_tri_v2_int() and was called IsPointInTri2D
+#if 0 /* XXX this version used to be used in isect_point_tri_v2_int() and was called IsPointInTri2D */
int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2])
{
@@ -1777,7 +1806,7 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int,
signed char ix;
signed char iy;
- // if x1 == x2 or y1 == y2, then it does not matter what we set here
+ /* if x1 == x2 or y1 == y2, then it does not matter what we set here */
int delta_x = (x2 > x1 ? (ix = 1, x2 - x1) : (ix = -1, x1 - x2)) << 1;
int delta_y = (y2 > y1 ? (iy = 1, y2 - y1) : (iy = -1, y1 - y2)) << 1;
@@ -1786,7 +1815,7 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int,
}
if (delta_x >= delta_y) {
- // error may go below zero
+ /* error may go below zero */
int error = delta_y - (delta_x >> 1);
while (x1 != x2) {
@@ -1795,9 +1824,9 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int,
y1 += iy;
error -= delta_x;
}
- // else do nothing
+ /* else do nothing */
}
- // else do nothing
+ /* else do nothing */
x1 += ix;
error += delta_y;
@@ -1808,7 +1837,7 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int,
}
}
else {
- // error may go below zero
+ /* error may go below zero */
int error = delta_x - (delta_y >> 1);
while (y1 != y2) {
@@ -1817,9 +1846,9 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int,
x1 += ix;
error -= delta_y;
}
- // else do nothing
+ /* else do nothing */
}
- // else do nothing
+ /* else do nothing */
y1 += iy;
error += delta_x;
@@ -2323,18 +2352,18 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const
(st2[0] * st3[1] - st2[1] * st3[0]) + (st3[0] * st0[1] - st3[1] * st0[0]);
/* X is 2D cross product (determinant)
- * A= (p0-p) X (p0-p3)*/
+ * A = (p0 - p) X (p0 - p3)*/
const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
- /* B= ( (p0-p) X (p1-p2) + (p1-p) X (p0-p3) ) / 2 */
- const double b = 0.5 * (((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
- ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
+ /* B = ( (p0 - p) X (p1 - p2) + (p1 - p) X (p0 - p3) ) / 2 */
+ const double b = 0.5 * (double)(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
+ ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
/* C = (p1-p) X (p1-p2) */
const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
const double denom = a - 2 * b + fC;
- // clear outputs
+ /* clear outputs */
zero_v2(r_uv);
if (IS_ZERO(denom) != 0) {
@@ -2364,7 +2393,7 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const
}
if (IS_ZERO(denom) == 0)
- r_uv[1] = (float)(((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) / denom);
+ r_uv[1] = (float)((double)((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) / denom);
}
}
@@ -2650,7 +2679,7 @@ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3],
const float *cur_edge = vdiffs[i];
const float fac = saacos(-dot_v3v3(cur_edge, prev_edge));
- // accumulate
+ /* accumulate */
madd_v3_v3fl(vn[i], f_no, fac);
prev_edge = cur_edge;
}
@@ -2691,50 +2720,6 @@ void accumulate_vertex_normals_poly(float **vertnos, float polyno[3],
/********************************* Tangents **********************************/
-/* For normal map tangents we need to detect uv boundaries, and only average
- * tangents in case the uvs are connected. Alternative would be to store 1
- * tangent per face rather than 4 per face vertex, but that's not compatible
- * with games */
-
-
-/* from BKE_mesh.h */
-#define STD_UV_CONNECT_LIMIT 0.0001f
-
-void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, const float tang[3], const float uv[2])
-{
- VertexTangent *vt;
-
- /* find a tangent with connected uvs */
- for (vt = *vtang; vt; vt = vt->next) {
- if (fabsf(uv[0] - vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1] - vt->uv[1]) < STD_UV_CONNECT_LIMIT) {
- add_v3_v3(vt->tang, tang);
- return;
- }
- }
-
- /* if not found, append a new one */
- vt = BLI_memarena_alloc((MemArena *) arena, sizeof(VertexTangent));
- copy_v3_v3(vt->tang, tang);
- vt->uv[0] = uv[0];
- vt->uv[1] = uv[1];
-
- if (*vtang)
- vt->next = *vtang;
- *vtang = vt;
-}
-
-float *find_vertex_tangent(VertexTangent *vtang, const float uv[2])
-{
- VertexTangent *vt;
- static float nulltang[3] = {0.0f, 0.0f, 0.0f};
-
- for (vt = vtang; vt; vt = vt->next)
- if (fabsf(uv[0] - vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1] - vt->uv[1]) < STD_UV_CONNECT_LIMIT)
- return vt->tang;
-
- return nulltang; /* shouldn't happen, except for nan or so */
-}
-
void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], float co2[3], float co3[3], float n[3], float tang[3])
{
float s1 = uv2[0] - uv1[0];
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 0d4c797cefb..01585c93bc8 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -137,4 +137,24 @@ MINLINE void madd_sh_shfl(float r[9], const float sh[9], const float f)
add_sh_shsh(r, r, tmp);
}
+MINLINE int max_axis_v3(const float vec[3])
+{
+ const float x = vec[0];
+ const float y = vec[1];
+ const float z = vec[2];
+ return ((x > y) ?
+ ((x > z) ? 0 : 2) :
+ ((y > z) ? 1 : 2));
+}
+
+MINLINE int min_axis_v3(const float vec[3])
+{
+ const float x = vec[0];
+ const float y = vec[1];
+ const float z = vec[2];
+ return ((x < y) ?
+ ((x < z) ? 0 : 2) :
+ ((y < z) ? 1 : 2));
+}
+
#endif /* __MATH_GEOM_INLINE_C__ */
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
new file mode 100644
index 00000000000..742669354a9
--- /dev/null
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -0,0 +1,235 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#include <math.h>
+
+#include "BLI_math.h"
+
+/**************************************************************************
+ * INTERPOLATIONS
+ *
+ * Reference and docs:
+ * http://wiki.blender.org/index.php/User:Damiles#Interpolations_Algorithms
+ ***************************************************************************/
+
+/* BICUBIC Interpolation functions
+ * More info: http://wiki.blender.org/index.php/User:Damiles#Bicubic_pixel_interpolation
+ * function assumes out to be zero'ed, only does RGBA */
+
+static float P(float k)
+{
+ float p1, p2, p3, p4;
+ p1 = MAX2(k + 2.0f, 0);
+ p2 = MAX2(k + 1.0f, 0);
+ p3 = MAX2(k, 0);
+ p4 = MAX2(k - 1.0f, 0);
+ return (float)(1.0f / 6.0f) * (p1 * p1 * p1 - 4.0f * p2 * p2 * p2 + 6.0f * p3 * p3 * p3 - 4.0f * p4 * p4 * p4);
+}
+
+
+#if 0
+/* older, slower function, works the same as above */
+static float P(float k)
+{
+ return (float)(1.0f / 6.0f) * (pow(MAX2(k + 2.0f, 0), 3.0f) - 4.0f * pow(MAX2(k + 1.0f, 0), 3.0f) + 6.0f * pow(MAX2(k, 0), 3.0f) - 4.0f * pow(MAX2(k - 1.0f, 0), 3.0f));
+}
+#endif
+
+/* BICUBIC INTERPOLATION */
+void BLI_bicubic_interpolation(const float *buffer, float *output, int width, int height, int components, float u, float v)
+{
+ int i, j, n, m, x1, y1;
+ float a, b, w, wx, wy[4], out[4];
+ const float *data;
+
+ /* sample area entirely outside image? */
+ if (ceil(u) < 0 || floor(u) > width - 1 || ceil(v) < 0 || floor(v) > height - 1) {
+ return;
+ }
+
+ i = (int)floor(u);
+ j = (int)floor(v);
+ a = u - i;
+ b = v - j;
+
+ zero_v4(out);
+
+/* Optimized and not so easy to read */
+
+ /* avoid calling multiple times */
+ wy[0] = P(b - (-1));
+ wy[1] = P(b - 0);
+ wy[2] = P(b - 1);
+ wy[3] = P(b - 2);
+
+ for (n = -1; n <= 2; n++) {
+ x1 = i + n;
+ CLAMP(x1, 0, width - 1);
+ wx = P(n - a);
+ for (m = -1; m <= 2; m++) {
+ y1 = j + m;
+ CLAMP(y1, 0, height - 1);
+ /* normally we could do this */
+ /* w = P(n-a) * P(b-m); */
+ /* except that would call P() 16 times per pixel therefor pow() 64 times, better precalc these */
+ w = wx * wy[m + 1];
+
+ data = buffer + width * y1 * 4 + 4 * x1;
+
+ if (components == 1) {
+ out[0] += data[0] * w;
+ }
+ else if (components == 2) {
+ out[0] += data[0] * w;
+ out[1] += data[1] * w;
+ }
+ else if (components == 3) {
+ out[0] += data[0] * w;
+ out[1] += data[1] * w;
+ out[2] += data[2] * w;
+ }
+ else {
+ out[0] += data[0] * w;
+ out[1] += data[1] * w;
+ out[2] += data[2] * w;
+ out[3] += data[3] * w;
+ }
+ }
+ }
+
+/* Done with optimized part */
+
+#if 0
+ /* older, slower function, works the same as above */
+ for (n = -1; n <= 2; n++) {
+ for (m = -1; m <= 2; m++) {
+ x1 = i + n;
+ y1 = j + m;
+ if (x1 > 0 && x1 < width && y1 > 0 && y1 < height) {
+ data = in->rect_float + width * y1 * 4 + 4 * x1;
+
+ if (components == 1) {
+ out[0] += data[0] * P(n - a) * P(b - m);
+ }
+ else if (components == 2) {
+ out[0] += data[0] * P(n - a) * P(b - m);
+ out[1] += data[1] * P(n - a) * P(b - m);
+ }
+ else if (components == 3) {
+ out[0] += data[0] * P(n - a) * P(b - m);
+ out[1] += data[1] * P(n - a) * P(b - m);
+ out[2] += data[2] * P(n - a) * P(b - m);
+ }
+ else {
+ out[0] += data[0] * P(n - a) * P(b - m);
+ out[1] += data[1] * P(n - a) * P(b - m);
+ out[2] += data[2] * P(n - a) * P(b - m);
+ out[3] += data[3] * P(n - a) * P(b - m);
+ }
+ }
+ }
+ }
+#endif
+
+ if (components == 1) {
+ output[0] = out[0];
+ }
+ else if (components == 2) {
+ output[0] = out[0];
+ output[1] = out[1];
+ }
+ else if (components == 3) {
+ output[0] = out[0];
+ output[1] = out[1];
+ output[2] = out[2];
+ }
+ else {
+ output[0] = out[0];
+ output[1] = out[1];
+ output[2] = out[2];
+ output[3] = out[3];
+ }
+}
+
+/* BILINEAR INTERPOLATION */
+void BLI_bilinear_interpolation(const float *buffer, float *output, int width, int height, int components, float u, float v)
+{
+ const float *row1, *row2, *row3, *row4;
+ float a, b;
+ float a_b, ma_b, a_mb, ma_mb;
+ float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ int y1, y2, x1, x2;
+
+ /* ImBuf in must have a valid rect or rect_float, assume this is already checked */
+
+ x1 = (int)floor(u);
+ x2 = (int)ceil(u);
+ y1 = (int)floor(v);
+ y2 = (int)ceil(v);
+
+ /* sample area entirely outside image? */
+ if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) {
+ return;
+ }
+
+ /* sample including outside of edges of image */
+ if (x1 < 0 || y1 < 0) row1 = empty;
+ else row1 = buffer + width * y1 * 4 + 4 * x1;
+
+ if (x1 < 0 || y2 > height - 1) row2 = empty;
+ else row2 = buffer + width * y2 * 4 + 4 * x1;
+
+ if (x2 > width - 1 || y1 < 0) row3 = empty;
+ else row3 = buffer + width * y1 * 4 + 4 * x2;
+
+ if (x2 > width - 1 || y2 > height - 1) row4 = empty;
+ else row4 = buffer + width * y2 * 4 + 4 * x2;
+
+ a = u - floorf(u);
+ b = v - floorf(v);
+ a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
+
+ if (components == 1) {
+ output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
+ }
+ else if (components == 2) {
+ output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
+ output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1];
+ }
+ else if (components == 3) {
+ output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
+ output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1];
+ output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2];
+ }
+ else {
+ output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
+ output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1];
+ output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2];
+ output[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3];
+ }
+}
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 4a828e2c2e1..188ca5d5ee7 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -553,6 +553,51 @@ void sub_m4_m4m4(float m1[][4], float m2[][4], float m3[][4])
m1[i][j] = m2[i][j] - m3[i][j];
}
+/* why not make this a standard part of the API? */
+static float determinant_m3_local(float m[3][3])
+{
+ return (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) -
+ m[1][0] * (m[0][1] * m[2][2] - m[0][2] * m[2][1]) +
+ m[2][0] * (m[0][1] * m[1][2] - m[0][2] * m[1][1]));
+}
+
+int invert_m3_ex(float m[3][3], const float epsilon)
+{
+ float tmp[3][3];
+ int success;
+
+ success = invert_m3_m3_ex(tmp, m, epsilon);
+ copy_m3_m3(m, tmp);
+
+ return success;
+}
+
+int invert_m3_m3_ex(float m1[3][3], float m2[3][3], const float epsilon)
+{
+ float det;
+ int a, b, success;
+
+ BLI_assert(epsilon >= 0.0f);
+
+ /* calc adjoint */
+ adjoint_m3_m3(m1, m2);
+
+ /* then determinant old matrix! */
+ det = determinant_m3_local(m2);
+
+ success = (fabsf(det) > epsilon);
+
+ if (LIKELY(det != 0.0f)) {
+ det = 1.0f / det;
+ for (a = 0; a < 3; a++) {
+ for (b = 0; b < 3; b++) {
+ m1[a][b] *= det;
+ }
+ }
+ }
+ return success;
+}
+
int invert_m3(float m[3][3])
{
float tmp[3][3];
@@ -573,17 +618,16 @@ int invert_m3_m3(float m1[3][3], float m2[3][3])
adjoint_m3_m3(m1, m2);
/* then determinant old matrix! */
- det = (m2[0][0] * (m2[1][1] * m2[2][2] - m2[1][2] * m2[2][1]) -
- m2[1][0] * (m2[0][1] * m2[2][2] - m2[0][2] * m2[2][1]) +
- m2[2][0] * (m2[0][1] * m2[1][2] - m2[0][2] * m2[1][1]));
+ det = determinant_m3_local(m2);
- success = (det != 0);
+ success = (det != 0.0f);
- if (det == 0) det = 1;
- det = 1 / det;
- for (a = 0; a < 3; a++) {
- for (b = 0; b < 3; b++) {
- m1[a][b] *= det;
+ if (LIKELY(det != 0.0f)) {
+ det = 1.0f / det;
+ for (a = 0; a < 3; a++) {
+ for (b = 0; b < 3; b++) {
+ m1[a][b] *= det;
+ }
}
}
@@ -652,15 +696,15 @@ int invert_m4_m4(float inverse[4][4], float mat[4][4])
if (temp == 0)
return 0; /* No non-zero pivot */
for (k = 0; k < 4; k++) {
- tempmat[i][k] = (float)(tempmat[i][k] / temp);
- inverse[i][k] = (float)(inverse[i][k] / temp);
+ tempmat[i][k] = (float)((double)tempmat[i][k] / temp);
+ inverse[i][k] = (float)((double)inverse[i][k] / temp);
}
for (j = 0; j < 4; j++) {
if (j != i) {
temp = tempmat[j][i];
for (k = 0; k < 4; k++) {
- tempmat[j][k] -= (float)(tempmat[i][k] * temp);
- inverse[j][k] -= (float)(inverse[i][k] * temp);
+ tempmat[j][k] -= (float)((double)tempmat[i][k] * temp);
+ inverse[j][k] -= (float)((double)inverse[i][k] * temp);
}
}
}
@@ -994,8 +1038,18 @@ void normalize_m4_m4(float rmat[][4], float mat[][4])
if (len != 0.0f) rmat[2][3] = mat[2][3] / len;
}
+void adjoint_m2_m2(float m1[][2], float m[][2])
+{
+ BLI_assert(m1 != m);
+ m1[0][0] = m[1][1];
+ m1[0][1] = -m[1][0];
+ m1[1][0] = -m[0][1];
+ m1[1][1] = m[0][0];
+}
+
void adjoint_m3_m3(float m1[][3], float m[][3])
{
+ BLI_assert(m1 != m);
m1[0][0] = m[1][1] * m[2][2] - m[1][2] * m[2][1];
m1[0][1] = -m[0][1] * m[2][2] + m[0][2] * m[2][1];
m1[0][2] = m[0][1] * m[1][2] - m[0][2] * m[1][1];
@@ -1512,7 +1566,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
int m = 4;
int n = 4;
int maxiter = 200;
- int nu = minf(m, n);
+ int nu = min_ff(m, n);
float *work = work1;
float *e = work2;
@@ -1520,22 +1574,22 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
int i = 0, j = 0, k = 0, p, pp, iter;
- // Reduce A to bidiagonal form, storing the diagonal elements
- // in s and the super-diagonal elements in e.
+ /* Reduce A to bidiagonal form, storing the diagonal elements
+ * in s and the super-diagonal elements in e. */
- int nct = minf(m - 1, n);
- int nrt = maxf(0, minf(n - 2, m));
+ int nct = min_ff(m - 1, n);
+ int nrt = max_ff(0, min_ff(n - 2, m));
copy_m4_m4(A, A_);
zero_m4(U);
zero_v4(s);
- for (k = 0; k < maxf(nct, nrt); k++) {
+ for (k = 0; k < max_ff(nct, nrt); k++) {
if (k < nct) {
- // Compute the transformation for the k-th column and
- // place the k-th diagonal in s[k].
- // Compute 2-norm of k-th column without under/overflow.
+ /* Compute the transformation for the k-th column and
+ * place the k-th diagonal in s[k].
+ * Compute 2-norm of k-th column without under/overflow. */
s[k] = 0;
for (i = k; i < m; i++) {
s[k] = hypotf(s[k], A[i][k]);
@@ -1556,7 +1610,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
for (j = k + 1; j < n; j++) {
if ((k < nct) && (s[k] != 0.0f)) {
- // Apply the transformation.
+ /* Apply the transformation. */
float t = 0;
for (i = k; i < m; i++) {
@@ -1568,24 +1622,24 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
}
}
- // Place the k-th row of A into e for the
- // subsequent calculation of the row transformation.
+ /* Place the k-th row of A into e for the */
+ /* subsequent calculation of the row transformation. */
e[j] = A[k][j];
}
if (k < nct) {
- // Place the transformation in U for subsequent back
- // multiplication.
+ /* Place the transformation in U for subsequent back
+ * multiplication. */
for (i = k; i < m; i++)
U[i][k] = A[i][k];
}
if (k < nrt) {
- // Compute the k-th row transformation and place the
- // k-th super-diagonal in e[k].
- // Compute 2-norm without under/overflow.
+ /* Compute the k-th row transformation and place the
+ * k-th super-diagonal in e[k].
+ * Compute 2-norm without under/overflow. */
e[k] = 0;
for (i = k + 1; i < n; i++) {
e[k] = hypotf(e[k], e[i]);
@@ -1605,7 +1659,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
if ((k + 1 < m) & (e[k] != 0.0f)) {
float invek1;
- // Apply the transformation.
+ /* Apply the transformation. */
for (i = k + 1; i < m; i++) {
work[i] = 0.0f;
@@ -1624,17 +1678,17 @@ 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.
+ /* Place the transformation in V for subsequent
+ * back multiplication. */
for (i = k + 1; i < n; i++)
V[i][k] = e[i];
}
}
- // Set up the final bidiagonal matrix or order p.
+ /* Set up the final bidiagonal matrix or order p. */
- p = minf(n, m + 1);
+ p = min_ff(n, m + 1);
if (nct < n) {
s[nct] = A[nct][nct];
}
@@ -1646,7 +1700,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
}
e[p - 1] = 0.0f;
- // If required, generate U.
+ /* If required, generate U. */
for (j = nct; j < nu; j++) {
for (i = 0; i < m; i++) {
@@ -1682,7 +1736,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
}
}
- // If required, generate V.
+ /* If required, generate V. */
for (k = n - 1; k >= 0; k--) {
if ((k < nrt) & (e[k] != 0.0f)) {
@@ -1703,7 +1757,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
V[k][k] = 1.0f;
}
- // Main iteration loop for the singular values.
+ /* Main iteration loop for the singular values. */
pp = p - 1;
iter = 0;
@@ -1711,20 +1765,20 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
while (p > 0) {
int kase = 0;
- // Test for maximum iterations to avoid infinite loop
+ /* Test for maximum iterations to avoid infinite loop */
if (maxiter == 0)
break;
maxiter--;
- // This section of the program inspects for
- // negligible elements in the s and e arrays. On
- // completion the variables kase and k are set as follows.
-
- // kase = 1 if s(p) and e[k - 1] are negligible and k<p
- // kase = 2 if s(k) is negligible and k<p
- // kase = 3 if e[k - 1] is negligible, k<p, and
- // s(k), ..., s(p) are not negligible (qr step).
- // kase = 4 if e(p - 1) is negligible (convergence).
+ /* This section of the program inspects for
+ * negligible elements in the s and e arrays. On
+ * completion the variables kase and k are set as follows.
+ *
+ * kase = 1 if s(p) and e[k - 1] are negligible and k<p
+ * kase = 2 if s(k) is negligible and k<p
+ * kase = 3 if e[k - 1] is negligible, k<p, and
+ * s(k), ..., s(p) are not negligible (qr step).
+ * kase = 4 if e(p - 1) is negligible (convergence). */
for (k = p - 2; k >= -1; k--) {
if (k == -1) {
@@ -1765,11 +1819,11 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
}
k++;
- // Perform the task indicated by kase.
+ /* Perform the task indicated by kase. */
switch (kase) {
- // Deflate negligible s(p).
+ /* Deflate negligible s(p). */
case 1:
{
@@ -1795,7 +1849,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
break;
}
- // Split at negligible s(k).
+ /* Split at negligible s(k). */
case 2:
{
@@ -1819,14 +1873,14 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
break;
}
- // Perform one qr step.
+ /* Perform one qr step. */
case 3:
{
- // Calculate the shift.
+ /* Calculate the shift. */
- float scale = maxf(maxf(maxf(maxf(
+ float scale = max_ff(max_ff(max_ff(max_ff(
fabsf(s[p - 1]), fabsf(s[p - 2])), fabsf(e[p - 2])),
fabsf(s[k])), fabsf(e[k]));
float invscale = 1.0f / scale;
@@ -1849,7 +1903,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
f = (sk + sp) * (sk - sp) + shift;
g = sk * ek;
- // Chase zeros.
+ /* Chase zeros. */
for (j = k; j < p - 1; j++) {
float t = hypotf(f, g);
@@ -1891,12 +1945,12 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
iter = iter + 1;
break;
}
- // Convergence.
+ /* Convergence. */
case 4:
{
- // Make the singular values positive.
+ /* Make the singular values positive. */
if (s[k] <= 0.0f) {
s[k] = (s[k] < 0.0f ? -s[k] : 0.0f);
@@ -1905,7 +1959,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
V[i][k] = -V[i][k];
}
- // Order the singular values.
+ /* Order the singular values. */
while (k < pp) {
float t;
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 53f2c1cd0d9..b0c4724e1ec 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -234,7 +234,7 @@ void quat_to_mat4(float m[][4], const float q[4])
double q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
#ifdef DEBUG
- if (!((q0 = dot_qtqt(q, q)) == 0.0f || (fabsf(q0 - 1.0) < QUAT_EPSILON))) {
+ if (!((q0 = dot_qtqt(q, q)) == 0.0 || (fabs(q0 - 1.0) < QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0);
}
#endif
@@ -288,9 +288,9 @@ void mat3_to_quat(float q[4], float wmat[][3])
s = sqrt(tr);
q[0] = (float)s;
s = 1.0 / (4.0 * s);
- q[1] = (float)((mat[1][2] - mat[2][1]) * s);
- q[2] = (float)((mat[2][0] - mat[0][2]) * s);
- q[3] = (float)((mat[0][1] - mat[1][0]) * s);
+ q[1] = (float)((double)(mat[1][2] - mat[2][1]) * s);
+ q[2] = (float)((double)(mat[2][0] - mat[0][2]) * s);
+ q[3] = (float)((double)(mat[0][1] - mat[1][0]) * s);
}
else {
if (mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) {
@@ -797,7 +797,7 @@ void mat3_to_axis_angle(float axis[3], float *angle, float mat[3][3])
float q[4];
/* use quaternions as intermediate representation */
- // TODO: it would be nicer to go straight there...
+ /* TODO: it would be nicer to go straight there... */
mat3_to_quat(q, mat);
quat_to_axis_angle(axis, angle, q);
}
@@ -808,7 +808,7 @@ void mat4_to_axis_angle(float axis[3], float *angle, float mat[4][4])
float q[4];
/* use quaternions as intermediate representation */
- // TODO: it would be nicer to go straight there...
+ /* TODO: it would be nicer to go straight there... */
mat4_to_quat(q, mat);
quat_to_axis_angle(axis, angle, q);
}
@@ -1077,11 +1077,11 @@ void compatible_eul(float eul[3], const float oldrot[3])
for (i = 0; i < 3; i++) {
deul[i] = eul[i] - oldrot[i];
if (deul[i] > pi_thresh) {
- eul[i] -= floorf(( deul[i] / pi_x2) + 0.5) * pi_x2;
+ eul[i] -= floorf(( deul[i] / pi_x2) + 0.5f) * pi_x2;
deul[i] = eul[i] - oldrot[i];
}
else if (deul[i] < -pi_thresh) {
- eul[i] += floorf((-deul[i] / pi_x2) + 0.5) * pi_x2;
+ eul[i] += floorf((-deul[i] / pi_x2) + 0.5f) * pi_x2;
deul[i] = eul[i] - oldrot[i];
}
}
@@ -1363,7 +1363,7 @@ void mat4_to_compatible_eulO(float eul[3], float oldrot[3], const short order, f
mat3_to_compatible_eulO(eul, oldrot, order, m);
}
/* rotate the given euler by the given angle on the specified axis */
-// NOTE: is this safe to do with different axis orders?
+/* NOTE: is this safe to do with different axis orders? */
void rotate_eulO(float beul[3], const short order, char axis, float ang)
{
@@ -1679,34 +1679,34 @@ void vec_apply_track(float vec[3], short axis)
switch (axis) {
case 0: /* pos-x */
- /* vec[0]= 0.0; */
+ /* vec[0] = 0.0; */
vec[1] = tvec[2];
vec[2] = -tvec[1];
break;
case 1: /* pos-y */
- /* vec[0]= tvec[0]; */
- /* vec[1]= 0.0; */
- /* vec[2]= tvec[2]; */
+ /* vec[0] = tvec[0]; */
+ /* vec[1] = 0.0; */
+ /* vec[2] = tvec[2]; */
break;
case 2: /* pos-z */
- /* vec[0]= tvec[0]; */
- /* vec[1]= tvec[1]; */
- // vec[2]= 0.0; */
+ /* vec[0] = tvec[0]; */
+ /* vec[1] = tvec[1]; */
+ /* vec[2] = 0.0; */
break;
case 3: /* neg-x */
- /* vec[0]= 0.0; */
+ /* vec[0] = 0.0; */
vec[1] = tvec[2];
vec[2] = -tvec[1];
break;
case 4: /* neg-y */
vec[0] = -tvec[2];
- /* vec[1]= 0.0; */
+ /* vec[1] = 0.0; */
vec[2] = tvec[0];
break;
case 5: /* neg-z */
vec[0] = -tvec[0];
vec[1] = -tvec[1];
- /* vec[2]= 0.0; */
+ /* vec[2] = 0.0; */
break;
}
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 4196bab0474..976895fe6fc 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -451,6 +451,15 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
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 (max[0] < vec[0]) max[0] = vec[0];
+ if (max[1] < vec[1]) max[1] = vec[1];
+}
+
/** ensure \a v1 is \a dist from \a v2 */
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist)
{
@@ -483,7 +492,7 @@ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int s
const float *array_pt_b = array_src_b + (size - 1);
int i = size;
while (i--) {
- d += *(array_pt_a--) * *(array_pt_b--);
+ d += (double)(*(array_pt_a--) * *(array_pt_b--));
}
return d;
}
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index bf562684604..d96beadd63b 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -134,6 +134,13 @@ MINLINE void copy_v4_v4_char(char r[4], const char a[4])
}
/* short */
+MINLINE void zero_v3_int(int r[3])
+{
+ r[0] = 0;
+ r[1] = 0;
+ r[2] = 0;
+}
+
MINLINE void copy_v2_v2_short(short r[2], const short a[2])
{
r[0] = a[0];
@@ -574,6 +581,16 @@ MINLINE float len_squared_v3(const float v[3])
return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
}
+MINLINE float len_manhattan_v2(const float v[2])
+{
+ return fabsf(v[0]) + fabsf(v[1]);
+}
+
+MINLINE float len_manhattan_v3(const float v[3])
+{
+ return fabsf(v[0]) + fabsf(v[1]) + fabsf(v[2]);
+}
+
MINLINE float len_v2(const float v[2])
{
return sqrtf(v[0] * v[0] + v[1] * v[1]);
@@ -601,20 +618,36 @@ MINLINE float len_squared_v2v2(const float a[2], const float b[2])
return dot_v2v2(d, d);
}
-MINLINE float len_v3v3(const float a[3], const float b[3])
+MINLINE float len_squared_v3v3(const float a[3], const float b[3])
{
float d[3];
sub_v3_v3v3(d, b, a);
- return len_v3(d);
+ return dot_v3v3(d, d);
}
-MINLINE float len_squared_v3v3(const float a[3], const float b[3])
+MINLINE float len_manhattan_v2v2(const float a[2], const float b[2])
+{
+ float d[2];
+
+ sub_v2_v2v2(d, b, a);
+ return len_manhattan_v2(d);
+}
+
+MINLINE float len_manhattan_v3v3(const float a[3], const float b[3])
{
float d[3];
sub_v3_v3v3(d, b, a);
- return dot_v3v3(d, d);
+ return len_manhattan_v3(d);
+}
+
+MINLINE float len_v3v3(const float a[3], const float b[3])
+{
+ float d[3];
+
+ sub_v3_v3v3(d, b, a);
+ return len_v3(d);
}
MINLINE float normalize_v2_v2(float r[2], const float a[2])
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 792bf929182..fb33d7ce127 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -31,9 +31,9 @@
*/
-#ifdef _WIN32
-#pragma warning (disable : 4244) // "conversion from double to float"
-#pragma warning (disable : 4305) // "truncation from const double to float"
+#ifdef _MSC_VER
+# pragma warning (disable:4244) /* "conversion from double to float" */
+# pragma warning (disable:4305) /* "truncation from const double to float" */
#endif
#include <math.h>
@@ -301,8 +301,8 @@ static float newPerlin(float x, float y, float z)
u = npfade(x); /* COMPUTE FADE CURVES */
v = npfade(y); /* FOR EACH OF X,Y,Z. */
w = npfade(z);
- A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; /* HASH COORDINATES OF */
- B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; /* THE 8 CUBE CORNERS, */
+ A = hash[X ] + Y; AA = hash[A] + Z; AB = hash[A + 1] + Z; /* HASH COORDINATES OF */
+ B = hash[X + 1] + Y; BA = hash[B] + Z; BB = hash[B + 1] + Z; /* THE 8 CUBE CORNERS, */
return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), /* AND ADD */
grad(hash[BA ], x - 1, y, z )), /* BLENDED */
lerp(u, grad(hash[AB ], x, y - 1, z ), /* RESULTS */
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index de85c11176b..a6289aa4031 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -47,7 +47,7 @@
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
-#include "BKE_blender.h" // BLENDER_VERSION
+#include "BKE_blender.h" /* BLENDER_VERSION */
#include "GHOST_Path-api.h"
@@ -330,7 +330,7 @@ void BLI_cleanup_path(const char *relabase, char *dir)
if (strcmp(dir, ".") == 0) { /* happens for example in FILE_MAIN */
get_default_root(dir);
return;
- }
+ }
while ( (start = strstr(dir, "\\..\\")) ) {
eind = start + strlen("\\..\\") - 1;
@@ -492,7 +492,7 @@ void BLI_path_rel(char *file, const char *relfile)
*/
if (*q != '/') {
while ( (q >= file) && (*q != '/') ) { --q; --p; }
- }
+ }
else if (*p != '/') {
while ( (p >= temp) && (*p != '/') ) { --p; --q; }
}
@@ -544,7 +544,7 @@ int BLI_parent_dir(char *path)
BLI_cleanup_dir(NULL, tmp);
if (!BLI_testextensie(tmp, parent_dir)) {
- BLI_strncpy(path, tmp, sizeof(tmp));
+ BLI_strncpy(path, tmp, sizeof(tmp));
return 1;
}
else {
@@ -691,7 +691,7 @@ int BLI_path_abs(char *path, const char *basepath)
* of paths and solving some problems (and prevent potential future
* ones) -jesterKing. */
BLI_char_switch(tmp, '\\', '/');
- BLI_char_switch(base, '\\', '/');
+ BLI_char_switch(base, '\\', '/');
/* Paths starting with // will get the blend file as their base,
* this isn't standard in any os but is used in blender all over the place */
@@ -1300,7 +1300,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir,
BLI_char_switch(file, '\\', '/');
#endif
- /* Resolve relative references */
+ /* Resolve relative references */
if (relabase && dir[0] == '/' && dir[1] == '/') {
char *lslash;
@@ -1321,7 +1321,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir,
else { /* no drive specified */
/* first option: get the drive from the relabase if it has one */
if (relabase && strlen(relabase) >= 2 && relabase[1] == ':') {
- BLI_strncpy(string, relabase, 3);
+ BLI_strncpy(string, relabase, 3);
string[2] = '\\';
string[3] = '\0';
}
@@ -1337,7 +1337,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir,
strcat(string, dir);
- /* Make sure string ends in one (and only one) slash */
+ /* Make sure string ends in one (and only one) slash */
/* first trim all slashes from the end of the string */
sl = strlen(string);
while (sl > 0 && (string[sl - 1] == '/' || string[sl - 1] == '\\') ) {
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index 49e6ab8b53e..9fd214c0f86 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -157,6 +157,8 @@ struct PBVH {
/* flag are verts/faces deformed */
int deformed;
+
+ int show_diffuse_color;
};
#define STACK_FIXED_DEPTH 100
@@ -189,8 +191,8 @@ static void BB_expand(BB *bb, float co[3])
{
int i;
for (i = 0; i < 3; ++i) {
- bb->bmin[i] = minf(bb->bmin[i], co[i]);
- bb->bmax[i] = maxf(bb->bmax[i], co[i]);
+ bb->bmin[i] = min_ff(bb->bmin[i], co[i]);
+ bb->bmax[i] = max_ff(bb->bmax[i], co[i]);
}
}
@@ -199,8 +201,8 @@ static void BB_expand_with_bb(BB *bb, BB *bb2)
{
int i;
for (i = 0; i < 3; ++i) {
- bb->bmin[i] = minf(bb->bmin[i], bb2->bmin[i]);
- bb->bmax[i] = maxf(bb->bmax[i], bb2->bmax[i]);
+ bb->bmin[i] = min_ff(bb->bmin[i], bb2->bmin[i]);
+ bb->bmax[i] = max_ff(bb->bmax[i], bb2->bmax[i]);
}
}
@@ -663,7 +665,7 @@ void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj,
bvh->totgrid = totgrid;
bvh->gridkey = *key;
bvh->grid_hidden = grid_hidden;
- bvh->leaf_limit = maxi(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1);
+ bvh->leaf_limit = max_ii(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1);
BB_reset(&cb);
@@ -1001,7 +1003,7 @@ static int update_search_cb(PBVHNode *node, void *data_v)
if (node->flag & PBVH_Leaf)
return (node->flag & flag);
-
+
return 1;
}
@@ -1165,7 +1167,8 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
bvh->grid_flag_mats,
node->prim_indices,
node->totprim,
- &bvh->gridkey);
+ &bvh->gridkey,
+ bvh->show_diffuse_color);
break;
case PBVH_FACES:
GPU_update_mesh_buffers(node->draw_buffers,
@@ -1174,7 +1177,9 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
node->uniq_verts +
node->face_verts,
CustomData_get_layer(bvh->vdata,
- CD_PAINT_MASK));
+ CD_PAINT_MASK),
+ node->face_vert_indices,
+ bvh->show_diffuse_color);
break;
}
@@ -1632,9 +1637,9 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3],
PlaneAABBIsect ret = ISECT_INSIDE;
int i, axis;
- for (i = 0; i < 4; ++i) {
+ for (i = 0; i < 4; ++i) {
for (axis = 0; axis < 3; ++axis) {
- if (planes[i][axis] > 0) {
+ if (planes[i][axis] > 0) {
vmin[axis] = bb_min[axis];
vmax[axis] = bb_max[axis];
}
@@ -1648,7 +1653,7 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3],
return ISECT_OUTSIDE;
else if (dot_v3v3(planes[i], vmax) + planes[i][3] >= 0)
ret = ISECT_INTERSECT;
- }
+ }
return ret;
}
@@ -1669,11 +1674,23 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data)
return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE;
}
+static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node)
+{
+ if (!node->draw_buffers)
+ return;
+
+ if (GPU_buffers_diffuse_changed(node->draw_buffers, bvh->show_diffuse_color))
+ node->flag |= PBVH_UpdateDrawBuffers;
+}
+
void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
DMSetMaterial setMaterial)
{
PBVHNode **nodes;
- int totnode;
+ int a, totnode;
+
+ for (a = 0; a < bvh->totnode; a++)
+ pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]);
BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers),
&nodes, &totnode);
@@ -1692,11 +1709,19 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
}
}
-void BLI_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces)
+void BLI_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces,
+ DMFlagMat *flagmats, BLI_bitmap *grid_hidden)
{
+ int a;
+
bvh->grids = grids;
bvh->gridadj = gridadj;
bvh->gridfaces = gridfaces;
+ bvh->grid_flag_mats = flagmats;
+ bvh->grid_hidden = grid_hidden;
+
+ for (a = 0; a < bvh->totnode; ++a)
+ BLI_pbvh_node_mark_rebuild_draw(&bvh->nodes[a]);
}
float (*BLI_pbvh_get_vertCos(PBVH * pbvh))[3]
@@ -1878,3 +1903,8 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
if (!vi->grids)
vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK);
}
+
+void pbvh_show_diffuse_color_set(PBVH *bvh, int show_diffuse_color)
+{
+ bvh->show_diffuse_color = show_diffuse_color;
+}
diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c
new file mode 100644
index 00000000000..b06534d282a
--- /dev/null
+++ b/source/blender/blenlib/intern/quadric.c
@@ -0,0 +1,126 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Laurence Bourn, Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenlib/intern/quadric.c
+ * \ingroup bli
+ *
+ * \note This isn't fully complete,
+ * possible there are other useful functions to add here.
+ *
+ * \note try to follow BLI_math naming convention here.
+ */
+
+//#include <string.h>
+
+#include "BLI_math.h"
+#include "BLI_quadric.h" /* own include */
+
+
+#define QUADRIC_FLT_TOT (sizeof(Quadric) / sizeof(float))
+
+void BLI_quadric_from_v3_dist(Quadric *q, const float v[3], const float offset)
+{
+ q->a2 = v[0] * v[0];
+ q->b2 = v[1] * v[1];
+ q->c2 = v[2] * v[2];
+
+ q->ab = v[0] * v[1];
+ q->ac = v[0] * v[2];
+ q->bc = v[1] * v[2];
+
+ q->ad = v[0] * offset;
+ q->bd = v[1] * offset;
+ q->cd = v[2] * offset;
+
+ q->d2 = offset * offset;
+}
+
+void BLI_quadric_to_tensor_m3(const Quadric *q, float m[3][3])
+{
+ m[0][0] = q->a2;
+ m[0][1] = q->ab;
+ m[0][2] = q->ac;
+
+ m[1][0] = q->ab;
+ m[1][1] = q->b2;
+ m[1][2] = q->bc;
+
+ m[2][0] = q->ac;
+ m[2][1] = q->bc;
+ m[2][2] = q->c2;
+}
+
+void BLI_quadric_to_vector_v3(const Quadric *q, float v[3])
+{
+ v[0] = q->ad;
+ v[1] = q->bd;
+ v[2] = q->cd;
+}
+
+void BLI_quadric_clear(Quadric *q)
+{
+ memset(q, 0, sizeof(*q));
+}
+
+void BLI_quadric_add_qu_qu(Quadric *a, const Quadric *b)
+{
+ add_vn_vn((float *)a, (float *)b, QUADRIC_FLT_TOT);
+}
+
+void BLI_quadric_add_qu_ququ(Quadric *r, const Quadric *a, const Quadric *b)
+{
+ add_vn_vnvn((float *)r, (const float *)a, (const float *)b, QUADRIC_FLT_TOT);
+}
+
+void BLI_quadric_mul(Quadric *a, const float scalar)
+{
+ mul_vn_fl((float *)a, QUADRIC_FLT_TOT, scalar);
+}
+
+float BLI_quadric_evaluate(const Quadric *q, const float v[3])
+{
+ return (v[0] * v[0] * q->a2 + 2.0f * v[0] * v[1] * q->ab + 2.0f * v[0] * v[2] * q->ac + 2.0f * v[0] * q->ad +
+ v[1] * v[1] * q->b2 + 2.0f * v[1] * v[2] * q->bc + 2.0f * v[1] * q->bd +
+ v[2] * v[2] * q->c2 + 2.0f * v[2] * q->cd +
+ q->d2);
+}
+
+int BLI_quadric_optimize(const Quadric *q, float v[3], const float epsilon)
+{
+ float m[3][3];
+
+ BLI_quadric_to_tensor_m3(q, m);
+
+ if (invert_m3_ex(m, epsilon)) {
+ BLI_quadric_to_vector_v3(q, v);
+ mul_m3_v3(m, v);
+ negate_v3(v);
+
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 4435e9ce09c..76d17f34b5e 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -40,7 +40,7 @@
#include "BLI_threads.h"
#include "BLI_rand.h"
-#if defined(WIN32) && !defined(FREE_WINDOWS)
+#ifdef _MSC_VER
typedef unsigned __int64 r_uint64;
#define MULTIPLIER 0x5DEECE66Di64
@@ -64,51 +64,51 @@ struct RNG {
r_uint64 X;
};
-RNG *rng_new(unsigned int seed)
+RNG *BLI_rng_new(unsigned int seed)
{
RNG *rng = MEM_mallocN(sizeof(*rng), "rng");
- rng_seed(rng, seed);
+ BLI_rng_seed(rng, seed);
return rng;
}
-void rng_free(RNG *rng)
+void BLI_rng_free(RNG *rng)
{
MEM_freeN(rng);
}
-void rng_seed(RNG *rng, unsigned int seed)
+void BLI_rng_seed(RNG *rng, unsigned int seed)
{
rng->X = (((r_uint64) seed) << 16) | LOWSEED;
}
-void rng_srandom(RNG *rng, unsigned int seed)
+void BLI_rng_srandom(RNG *rng, unsigned int seed)
{
- rng_seed(rng, seed + hash[seed & 255]);
- seed = rng_getInt(rng);
- rng_seed(rng, seed + hash[seed & 255]);
- seed = rng_getInt(rng);
- rng_seed(rng, seed + hash[seed & 255]);
+ BLI_rng_seed(rng, seed + hash[seed & 255]);
+ seed = BLI_rng_get_int(rng);
+ BLI_rng_seed(rng, seed + hash[seed & 255]);
+ seed = BLI_rng_get_int(rng);
+ BLI_rng_seed(rng, seed + hash[seed & 255]);
}
-int rng_getInt(RNG *rng)
+int BLI_rng_get_int(RNG *rng)
{
rng->X = (MULTIPLIER * rng->X + ADDEND) & MASK;
return (int) (rng->X >> 17);
}
-double rng_getDouble(RNG *rng)
+double BLI_rng_get_double(RNG *rng)
{
- return (double) rng_getInt(rng) / 0x80000000;
+ return (double) BLI_rng_get_int(rng) / 0x80000000;
}
-float rng_getFloat(RNG *rng)
+float BLI_rng_get_float(RNG *rng)
{
- return (float) rng_getInt(rng) / 0x80000000;
+ return (float) BLI_rng_get_int(rng) / 0x80000000;
}
-void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems)
+void BLI_rng_shuffle_array(RNG *rng, void *data, int elemSize, int numElems)
{
int i = numElems;
void *temp;
@@ -122,7 +122,7 @@ void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems)
/* XXX Shouldn't it rather be "while (i--) {" ?
* Else we have no guaranty first (0) element has a chance to be shuffled... --mont29 */
while (--i) {
- int j = rng_getInt(rng) % numElems;
+ int j = BLI_rng_get_int(rng) % numElems;
if (i != j) {
void *iElem = (unsigned char *)data + i * elemSize;
void *jElem = (unsigned char *)data + j * elemSize;
@@ -135,12 +135,12 @@ void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems)
free(temp);
}
-void rng_skip(RNG *rng, int n)
+void BLI_rng_skip(RNG *rng, int n)
{
int i;
for (i = 0; i < n; i++)
- rng_getInt(rng);
+ BLI_rng_get_int(rng);
}
/***/
@@ -150,28 +150,28 @@ static RNG theBLI_rng = {0};
/* note, this one creates periodical patterns */
void BLI_srand(unsigned int seed)
{
- rng_seed(&theBLI_rng, seed);
+ BLI_rng_seed(&theBLI_rng, seed);
}
/* using hash table to create better seed */
void BLI_srandom(unsigned int seed)
{
- rng_srandom(&theBLI_rng, seed);
+ BLI_rng_srandom(&theBLI_rng, seed);
}
int BLI_rand(void)
{
- return rng_getInt(&theBLI_rng);
+ return BLI_rng_get_int(&theBLI_rng);
}
double BLI_drand(void)
{
- return rng_getDouble(&theBLI_rng);
+ return BLI_rng_get_double(&theBLI_rng);
}
float BLI_frand(void)
{
- return rng_getFloat(&theBLI_rng);
+ return BLI_rng_get_float(&theBLI_rng);
}
void BLI_fillrand(void *addr, int len)
@@ -179,16 +179,16 @@ void BLI_fillrand(void *addr, int len)
RNG rng;
unsigned char *p = addr;
- rng_seed(&rng, (unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF));
- while (len--) *p++ = rng_getInt(&rng) & 0xFF;
+ BLI_rng_seed(&rng, (unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF));
+ while (len--) *p++ = BLI_rng_get_int(&rng) & 0xFF;
}
void BLI_array_randomize(void *data, int elemSize, int numElems, unsigned int seed)
{
RNG rng;
- rng_seed(&rng, seed);
- rng_shuffleArray(&rng, data, elemSize, numElems);
+ BLI_rng_seed(&rng, seed);
+ BLI_rng_shuffle_array(&rng, data, elemSize, numElems);
}
/* ********* for threaded random ************** */
@@ -200,20 +200,20 @@ void BLI_thread_srandom(int thread, unsigned int seed)
if (thread >= BLENDER_MAX_THREADS)
thread = 0;
- rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
- seed = rng_getInt(&rng_tab[thread]);
- rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
- seed = rng_getInt(&rng_tab[thread]);
- rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
+ BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
+ seed = BLI_rng_get_int(&rng_tab[thread]);
+ BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
+ seed = BLI_rng_get_int(&rng_tab[thread]);
+ BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
}
int BLI_thread_rand(int thread)
{
- return rng_getInt(&rng_tab[thread]);
+ return BLI_rng_get_int(&rng_tab[thread]);
}
float BLI_thread_frand(int thread)
{
- return rng_getFloat(&rng_tab[thread]);
+ return BLI_rng_get_float(&rng_tab[thread]);
}
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index cab383b60f3..ee073d5d309 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -102,16 +102,28 @@ int BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
}
/* based closely on 'isect_line_line_v2_int', but in modified so corner cases are treated as intersections */
-static int isect_segments(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
+static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
{
const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
- if (div == 0.0f) {
+ if (div == 0.0) {
return 1; /* co-linear */
}
else {
const double labda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
- return (labda >= 0.0f && labda <= 1.0f && mu >= 0.0f && mu <= 1.0f);
+ return (labda >= 0.0 && labda <= 1.0 && mu >= 0.0 && mu <= 1.0);
+ }
+}
+static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
+{
+ const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
+ if (div == 0.0) {
+ return 1; /* co-linear */
+ }
+ else {
+ const double labda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
+ const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
+ return (labda >= 0.0 && labda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}
}
@@ -134,14 +146,49 @@ int BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
/* diagonal: [/] */
tvec1[0] = rect->xmin; tvec1[1] = rect->ymin;
tvec2[0] = rect->xmin; tvec2[1] = rect->ymax;
- if (isect_segments(s1, s2, tvec1, tvec2)) {
+ if (isect_segments_i(s1, s2, tvec1, tvec2)) {
+ return 1;
+ }
+
+ /* diagonal: [\] */
+ tvec1[0] = rect->xmin; tvec1[1] = rect->ymax;
+ tvec2[0] = rect->xmax; tvec2[1] = rect->ymin;
+ if (isect_segments_i(s1, s2, tvec1, tvec2)) {
+ return 1;
+ }
+
+ /* no intersection */
+ return 0;
+ }
+}
+
+int 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 0;
+ if (s1[0] > rect->xmax && s2[0] > rect->xmax) return 0;
+ if (s1[1] < rect->ymin && s2[1] < rect->ymin) return 0;
+ if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0;
+
+ /* if either points intersect then we definetly intersect */
+ if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
+ return 1;
+ }
+ else {
+ /* both points are outside but may insersect the rect */
+ float tvec1[2];
+ float tvec2[2];
+ /* diagonal: [/] */
+ tvec1[0] = rect->xmin; tvec1[1] = rect->ymin;
+ tvec2[0] = rect->xmin; tvec2[1] = rect->ymax;
+ if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
return 1;
}
/* diagonal: [\] */
tvec1[0] = rect->xmin; tvec1[1] = rect->ymax;
tvec2[0] = rect->xmax; tvec2[1] = rect->ymin;
- if (isect_segments(s1, s2, tvec1, tvec2)) {
+ if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
return 1;
}
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 7ae27b83e67..362a87782c6 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -661,8 +661,8 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
/* this happens with a serial of overlapping edges */
if (v1 == v2 || v2 == v3) break;
/* printf("test verts %x %x %x\n",v1,v2,v3); */
- miny = minf(v1->xy[1], v3->xy[1]);
- /* miny= minf(v1->xy[1],v3->xy[1]); */
+ miny = min_ff(v1->xy[1], v3->xy[1]);
+ /* miny = min_ff(v1->xy[1],v3->xy[1]); */
sc1 = sc + 1;
test = 0;
@@ -985,12 +985,12 @@ int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedu
/* CURRENT STATUS:
- * - eve->f :1= availalble in edges
+ * - eve->f :1 = availalble in edges
* - eve->xs :polynumber
* - eve->h :amount of edges connected to vertex
* - eve->tmp.v :store! original vertex number
*
- * - eed->f :1= boundary edge (optionally set by caller)
+ * - eed->f :1 = boundary edge (optionally set by caller)
* - eed->poly_nr :poly number
*/
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 92125c6e988..64bb503fa3c 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -43,8 +43,22 @@
#define SMHASH_CELL_UNUSED ((void *)0x7FFFFFFF)
#define SMHASH_CELL_FREE ((void *)0x7FFFFFFD)
-#define SMHASH_NONZERO(n) ((n) + !(n))
-#define SMHASH_NEXT(h, hoff) ABS(((h) + ((hoff = SMHASH_NONZERO(hoff * 2) + 1), hoff)))
+BLI_INLINE int smhash_nonzero(const int n)
+{
+ return n + !n;
+}
+
+BLI_INLINE int smhash_abs_i(const int n)
+{
+ return (n > 0) ? n : -n;
+}
+
+/* typically this re-assigns 'h' */
+#define SMHASH_NEXT(h, hoff) ( \
+ CHECK_TYPE_INLINE(&(h), int), \
+ CHECK_TYPE_INLINE(&(hoff), int), \
+ smhash_abs_i((h) + (((hoff) = smhash_nonzero((hoff) * 2) + 1), (hoff))) \
+ )
extern unsigned int hashsizes[];
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index fd79b1c09a0..fccac67e9df 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -187,7 +187,7 @@ double BLI_dir_free_space(const char *dir)
#endif
#if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
- if (statvfs(name, &disk)) return(-1);
+ if (statvfs(name, &disk)) return(-1);
#elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__))
/* WARNING - This may not be supported by geeneric unix os's - Campbell */
if (statfs(name, &disk, sizeof(struct statfs), 0)) return(-1);
@@ -418,9 +418,9 @@ static void bli_adddirstrings(void)
unsigned int BLI_dir_contents(const char *dirname, struct direntry **filelist)
{
- // reset global variables
- // memory stored in files is free()'d in
- // filesel.c:freefilelist()
+ /* reset global variables
+ * memory stored in files is free()'d in
+ * filesel.c:freefilelist() */
actnum = totnum = 0;
files = NULL;
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 8501db7c8b8..ff589764287 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -41,6 +41,8 @@
#include "BLI_dynstr.h"
#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
char *BLI_strdupn(const char *str, const size_t len)
{
char *n = MEM_mallocN(len + 1, "strdup");
@@ -71,6 +73,7 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
{
size_t srclen = strlen(src);
size_t cpylen = (srclen > (maxncpy - 1)) ? (maxncpy - 1) : srclen;
+ BLI_assert(maxncpy != 0);
memcpy(dst, src, cpylen);
dst[cpylen] = '\0';
@@ -130,10 +133,13 @@ char *BLI_sprintfN(const char *format, ...)
* TODO: support more fancy string escaping. current code is primitive
* this basically is an ascii version of PyUnicode_EncodeUnicodeEscape()
* which is a useful reference. */
-size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
+size_t BLI_strescape(char *dst, const char *src, const size_t maxncpy)
{
size_t len = 0;
- while (len < maxlen) {
+
+ BLI_assert(maxncpy != 0);
+
+ while (len < maxncpy) {
switch (*src) {
case '\0':
goto escape_finish;
@@ -144,7 +150,7 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
case '\t':
case '\n':
case '\r':
- if (len + 1 < maxlen) {
+ if (len + 1 < maxncpy) {
*dst++ = '\\';
len++;
}
@@ -296,11 +302,12 @@ char *BLI_strcasestr(const char *s, const char *find)
int BLI_strcasecmp(const char *s1, const char *s2)
{
- int i;
+ register int i;
+ register char c1, c2;
for (i = 0;; i++) {
- char c1 = tolower(s1[i]);
- char c2 = tolower(s2[i]);
+ c1 = tolower(s1[i]);
+ c2 = tolower(s2[i]);
if (c1 < c2) {
return -1;
@@ -318,11 +325,12 @@ int BLI_strcasecmp(const char *s1, const char *s2)
int BLI_strncasecmp(const char *s1, const char *s2, size_t len)
{
- int i;
+ register size_t i;
+ register char c1, c2;
for (i = 0; i < len; i++) {
- char c1 = tolower(s1[i]);
- char c2 = tolower(s2[i]);
+ c1 = tolower(s1[i]);
+ c2 = tolower(s2[i]);
if (c1 < c2) {
return -1;
@@ -341,15 +349,16 @@ int BLI_strncasecmp(const char *s1, const char *s2, size_t len)
/* natural string compare, keeping numbers in order */
int BLI_natstrcmp(const char *s1, const char *s2)
{
- int d1 = 0, d2 = 0;
+ register int d1 = 0, d2 = 0;
+ register char c1, c2;
/* if both chars are numeric, to a strtol().
* then increase string deltas as long they are
* numeric, else do a tolower and char compare */
while (1) {
- char c1 = tolower(s1[d1]);
- char c2 = tolower(s2[d2]);
+ c1 = tolower(s1[d1]);
+ c2 = tolower(s2[d2]);
if (isdigit(c1) && isdigit(c2) ) {
int val1, val2;
@@ -374,7 +383,7 @@ int BLI_natstrcmp(const char *s1, const char *s2)
c2 = tolower(s2[d2]);
}
- /* first check for '.' so "foo.bar" comes before "foo 1.bar" */
+ /* first check for '.' so "foo.bar" comes before "foo 1.bar" */
if (c1 == '.' && c2 != '.')
return -1;
if (c1 != '.' && c2 == '.')
@@ -413,27 +422,26 @@ void BLI_timestr(double _time, char *str)
}
/* determine the length of a fixed-size string */
-size_t BLI_strnlen(const char *str, size_t maxlen)
+size_t BLI_strnlen(const char *str, const size_t maxlen)
{
const char *end = memchr(str, '\0', maxlen);
return end ? (size_t) (end - str) : maxlen;
}
-void BLI_ascii_strtolower(char *str, int len)
+void BLI_ascii_strtolower(char *str, const size_t len)
{
- int i;
+ size_t i;
for (i = 0; i < len; i++)
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 'a' - 'A';
}
-void BLI_ascii_strtoupper(char *str, int len)
+void BLI_ascii_strtoupper(char *str, const size_t len)
{
- int i;
+ size_t i;
for (i = 0; i < len; i++)
if (str[i] >= 'a' && str[i] <= 'z')
str[i] -= 'a' - 'A';
}
-
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index 17b9ed7ea8d..e80f96ee0fe 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -33,8 +33,12 @@
#include <string.h>
#include <wchar.h>
#include <wctype.h>
+#include <stdio.h>
+#include <stdlib.h>
-#include "BLI_string_utf8.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_string_utf8.h" /* own include */
/* from libswish3, originally called u8_isvalid(),
* modified to return the index of the bad character (byte index not utf).
@@ -124,15 +128,15 @@ utf8_error:
int BLI_utf8_invalid_strip(char *str, int length)
{
- int bad_char, tot= 0;
+ int bad_char, tot = 0;
- while ((bad_char= BLI_utf8_invalid_byte(str, length)) != -1) {
+ while ((bad_char = BLI_utf8_invalid_byte(str, length)) != -1) {
str += bad_char;
length -= bad_char;
if (length == 0) {
/* last character bad, strip it */
- *str= '\0';
+ *str = '\0';
tot++;
break;
}
@@ -153,22 +157,22 @@ int BLI_utf8_invalid_strip(char *str, int length)
* note: this looks to be at odd's with 'trailingBytesForUTF8',
* need to find out what gives here! - campbell */
static const size_t utf8_skip_data[256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1
};
#define BLI_STR_UTF8_CPY(dst, src, maxncpy) \
{ \
size_t utf8_size; \
- while (*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) { \
+ while (*src != '\0' && (utf8_size = utf8_skip_data[*src]) < maxncpy) {\
maxncpy -= utf8_size; \
- switch (utf8_size) { \
+ switch (utf8_size) { \
case 6: *dst ++ = *src ++; \
case 5: *dst ++ = *src ++; \
case 4: *dst ++ = *src ++; \
@@ -177,12 +181,14 @@ static const size_t utf8_skip_data[256] = {
case 1: *dst ++ = *src ++; \
} \
} \
- *dst= '\0'; \
+ *dst = '\0'; \
} (void)0
char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy)
{
- char *dst_r= dst;
+ char *dst_r = dst;
+
+ BLI_assert(maxncpy != 0);
/* note: currently we don't attempt to deal with invalid utf8 chars */
BLI_STR_UTF8_CPY(dst, src, maxncpy);
@@ -207,14 +213,17 @@ char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy)
/* --------------------------------------------------------------------------*/
/* wchar_t / utf8 functions */
-size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy)
+size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxncpy)
{
size_t len = 0;
- while (*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
+
+ BLI_assert(maxncpy != 0);
+
+ while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
len += BLI_str_utf8_from_unicode(*src++, dst + len);
}
- dst[len]= '\0';
+ dst[len] = '\0';
return len;
}
@@ -231,33 +240,56 @@ size_t BLI_wstrlen_utf8(const wchar_t *src)
return len;
}
-// utf8slen
+/* this is very close to 'BLI_str_utf8_size' functionality, perhaps we should de-duplicate */
+/* size of UTF-8 character in bytes */
+static size_t strlen_utf8_char(const char *strc)
+{
+ if ((*strc & 0xe0) == 0xc0) {
+ if ((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
+ return 2;
+ }
+ else if ((*strc & 0xf0) == 0xe0) {
+ if ((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
+ return 3;
+ }
+ else if ((*strc & 0xf8) == 0xf0) {
+ if ((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
+ return 4;
+ }
+
+ return 1;
+}
+
size_t BLI_strlen_utf8(const char *strc)
{
- int len = 0;
+ int len;
- while (*strc) {
- if ((*strc & 0xe0) == 0xc0) {
- if ((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
- strc++;
- }
- else if ((*strc & 0xf0) == 0xe0) {
- if ((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
- strc += 2;
- }
- else if ((*strc & 0xf8) == 0xf0) {
- if ((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
- strc += 3;
- }
+ for (len = 0; *strc; len++)
+ strc += strlen_utf8_char(strc);
- strc++;
- len++;
+ return len;
+}
+
+/**
+ * \param start the string to measure the length.
+ * \param maxlen the string length (in bytes)
+ * \return the unicode length (not in bytes!)
+ */
+size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
+{
+ const char *strc = start;
+ const char *strc_end = start + maxlen;
+
+ size_t len;
+
+ for (len = 0; *strc && strc < strc_end; len++) {
+ strc += strlen_utf8_char(strc);
}
return len;
}
-size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxcpy)
+size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxncpy)
{
int len = 0;
@@ -265,16 +297,16 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size
return 0;
}
- while (*src_c && len < maxcpy) {
- size_t step= 0;
- unsigned int unicode= BLI_str_utf8_as_unicode_and_size(src_c, &step);
+ while (*src_c && len < maxncpy) {
+ size_t step = 0;
+ unsigned int unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step);
if (unicode != BLI_UTF8_ERR) {
- *dst_w= (wchar_t)unicode;
+ *dst_w = (wchar_t)unicode;
src_c += step;
}
else {
*dst_w = '?';
- src_c= BLI_str_find_next_char_utf8(src_c, NULL);
+ src_c = BLI_str_find_next_char_utf8(src_c, NULL);
}
dst_w++;
len++;
@@ -285,12 +317,12 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size
/* end wchar_t / utf8 functions */
/* --------------------------------------------------------------------------*/
-/* copied from glib's gutf8.c */
+/* copied from glib's gutf8.c, added 'Err' arg */
/* note, glib uses unsigned int for unicode, best we do the same,
* though we don't typedef it - campbell */
-#define UTF8_COMPUTE(Char, Mask, Len) \
+#define UTF8_COMPUTE(Char, Mask, Len, Err) \
if (Char < 128) { \
Len = 1; \
Mask = 0x7f; \
@@ -316,7 +348,7 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size
Mask = 0x01; \
} \
else { \
- Len = -1; \
+ Len = Err; /* -1 is the typical error value or 1 to skip */ \
} (void)0
/* same as glib define but added an 'Err' arg */
@@ -339,7 +371,20 @@ int BLI_str_utf8_size(const char *p)
int mask = 0, len;
unsigned char c = (unsigned char) *p;
- UTF8_COMPUTE (c, mask, len);
+ UTF8_COMPUTE (c, mask, len, -1);
+
+ (void)mask; /* quiet warning */
+
+ return len;
+}
+
+/* use when we want to skip errors */
+int BLI_str_utf8_size_safe(const char *p)
+{
+ int mask = 0, len;
+ unsigned char c = (unsigned char) *p;
+
+ UTF8_COMPUTE (c, mask, len, 1);
(void)mask; /* quiet warning */
@@ -365,7 +410,7 @@ unsigned int BLI_str_utf8_as_unicode(const char *p)
unsigned int result;
unsigned char c = (unsigned char) *p;
- UTF8_COMPUTE (c, mask, len);
+ UTF8_COMPUTE (c, mask, len, -1);
if (len == -1)
return BLI_UTF8_ERR;
UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
@@ -380,7 +425,7 @@ unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index)
unsigned int result;
unsigned char c = (unsigned char) *p;
- UTF8_COMPUTE (c, mask, len);
+ UTF8_COMPUTE (c, mask, len, -1);
if (len == -1)
return BLI_UTF8_ERR;
UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
@@ -397,13 +442,13 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index)
unsigned char c;
p += *index;
- c= (unsigned char) *p;
+ c = (unsigned char) *p;
- UTF8_COMPUTE (c, mask, len);
+ UTF8_COMPUTE (c, mask, len, -1);
if (len == -1) {
/* when called with NULL end, result will never be NULL,
* checks for a NULL character */
- char *p_next= BLI_str_find_next_char_utf8(p, NULL);
+ char *p_next = BLI_str_find_next_char_utf8(p, NULL);
/* will never return the same pointer unless '\0',
* eternal loop is prevented */
*index += (size_t)(p_next - p);
@@ -420,8 +465,8 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index)
* characters */
UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
if (result == BLI_UTF8_ERR) {
- len= 1;
- result= *p;
+ len = 1;
+ result = *p;
}
/* end warning! */
#else
diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c
index bf9720fee09..078fc2c295b 100644
--- a/source/blender/blenlib/intern/time.c
+++ b/source/blender/blenlib/intern/time.c
@@ -44,7 +44,7 @@ double PIL_check_seconds_timer(void)
__int64 ifreq;
hasperfcounter = QueryPerformanceFrequency((LARGE_INTEGER *) &ifreq);
perffreq = (double) ifreq;
- }
+ }
if (hasperfcounter) {
__int64 count;
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c
index 3030e54eb78..601b07c9a5d 100644
--- a/source/blender/blenlib/intern/voronoi.c
+++ b/source/blender/blenlib/intern/voronoi.c
@@ -39,7 +39,7 @@
#include "BLI_voronoi.h"
#include "BLI_utildefines.h"
-#define VORONOI_EPS 1e-2
+#define VORONOI_EPS 1e-2f
enum {
voronoiEventType_Site = 0,
@@ -259,9 +259,9 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f
x2 = (-b - sqrtf(disc)) / (2 * a);
if (p[1] < r[1])
- ry = maxf(x1, x2);
+ ry = max_ff(x1, x2);
else
- ry = minf(x1, x2);
+ ry = min_ff(x1, x2);
return ry;
}
@@ -490,9 +490,9 @@ static void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabol
}
if (parabola->edge->direction[0] > 0.0f)
- mx = MAX2(process->width, parabola->edge->start[0] + 10);
+ mx = max_ff(process->width, parabola->edge->start[0] + 10);
else
- mx = MIN2(0.0, parabola->edge->start[0] - 10);
+ 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;
@@ -609,9 +609,9 @@ static int voronoi_getNextSideCoord(ListBase *edges, float coord[2], int dim, in
static void voronoi_createBoundaryEdges(ListBase *edges, int width, int height)
{
const float corners[4][2] = {{width - 1, 0.0f},
- {width - 1, height - 1},
- {0.0f, height - 1},
- {0.0f, 0.0f}};
+ {width - 1, height - 1},
+ {0.0f, height - 1},
+ {0.0f, 0.0f}};
int i, dim = 0, dir = 1;
float coord[2] = {0.0f, 0.0f};
diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c
index bc775cb8f0c..5d58f9e9231 100644
--- a/source/blender/blenlib/intern/voxel.c
+++ b/source/blender/blenlib/intern/voxel.c
@@ -117,19 +117,19 @@ float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float c
const int zc[3] = {res[0] * res[1] * _clamp(z - 1, 0, res[2] - 1), res[0] * res[1] * _clamp(z, 0, res[2] - 1), res[0] * res[1] * _clamp(z + 1, 0, res[2] - 1)};
const float dx = xf - (float)x, dy = yf - (float)y, dz = zf - (float)z;
- const float u[3] = {dx*(0.5f*dx - 1.f) + 0.5f, dx*(1.f - dx) + 0.5f, 0.5f*dx*dx};
- const float v[3] = {dy*(0.5f*dy - 1.f) + 0.5f, dy*(1.f - dy) + 0.5f, 0.5f*dy*dy};
- const float w[3] = {dz*(0.5f*dz - 1.f) + 0.5f, dz*(1.f - dz) + 0.5f, 0.5f*dz*dz};
+ const float u[3] = {dx * (0.5f * dx - 1.f) + 0.5f, dx * (1.0f - dx) + 0.5f, 0.5f * dx * dx};
+ const float v[3] = {dy * (0.5f * dy - 1.f) + 0.5f, dy * (1.0f - dy) + 0.5f, 0.5f * dy * dy};
+ const float w[3] = {dz * (0.5f * dz - 1.f) + 0.5f, dz * (1.0f - dz) + 0.5f, 0.5f * dz * dz};
return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] + u[2] * data[xc[2] + yc[0] + zc[0]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] ) )
- + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] ) )
- + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] ) );
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] ) )
+ + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] )
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] ) )
+ + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] )
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] ) );
}
return 0.f;
@@ -179,21 +179,21 @@ float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3]
}
return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] + u[2] * data[xc[2] + yc[0] + zc[0]] + u[3] * data[xc[3] + yc[0] + zc[0]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] + u[3] * data[xc[3] + yc[1] + zc[0]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] + u[3] * data[xc[3] + yc[2] + zc[0]] )
- + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[0]] + u[1] * data[xc[1] + yc[3] + zc[0]] + u[2] * data[xc[2] + yc[3] + zc[0]] + u[3] * data[xc[3] + yc[3] + zc[0]] ) )
- + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] + u[3] * data[xc[3] + yc[0] + zc[1]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] + u[3] * data[xc[3] + yc[1] + zc[1]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] + u[3] * data[xc[3] + yc[2] + zc[1]] )
- + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[1]] + u[1] * data[xc[1] + yc[3] + zc[1]] + u[2] * data[xc[2] + yc[3] + zc[1]] + u[3] * data[xc[3] + yc[3] + zc[1]] ) )
- + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] + u[3] * data[xc[3] + yc[0] + zc[2]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] + u[3] * data[xc[3] + yc[1] + zc[2]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] + u[3] * data[xc[3] + yc[2] + zc[2]] )
- + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[2]] + u[1] * data[xc[1] + yc[3] + zc[2]] + u[2] * data[xc[2] + yc[3] + zc[2]] + u[3] * data[xc[3] + yc[3] + zc[2]] ) )
- + w[3] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[3]] + u[1] * data[xc[1] + yc[0] + zc[3]] + u[2] * data[xc[2] + yc[0] + zc[3]] + u[3] * data[xc[3] + yc[0] + zc[3]] )
- + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[3]] + u[1] * data[xc[1] + yc[1] + zc[3]] + u[2] * data[xc[2] + yc[1] + zc[3]] + u[3] * data[xc[3] + yc[1] + zc[3]] )
- + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[3]] + u[1] * data[xc[1] + yc[2] + zc[3]] + u[2] * data[xc[2] + yc[2] + zc[3]] + u[3] * data[xc[3] + yc[2] + zc[3]] )
- + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[3]] + u[1] * data[xc[1] + yc[3] + zc[3]] + u[2] * data[xc[2] + yc[3] + zc[3]] + u[3] * data[xc[3] + yc[3] + zc[3]] ) );
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] + u[3] * data[xc[3] + yc[1] + zc[0]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] + u[3] * data[xc[3] + yc[2] + zc[0]] )
+ + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[0]] + u[1] * data[xc[1] + yc[3] + zc[0]] + u[2] * data[xc[2] + yc[3] + zc[0]] + u[3] * data[xc[3] + yc[3] + zc[0]] ) )
+ + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] + u[3] * data[xc[3] + yc[0] + zc[1]] )
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] + u[3] * data[xc[3] + yc[1] + zc[1]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] + u[3] * data[xc[3] + yc[2] + zc[1]] )
+ + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[1]] + u[1] * data[xc[1] + yc[3] + zc[1]] + u[2] * data[xc[2] + yc[3] + zc[1]] + u[3] * data[xc[3] + yc[3] + zc[1]] ) )
+ + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] + u[3] * data[xc[3] + yc[0] + zc[2]] )
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] + u[3] * data[xc[3] + yc[1] + zc[2]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] + u[3] * data[xc[3] + yc[2] + zc[2]] )
+ + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[2]] + u[1] * data[xc[1] + yc[3] + zc[2]] + u[2] * data[xc[2] + yc[3] + zc[2]] + u[3] * data[xc[3] + yc[3] + zc[2]] ) )
+ + w[3] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[3]] + u[1] * data[xc[1] + yc[0] + zc[3]] + u[2] * data[xc[2] + yc[0] + zc[3]] + u[3] * data[xc[3] + yc[0] + zc[3]] )
+ + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[3]] + u[1] * data[xc[1] + yc[1] + zc[3]] + u[2] * data[xc[2] + yc[1] + zc[3]] + u[3] * data[xc[3] + yc[1] + zc[3]] )
+ + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[3]] + u[1] * data[xc[1] + yc[2] + zc[3]] + u[2] * data[xc[2] + yc[2] + zc[3]] + u[3] * data[xc[3] + yc[2] + zc[3]] )
+ + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[3]] + u[1] * data[xc[1] + yc[3] + zc[3]] + u[2] * data[xc[2] + yc[3] + zc[3]] + u[3] * data[xc[3] + yc[3] + zc[3]] ) );
}
return 0.f;
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index a0b31f8d5b8..68d9d74cca4 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -293,7 +293,7 @@ void get_default_root(char *root)
root[3] = '\0';
if (GetFileAttributes(root) != 0xFFFFFFFF) {
rc = i;
- break;
+ break;
}
}
}
@@ -304,7 +304,7 @@ void get_default_root(char *root)
root[2] = '\\';
root[3] = '\0';
}
- }
+ }
}
}
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 74df5211dad..3c5812fa513 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -25,6 +25,7 @@
set(INC
.
+ ../blenfont
../blenkernel
../blenlib
../makesdna
@@ -62,4 +63,8 @@ if(WITH_BUILDINFO)
add_definitions(-DWITH_BUILDINFO)
endif()
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript
index 20b560744b3..49e8869637e 100644
--- a/source/blender/blenloader/SConscript
+++ b/source/blender/blenloader/SConscript
@@ -3,7 +3,7 @@ Import ('env')
sources = env.Glob('intern/*.c')
-incs = '. #/intern/guardedalloc ../blenlib ../blenkernel'
+incs = '. #/intern/guardedalloc ../blenfont ../blenlib ../blenkernel'
incs += ' ../makesdna ../editors/include'
incs += ' ../render/extern/include ../makesrna ../nodes ../bmesh ../imbuf'
@@ -11,6 +11,9 @@ incs += ' ' + env['BF_ZLIB_INC']
defs = []
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
+
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env.BlenderLib ( 'bf_blenloader', sources, Split(incs), defs, libtype=['core','player'], priority = [167,30]) #, cc_compileflags=['/WX'] )
else:
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index e917ccdf342..e9caa337129 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -175,7 +175,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
else if (bhead->code == DATA) {
if (looking) {
if (bhead->SDNAnr == DNA_struct_find_nr(fd->filesdna, "PreviewImage") ) {
- prv = BLO_library_read_struct(fd, bhead, "PreviewImage");
+ prv = BLO_library_read_struct(fd, bhead, "PreviewImage");
if (prv) {
memcpy(new_prv, prv, sizeof(PreviewImage));
if (prv->rect[0]) {
@@ -183,7 +183,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
new_prv->rect[0] = MEM_callocN(new_prv->w[0] * new_prv->h[0] * sizeof(unsigned int), "prvrect");
bhead = blo_nextbhead(fd, bhead);
rect = (unsigned int *)(bhead + 1);
- memcpy(new_prv->rect[0], rect, bhead->len);
+ memcpy(new_prv->rect[0], rect, bhead->len);
}
else {
new_prv->rect[0] = NULL;
@@ -194,7 +194,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
new_prv->rect[1] = MEM_callocN(new_prv->w[1] * new_prv->h[1] * sizeof(unsigned int), "prvrect");
bhead = blo_nextbhead(fd, bhead);
rect = (unsigned int *)(bhead + 1);
- memcpy(new_prv->rect[1], rect, bhead->len);
+ memcpy(new_prv->rect[1], rect, bhead->len);
}
else {
new_prv->rect[1] = NULL;
@@ -265,10 +265,10 @@ BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports)
if (fd) {
fd->reports = reports;
bfd = blo_read_file_internal(fd, filepath);
- blo_freefiledata(fd);
+ blo_freefiledata(fd);
}
- return bfd;
+ return bfd;
}
BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports)
@@ -280,10 +280,10 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports)
if (fd) {
fd->reports = reports;
bfd = blo_read_file_internal(fd, "");
- blo_freefiledata(fd);
+ blo_freefiledata(fd);
}
- return bfd;
+ return bfd;
}
BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFile *memfile, ReportList *reports)
@@ -332,10 +332,10 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
}
blo_join_main(&mainlist);
- blo_freefiledata(fd);
+ blo_freefiledata(fd);
}
- return bfd;
+ return bfd;
}
void BLO_blendfiledata_free(BlendFileData *bfd)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 26d9fb9e829..30331713463 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -105,6 +105,8 @@
#include "BLI_math.h"
#include "BLI_edgehash.h"
+#include "BLF_translation.h"
+
#include "BKE_anim.h"
#include "BKE_action.h"
#include "BKE_armature.h"
@@ -358,36 +360,39 @@ static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr)
}
/* for libdata, nr has ID code, no increment */
-static void *oldnewmap_liblookup(OldNewMap *onm, void *addr, void *lib)
+static void *oldnewmap_liblookup(OldNewMap *onm, void *addr, void *lib)
{
- int i;
-
- if (addr == NULL) return NULL;
-
+ if (addr == NULL) {
+ return NULL;
+ }
+
/* lasthit works fine for non-libdata, linking there is done in same sequence as writing */
if (onm->sorted) {
OldNew entry_s, *entry;
-
+
entry_s.old = addr;
-
+
entry = bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
if (entry) {
ID *id = entry->newp;
-
+
if (id && (!lib || id->lib)) {
- return entry->newp;
+ return id;
}
}
}
-
- for (i = 0; i < onm->nentries; i++) {
- OldNew *entry = &onm->entries[i];
-
- if (entry->old == addr) {
- ID *id = entry->newp;
-
- if (id && (!lib || id->lib)) {
- return entry->newp;
+ else {
+ /* note, this can be a bottle neck when loading some files */
+ unsigned int nentries = (unsigned int)onm->nentries;
+ unsigned int i;
+ OldNew *entry;
+
+ for (i = 0, entry = onm->entries; i < nentries; i++, entry++) {
+ if (entry->old == addr) {
+ ID *id = id = entry->newp;
+ if (id && (!lib || id->lib)) {
+ return id;
+ }
}
}
}
@@ -816,7 +821,7 @@ static void decode_blender_header(FileData *fd)
/* is the file saved in a different endian
* than we need ?
*/
- if (((((char*)&remove_this_endian_test)[0]==1)?L_ENDIAN:B_ENDIAN) != ((header[8]=='v')?L_ENDIAN:B_ENDIAN)) {
+ if (((((char *)&remove_this_endian_test)[0] == 1) ? L_ENDIAN : B_ENDIAN) != ((header[8] == 'v') ? L_ENDIAN : B_ENDIAN)) {
fd->flags |= FD_FLAGS_SWITCH_ENDIAN;
}
@@ -938,7 +943,7 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int s
if (chunkoffset+readsize > chunk->size)
readsize= chunk->size-chunkoffset;
- memcpy((char*)buffer + totread, chunk->buf + chunkoffset, readsize);
+ memcpy((char *)buffer + totread, chunk->buf + chunkoffset, readsize);
totread += readsize;
filedata->seek += readsize;
seek += readsize;
@@ -976,13 +981,13 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
if (fd->flags & FD_FLAGS_FILE_OK) {
if (!read_file_dna(fd)) {
- BKE_reportf(reports, RPT_ERROR, "Failed to read blend file: \"%s\", incomplete", fd->relabase);
+ BKE_reportf(reports, RPT_ERROR, "Failed to read blend file '%s', incomplete", fd->relabase);
blo_freefiledata(fd);
fd = NULL;
}
- }
+ }
else {
- BKE_reportf(reports, RPT_ERROR, "Failed to read blend file: \"%s\", not a blend file", fd->relabase);
+ BKE_reportf(reports, RPT_ERROR, "Failed to read blend file '%s', not a blend file", fd->relabase);
blo_freefiledata(fd);
fd = NULL;
}
@@ -999,7 +1004,8 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports)
gzfile = BLI_gzopen(filepath, "rb");
if (gzfile == (gzFile)Z_NULL) {
- BKE_reportf(reports, RPT_WARNING, "Unable to open \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error reading file");
+ BKE_reportf(reports, RPT_WARNING, "Unable to open '%s': %s",
+ filepath, errno ? strerror(errno) : TIP_("unknown error reading file"));
return NULL;
}
else {
@@ -1017,7 +1023,7 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports)
FileData *blo_openblendermemory(void *mem, int memsize, ReportList *reports)
{
if (!mem || memsize<SIZEOFBLENDERHEADER) {
- BKE_report(reports, RPT_WARNING, (mem)? "Unable to read": "Unable to open");
+ BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read"): TIP_("Unable to open"));
return NULL;
}
else {
@@ -1126,7 +1132,7 @@ int BLO_is_a_library(const char *path, char *dir, char *group)
/* the last part of the dir is a .blend file, no group follows */
*fd = '/'; /* put back the removed slash separating the dir and the .blend file name */
}
- else {
+ else {
char *gp = fd + 1; // in case we have a .blend file, gp points to the group
/* Find the last slash */
@@ -1290,6 +1296,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
if (NULL == newimaadr(fd, ibuf)) { /* so was restored */
BLI_remlink(&ima->ibufs, ibuf);
ima->bindcode = 0;
+ ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
ima->gputexture = NULL;
}
}
@@ -1628,6 +1635,19 @@ static void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endi
{
}
+/* ************ READ ID *************** */
+
+static void direct_link_id(FileData *fd, ID *id)
+{
+ /*link direct data of ID properties*/
+ if (id->properties) {
+ id->properties = newdataadr(fd, id->properties);
+ if (id->properties) { /* this case means the data was written incorrectly, it should not happen */
+ IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+ }
+}
+
/* ************ READ CurveMapping *************** */
/* cuma itself has been read! */
@@ -1821,7 +1841,7 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
DRIVER_TARGETS_LOOPER(dvar)
- {
+ {
/* only relink if still used */
if (tarIndex < dvar->num_targets)
dtar->id = newlibadr(fd, id->lib, dtar->id);
@@ -2396,6 +2416,14 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
link_list(fd, &node->inputs);
link_list(fd, &node->outputs);
+ link_list(fd, &node->internal_links);
+ for (link = node->internal_links.first; link; link = link->next) {
+ link->fromnode = newdataadr(fd, link->fromnode);
+ link->fromsock = newdataadr(fd, link->fromsock);
+ link->tonode = newdataadr(fd, link->tonode);
+ link->tosock = newdataadr(fd, link->tosock);
+ }
+
if (node->type == CMP_NODE_MOVIEDISTORTION) {
node->storage = newmclipadr(fd, node->storage);
}
@@ -2404,8 +2432,18 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
if (node->storage) {
/* could be handlerized at some point */
- if (ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
- direct_link_curvemapping(fd, node->storage);
+ if (ntree->type==NTREE_SHADER) {
+ if (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB) {
+ direct_link_curvemapping(fd, node->storage);
+ }
+ else if (node->type==SH_NODE_SCRIPT) {
+ NodeShaderScript *nss = (NodeShaderScript *) node->storage;
+ nss->bytecode = newdataadr(fd, nss->bytecode);
+ nss->prop = newdataadr(fd, nss->prop);
+ if (nss->prop)
+ IDP_DirectLinkProperty(nss->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+ }
else if (ntree->type==NTREE_COMPOSIT) {
if (ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
direct_link_curvemapping(fd, node->storage);
@@ -2527,8 +2565,13 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
break;
case CONSTRAINT_TYPE_KINEMATIC:
{
+ bKinematicConstraint *data = con->data;
+
con->lin_error = 0.f;
con->rot_error = 0.f;
+
+ /* version patch for runtime flag, was not cleared in some case */
+ data->flag &= ~CONSTRAINT_IK_AUTO;
}
case CONSTRAINT_TYPE_CHILDOF:
{
@@ -2709,8 +2752,10 @@ static void direct_link_lamp(FileData *fd, Lamp *la)
direct_link_curvemapping(fd, la->curfalloff);
la->nodetree= newdataadr(fd, la->nodetree);
- if (la->nodetree)
+ if (la->nodetree) {
+ direct_link_id(fd, &la->nodetree->id);
direct_link_nodetree(fd, la->nodetree);
+ }
la->preview = direct_link_preview_image(fd, la->preview);
}
@@ -2773,7 +2818,7 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb)
cp += 2;
}
- data+= elemsize;
+ data += elemsize;
}
}
@@ -2808,7 +2853,7 @@ static void lib_link_mball(FileData *fd, Main *main)
if (mb->adt) lib_link_animdata(fd, &mb->id, mb->adt);
for (a = 0; a < mb->totcol; a++)
- mb->mat[a]= newlibadr_us(fd, mb->id.lib, mb->mat[a]);
+ mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]);
mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system
@@ -2876,8 +2921,10 @@ static void direct_link_world(FileData *fd, World *wrld)
}
wrld->nodetree = newdataadr(fd, wrld->nodetree);
- if (wrld->nodetree)
+ if (wrld->nodetree) {
+ direct_link_id(fd, &wrld->nodetree->id);
direct_link_nodetree(fd, wrld->nodetree);
+ }
wrld->preview = direct_link_preview_image(fd, wrld->preview);
}
@@ -3000,6 +3047,7 @@ static void direct_link_image(FileData *fd, Image *ima)
/* if not restored, we keep the binded opengl index */
if (ima->ibufs.first == NULL) {
ima->bindcode = 0;
+ ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
ima->gputexture = NULL;
}
@@ -3043,7 +3091,7 @@ static void lib_link_curve(FileData *fd, Main *main)
cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont);
- cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
+ cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti);
cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi);
@@ -3077,7 +3125,7 @@ static void direct_link_curve(FileData *fd, Curve *cu)
cu->mat = newdataadr(fd, cu->mat);
test_pointer_array(fd, (void **)&cu->mat);
cu->str = newdataadr(fd, cu->str);
- cu->strinfo= newdataadr(fd, cu->strinfo);
+ cu->strinfo= newdataadr(fd, cu->strinfo);
cu->tb = newdataadr(fd, cu->tb);
if (cu->vfont == NULL) link_list(fd, &(cu->nurb));
@@ -3088,14 +3136,14 @@ static void direct_link_curve(FileData *fd, Curve *cu)
if (cu->tb) {
memcpy(tb, cu->tb, cu->totbox*sizeof(TextBox));
MEM_freeN(cu->tb);
- cu->tb = tb;
+ cu->tb = tb;
}
else {
cu->totbox = 1;
cu->actbox = 1;
cu->tb = tb;
cu->tb[0].w = cu->linewidth;
- }
+ }
if (cu->wordspace == 0.0f) cu->wordspace = 1.0f;
}
@@ -3184,8 +3232,10 @@ static void direct_link_texture(FileData *fd, Tex *tex)
tex->ot = newdataadr(fd, tex->ot);
tex->nodetree = newdataadr(fd, tex->nodetree);
- if (tex->nodetree)
+ if (tex->nodetree) {
+ direct_link_id(fd, &tex->nodetree->id);
direct_link_nodetree(fd, tex->nodetree);
+ }
tex->preview = direct_link_preview_image(fd, tex->preview);
@@ -3244,8 +3294,10 @@ static void direct_link_material(FileData *fd, Material *ma)
ma->ramp_spec = newdataadr(fd, ma->ramp_spec);
ma->nodetree = newdataadr(fd, ma->nodetree);
- if (ma->nodetree)
+ if (ma->nodetree) {
+ direct_link_id(fd, &ma->nodetree->id);
direct_link_nodetree(fd, ma->nodetree);
+ }
ma->preview = direct_link_preview_image(fd, ma->preview);
ma->gpumaterial.first = ma->gpumaterial.last = NULL;
@@ -3260,7 +3312,7 @@ static const char *ptcache_data_struct[] = {
"", // BPHYS_DATA_ROTATION
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
"", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
+ "", // BPHYS_DATA_TIMES:
"BoidData" // case BPHYS_DATA_BOIDS:
};
static void direct_link_pointcache(FileData *fd, PointCache *cache)
@@ -3335,6 +3387,8 @@ static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
{
if (pd && pd->tex)
pd->tex = newlibadr_us(fd, id->lib, pd->tex);
+ if (pd && pd->f_source)
+ pd->f_source = newlibadr_us(fd, id->lib, pd->f_source);
}
static void lib_link_particlesettings(FileData *fd, Main *main)
@@ -3363,32 +3417,31 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
if (part->dupliweights.first && part->dup_group) {
int index_ok = 0;
/* check for old files without indices (all indexes 0) */
- dw = part->dupliweights.first;
if (part->dupliweights.first == part->dupliweights.last) {
/* special case for only one object in the group */
index_ok = 1;
}
- else {
- for (; dw; dw=dw->next) {
+ else {
+ for (dw = part->dupliweights.first; dw; dw = dw->next) {
if (dw->index > 0) {
index_ok = 1;
break;
}
}
}
-
+
if (index_ok) {
/* if we have indexes, let's use them */
- dw = part->dupliweights.first;
- for (; dw; dw=dw->next) {
+ for (dw = part->dupliweights.first; dw; dw = dw->next) {
GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index);
- dw->ob = go ? go->ob : NULL;
+ dw->ob = go ? newlibadr(fd, part->id.lib, dw->ob) : NULL;
}
}
else {
/* otherwise try to get objects from own library (won't work on library linked groups) */
- for (; dw; dw=dw->next)
+ for (dw = part->dupliweights.first; dw; dw = dw->next) {
dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+ }
}
}
else {
@@ -3567,10 +3620,10 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
psys->clmd->clothObject = NULL;
psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms);
- psys->clmd->sim_parms->effector_weights = NULL;
psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms);
if (psys->clmd->sim_parms) {
+ psys->clmd->sim_parms->effector_weights = NULL;
if (psys->clmd->sim_parms->presets > 10)
psys->clmd->sim_parms->presets = 0;
}
@@ -3605,7 +3658,7 @@ static void lib_link_mtface(FileData *fd, Mesh *me, MTFace *mtface, int totface)
static void lib_link_customdata_mtface(FileData *fd, Mesh *me, CustomData *fdata, int totface)
{
- int i;
+ int i;
for (i = 0; i < fdata->totlayer; i++) {
CustomDataLayer *layer = &fdata->layers[i];
@@ -3624,12 +3677,13 @@ static void lib_link_customdata_mtpoly(FileData *fd, Mesh *me, CustomData *pdata
if (layer->type == CD_MTEXPOLY) {
MTexPoly *tf= layer->data;
- int i;
+ int j;
- for (i = 0; i < totface; i++, tf++) {
+ for (j = 0; j < totface; j++, tf++) {
tf->tpage = newlibadr(fd, me->id.lib, tf->tpage);
- if (tf->tpage && tf->tpage->id.us==0)
+ if (tf->tpage && tf->tpage->id.us == 0) {
tf->tpage->id.us = 1;
+ }
}
}
}
@@ -3688,7 +3742,7 @@ static void lib_link_mesh(FileData *fd, Main *main)
/*
* Re-tessellate, even if the polys were just created from tessfaces, this
* is important because it:
- * - fill the CD_POLYINDEX layer
+ * - fill the CD_ORIGINDEX layer
* - gives consistency of tessface between loading from a file and
* converting an edited BMesh back into a mesh (i.e. it replaces
* quad tessfaces in a loaded mesh immediately, instead of lazily
@@ -3783,7 +3837,7 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count)
/* annoying workaround for bug [#31079] loading legacy files with
* no polygons _but_ have stale customdata */
if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) {
- memset(data, 0, sizeof(*data));
+ CustomData_reset(data);
return;
}
@@ -4053,7 +4107,7 @@ static void lib_link_object(FileData *fd, Main *main)
if (paf->type == EFF_PARTICLE) {
paf->group = newlibadr_us(fd, ob->id.lib, paf->group);
}
- }
+ }
for (sens = ob->sensors.first; sens; sens = sens->next) {
for (a = 0; a < sens->totlinks; a++)
@@ -4317,10 +4371,12 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) {
if (smd->domain->point_cache[1]) {
PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]);
- if (cache->flag & PTCACHE_FAKE_SMOKE)
- ; /* Smoke was already saved in "new format" and this cache is a fake one. */
- else
+ if (cache->flag & PTCACHE_FAKE_SMOKE) {
+ /* Smoke was already saved in "new format" and this cache is a fake one. */
+ }
+ else {
printf("High resolution smoke cache not available due to pointcache update. Please reset the simulation.\n");
+ }
BKE_ptcache_free(cache);
}
smd->domain->ptcaches[1].first = NULL;
@@ -4333,6 +4389,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->coll = NULL;
smd->flow = newdataadr(fd, smd->flow);
smd->flow->smd = smd;
+ smd->flow->dm = NULL;
+ smd->flow->verts_old = NULL;
+ smd->flow->numverts = 0;
smd->flow->psys = newdataadr(fd, smd->flow->psys);
}
else if (smd->type == MOD_SMOKE_TYPE_COLL) {
@@ -4341,11 +4400,15 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->coll = newdataadr(fd, smd->coll);
if (smd->coll) {
smd->coll->smd = smd;
- smd->coll->points = NULL;
- smd->coll->numpoints = 0;
+ smd->coll->verts_old = NULL;
+ smd->coll->numverts = 0;
+ smd->coll->dm = NULL;
}
else {
smd->type = 0;
+ smd->flow = NULL;
+ smd->domain = NULL;
+ smd->coll = NULL;
}
}
}
@@ -4576,7 +4639,7 @@ static void direct_link_object(FileData *fd, Object *ob)
direct_link_partdeflect(ob->pd);
ob->soft= newdataadr(fd, ob->soft);
if (ob->soft) {
- SoftBody *sb = ob->soft;
+ SoftBody *sb = ob->soft;
sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
sb->bspring = NULL;
@@ -4753,8 +4816,7 @@ static void lib_link_scene(FileData *fd, Main *main)
base->object = newlibadr_us(fd, sce->id.lib, base->object);
if (base->object == NULL) {
- BKE_reportf_wrap(fd->reports, RPT_WARNING,
- "LIB ERROR: Object lost from scene:'%s\'",
+ BKE_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB ERROR: object lost from scene: '%s'"),
sce->id.name + 2);
BLI_remlink(&sce->base, base);
if (base == sce->basact) sce->basact = NULL;
@@ -5020,7 +5082,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
ed->seqbasep = (ListBase *)(poin+offset);
else
ed->seqbasep = &ed->seqbase;
- }
+ }
/* stack */
link_list(fd, &(ed->metastack));
@@ -5054,7 +5116,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
if (sce->r.ffcodecdata.properties) {
sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
- if (sce->r.ffcodecdata.properties) {
+ if (sce->r.ffcodecdata.properties) {
IDP_DirectLinkProperty(sce->r.ffcodecdata.properties,
(fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
@@ -5065,8 +5127,10 @@ static void direct_link_scene(FileData *fd, Scene *sce)
link_list(fd, &(sce->r.layers));
sce->nodetree = newdataadr(fd, sce->nodetree);
- if (sce->nodetree)
+ if (sce->nodetree) {
+ direct_link_id(fd, &sce->nodetree->id);
direct_link_nodetree(fd, sce->nodetree);
+ }
direct_link_view_settings(fd, &sce->view_settings);
}
@@ -5980,11 +6044,11 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
if (newmain->curlib) {
if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
BKE_reportf_wrap(fd->reports, RPT_WARNING,
- "Library '%s', '%s' had multiple instances, save and reload!",
+ TIP_("Library '%s', '%s' had multiple instances, save and reload!"),
lib->name, lib->filepath);
change_idid_adr(fd->mainlist, fd, lib, newmain->curlib);
-// change_idid_adr_fd(fd, lib, newmain->curlib);
+/* change_idid_adr_fd(fd, lib, newmain->curlib); */
BLI_remlink(&main->library, lib);
MEM_freeN(lib);
@@ -5998,8 +6062,10 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
cleanup_path(fd->relabase, lib->filepath);
-// printf("direct_link_library: name %s\n", lib->name);
-// printf("direct_link_library: filename %s\n", lib->filename);
+#if 0
+ printf("direct_link_library: name %s\n", lib->name);
+ printf("direct_link_library: filename %s\n", lib->filename);
+#endif
/* new main */
newmain= MEM_callocN(sizeof(Main), "directlink");
@@ -6436,6 +6502,8 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
bhead = read_data_into_oldnewmap(fd, bhead, allocname);
/* init pointers direct data */
+ direct_link_id(fd, id);
+
switch (GS(id->name)) {
case ID_WM:
direct_link_windowmanager(fd, (wmWindowManager *)id);
@@ -6532,14 +6600,6 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
break;
}
- /*link direct data of ID properties*/
- if (id->properties) {
- id->properties = newdataadr(fd, id->properties);
- if (id->properties) { /* this case means the data was written incorrectly, it should not happen */
- IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
- }
-
oldnewmap_free_unused(fd->datamap);
oldnewmap_clear(fd->datamap);
@@ -6602,7 +6662,7 @@ void convert_tface_mt(FileData *fd, Main *main)
G.main = main;
if (!(do_version_tface(main, 1))) {
- BKE_report(fd->reports, RPT_WARNING, "Texface conversion problem. Error in console");
+ BKE_report(fd->reports, RPT_WARNING, "Texface conversion problem (see error in console)");
}
//XXX hack, material.c uses G.main allover the place, instead of main
@@ -6775,7 +6835,6 @@ static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNodeTree *ntree)
{
bNode *node;
- bNodeSocket *sock;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_OUTPUT_FILE) {
@@ -6852,6 +6911,7 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
}
else if (node->type==CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
NodeImageMultiFile *nimf = node->storage;
+ bNodeSocket *sock;
/* CMP_NODE_OUTPUT_MULTI_FILE has been redeclared as CMP_NODE_OUTPUT_FILE */
node->type = CMP_NODE_OUTPUT_FILE;
@@ -7005,6 +7065,20 @@ static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id),
}
}
+static void do_version_ntree_defocus_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+ bNode *node;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_DEFOCUS) {
+ NodeDefocus *data = node->storage;
+ if (data->maxblur == 0.0f) {
+ data->maxblur = 16.0f;
+ }
+ }
+ }
+}
+
static void do_version_ntree_mask_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
@@ -7047,6 +7121,88 @@ static void do_version_ntree_tex_coord_from_dupli_264(void *UNUSED(data), ID *UN
node->flag |= NODE_OPTIONS;
}
+static void do_version_node_cleanup_dynamic_sockets_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+ bNode *node;
+ bNodeSocket *sock;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (!ELEM(node->type, NODE_GROUP, CMP_NODE_IMAGE)) {
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ sock->flag &= ~SOCK_DYNAMIC;
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ sock->flag &= ~SOCK_DYNAMIC;
+ }
+ }
+}
+
+static void do_version_node_fix_internal_links_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+ bNode *node;
+ bNodeLink *link, *nextlink;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (link = node->internal_links.first; link; link = nextlink) {
+ nextlink = link->next;
+ if (!link->fromnode || !link->fromsock || !link->tonode || !link->tosock) {
+ BLI_remlink(&node->internal_links, link);
+ }
+ }
+ }
+}
+
+static void do_version_logic_264(ListBase *regionbase)
+{
+ ARegion *ar;
+
+ /* view settings for logic changed */
+ for (ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.keeptot == 0) {
+ ar->v2d.maxzoom = 1.5f;
+
+ ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT;
+ ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X;
+ ar->v2d.keepofs = V2D_KEEPOFS_Y;
+ }
+ }
+ }
+
+
+}
+
+static void do_versions_affine_tracker_track(MovieTrackingTrack *track)
+{
+ int i;
+
+ for (i = 0; i < track->markersnr; i++) {
+ MovieTrackingMarker *marker = &track->markers[i];
+
+ if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
+ is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3]))
+ {
+ marker->pattern_corners[0][0] = track->pat_min[0];
+ marker->pattern_corners[0][1] = track->pat_min[1];
+
+ marker->pattern_corners[1][0] = track->pat_max[0];
+ marker->pattern_corners[1][1] = track->pat_min[1];
+
+ marker->pattern_corners[2][0] = track->pat_max[0];
+ marker->pattern_corners[2][1] = track->pat_max[1];
+
+ marker->pattern_corners[3][0] = track->pat_min[0];
+ marker->pattern_corners[3][1] = track->pat_max[1];
+ }
+
+ if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
+ copy_v2_v2(marker->search_min, track->search_min);
+ copy_v2_v2(marker->search_max, track->search_max);
+ }
+ }
+}
+
+
static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -7160,9 +7316,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
v3d->bundle_drawtype = OB_PLAINAXES;
}
else if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sc = (SpaceClip *)sl;
- if (sc->scopes.track_preview_height == 0)
- sc->scopes.track_preview_height = 120;
+ SpaceClip *sclip = (SpaceClip *)sl;
+ if (sclip->scopes.track_preview_height == 0)
+ sclip->scopes.track_preview_height = 120;
}
}
}
@@ -7242,10 +7398,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
(ob->size[i] == 0.0f)) /* cant scale the dsize to give a non zero result, so fallback to 1.0f */
{
- ob->dscale[i]= 1.0f;
+ ob->dscale[i] = 1.0f;
}
else {
- ob->dscale[i]= (ob->size[i] + ob->dsize[i]) / ob->size[i];
+ ob->dscale[i] = (ob->size[i] + ob->dsize[i]) / ob->size[i];
}
}
}
@@ -7370,8 +7526,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
prop = BKE_bproperty_object_get(ob, "Text");
if (prop) {
BKE_reportf_wrap(fd->reports, RPT_WARNING,
- "Game property name conflict in object: \"%s\".\nText objects reserve the "
- "[\"Text\"] game property to change their content through Logic Bricks.",
+ TIP_("Game property name conflict in object '%s':\ntext objects reserve the "
+ "['Text'] game property to change their content through logic bricks"),
ob->id.name + 2);
}
}
@@ -7564,13 +7720,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 263) {
/* Default for old files is to save particle rotations to pointcache */
ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next)
+ for (part = main->particle.first; part; part = part->id.next) {
part->flag |= PART_ROTATIONS;
- {
- /* Default for old files is to save particle rotations to pointcache */
- ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next)
- part->flag |= PART_ROTATIONS;
}
}
@@ -7765,6 +7916,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) {
{
Scene *scene;
+ bNodeTreeType *ntreetype;
// composite redesign
for (scene=main->scene.first; scene; scene=scene->id.next) {
if (scene->nodetree) {
@@ -7773,6 +7925,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+ ntreetype = ntreeGetType(NTREE_COMPOSIT);
+
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_ntree_defocus_264);
+
}
{
@@ -7814,32 +7971,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
track = clip->tracking.tracks.first;
while (track) {
- int i;
-
- for (i = 0; i < track->markersnr; i++) {
- MovieTrackingMarker *marker = &track->markers[i];
-
- if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
- is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3]))
- {
- marker->pattern_corners[0][0] = track->pat_min[0];
- marker->pattern_corners[0][1] = track->pat_min[1];
-
- marker->pattern_corners[1][0] = track->pat_max[0];
- marker->pattern_corners[1][1] = track->pat_min[1];
-
- marker->pattern_corners[2][0] = track->pat_max[0];
- marker->pattern_corners[2][1] = track->pat_max[1];
-
- marker->pattern_corners[3][0] = track->pat_min[0];
- marker->pattern_corners[3][1] = track->pat_max[1];
- }
-
- if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
- copy_v2_v2(marker->search_min, track->search_min);
- copy_v2_v2(marker->search_max, track->search_max);
- }
- }
+ do_versions_affine_tracker_track(track);
track = track->next;
}
@@ -7983,6 +8115,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
{
Mesh *me;
for (me = main->mesh.first; me; me = me->id.next) {
+ CustomData_update_typemap(&me->vdata);
CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert);
}
}
@@ -8016,6 +8149,221 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
do_version_ntree_tex_coord_from_dupli_264(NULL, NULL, ntree);
}
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 2)) {
+ MovieClip *clip;
+
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object;
+
+ for (tracking_object = tracking->objects.first;
+ tracking_object;
+ tracking_object = tracking_object->next)
+ {
+ if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) {
+ tracking_object->keyframe1 = tracking->settings.keyframe1;
+ tracking_object->keyframe2 = tracking->settings.keyframe2;
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 3)) {
+ /* smoke branch */
+ {
+ Object *ob;
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ /* keep branch saves if possible */
+ if (!smd->domain->flame_max_temp) {
+ smd->domain->burning_rate = 0.75f;
+ smd->domain->flame_smoke = 1.0f;
+ smd->domain->flame_vorticity = 0.5f;
+ smd->domain->flame_ignition = 1.25f;
+ smd->domain->flame_max_temp = 1.75f;
+ smd->domain->adapt_threshold = 0.02f;
+ smd->domain->adapt_margin = 4;
+ smd->domain->flame_smoke_color[0] = 0.7f;
+ smd->domain->flame_smoke_color[1] = 0.7f;
+ smd->domain->flame_smoke_color[2] = 0.7f;
+ }
+ }
+ else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+ if (!smd->flow->texture_size) {
+ smd->flow->fuel_amount = 1.0;
+ smd->flow->surface_distance = 1.5;
+ smd->flow->color[0] = 0.7f;
+ smd->flow->color[1] = 0.7f;
+ smd->flow->color[2] = 0.7f;
+ smd->flow->texture_size = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* render border for viewport */
+ {
+ bScreen *sc;
+
+ for (sc = main->screen.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f &&
+ v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f)
+ {
+ v3d->render_border.xmax = 1.0f;
+ v3d->render_border.ymax = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 4)) {
+ /* Fix for old node flags: Apparently the SOCK_DYNAMIC flag has been in use for other
+ * purposes before and then removed and later reused for SOCK_DYNAMIC. This socket should
+ * only be used by certain node types which don't use template lists, cleaning this up here.
+ */
+ bNodeTreeType *ntreetype;
+ bNodeTree *ntree;
+
+ ntreetype = ntreeGetType(NTREE_COMPOSIT);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_node_cleanup_dynamic_sockets_264);
+ ntreetype = ntreeGetType(NTREE_SHADER);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_node_cleanup_dynamic_sockets_264);
+ ntreetype = ntreeGetType(NTREE_TEXTURE);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_node_cleanup_dynamic_sockets_264);
+
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
+ do_version_node_cleanup_dynamic_sockets_264(NULL, NULL, ntree);
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 5)) {
+ /* set a unwrapping margin and ABF by default */
+ Scene *scene;
+
+ for (scene=main->scene.first; scene; scene=scene->id.next) {
+ if (scene->toolsettings->uvcalc_margin == 0.0f) {
+ scene->toolsettings->uvcalc_margin = 0.001f;
+ scene->toolsettings->unwrapper = 0;
+ }
+ }
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) {
+ /* Fix for bug #32982, internal_links list could get corrupted from r51630 onward.
+ * Simply remove bad internal_links lists to avoid NULL pointers.
+ */
+ bNodeTreeType *ntreetype;
+ bNodeTree *ntree;
+
+ ntreetype = ntreeGetType(NTREE_COMPOSIT);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_internal_links_264);
+ ntreetype = ntreeGetType(NTREE_SHADER);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_internal_links_264);
+ ntreetype = ntreeGetType(NTREE_TEXTURE);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_internal_links_264);
+
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
+ do_version_node_fix_internal_links_264(NULL, NULL, ntree);
+
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) {
+ bScreen *sc;
+
+ for (sc = main->screen.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ if ( sa->spacetype == SPACE_LOGIC)
+ do_version_logic_264(&sa->regionbase);
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_LOGIC)
+ do_version_logic_264(&sl->regionbase);
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
+ /* convert tiles size from resolution and number of tiles */
+ {
+ Scene *scene;
+
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->r.tilex == 0 || scene->r.tiley == 1) {
+ /* scene could be set for panoramic rendering, so clamp with the
+ * lowest possible tile size value
+ */
+ scene->r.tilex = max_ii(scene->r.xsch * scene->r.size / scene->r.xparts / 100, 8);
+ scene->r.tiley = max_ii(scene->r.ysch * scene->r.size / scene->r.yparts / 100, 8);
+ }
+ }
+ }
+
+ /* collision masks */
+ {
+ Object *ob;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ if (ob->col_group == 0) {
+ ob->col_group = 0x01;
+ ob->col_mask = 0xff;
+ }
+ }
+ }
+
+ /* fallbck resection method settings */
+ {
+ MovieClip *clip;
+
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ if (clip->tracking.settings.reconstruction_success_threshold == 0.0f) {
+ clip->tracking.settings.reconstruction_success_threshold = 1e-3;
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
+ MovieClip *clip;
+
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ MovieTrackingTrack *track;
+ MovieTrackingObject *object;
+
+ for (track = clip->tracking.tracks.first; track; track = track->next) {
+ do_versions_affine_tracker_track(track);
+ }
+
+ for (object = clip->tracking.objects.first; object; object = object->next) {
+ for (track = object->tracks.first; track; track = track->next) {
+ do_versions_affine_tracker_track(track);
+ }
+ }
+ }
+ }
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
@@ -8672,7 +9020,7 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
}
expand_doit(fd, mainvar, cu->vfont);
- expand_doit(fd, mainvar, cu->vfontb);
+ expand_doit(fd, mainvar, cu->vfontb);
expand_doit(fd, mainvar, cu->vfonti);
expand_doit(fd, mainvar, cu->vfontbi);
expand_doit(fd, mainvar, cu->key);
@@ -9494,7 +9842,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
if ((*fd)->flags & FD_FLAGS_SWITCH_ENDIAN) {
blo_freefiledata(*fd);
*fd = NULL;
- }
+ }
}
void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
@@ -9549,8 +9897,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
if (fd == NULL) {
/* printf and reports for now... its important users know this */
- BKE_reportf_wrap(basefd->reports, RPT_INFO,
- "read library: '%s', '%s'",
+ BKE_reportf_wrap(basefd->reports, RPT_INFO, TIP_("Read library: '%s', '%s'"),
mainptr->curlib->filepath, mainptr->curlib->name);
fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
@@ -9603,8 +9950,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
else mainptr->curlib->filedata = NULL;
if (fd == NULL) {
- BKE_reportf_wrap(basefd->reports, RPT_WARNING,
- "Can't find lib '%s'",
+ BKE_reportf_wrap(basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"),
mainptr->curlib->filepath);
}
}
@@ -9623,7 +9969,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
append_id_part(fd, mainptr, id, &realid);
if (!realid) {
BKE_reportf_wrap(fd->reports, RPT_WARNING,
- "LIB ERROR: %s:'%s' missing from '%s'",
+ TIP_("LIB ERROR: %s: '%s' missing from '%s'"),
BKE_idcode_to_name(GS(id->name)),
id->name+2, mainptr->curlib->filepath);
}
@@ -9655,7 +10001,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
if (id->flag & LIB_READ) {
BLI_remlink(lbarray[a], id);
BKE_reportf_wrap(basefd->reports, RPT_WARNING,
- "LIB ERROR: %s:'%s' unread libblock missing from '%s'",
+ TIP_("LIB ERROR: %s: '%s' unread lib block missing from '%s'"),
BKE_idcode_to_name(GS(id->name)), id->name + 2, mainptr->curlib->filepath);
change_idid_adr(mainlist, basefd, id, NULL);
diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c
index eaf725dda9e..5d8a865eea8 100644
--- a/source/blender/blenloader/intern/runtime.c
+++ b/source/blender/blenloader/intern/runtime.c
@@ -91,7 +91,7 @@ cleanup:
if (fd != -1)
close(fd);
- return res;
+ return res;
}
BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
@@ -104,7 +104,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
fd = BLI_open(path, O_BINARY | O_RDONLY, 0);
if (fd == -1) {
- BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", path, strerror(errno));
+ BKE_reportf(reports, RPT_ERROR, "Unable to open '%s': %s", path, strerror(errno));
goto cleanup;
}
@@ -115,18 +115,18 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
datastart = handle_read_msb_int(fd);
if (datastart == -1) {
- BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (problem seeking)", path);
+ BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (problem seeking)", path);
goto cleanup;
}
else if (read(fd, buf, 8) != 8) {
- BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (truncated header)", path);
+ BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (truncated header)", path);
goto cleanup;
}
else if (memcmp(buf, "BRUNTIME", 8) != 0) {
- BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (not a blend file)", path);
+ BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (not a blend file)", path);
goto cleanup;
}
- else {
+ else {
//printf("starting to read runtime from %s at datastart %d\n", path, datastart);
lseek(fd, datastart, SEEK_SET);
bfd = blo_read_blendafterruntime(fd, path, actualsize - datastart, reports);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index a3cfa4413a8..d75339252d9 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -32,7 +32,7 @@
#include "zlib.h"
#ifndef WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> /* for read close */
#else
# include <io.h> // for open close read
# include "winsock2.h"
@@ -1134,7 +1134,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
/* Add default gravity to scenes */
for (sce = main->scene.first; sce; sce = sce->id.next) {
if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
- len_v3(sce->physics_settings.gravity) == 0.0f)
+ is_zero_v3(sce->physics_settings.gravity))
{
sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
sce->physics_settings.gravity[2] = -9.81f;
@@ -2062,7 +2062,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
{
brush->add_col[0] = 1.00f;
brush->add_col[1] = 0.39f;
- brush->add_col[2] = 0.39f;
+ brush->add_col[2] = 0.39f;
}
if (brush->sub_col[0] == 0 &&
@@ -2333,7 +2333,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
for (sc = main->screen.first; sc; sc = sc->id.next) {
if (sc->redraws_flag == 0) {
/* just initialize to default? */
- // XXX: we could also have iterated through areas, and taken them from the first timeline available...
+ /* XXX: we could also have iterated through areas, and taken them from the first timeline available... */
sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
}
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index d8333e7c8f4..8a56e3c2ab8 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -1237,7 +1237,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
TFace *tf = &((TFace*) me->tface)[i];
for (j = 0; j < 4; j++) {
- char *col = (char*) &tf->col[j];
+ char *col = (char *) &tf->col[j];
col[0] = 255;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 536376ac577..ac5366c26a3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -197,7 +197,7 @@ static WriteData *writedata_new(int file)
if (wd == NULL) return NULL;
- wd->sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0);
+ wd->sdna = DNA_sdna_from_data(DNAstr, DNAlen, 0);
wd->file= file;
@@ -511,7 +511,7 @@ static void write_fcurves(WriteData *wd, ListBase *fcurves)
writestruct(wd, DATA, "FCurve", 1, fcu);
/* curve data */
- if (fcu->bezt)
+ if (fcu->bezt)
writestruct(wd, DATA, "BezTriple", fcu->totvert, fcu->bezt);
if (fcu->fpt)
writestruct(wd, DATA, "FPoint", fcu->totvert, fcu->fpt);
@@ -720,18 +720,31 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
write_node_socket(wd, sock);
for (sock= node->outputs.first; sock; sock= sock->next)
write_node_socket(wd, sock);
-
+
+ for (link = node->internal_links.first; link; link = link->next)
+ writestruct(wd, DATA, "bNodeLink", 1, link);
if (node->storage) {
/* could be handlerized at some point, now only 1 exception still */
if (ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
write_curvemapping(wd, node->storage);
+ else if (ntree->type==NTREE_SHADER && node->type==SH_NODE_SCRIPT) {
+ NodeShaderScript *nss = (NodeShaderScript *)node->storage;
+ if (nss->bytecode)
+ writedata(wd, DATA, strlen(nss->bytecode)+1, nss->bytecode);
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ if (nss->prop)
+ IDP_WriteProperty(nss->prop, wd);
+ writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
else if (ntree->type==NTREE_COMPOSIT && ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
write_curvemapping(wd, node->storage);
else if (ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) )
write_curvemapping(wd, node->storage);
- else if (ntree->type==NTREE_COMPOSIT && node->type==CMP_NODE_MOVIEDISTORTION)
- /* pass */;
+ else if (ntree->type==NTREE_COMPOSIT && node->type==CMP_NODE_MOVIEDISTORTION) {
+ /* pass */
+ }
else
writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
@@ -776,13 +789,16 @@ typedef struct RenderInfo {
char scene_name[MAX_ID_NAME - 2];
} RenderInfo;
-static void write_renderinfo(WriteData *wd, Main *mainvar) /* for renderdeamon */
+/* was for historic render-deamon feature,
+ * now write because it can be easily extracted without
+ * reading the whole blend file */
+static void write_renderinfo(WriteData *wd, Main *mainvar)
{
bScreen *curscreen;
Scene *sce;
RenderInfo data;
- /* XXX in future, handle multiple windows with multiple screnes? */
+ /* XXX in future, handle multiple windows with multiple screens? */
current_screen_compat(mainvar, &curscreen);
for (sce= mainvar->scene.first; sce; sce= sce->id.next) {
@@ -884,7 +900,7 @@ static const char *ptcache_data_struct[] = {
"", // BPHYS_DATA_ROTATION
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
"", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
+ "", // BPHYS_DATA_TIMES:
"BoidData" // case BPHYS_DATA_BOIDS:
};
static const char *ptcache_extra_struct[] = {
@@ -1237,7 +1253,7 @@ static void write_constraints(WriteData *wd, ListBase *conlist)
break;
case CONSTRAINT_TYPE_SPLINEIK:
{
- bSplineIKConstraint *data= (bSplineIKConstraint*)con->data;
+ bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
/* write points array */
writedata(wd, DATA, sizeof(float)*(data->numpoints), data->points);
@@ -1325,7 +1341,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms);
writestruct(wd, DATA, "EffectorWeights", 1, clmd->sim_parms->effector_weights);
write_pointcaches(wd, &clmd->ptcaches);
- }
+ }
else if (md->type==eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData*) md;
@@ -1355,7 +1371,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow);
else if (smd->type & MOD_SMOKE_TYPE_COLL)
writestruct(wd, DATA, "SmokeCollSettings", 1, smd->coll);
- }
+ }
else if (md->type==eModifierType_Fluidsim) {
FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
@@ -1383,7 +1399,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp);
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp);
}
- }
+ }
else if (md->type==eModifierType_Collision) {
#if 0
@@ -1603,7 +1619,7 @@ static void write_curves(WriteData *wd, ListBase *idbase)
if (cu->vfont) {
writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str);
writestruct(wd, DATA, "CharInfo", cu->len+1, cu->strinfo);
- writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb);
+ writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb);
}
else {
/* is also the order of reading */
@@ -1725,9 +1741,10 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
writestruct(wd, DATA, structname, datasize, layer->data);
}
- else
+ else {
printf("%s error: layer '%s':%d - can't be written to file\n",
__func__, structname, layer->type);
+ }
}
}
@@ -1759,6 +1776,9 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
backup_mesh.totface = mesh->totface;
mesh->totface = 0;
/* -- */
+ backup_mesh.fdata = mesh->fdata;
+ memset(&mesh->fdata, 0, sizeof(mesh->fdata));
+ /* -- */
#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
writestruct(wd, ID_ME, "Mesh", 1, mesh);
@@ -1782,6 +1802,8 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
mesh->mface = backup_mesh.mface;
/* -- */
mesh->totface = backup_mesh.totface;
+ /* -- */
+ mesh->fdata = backup_mesh.fdata;
#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
}
@@ -1808,13 +1830,13 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
mesh->totloop = 0;
/* -- */
backup_mesh.fdata = mesh->fdata;
- memset(&mesh->fdata, 0, sizeof(CustomData));
+ CustomData_reset(&mesh->fdata);
/* -- */
backup_mesh.pdata = mesh->pdata;
- memset(&mesh->pdata, 0, sizeof(CustomData));
+ CustomData_reset(&mesh->pdata);
/* -- */
backup_mesh.ldata = mesh->ldata;
- memset(&mesh->ldata, 0, sizeof(CustomData));
+ CustomData_reset(&mesh->ldata);
/* -- */
backup_mesh.edit_btmesh = mesh->edit_btmesh;
mesh->edit_btmesh = NULL;
@@ -2021,7 +2043,7 @@ static void write_materials(WriteData *wd, ListBase *idbase)
write_nodetree(wd, ma->nodetree);
}
- write_previews(wd, ma->preview);
+ write_previews(wd, ma->preview);
}
ma= ma->id.next;
}
@@ -2077,7 +2099,7 @@ static void write_lamps(WriteData *wd, ListBase *idbase)
}
if (la->curfalloff)
- write_curvemapping(wd, la->curfalloff);
+ write_curvemapping(wd, la->curfalloff);
/* nodetree is integral part of lamps, no libdata */
if (la->nodetree) {
@@ -2300,7 +2322,7 @@ static void write_gpencils(WriteData *wd, ListBase *lb)
/* write strokes */
for (gps= gpf->strokes.first; gps; gps= gps->next) {
writestruct(wd, DATA, "bGPDstroke", 1, gps);
- writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points);
+ writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points);
}
}
}
@@ -2536,7 +2558,7 @@ static void write_bone(WriteData *wd, Bone *bone)
Bone* cbone;
// PATCH for upward compatibility after 2.37+ armature recode
- bone->size[0]= bone->size[1]= bone->size[2]= 1.0f;
+ bone->size[0] = bone->size[1] = bone->size[2] = 1.0f;
// Write this bone
writestruct(wd, DATA, "Bone", 1, bone);
@@ -2868,7 +2890,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
fg.winpos= G.winpos;
/* prevent to save this, is not good convention, and feature with concerns... */
- fg.fileflags= (fileflags & ~(G_FILE_NO_UI|G_FILE_RELATIVE_REMAP|G_FILE_MESH_COMPAT));
+ fg.fileflags= (fileflags & ~G_FILE_FLAGS_RUNTIME);
fg.globalf= G.f;
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
@@ -2995,7 +3017,7 @@ static int do_history(const char *name, ReportList *reports)
if (BLI_rename(tempname1, tempname2)) {
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
return 1;
- }
+ }
hisnr--;
}
@@ -3017,15 +3039,24 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
char tempname[FILE_MAX+1];
int file, err, write_user_block;
+ /* path backup/restore */
+ void *path_list_backup = NULL;
+ const int path_list_flag = (BLI_BPATH_TRAVERSE_SKIP_LIBRARY | BLI_BPATH_TRAVERSE_SKIP_MULTIFILE);
+
/* open temporary file, so we preserve the original in case we crash */
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
file = BLI_open(tempname, O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
if (file == -1) {
- BKE_reportf(reports, RPT_ERROR, "Can't open file %s for writing: %s.", tempname, strerror(errno));
+ BKE_reportf(reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
return 0;
}
+ /* check if we need to backup and restore paths */
+ if (UNLIKELY((write_flags & G_FILE_RELATIVE_REMAP) && (G_FILE_SAVE_COPY & write_flags))) {
+ path_list_backup = BLI_bpath_list_backup(mainvar, path_list_flag);
+ }
+
/* remapping of relative paths to new file location */
if (write_flags & G_FILE_RELATIVE_REMAP) {
char dir1[FILE_MAX];
@@ -3061,6 +3092,11 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
err= write_file_handle(mainvar, file, NULL, NULL, write_user_block, write_flags, thumb);
close(file);
+ if (UNLIKELY(path_list_backup)) {
+ BLI_bpath_list_restore(mainvar, path_list_flag, path_list_backup);
+ BLI_bpath_list_free(path_list_backup);
+ }
+
if (err) {
BKE_report(reports, RPT_ERROR, strerror(errno));
remove(tempname);
@@ -3070,10 +3106,10 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
/* file save to temporary file was successful */
/* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */
- if (write_flags & G_FILE_HISTORY) {
+ if (write_flags & G_FILE_HISTORY) {
int err_hist = do_history(filepath, reports);
if (err_hist) {
- BKE_report(reports, RPT_ERROR, "Version backup failed. File saved with @");
+ BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)");
return 0;
}
}
@@ -3090,23 +3126,23 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
if (0==ret) {
/* now rename to real file name, and delete temp @ file too */
if (BLI_rename(gzname, filepath) != 0) {
- BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @.");
+ BKE_report(reports, RPT_ERROR, "Cannot change old file (file saved with @)");
return 0;
}
BLI_delete(tempname, 0, 0);
}
else if (-1==ret) {
- BKE_report(reports, RPT_ERROR, "Failed opening .gz file.");
+ BKE_report(reports, RPT_ERROR, "Failed opening .gz file");
return 0;
}
else if (-2==ret) {
- BKE_report(reports, RPT_ERROR, "Failed opening .blend file for compression.");
+ BKE_report(reports, RPT_ERROR, "Failed opening .blend file for compression");
return 0;
}
}
else if (BLI_rename(tempname, filepath) != 0) {
- BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @");
+ BKE_report(reports, RPT_ERROR, "Cannot change old file (file saved with @)");
return 0;
}
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 4bce7a6ff51..d7858ebbc0d 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 31746 2010-09-04 05:31:25Z joeedh $
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
@@ -26,10 +25,13 @@
set(INC
.
+ ../blenfont
../blenkernel
../blenlib
../makesdna
../../../intern/guardedalloc
+ ../../../extern/bullet2/src
+ ../../../intern/opennl/extern
)
set(INC_SYS
@@ -52,9 +54,13 @@ set(SRC
operators/bmo_mirror.c
operators/bmo_primitive.c
operators/bmo_removedoubles.c
+ operators/bmo_similar.c
+ operators/bmo_smooth_laplacian.c
+ operators/bmo_symmetrize.c
operators/bmo_subdivide.c
operators/bmo_subdivide.h
operators/bmo_triangulate.c
+ operators/bmo_unsubdivide.c
operators/bmo_utils.c
operators/bmo_wireframe.c
@@ -62,6 +68,10 @@ set(SRC
intern/bmesh_construct.h
intern/bmesh_core.c
intern/bmesh_core.h
+ intern/bmesh_decimate_collapse.c
+ intern/bmesh_decimate_dissolve.c
+ intern/bmesh_decimate_unsubdivide.c
+ intern/bmesh_decimate.h
intern/bmesh_inline.h
intern/bmesh_interp.c
intern/bmesh_interp.h
@@ -108,4 +118,12 @@ if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif()
+if(WITH_BULLET)
+ add_definitions(-DWITH_BULLET)
+endif()
+
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
blender_add_lib(bf_bmesh "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/bmesh/SConscript b/source/blender/bmesh/SConscript
index fb00aef4d78..6765d57cb3e 100644
--- a/source/blender/bmesh/SConscript
+++ b/source/blender/bmesh/SConscript
@@ -9,11 +9,20 @@ sources += env.Glob('tools/*.c')
incs = [
'./',
+ '../blenfont',
'../blenlib',
'../makesdna',
'../blenkernel',
'#/intern/guardedalloc',
- ]
+ '#/extern/bullet2/src',
+ '#/intern/opennl/extern', ]
defs = []
+
+if env['WITH_BF_BULLET']:
+ defs.append('WITH_BULLET')
+
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
+
env.BlenderLib ( libname = 'bf_bmesh', sources = sources, includes = Split(incs), libtype = ['core','player'], defines=defs, priority=[100, 100], compileflags=cflags )
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index 955b1a729c5..a672ec0b6a7 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -252,6 +252,7 @@ extern "C" {
#include "intern/bmesh_construct.h"
#include "intern/bmesh_core.h"
+#include "intern/bmesh_decimate.h"
#include "intern/bmesh_interp.h"
#include "intern/bmesh_iterators.h"
#include "intern/bmesh_marking.h"
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 3bd99b748f6..cff7da78ef2 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -225,9 +225,8 @@ enum {
BM_ELEM_DRAW = (1 << 5), /* edge display */
- /* we have 1 spare flag which is awesome but since we're limited to 8
- * only add new flags with care! - campbell */
- /* BM_ELEM_SPARE = (1 << 6), */
+ /* spare tag, assumed dirty, use define in each function to name based on use */
+ // _BM_ELEM_TAG_ALT = (1 << 6), // UNUSED
BM_ELEM_INTERNAL_TAG = (1 << 7) /* for low level internal API tagging,
* since tools may want to tag verts and
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index bc121303046..eae78c6cc25 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -397,11 +397,11 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n
/* more of a weight then a distance */
far_cross_dist = (/* first we want to have a value close to zero mapped to 1 */
- 1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) *
+ 1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) *
- /* second we multiply by the distance
- * so points close to the center are not preferred */
- far_cross_dist);
+ /* second we multiply by the distance
+ * so points close to the center are not preferred */
+ far_cross_dist);
if (far_cross_dist > far_cross_best || far_cross == NULL) {
far_cross = vert_arr[i]->co;
@@ -725,6 +725,7 @@ static void bm_vert_attrs_copy(BMesh *source_mesh, BMesh *target_mesh,
const BMVert *source_vertex, BMVert *target_vertex)
{
if ((source_mesh == target_mesh) && (source_vertex == target_vertex)) {
+ BLI_assert(!"BMVert: source and targer match");
return;
}
copy_v3_v3(target_vertex->no, source_vertex->no);
@@ -737,6 +738,7 @@ static void bm_edge_attrs_copy(BMesh *source_mesh, BMesh *target_mesh,
const BMEdge *source_edge, BMEdge *target_edge)
{
if ((source_mesh == target_mesh) && (source_edge == target_edge)) {
+ BLI_assert(!"BMEdge: source and targer match");
return;
}
CustomData_bmesh_free_block(&target_mesh->edata, &target_edge->head.data);
@@ -748,6 +750,7 @@ static void bm_loop_attrs_copy(BMesh *source_mesh, BMesh *target_mesh,
const BMLoop *source_loop, BMLoop *target_loop)
{
if ((source_mesh == target_mesh) && (source_loop == target_loop)) {
+ BLI_assert(!"BMLoop: source and targer match");
return;
}
CustomData_bmesh_free_block(&target_mesh->ldata, &target_loop->head.data);
@@ -759,6 +762,7 @@ static void bm_face_attrs_copy(BMesh *source_mesh, BMesh *target_mesh,
const BMFace *source_face, BMFace *target_face)
{
if ((source_mesh == target_mesh) && (source_face == target_face)) {
+ BLI_assert(!"BMFace: source and targer match");
return;
}
copy_v3_v3(target_face->no, source_face->no);
@@ -781,8 +785,10 @@ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *sour
BLI_assert(sheader->htype == theader->htype);
- if (sheader->htype != theader->htype)
+ if (sheader->htype != theader->htype) {
+ BLI_assert(!"type mismatch");
return;
+ }
/* First we copy select */
if (BM_elem_flag_test((BMElem *)sheader, BM_ELEM_SELECT)) {
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index d50c94d5e6a..0910dd82701 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -28,12 +28,13 @@
#include "MEM_guardedalloc.h"
#include "BLI_math_vector.h"
-
-#include "BKE_DerivedMesh.h"
-
#include "BLI_listbase.h"
#include "BLI_array.h"
+#include "BLF_translation.h"
+
+#include "BKE_DerivedMesh.h"
+
#include "bmesh.h"
#include "intern/bmesh_private.h"
@@ -810,7 +811,7 @@ static int bm_loop_reverse_loop(BMesh *bm, BMFace *f
int bmesh_loop_reverse(BMesh *bm, BMFace *f)
{
#ifdef USE_BMESH_HOLES
- return bmesh_loop_reverse_loop(bm, f, f->loops.first);
+ return bm_loop_reverse_loop(bm, f, f->loops.first);
#else
return bm_loop_reverse_loop(bm, f);
#endif
@@ -960,7 +961,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
int rlen = count_flagged_radial(bm, l_iter, _FLAG_JF);
if (rlen > 2) {
- err = "Input faces do not form a contiguous manifold region";
+ err = N_("Input faces do not form a contiguous manifold region");
goto error;
}
else if (rlen == 1) {
@@ -1023,7 +1024,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE);
if (UNLIKELY(!newf || BMO_error_occurred(bm))) {
if (!BMO_error_occurred(bm))
- err = "Invalid boundary region to join faces";
+ err = N_("Invalid boundary region to join faces");
goto error;
}
@@ -1143,6 +1144,8 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
/**
* \brief Split Face Make Edge (SFME)
*
+ * \warning this is a low level function, most likely you want to use #BM_face_split()
+ *
* Takes as input two vertices in a single face. An edge is created which divides the original face
* into two distinct regions. One of the regions is assigned to the original face and it is closed off.
* The second region has a new face assigned to it.
@@ -1186,13 +1189,15 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
{
#ifdef USE_BMESH_HOLES
BMLoopList *lst, *lst2;
+#else
+ int first_loop_f1;
#endif
BMFace *f2;
BMLoop *l_iter, *l_first;
BMLoop *v1loop = NULL, *v2loop = NULL, *f1loop = NULL, *f2loop = NULL;
BMEdge *e;
- int i, len, f1len, f2len, first_loop_f1;
+ int i, len, f1len, f2len;
/* verify that v1 and v2 are in face */
len = f->len;
@@ -1603,10 +1608,10 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_dou
BMESH_ASSERT(edok != FALSE);
}
- /* deallocate edg */
+ /* deallocate edge */
bm_kill_only_edge(bm, ke);
- /* deallocate verte */
+ /* deallocate vertex */
bm_kill_only_vert(bm, kv);
/* Validate disk cycle lengths of ov, tv are unchanged */
@@ -1615,7 +1620,7 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_dou
edok = bmesh_disk_validate(valence2, tv->e, tv);
BMESH_ASSERT(edok != FALSE);
- /* Validate loop cycle of all faces attached to oe */
+ /* Validate loop cycle of all faces attached to 'oe' */
for (i = 0, l = oe->l; i < radlen; i++, l = l->radial_next) {
BMESH_ASSERT(l->e == oe);
edok = bmesh_verts_in_edge(l->v, l->next->v, oe);
@@ -1796,8 +1801,12 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
* Merges two verts into one (\a v into \a vtarget).
*
* \return Success
+ *
+ * \warning This does't work for collapsing edges,
+ * where \a v and \a vtarget are connected by an edge
+ * (assert checks for this case).
*/
-int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget)
+int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target)
{
BMEdge *e;
@@ -1805,26 +1814,29 @@ int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget)
int i, loops_tot;
/* verts already spliced */
- if (v == vtarget) {
+ if (v == v_target) {
return FALSE;
}
/* we can't modify the vert while iterating so first allocate an array of loops */
loops = BM_iter_as_arrayN(bm, BM_LOOPS_OF_VERT, v, &loops_tot);
- for (i = 0; i < loops_tot; i++) {
- loops[i]->v = vtarget;
+ if (loops) {
+ for (i = 0; i < loops_tot; i++) {
+ loops[i]->v = v_target;
+ }
+ MEM_freeN(loops);
}
- MEM_freeN(loops);
/* move all the edges from v's disk to vtarget's disk */
while ((e = v->e)) {
bmesh_disk_edge_remove(e, v);
- bmesh_edge_swapverts(e, v, vtarget);
- bmesh_disk_edge_append(e, vtarget);
+ bmesh_edge_swapverts(e, v, v_target);
+ bmesh_disk_edge_append(e, v_target);
+ BLI_assert(e->v1 != e->v2);
}
BM_CHECK_ELEMENT(v);
- BM_CHECK_ELEMENT(vtarget);
+ BM_CHECK_ELEMENT(v_target);
/* v is unused now, and can be killed */
BM_vert_kill(bm, v);
@@ -1990,27 +2002,32 @@ int BM_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len,
*
* \note Edges must already have the same vertices.
*/
-int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget)
+int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *e_target)
{
BMLoop *l;
- if (!BM_vert_in_edge(e, etarget->v1) || !BM_vert_in_edge(e, etarget->v2)) {
+ if (!BM_vert_in_edge(e, e_target->v1) || !BM_vert_in_edge(e, e_target->v2)) {
/* not the same vertices can't splice */
+
+ /* the caller should really make sure this doesn't happen ever
+ * so assert on release builds */
+ BLI_assert(0);
+
return FALSE;
}
while (e->l) {
l = e->l;
- BLI_assert(BM_vert_in_edge(etarget, l->v));
- BLI_assert(BM_vert_in_edge(etarget, l->next->v));
+ BLI_assert(BM_vert_in_edge(e_target, l->v));
+ BLI_assert(BM_vert_in_edge(e_target, l->next->v));
bmesh_radial_loop_remove(l, e);
- bmesh_radial_append(etarget, l);
+ bmesh_radial_append(e_target, l);
}
BLI_assert(bmesh_radial_length(e->l) == 0);
BM_CHECK_ELEMENT(e);
- BM_CHECK_ELEMENT(etarget);
+ BM_CHECK_ELEMENT(e_target);
/* removes from disks too */
BM_edge_kill(bm, e);
diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h
index 491287993df..0667ed9ea1c 100644
--- a/source/blender/bmesh/intern/bmesh_core.h
+++ b/source/blender/bmesh/intern/bmesh_core.h
@@ -41,8 +41,8 @@ void BM_edge_kill(BMesh *bm, BMEdge *e);
void BM_vert_kill(BMesh *bm, BMVert *v);
int bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep);
-int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget);
-int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget);
+int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *e_target);
+int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target);
int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len);
diff --git a/source/blender/bmesh/intern/bmesh_decimate.h b/source/blender/bmesh/intern/bmesh_decimate.h
new file mode 100644
index 00000000000..04dc0cfd2ea
--- /dev/null
+++ b/source/blender/bmesh/intern/bmesh_decimate.h
@@ -0,0 +1,41 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BMESH_DECIMATE_H__
+#define __BMESH_DECIMATE_H__
+
+/** \file blender/bmesh/intern/bmesh_decimate.h
+ * \ingroup bmesh
+ */
+
+void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate);
+
+void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const int tag_only);
+void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations);
+
+void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries,
+ BMVert **vinput_arr, const int vinput_len,
+ BMEdge **einput_arr, const int einput_len);
+void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries);
+
+
+#endif /* __BMESH_DECIMATE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/intern/bmesh_decimate_collapse.c
new file mode 100644
index 00000000000..74792d1d558
--- /dev/null
+++ b/source/blender/bmesh/intern/bmesh_decimate_collapse.c
@@ -0,0 +1,1044 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/intern/bmesh_decimate_collapse.c
+ * \ingroup bmesh
+ *
+ * BMesh decimator that uses an edge collapse method.
+ */
+
+#include <stddef.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+
+#include "BLI_math.h"
+#include "BLI_quadric.h"
+#include "BLI_heap.h"
+
+#include "BKE_customdata.h"
+
+#include "bmesh.h"
+#include "bmesh_structure.h"
+#include "bmesh_decimate.h" /* own include */
+
+/* defines for testing */
+#define USE_CUSTOMDATA
+#define USE_TRIANGULATE
+#define USE_VERT_NORMAL_INTERP /* has the advantage that flipped faces don't mess up vertex normals */
+
+/* these checks are for rare cases that we can't avoid since they are valid meshes still */
+#define USE_SAFETY_CHECKS
+
+#define BOUNDARY_PRESERVE_WEIGHT 100.0f
+#define OPTIMIZE_EPS 0.01f /* FLT_EPSILON is too small, see [#33106] */
+#define COST_INVALID FLT_MAX
+
+typedef enum CD_UseFlag {
+ CD_DO_VERT = (1 << 0),
+ CD_DO_EDGE = (1 << 1),
+ CD_DO_LOOP = (1 << 2)
+} CD_UseFlag;
+
+
+/* BMesh Helper Functions
+ * ********************** */
+
+/**
+ * \param vquadrics must be calloc'd
+ */
+static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics)
+{
+ BMIter iter;
+ BMFace *f;
+ BMEdge *e;
+
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ BMLoop *l_first;
+ BMLoop *l_iter;
+
+ const float *co = BM_FACE_FIRST_LOOP(f)->v->co;
+ const float *no = f->no;
+ const float offset = -dot_v3v3(no, co);
+ Quadric q;
+
+ BLI_quadric_from_v3_dist(&q, no, offset);
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(l_iter->v)], &q);
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+
+ /* boundary edges */
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (UNLIKELY(BM_edge_is_boundary(e))) {
+ float edge_vector[3];
+ float edge_cross[3];
+ sub_v3_v3v3(edge_vector, e->v2->co, e->v1->co);
+ f = e->l->f;
+ cross_v3_v3v3(edge_cross, edge_vector, f->no);
+
+ if (normalize_v3(edge_cross) > FLT_EPSILON) {
+ Quadric q;
+ BLI_quadric_from_v3_dist(&q, edge_cross, -dot_v3v3(edge_cross, e->v1->co));
+ BLI_quadric_mul(&q, BOUNDARY_PRESERVE_WEIGHT);
+
+ BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v1)], &q);
+ BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v2)], &q);
+ }
+ }
+ }
+}
+
+
+static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3],
+ const Quadric *vquadrics)
+{
+ /* compute an edge contration target for edge 'e'
+ * this is computed by summing it's vertices quadrics and
+ * optimizing the result. */
+ Quadric q;
+
+ BLI_quadric_add_qu_ququ(&q,
+ &vquadrics[BM_elem_index_get(e->v1)],
+ &vquadrics[BM_elem_index_get(e->v2)]);
+
+
+ if (BLI_quadric_optimize(&q, optimize_co, OPTIMIZE_EPS)) {
+ return; /* all is good */
+ }
+ else {
+ mid_v3_v3v3(optimize_co, e->v1->co, e->v2->co);
+ }
+}
+
+static int bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_co[3])
+{
+ BMIter liter;
+ BMLoop *l;
+ unsigned int i;
+
+ for (i = 0; i < 2; i++) {
+ /* loop over both verts */
+ BMVert *v = *((&e->v1) + i);
+
+ BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
+ if (l->e != e && l->prev->e != e) {
+ float *co_prev = l->prev->v->co;
+ float *co_next = l->next->v->co;
+ float cross_exist[3];
+ float cross_optim[3];
+
+#if 1
+ float vec_other[3]; /* line between the two outer verts, re-use for both cross products */
+ float vec_exist[3]; /* before collapse */
+ float vec_optim[3]; /* after collapse */
+
+ sub_v3_v3v3(vec_other, co_prev, co_next);
+ sub_v3_v3v3(vec_exist, co_prev, v->co);
+ sub_v3_v3v3(vec_optim, co_prev, optimize_co);
+
+ cross_v3_v3v3(cross_exist, vec_other, vec_exist);
+ cross_v3_v3v3(cross_optim, vec_other, vec_optim);
+
+ /* normalize isn't really needed, but ensures the value at a unit we can compare against */
+ normalize_v3(cross_exist);
+ normalize_v3(cross_optim);
+#else
+ normal_tri_v3(cross_exist, v->co, co_prev, co_next);
+ normal_tri_v3(cross_optim, optimize_co, co_prev, co_next);
+#endif
+
+ /* use a small value rather then zero so we don't flip a face in multiple steps
+ * (first making it zero area, then flipping again)*/
+ if (dot_v3v3(cross_exist, cross_optim) <= FLT_EPSILON) {
+ //printf("no flip\n");
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+static void bm_decim_build_edge_cost_single(BMEdge *e,
+ const Quadric *vquadrics, const float *vweights,
+ Heap *eheap, HeapNode **eheap_table)
+{
+ const Quadric *q1, *q2;
+ float optimize_co[3];
+ float cost;
+
+ if (eheap_table[BM_elem_index_get(e)]) {
+ BLI_heap_remove(eheap, eheap_table[BM_elem_index_get(e)]);
+ }
+
+ /* check we can collapse, some edges we better not touch */
+ if (BM_edge_is_boundary(e)) {
+ if (e->l->f->len == 3) {
+ /* pass */
+ }
+ else {
+ /* only collapse tri's */
+ eheap_table[BM_elem_index_get(e)] = NULL;
+ return;
+ }
+ }
+ else if (BM_edge_is_manifold(e)) {
+ if ((e->l->f->len == 3) && (e->l->radial_next->f->len == 3)) {
+ /* pass */
+ }
+ else {
+ /* only collapse tri's */
+ eheap_table[BM_elem_index_get(e)] = NULL;
+ return;
+ }
+ }
+ else {
+ eheap_table[BM_elem_index_get(e)] = NULL;
+ return;
+ }
+
+ if (vweights) {
+ if ((vweights[BM_elem_index_get(e->v1)] < FLT_EPSILON) &&
+ (vweights[BM_elem_index_get(e->v2)] < FLT_EPSILON))
+ {
+ /* skip collapsing this edge */
+ eheap_table[BM_elem_index_get(e)] = NULL;
+ return;
+ }
+ }
+ /* end sanity check */
+
+
+ bm_decim_calc_target_co(e, optimize_co, vquadrics);
+
+ q1 = &vquadrics[BM_elem_index_get(e->v1)];
+ q2 = &vquadrics[BM_elem_index_get(e->v2)];
+
+ if (vweights == NULL) {
+ cost = (BLI_quadric_evaluate(q1, optimize_co) +
+ BLI_quadric_evaluate(q2, optimize_co));
+ }
+ else {
+ cost = ((BLI_quadric_evaluate(q1, optimize_co) * vweights[BM_elem_index_get(e->v1)]) +
+ (BLI_quadric_evaluate(q2, optimize_co) * vweights[BM_elem_index_get(e->v2)]));
+ }
+ // print("COST %.12f\n");
+
+ eheap_table[BM_elem_index_get(e)] = BLI_heap_insert(eheap, cost, e);
+}
+
+
+/* use this for degenerate cases - add back to the heap with an invalid cost,
+ * this way it may be calculated again if surrounding geometry changes */
+static void bm_decim_invalid_edge_cost_single(BMEdge *e,
+ Heap *eheap, HeapNode **eheap_table)
+{
+ BLI_assert(eheap_table[BM_elem_index_get(e)] == NULL);
+ eheap_table[BM_elem_index_get(e)] = BLI_heap_insert(eheap, COST_INVALID, e);
+}
+
+static void bm_decim_build_edge_cost(BMesh *bm,
+ const Quadric *vquadrics, const float *vweights,
+ Heap *eheap, HeapNode **eheap_table)
+{
+ BMIter iter;
+ BMEdge *e;
+ unsigned int i;
+
+ BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
+ eheap_table[i] = NULL; /* keep sanity check happy */
+ bm_decim_build_edge_cost_single(e, vquadrics, vweights, eheap, eheap_table);
+ }
+}
+
+#ifdef USE_TRIANGULATE
+/* Temp Triangulation
+ * ****************** */
+
+/**
+ * To keep things simple we can only collapse edges on triangulated data
+ * (limitation with edge collapse and error calculation functions).
+ *
+ * But to avoid annoying users by only giving triangle results, we can
+ * triangulate, keeping a reference between the faces, then join after
+ * if the edges don't collapse, this will also allow more choices when
+ * collapsing edges so even has some advantage over decimating quads
+ * directly.
+ *
+ * \return TRUE if any faces were triangulated.
+ */
+
+static int bm_decim_triangulate_begin(BMesh *bm)
+{
+ BMIter iter;
+ BMFace *f;
+ // int has_quad; // could optimize this a little
+ int has_cut = FALSE;
+
+ BLI_assert((bm->elem_index_dirty & BM_VERT) == 0);
+
+ /* first clear loop index values */
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ BMLoop *l_iter;
+ BMLoop *l_first;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ BM_elem_index_set(l_iter, -1);
+ } while ((l_iter = l_iter->next) != l_first);
+
+ // has_quad |= (f->len == 4)
+ }
+
+ /* adding new faces as we loop over faces
+ * is normally best avoided, however in this case its not so bad because any face touched twice
+ * will already be triangulated*/
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (f->len == 4) {
+ BMLoop *f_l[4];
+ BMLoop *l_a, *l_b;
+
+ {
+ BMLoop *l_iter = BM_FACE_FIRST_LOOP(f);
+
+ f_l[0] = l_iter; l_iter = l_iter->next;
+ f_l[1] = l_iter; l_iter = l_iter->next;
+ f_l[2] = l_iter; l_iter = l_iter->next;
+ f_l[3] = l_iter;
+ }
+
+ if (len_squared_v3v3(f_l[0]->v->co, f_l[2]->v->co) <
+ len_squared_v3v3(f_l[1]->v->co, f_l[3]->v->co))
+ {
+ l_a = f_l[0];
+ l_b = f_l[2];
+ }
+ else {
+ l_a = f_l[1];
+ l_b = f_l[3];
+ }
+
+#ifdef USE_SAFETY_CHECKS
+ if (BM_edge_exists(l_a->v, l_b->v) == FALSE)
+#endif
+ {
+ BMFace *f_new;
+ BMLoop *l_new;
+
+ /* warning, NO_DOUBLE option here isn't handled as nice as it could be
+ * - if there is a quad that has a free standing edge joining it along
+ * where we want to split the face, there isnt a good way we can handle this.
+ * currently that edge will get removed when joining the tris back into a quad. */
+ f_new = BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE);
+
+ if (f_new) {
+ /* the value of this doesn't matter, only that the 2 loops match and have unique values */
+ const int f_index = BM_elem_index_get(f);
+
+ /* since we just split theres only ever 2 loops */
+ BLI_assert(BM_edge_is_manifold(l_new->e));
+
+ BM_elem_index_set(l_new, f_index);
+ BM_elem_index_set(l_new->radial_next, f_index);
+
+ BM_face_normal_update(f);
+ BM_face_normal_update(f_new);
+
+ has_cut = TRUE;
+ }
+ }
+ }
+ }
+
+ BLI_assert((bm->elem_index_dirty & BM_VERT) == 0);
+
+ if (has_cut) {
+ /* now triangulation is done we need to correct index values */
+ BM_mesh_elem_index_ensure(bm, BM_EDGE | BM_FACE);
+ }
+
+ return has_cut;
+}
+
+static void bm_decim_triangulate_end(BMesh *bm)
+{
+ /* decimation finished, now re-join */
+ BMIter iter;
+ BMEdge *e;
+
+ /* boundary edges */
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ BMLoop *l_a, *l_b;
+ if (BM_edge_loop_pair(e, &l_a, &l_b)) {
+ const int l_a_index = BM_elem_index_get(l_a);
+ if (l_a_index != -1) {
+ const int l_b_index = BM_elem_index_get(l_b);
+ if (l_a_index == l_b_index) {
+ if (LIKELY(l_a->f->len == 3 && l_b->f->len == 3)) {
+ if (l_a->v != l_b->v) { /* if this is the case, faces have become flipped */
+ /* check we are not making a degenerate quad */
+ BMVert *vquad[4] = {
+ e->v1,
+ BM_vert_in_edge(e, l_a->next->v) ? l_a->prev->v : l_a->next->v,
+ e->v2,
+ BM_vert_in_edge(e, l_b->next->v) ? l_b->prev->v : l_b->next->v,
+ };
+
+ BLI_assert(ELEM3(vquad[0], vquad[1], vquad[2], vquad[3]) == FALSE);
+ BLI_assert(ELEM3(vquad[1], vquad[0], vquad[2], vquad[3]) == FALSE);
+ BLI_assert(ELEM3(vquad[2], vquad[1], vquad[0], vquad[3]) == FALSE);
+ BLI_assert(ELEM3(vquad[3], vquad[1], vquad[2], vquad[0]) == FALSE);
+
+ if (is_quad_convex_v3(vquad[0]->co, vquad[1]->co, vquad[2]->co, vquad[3]->co)) {
+ /* highly unlikely to fail, but prevents possible double-ups */
+ BMFace *f[2] = {l_a->f, l_b->f};
+ BM_faces_join(bm, f, 2, TRUE);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+#endif /* USE_TRIANGULATE */
+
+/* Edge Collapse Functions
+ * *********************** */
+
+#ifdef USE_CUSTOMDATA
+
+/**
+ * \param v is the target to merge into.
+ */
+static void bm_edge_collapse_loop_customdata(BMesh *bm, BMLoop *l, BMVert *v_clear, BMVert *v_other,
+ const float customdata_fac)
+{
+ /* these don't need to be updated, since they will get removed when the edge collapses */
+ BMLoop *l_clear, *l_other;
+ const int is_manifold = BM_edge_is_manifold(l->e);
+ int side;
+
+ /* l defines the vert to collapse into */
+
+ /* first find the loop of 'v_other' thats attached to the face of 'l' */
+ if (l->v == v_clear) {
+ l_clear = l;
+ l_other = l->next;
+ }
+ else {
+ l_clear = l->next;
+ l_other = l;
+ }
+
+ BLI_assert(l_clear->v == v_clear);
+ BLI_assert(l_other->v == v_other);
+ (void)v_other; /* quiet warnings for release */
+
+ /* now we have both corners of the face 'l->f' */
+ for (side = 0; side < 2; side++) {
+ int is_seam = FALSE;
+ void *src[2];
+ BMFace *f_exit = is_manifold ? l->radial_next->f : NULL;
+ BMEdge *e_prev = l->e;
+ BMLoop *l_first;
+ BMLoop *l_iter;
+ float w[2];
+
+ if (side == 0) {
+ l_iter = l_first = l_clear;
+ src[0] = l_clear->head.data;
+ src[1] = l_other->head.data;
+
+ w[0] = customdata_fac;
+ w[1] = 1.0f - customdata_fac;
+ }
+ else {
+ l_iter = l_first = l_other;
+ src[0] = l_other->head.data;
+ src[1] = l_clear->head.data;
+
+ w[0] = 1.0f - customdata_fac;
+ w[1] = customdata_fac;
+ }
+
+ // print_v2("weights", w);
+
+ /* WATCH IT! - should NOT reference (_clear or _other) vars for this while loop */
+
+ /* walk around the fan using 'e_prev' */
+ while (((l_iter = BM_vert_step_fan_loop(l_iter, &e_prev)) != l_first) && (l_iter != NULL)) {
+ int i;
+ /* quit once we hit the opposite face, if we have one */
+ if (f_exit && UNLIKELY(f_exit == l_iter->f)) {
+ break;
+ }
+
+ /* break out unless we find a match */
+ is_seam = TRUE;
+
+ /* ok. we have a loop. now be smart with it! */
+ for (i = 0; i < bm->ldata.totlayer; i++) {
+ if (CustomData_layer_has_math(&bm->ldata, i)) {
+ const int offset = bm->ldata.layers[i].offset;
+ const int type = bm->ldata.layers[i].type;
+ void *cd_src, *cd_iter;
+
+ /* todo, make nicer macros for this */
+ cd_src = (char *)src[0] + offset;
+ // cd_dst = (char *)src[1] + offset; // UNUSED
+ cd_iter = (char *)l_iter->head.data + offset;
+
+ /* detect seams */
+ if (CustomData_data_equals(type, cd_src, cd_iter)) {
+ CustomData_bmesh_interp(&bm->ldata, src, w, NULL, 2, l_iter->head.data);
+ is_seam = FALSE;
+ }
+ }
+ }
+
+ if (is_seam) {
+ break;
+ }
+ }
+ }
+}
+#endif /* USE_CUSTOMDATA */
+
+/**
+ * Check if the collapse will result in a degenerate mesh,
+ * that is - duplicate edges or faces.
+ *
+ * This situation could be checked for when calculating collapse cost
+ * however its quite slow and a degenerate collapse could eventuate
+ * after the cost is calculated, so instead, check just before collapsing.
+ */
+
+static void bm_edge_tag_enable(BMEdge *e)
+{
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
+ if (e->l) {
+ BM_elem_flag_enable(e->l->f, BM_ELEM_TAG);
+ if (e->l != e->l->radial_next) {
+ BM_elem_flag_enable(e->l->radial_next->f, BM_ELEM_TAG);
+ }
+ }
+}
+
+static void bm_edge_tag_disable(BMEdge *e)
+{
+ BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_disable(e->v2, BM_ELEM_TAG);
+ if (e->l) {
+ BM_elem_flag_disable(e->l->f, BM_ELEM_TAG);
+ if (e->l != e->l->radial_next) {
+ BM_elem_flag_disable(e->l->radial_next->f, BM_ELEM_TAG);
+ }
+ }
+}
+
+static int bm_edge_tag_test(BMEdge *e)
+{
+ /* is the edge or one of its faces tagged? */
+ return (BM_elem_flag_test(e->v1, BM_ELEM_TAG) ||
+ BM_elem_flag_test(e->v2, BM_ELEM_TAG) ||
+ (e->l && (BM_elem_flag_test(e->l->f, BM_ELEM_TAG) ||
+ (e->l != e->l->radial_next &&
+ BM_elem_flag_test(e->l->radial_next->f, BM_ELEM_TAG))))
+ );
+}
+
+/* takes the edges loop */
+BLI_INLINE int bm_edge_is_manifold_or_boundary(BMLoop *l)
+{
+#if 0
+ /* less optimized version of check below */
+ return (BM_edge_is_manifold(l->e) || BM_edge_is_boundary(l->e);
+#else
+ /* if the edge is a boundary it points to its self, else this must be a manifold */
+ return LIKELY(l) && LIKELY(l->radial_next->radial_next == l);
+#endif
+}
+
+static int bm_edge_collapse_is_degenerate_topology(BMEdge *e_first)
+{
+ /* simply check that there is no overlap between faces and edges of each vert,
+ * (excluding the 2 faces attached to 'e' and 'e' its self) */
+
+ BMEdge *e_iter;
+
+ /* clear flags on both disks */
+ e_iter = e_first;
+ do {
+ if (!bm_edge_is_manifold_or_boundary(e_iter->l)) {
+ return TRUE;
+ }
+ bm_edge_tag_disable(e_iter);
+ } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v1)) != e_first);
+
+ e_iter = e_first;
+ do {
+ if (!bm_edge_is_manifold_or_boundary(e_iter->l)) {
+ return TRUE;
+ }
+ bm_edge_tag_disable(e_iter);
+ } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v2)) != e_first);
+
+ /* now enable one side... */
+ e_iter = e_first;
+ do {
+ bm_edge_tag_enable(e_iter);
+ } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v1)) != e_first);
+
+ /* ... except for the edge we will collapse, we know thats shared,
+ * disable this to avoid false positive. We could be smart and never enable these
+ * face/edge tags in the first place but easier to do this */
+ // bm_edge_tag_disable(e_first);
+ /* do inline... */
+ {
+#if 0
+ BMIter iter;
+ BMIter liter;
+ BMLoop *l;
+ BMVert *v;
+ BM_ITER_ELEM (l, &liter, e_first, BM_LOOPS_OF_EDGE) {
+ BM_elem_flag_disable(l->f, BM_ELEM_TAG);
+ BM_ITER_ELEM (v, &iter, l->f, BM_VERTS_OF_FACE) {
+ BM_elem_flag_disable(v, BM_ELEM_TAG);
+ }
+ }
+#else
+ /* we know each face is a triangle, no looping/iterators needed here */
+
+ BMLoop *l_radial;
+ BMLoop *l_face;
+
+ l_radial = e_first->l;
+ l_face = l_radial;
+ BLI_assert(l_face->f->len == 3);
+ BM_elem_flag_disable(l_face->f, BM_ELEM_TAG);
+ BM_elem_flag_disable((l_face = l_radial)->v, BM_ELEM_TAG);
+ BM_elem_flag_disable((l_face = l_face->next)->v, BM_ELEM_TAG);
+ BM_elem_flag_disable(( l_face->next)->v, BM_ELEM_TAG);
+ l_face = l_radial->radial_next;
+ if (l_radial != l_face) {
+ BLI_assert(l_face->f->len == 3);
+ BM_elem_flag_disable(l_face->f, BM_ELEM_TAG);
+ BM_elem_flag_disable((l_face = l_radial->radial_next)->v, BM_ELEM_TAG);
+ BM_elem_flag_disable((l_face = l_face->next)->v, BM_ELEM_TAG);
+ BM_elem_flag_disable(( l_face->next)->v, BM_ELEM_TAG);
+ }
+#endif
+ }
+
+ /* and check for overlap */
+ e_iter = e_first;
+ do {
+ if (bm_edge_tag_test(e_iter)) {
+ return TRUE;
+ }
+ } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v2)) != e_first);
+
+ return FALSE;
+}
+
+/**
+ * special, highly limited edge collapse function
+ * intended for speed over flexibiliy.
+ * can only collapse edges connected to (1, 2) tris.
+ *
+ * Important - dont add vert/edge/face data on collapsing!
+ *
+ * \param e_clear_other let caller know what edges we remove besides \a e_clear
+ * \param customdata_flag merge factor, scales from 0 - 1 ('v_clear' -> 'v_other')
+ */
+static int bm_edge_collapse(BMesh *bm, BMEdge *e_clear, BMVert *v_clear, int r_e_clear_other[2],
+#ifdef USE_CUSTOMDATA
+ const CD_UseFlag customdata_flag,
+ const float customdata_fac
+#else
+ const CD_UseFlag UNUSED(customdata_flag),
+ const float UNUSED(customdata_fac)
+#endif
+ )
+{
+ BMVert *v_other;
+
+ v_other = BM_edge_other_vert(e_clear, v_clear);
+ BLI_assert(v_other != NULL);
+
+ if (BM_edge_is_manifold(e_clear)) {
+ BMLoop *l_a, *l_b;
+ BMEdge *e_a_other[2], *e_b_other[2];
+ int ok;
+
+ ok = BM_edge_loop_pair(e_clear, &l_a, &l_b);
+
+ BLI_assert(ok == TRUE);
+ BLI_assert(l_a->f->len == 3);
+ BLI_assert(l_b->f->len == 3);
+
+ /* keep 'v_clear' 0th */
+ if (BM_vert_in_edge(l_a->prev->e, v_clear)) {
+ e_a_other[0] = l_a->prev->e;
+ e_a_other[1] = l_a->next->e;
+ }
+ else {
+ e_a_other[1] = l_a->prev->e;
+ e_a_other[0] = l_a->next->e;
+ }
+
+ if (BM_vert_in_edge(l_b->prev->e, v_clear)) {
+ e_b_other[0] = l_b->prev->e;
+ e_b_other[1] = l_b->next->e;
+ }
+ else {
+ e_b_other[1] = l_b->prev->e;
+ e_b_other[0] = l_b->next->e;
+ }
+
+ BLI_assert(BM_edge_share_vert(e_a_other[0], e_b_other[0]));
+ BLI_assert(BM_edge_share_vert(e_a_other[1], e_b_other[1]));
+
+ /* we could assert this case, but better just bail out */
+#if 0
+ BLI_assert(e_a_other[0] != e_b_other[0]);
+ BLI_assert(e_a_other[0] != e_b_other[1]);
+ BLI_assert(e_b_other[0] != e_a_other[0]);
+ BLI_assert(e_b_other[0] != e_a_other[1]);
+#endif
+ /* not totally common but we want to avoid */
+ if (ELEM(e_a_other[0], e_b_other[0], e_b_other[1]) ||
+ ELEM(e_a_other[1], e_b_other[0], e_b_other[1]))
+ {
+ return FALSE;
+ }
+
+ r_e_clear_other[0] = BM_elem_index_get(e_a_other[0]);
+ r_e_clear_other[1] = BM_elem_index_get(e_b_other[0]);
+
+#ifdef USE_CUSTOMDATA
+ /* before killing, do customdata */
+ if (customdata_flag & CD_DO_VERT) {
+ BM_data_interp_from_verts(bm, v_other, v_clear, v_other, customdata_fac);
+ }
+ if (customdata_flag & CD_DO_EDGE) {
+ BM_data_interp_from_edges(bm, e_a_other[1], e_a_other[0], e_a_other[1], customdata_fac);
+ BM_data_interp_from_edges(bm, e_b_other[1], e_b_other[0], e_b_other[1], customdata_fac);
+ }
+ if (customdata_flag & CD_DO_LOOP) {
+ bm_edge_collapse_loop_customdata(bm, e_clear->l, v_clear, v_other, customdata_fac);
+ bm_edge_collapse_loop_customdata(bm, e_clear->l->radial_next, v_clear, v_other, customdata_fac);
+ }
+#endif
+
+ BM_edge_kill(bm, e_clear);
+
+ v_other->head.hflag |= v_clear->head.hflag;
+ BM_vert_splice(bm, v_clear, v_other);
+
+ e_a_other[1]->head.hflag |= e_a_other[0]->head.hflag;
+ e_b_other[1]->head.hflag |= e_b_other[0]->head.hflag;
+ BM_edge_splice(bm, e_a_other[0], e_a_other[1]);
+ BM_edge_splice(bm, e_b_other[0], e_b_other[1]);
+
+ // BM_mesh_validate(bm);
+
+ return TRUE;
+ }
+ else if (BM_edge_is_boundary(e_clear)) {
+ /* same as above but only one triangle */
+ BMLoop *l_a;
+ BMEdge *e_a_other[2];
+
+ l_a = e_clear->l;
+
+ BLI_assert(l_a->f->len == 3);
+
+ /* keep 'v_clear' 0th */
+ if (BM_vert_in_edge(l_a->prev->e, v_clear)) {
+ e_a_other[0] = l_a->prev->e;
+ e_a_other[1] = l_a->next->e;
+ }
+ else {
+ e_a_other[1] = l_a->prev->e;
+ e_a_other[0] = l_a->next->e;
+ }
+
+ r_e_clear_other[0] = BM_elem_index_get(e_a_other[0]);
+ r_e_clear_other[1] = -1;
+
+#ifdef USE_CUSTOMDATA
+ /* before killing, do customdata */
+ if (customdata_flag & CD_DO_VERT) {
+ BM_data_interp_from_verts(bm, v_other, v_clear, v_other, customdata_fac);
+ }
+ if (customdata_flag & CD_DO_EDGE) {
+ BM_data_interp_from_edges(bm, e_a_other[1], e_a_other[0], e_a_other[1], customdata_fac);
+ }
+ if (customdata_flag & CD_DO_LOOP) {
+ bm_edge_collapse_loop_customdata(bm, e_clear->l, v_clear, v_other, customdata_fac);
+ }
+#endif
+
+ BM_edge_kill(bm, e_clear);
+
+ v_other->head.hflag |= v_clear->head.hflag;
+ BM_vert_splice(bm, v_clear, v_other);
+
+ e_a_other[1]->head.hflag |= e_a_other[0]->head.hflag;
+ BM_edge_splice(bm, e_a_other[0], e_a_other[1]);
+
+ // BM_mesh_validate(bm);
+
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+
+/* collapse e the edge, removing e->v2 */
+static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e,
+ Quadric *vquadrics, float *vweights,
+ Heap *eheap, HeapNode **eheap_table,
+ const CD_UseFlag customdata_flag)
+{
+ int e_clear_other[2];
+ BMVert *v_other = e->v1;
+ int v_clear_index = BM_elem_index_get(e->v2); /* the vert is removed so only store the index */
+ float optimize_co[3];
+ float customdata_fac;
+
+#ifdef USE_VERT_NORMAL_INTERP
+ float v_clear_no[3];
+ copy_v3_v3(v_clear_no, e->v2->no);
+#endif
+
+ /* disallow collapsing which results in degenerate cases */
+ if (UNLIKELY(bm_edge_collapse_is_degenerate_topology(e))) {
+ bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); /* add back with a high cost */
+ return;
+ }
+
+ bm_decim_calc_target_co(e, optimize_co, vquadrics);
+
+ /* check if this would result in an overlapping face */
+ if (UNLIKELY(bm_edge_collapse_is_degenerate_flip(e, optimize_co))) {
+ bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); /* add back with a high cost */
+ return;
+ }
+
+ /* use for customdata merging */
+ if (LIKELY(compare_v3v3(e->v1->co, e->v2->co, FLT_EPSILON) == FALSE)) {
+ customdata_fac = line_point_factor_v3(optimize_co, e->v1->co, e->v2->co);
+#if 0
+ /* simple test for stupid collapse */
+ if (customdata_fac < 0.0 - FLT_EPSILON || customdata_fac > 1.0f + FLT_EPSILON) {
+ return;
+ }
+#endif
+ }
+ else {
+ /* avoid divide by zero */
+ customdata_fac = 0.5f;
+ }
+
+ if (bm_edge_collapse(bm, e, e->v2, e_clear_other, customdata_flag, customdata_fac)) {
+ /* update collapse info */
+ int i;
+
+ if (vweights) {
+ const int fac = CLAMPIS(customdata_fac, 0.0f, 1.0f);
+ vweights[BM_elem_index_get(v_other)] = (vweights[v_clear_index] * (1.0f - fac)) +
+ (vweights[BM_elem_index_get(v_other)] * fac);
+ }
+
+ e = NULL; /* paranoid safety check */
+
+ copy_v3_v3(v_other->co, optimize_co);
+
+ /* remove eheap */
+ for (i = 0; i < 2; i++) {
+ /* highly unlikely 'eheap_table[ke_other[i]]' would be NULL, but do for sanity sake */
+ if ((e_clear_other[i] != -1) && (eheap_table[e_clear_other[i]] != NULL)) {
+ BLI_heap_remove(eheap, eheap_table[e_clear_other[i]]);
+ eheap_table[e_clear_other[i]] = NULL;
+ }
+ }
+
+ /* update vertex quadric, add kept vertex from killed vertex */
+ BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(v_other)], &vquadrics[v_clear_index]);
+
+ /* update connected normals */
+
+ /* in fact face normals are not used for progressive updates, no need to update them */
+ // BM_vert_normal_update_all(v);
+#ifdef USE_VERT_NORMAL_INTERP
+ interp_v3_v3v3(v_other->no, v_other->no, v_clear_no, customdata_fac);
+ normalize_v3(v_other->no);
+#else
+ BM_vert_normal_update(v_other);
+#endif
+
+
+ /* update error costs and the eheap */
+ if (LIKELY(v_other->e)) {
+ BMEdge *e_iter;
+ BMEdge *e_first;
+ e_iter = e_first = v_other->e;
+ do {
+ BLI_assert(BM_edge_find_double(e_iter) == NULL);
+ bm_decim_build_edge_cost_single(e_iter, vquadrics, vweights, eheap, eheap_table);
+ } while ((e_iter = bmesh_disk_edge_next(e_iter, v_other)) != e_first);
+ }
+
+ /* this block used to be disabled,
+ * but enable now since surrounding faces may have been
+ * set to COST_INVALID because of a face overlap that no longer occurs */
+#if 1
+ /* optional, update edges around the vertex face fan */
+ {
+ BMIter liter;
+ BMLoop *l;
+ 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))
+ e_outer = l->next->e;
+ else
+ e_outer = l->prev->e;
+
+ BLI_assert(BM_vert_in_edge(e_outer, l->v) == FALSE);
+
+ bm_decim_build_edge_cost_single(e_outer, vquadrics, vweights, eheap, eheap_table);
+ }
+ }
+ }
+ /* end optional update */
+#endif
+ }
+ else {
+ /* add back with a high cost */
+ bm_decim_invalid_edge_cost_single(e, eheap, eheap_table);
+ }
+}
+
+
+/* Main Decimate Function
+ * ********************** */
+
+/**
+ * \brief BM_mesh_decimate
+ * \param bm The mesh
+ * \param factor face count multiplier [0 - 1]
+ * \param vertex_weights Optional array of vertex aligned weights [0 - 1],
+ * a vertex group is the usual source for this.
+ */
+void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate)
+{
+ Heap *eheap; /* edge heap */
+ HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */
+ Quadric *vquadrics; /* vert index aligned quadrics */
+ int tot_edge_orig;
+ int face_tot_target;
+ int use_triangulate;
+
+ CD_UseFlag customdata_flag = 0;
+
+#ifdef USE_TRIANGULATE
+ /* temp convert quads to triangles */
+ use_triangulate = bm_decim_triangulate_begin(bm);
+#endif
+
+
+ /* alloc vars */
+ vquadrics = MEM_callocN(sizeof(Quadric) * bm->totvert, __func__);
+ /* since some edges may be degenerate, we might be over allocing a little here */
+ eheap = BLI_heap_new_ex(bm->totedge);
+ eheap_table = MEM_callocN(sizeof(HeapNode *) * bm->totedge, __func__);
+ tot_edge_orig = bm->totedge;
+
+
+ /* build initial edge collapse cost data */
+ bm_decim_build_quadrics(bm, vquadrics);
+
+ bm_decim_build_edge_cost(bm, vquadrics, vweights, eheap, eheap_table);
+
+ face_tot_target = bm->totface * factor;
+ bm->elem_index_dirty |= BM_FACE | BM_EDGE | BM_VERT;
+
+
+#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;
+#endif
+
+ /* iterative edge collapse and maintain the eheap */
+ while ((bm->totface > face_tot_target) &&
+ (BLI_heap_is_empty(eheap) == FALSE) &&
+ (BLI_heap_node_value(BLI_heap_top(eheap)) != COST_INVALID))
+ {
+ // const float value = BLI_heap_node_value(BLI_heap_top(eheap));
+ BMEdge *e = BLI_heap_popmin(eheap);
+ BLI_assert(BM_elem_index_get(e) < tot_edge_orig); /* handy to detect corruptions elsewhere */
+
+ // printf("COST %.10f\n", value);
+
+ /* under normal conditions wont be accessed again,
+ * but NULL just incase so we don't use freed node */
+ eheap_table[BM_elem_index_get(e)] = NULL;
+
+ bm_decim_edge_collapse(bm, e, vquadrics, vweights, eheap, eheap_table, customdata_flag);
+ }
+
+
+#ifdef USE_TRIANGULATE
+ if (do_triangulate == FALSE) {
+ /* its possible we only had triangles, skip this step in that case */
+ if (LIKELY(use_triangulate)) {
+ /* temp convert quads to triangles */
+ bm_decim_triangulate_end(bm);
+ }
+ }
+#endif
+
+ /* free vars */
+ MEM_freeN(vquadrics);
+ MEM_freeN(eheap_table);
+ BLI_heap_free(eheap, NULL);
+
+ /* testing only */
+ // BM_mesh_validate(bm);
+
+ (void)tot_edge_orig; /* quiet release build warning */
+}
diff --git a/source/blender/bmesh/intern/bmesh_decimate_dissolve.c b/source/blender/bmesh/intern/bmesh_decimate_dissolve.c
new file mode 100644
index 00000000000..d1371a18160
--- /dev/null
+++ b/source/blender/bmesh/intern/bmesh_decimate_dissolve.c
@@ -0,0 +1,243 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/intern/bmesh_decimate_dissolve.c
+ * \ingroup bmesh
+ *
+ * BMesh decimator that dissolves flat areas into polygons (ngons).
+ */
+
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "bmesh.h"
+#include "bmesh_decimate.h" /* own include */
+
+#define UNIT_TO_ANGLE DEG2RADF(90.0f)
+#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE)
+
+/* multiply vertex edge angle by face angle
+ * this means we are not left with sharp corners between _almost_ planer faces
+ * convert angles [0-PI/2] -> [0-1], multiply together, then convert back to radians. */
+static float bm_vert_edge_face_angle(BMVert *v)
+{
+ const float angle = BM_vert_calc_edge_angle(v);
+ /* note: could be either edge, it doesn't matter */
+ if (v->e && BM_edge_is_manifold(v->e)) {
+ return ((angle * ANGLE_TO_UNIT) * (BM_edge_calc_face_angle(v->e) * ANGLE_TO_UNIT)) * UNIT_TO_ANGLE;
+ }
+ else {
+ return angle;
+ }
+}
+
+#undef UNIT_TO_ANGLE
+#undef ANGLE_TO_UNIT
+
+typedef struct DissolveElemWeight {
+ BMHeader *ele;
+ float weight;
+} DissolveElemWeight;
+
+static int dissolve_elem_cmp(const void *a1, const void *a2)
+{
+ const struct DissolveElemWeight *d1 = a1, *d2 = a2;
+
+ if (d1->weight > d2->weight) return 1;
+ else if (d1->weight < d2->weight) return -1;
+ return 0;
+}
+
+/**
+ * \param do_all_verts Collapse all verts between 2 faces - don't check their edge angle.
+ */
+void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries,
+ BMVert **vinput_arr, const int vinput_len,
+ BMEdge **einput_arr, const int einput_len)
+{
+ const float angle_max = (float)M_PI / 2.0f;
+ DissolveElemWeight *weight_elems = MEM_mallocN(max_ii(einput_len, vinput_len) *
+ sizeof(DissolveElemWeight), __func__);
+ int i, tot_found;
+
+ BMIter iter;
+ BMEdge *e_iter;
+ BMEdge **earray;
+
+ int *vert_reverse_lookup;
+
+ /* --- first edges --- */
+
+ /* wire -> tag */
+ BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) {
+ BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter));
+ }
+
+ /* go through and split edge */
+ for (i = 0, tot_found = 0; i < einput_len; i++) {
+ BMEdge *e = einput_arr[i];
+ const float angle = BM_edge_calc_face_angle(e);
+
+ if (angle < angle_limit) {
+ tot_found++;
+ }
+ weight_elems[i].ele = (BMHeader *)e;
+ weight_elems[i].weight = angle;
+ }
+
+ if (tot_found != 0) {
+ qsort(weight_elems, einput_len, sizeof(DissolveElemWeight), dissolve_elem_cmp);
+
+ for (i = 0; i < tot_found; i++) {
+ BMEdge *e = (BMEdge *)weight_elems[i].ele;
+
+ if (/* may have become non-manifold */
+ BM_edge_is_manifold(e) &&
+ /* check twice because cumulative effect could dissolve over angle limit */
+ (BM_edge_calc_face_angle(e) < angle_limit))
+ {
+ BMFace *nf = BM_faces_join_pair(bm, e->l->f,
+ e->l->radial_next->f,
+ e,
+ FALSE); /* join faces */
+
+ /* there may be some errors, we don't mind, just move on */
+ if (nf) {
+ BM_face_normal_update(nf);
+ }
+ else {
+ BMO_error_clear(bm);
+ }
+ }
+ }
+ }
+
+ /* prepare for cleanup */
+ BM_mesh_elem_index_ensure(bm, BM_VERT);
+ vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__);
+ fill_vn_i(vert_reverse_lookup, bm->totvert, -1);
+ for (i = 0, tot_found = 0; i < vinput_len; i++) {
+ BMVert *v = vinput_arr[i];
+ vert_reverse_lookup[BM_elem_index_get(v)] = i;
+ }
+
+ /* --- cleanup --- */
+ earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__);
+ BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
+ earray[i] = e_iter;
+ }
+ /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */
+ for (i = bm->totedge - 1; i != -1; i--) {
+ e_iter = earray[i];
+
+ if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) {
+ /* edge has become wire */
+ int vidx_reverse;
+ BMVert *v1 = e_iter->v1;
+ BMVert *v2 = e_iter->v2;
+ 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;
+ 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;
+ BM_vert_kill(bm, v2);
+ }
+ }
+ }
+ MEM_freeN(vert_reverse_lookup);
+
+ MEM_freeN(earray);
+
+
+ /* --- second verts --- */
+ if (do_dissolve_boundaries) {
+ /* simple version of the branch below, sincve we will dissolve _all_ verts that use 2 edges */
+ for (i = 0; i < vinput_len; i++) {
+ BMVert *v = vinput_arr[i];
+ if (LIKELY(v != NULL) &&
+ BM_vert_edge_count(v) == 2)
+ {
+ BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */
+ }
+ }
+ }
+ else {
+ for (i = 0, tot_found = 0; i < vinput_len; i++) {
+ BMVert *v = vinput_arr[i];
+ const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit;
+
+ if (angle < angle_limit) {
+ weight_elems[i].ele = (BMHeader *)v;
+ weight_elems[i].weight = angle;
+ tot_found++;
+ }
+ else {
+ weight_elems[i].ele = NULL;
+ weight_elems[i].weight = angle_max;
+ }
+ }
+
+ if (tot_found != 0) {
+ qsort(weight_elems, vinput_len, sizeof(DissolveElemWeight), dissolve_elem_cmp);
+
+ for (i = 0; i < tot_found; i++) {
+ BMVert *v = (BMVert *)weight_elems[i].ele;
+ if (LIKELY(v != NULL) &&
+ /* topology changes may cause this to be un-collapsable */
+ (BM_vert_edge_count(v) == 2) &&
+ /* check twice because cumulative effect could dissolve over angle limit */
+ bm_vert_edge_face_angle(v) < angle_limit)
+ {
+ BMEdge *ne = BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */
+
+ if (ne && ne->l) {
+ BM_edge_normals_update(ne);
+ }
+ }
+ }
+ }
+ }
+
+ MEM_freeN(weight_elems);
+}
+
+void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries)
+{
+ int vinput_len;
+ int einput_len;
+
+ BMVert **vinput_arr = BM_iter_as_arrayN(bm, BM_VERTS_OF_MESH, NULL, &vinput_len);
+ BMEdge **einput_arr = BM_iter_as_arrayN(bm, BM_EDGES_OF_MESH, NULL, &einput_len);
+
+ BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
+ vinput_arr, vinput_len,
+ einput_arr, einput_len);
+
+ MEM_freeN(vinput_arr);
+ MEM_freeN(einput_arr);
+}
diff --git a/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c
new file mode 100644
index 00000000000..1ec13010d80
--- /dev/null
+++ b/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c
@@ -0,0 +1,344 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/intern/bmesh_decimate_unsubdivide.c
+ * \ingroup bmesh
+ *
+ * BMesh decimator that uses a grid un-subdivide method.
+ */
+
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "bmesh.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+
+static int bm_vert_dissolve_fan_test(BMVert *v)
+{
+ /* check if we should walk over these verts */
+ BMIter iter;
+ BMEdge *e;
+
+ unsigned int tot_edge = 0;
+ unsigned int tot_edge_boundary = 0;
+ unsigned int tot_edge_manifold = 0;
+ unsigned int tot_edge_wire = 0;
+
+ BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
+ if (BM_edge_is_boundary(e)) {
+ tot_edge_boundary++;
+ }
+ else if (BM_edge_is_manifold(e)) {
+ tot_edge_manifold++;
+ }
+ else if (BM_edge_is_wire(e)) {
+ tot_edge_wire++;
+ }
+ tot_edge++;
+ }
+
+ if ((tot_edge == 4) && (tot_edge_boundary == 0) && (tot_edge_manifold == 4)) {
+ return TRUE;
+ }
+ else if ((tot_edge == 3) && (tot_edge_boundary == 0) && (tot_edge_manifold == 3)) {
+ return TRUE;
+ }
+ else if ((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1)) {
+ return TRUE;
+ }
+ else if ((tot_edge == 2) && (tot_edge_wire == 2)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static int bm_vert_dissolve_fan(BMesh *bm, BMVert *v)
+{
+ /* collapse under 2 conditions.
+ * - vert connects to 4 manifold edges (and 4 faces).
+ * - vert connecrs to 1 manifold edge, 2 boundary edges (and 2 faces).
+ *
+ * This covers boundary verts of a quad grid and center verts.
+ * note that surrounding faces dont have to be quads.
+ */
+
+ BMIter iter;
+ BMEdge *e;
+
+ unsigned int tot_loop = 0;
+ unsigned int tot_edge = 0;
+ unsigned int tot_edge_boundary = 0;
+ unsigned int tot_edge_manifold = 0;
+ unsigned int tot_edge_wire = 0;
+
+ BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
+ if (BM_edge_is_boundary(e)) {
+ tot_edge_boundary++;
+ }
+ else if (BM_edge_is_manifold(e)) {
+ tot_edge_manifold++;
+ }
+ else if (BM_edge_is_wire(e)) {
+ tot_edge_wire++;
+ }
+ tot_edge++;
+ }
+
+ if (tot_edge == 2) {
+ /* check for 2 wire verts only */
+ if (tot_edge_wire == 2) {
+ return (BM_vert_collapse_edge(bm, v->e, v, TRUE) != NULL);
+ }
+ }
+ else if (tot_edge == 4) {
+ /* check for 4 faces surrounding */
+ if (tot_edge_boundary == 0 && tot_edge_manifold == 4) {
+ /* good to go! */
+ tot_loop = 4;
+ }
+ }
+ else if (tot_edge == 3) {
+ /* check for 2 faces surrounding at a boundary */
+ if (tot_edge_boundary == 2 && tot_edge_manifold == 1) {
+ /* good to go! */
+ tot_loop = 2;
+ }
+ else if (tot_edge_boundary == 0 && tot_edge_manifold == 3) {
+ /* good to go! */
+ tot_loop = 3;
+ }
+ }
+
+ if (tot_loop) {
+ BMLoop *f_loop[4];
+ unsigned int i;
+
+ /* ensure there are exactly tot_loop loops */
+ BLI_assert(BM_iter_at_index(bm, BM_LOOPS_OF_VERT, v, tot_loop) == NULL);
+ BM_iter_as_array(bm, BM_LOOPS_OF_VERT, v, (void **)f_loop, tot_loop);
+
+ for (i = 0; i < tot_loop; i++) {
+ BMLoop *l = f_loop[i];
+ if (l->f->len > 3) {
+ BMLoop *l_new;
+ BLI_assert(l->prev->v != l->next->v);
+ BM_face_split(bm, l->f, l->prev->v, l->next->v, &l_new, NULL, TRUE);
+ BM_elem_flag_merge_into(l_new->e, l->e, l->prev->e);
+ }
+ }
+
+ return BM_vert_dissolve(bm, v);
+ }
+
+ return FALSE;
+}
+
+enum {
+ VERT_INDEX_DO_COLLAPSE = -1,
+ VERT_INDEX_INIT = 0,
+ VERT_INDEX_IGNORE = 1
+};
+
+// #define USE_WALKER /* gives uneven results, disable for now */
+
+/* - BMVert.flag & BM_ELEM_TAG: shows we touched this vert
+ * - BMVert.index == -1: shows we will remove this vert
+ */
+
+/**
+ * \param tag_only so we can call this from an operator */
+void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const int tag_only)
+{
+#ifdef USE_WALKER
+# define ELE_VERT_TAG 1
+#else
+ BMVert **vert_seek_a = MEM_mallocN(sizeof(BMVert *) * bm->totvert, __func__);
+ BMVert **vert_seek_b = MEM_mallocN(sizeof(BMVert *) * bm->totvert, __func__);
+ unsigned vert_seek_a_tot = 0;
+ unsigned vert_seek_b_tot = 0;
+#endif
+
+ BMVert *v;
+ BMIter iter;
+
+ const unsigned int offset = 0;
+ const unsigned int nth = 2;
+
+ int iter_step;
+
+ /* if tag_only is set, we assyme the caller knows what verts to tag
+ * needed for the operator */
+ if (tag_only == FALSE) {
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
+ }
+ }
+
+ for (iter_step = 0; iter_step < iterations; iter_step++) {
+ int iter_done;
+
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG) && bm_vert_dissolve_fan_test(v)) {
+#ifdef USE_WALKER
+ BMO_elem_flag_enable(bm, v, ELE_VERT_TAG);
+#endif
+ BM_elem_index_set(v, VERT_INDEX_INIT); /* set_dirty! */
+ }
+ else {
+ BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */
+ }
+ }
+ /* done with selecting tagged verts */
+
+
+ /* main loop, keep tagging until we can't tag any more islands */
+ while (TRUE) {
+#ifdef USE_WALKER
+ BMWalker walker;
+#else
+ unsigned int depth = 1;
+ unsigned int i;
+#endif
+ BMVert *v_first = NULL;
+ BMVert *v;
+
+ /* we could avoid iterating from the start each time */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (v->e && (BM_elem_index_get(v) == VERT_INDEX_INIT)) {
+#ifdef USE_WALKER
+ if (BMO_elem_flag_test(bm, v, ELE_VERT_TAG))
+#endif
+ {
+ /* check again incase the topology changed */
+ if (bm_vert_dissolve_fan_test(v)) {
+ v_first = v;
+ }
+ break;
+ }
+ }
+ }
+ if (v_first == NULL) {
+ break;
+ }
+
+#ifdef USE_WALKER
+ /* Walk over selected elements starting at active */
+ BMW_init(&walker, bm, BMW_CONNECTED_VERTEX,
+ ELE_VERT_TAG, BMW_MASK_NOP, BMW_MASK_NOP,
+ BMW_FLAG_NOP, /* don't use BMW_FLAG_TEST_HIDDEN here since we want to desel all */
+ BMW_NIL_LAY);
+
+ BLI_assert(walker.order == BMW_BREADTH_FIRST);
+ for (v = BMW_begin(&walker, v_first); v != NULL; v = BMW_step(&walker)) {
+ /* Deselect elements that aren't at "nth" depth from active */
+ if (BM_elem_index_get(v) == VERT_INDEX_INIT) {
+ if ((offset + BMW_current_depth(&walker)) % nth) {
+ /* tag for removal */
+ BM_elem_index_set(v, VERT_INDEX_DO_COLLAPSE); /* set_dirty! */
+ }
+ else {
+ /* works better to allow these verts to be checked again */
+ //BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */
+ }
+ }
+ }
+ BMW_end(&walker);
+#else
+
+ BM_elem_index_set(v_first, (offset + depth) % nth ? VERT_INDEX_IGNORE : VERT_INDEX_DO_COLLAPSE); /* set_dirty! */
+
+ vert_seek_b_tot = 0;
+ vert_seek_b[vert_seek_b_tot++] = v_first;
+
+ while (TRUE) {
+ BMEdge *e;
+
+ if ((offset + depth) % nth) {
+ vert_seek_a_tot = 0;
+ for (i = 0; i < vert_seek_b_tot; i++) {
+ v = vert_seek_b[i];
+ BLI_assert(BM_elem_index_get(v) == VERT_INDEX_IGNORE);
+ BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
+ BMVert *v_other = BM_edge_other_vert(e, v);
+ if (BM_elem_index_get(v_other) == VERT_INDEX_INIT) {
+ BM_elem_index_set(v_other, VERT_INDEX_DO_COLLAPSE); /* set_dirty! */
+ vert_seek_a[vert_seek_a_tot++] = v_other;
+ }
+ }
+ }
+ if (vert_seek_a_tot == 0) {
+ break;
+ }
+ }
+ else {
+ vert_seek_b_tot = 0;
+ for (i = 0; i < vert_seek_a_tot; i++) {
+ v = vert_seek_a[i];
+ BLI_assert(BM_elem_index_get(v) == VERT_INDEX_DO_COLLAPSE);
+ BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
+ BMVert *v_other = BM_edge_other_vert(e, v);
+ if (BM_elem_index_get(v_other) == VERT_INDEX_INIT) {
+ BM_elem_index_set(v_other, VERT_INDEX_IGNORE); /* set_dirty! */
+ vert_seek_b[vert_seek_b_tot++] = v_other;
+ }
+ }
+ }
+ if (vert_seek_b_tot == 0) {
+ break;
+ }
+ }
+
+ depth++;
+ }
+#endif /* USE_WALKER */
+
+ }
+
+ /* now we tagged all verts -1 for removal, lets loop over and rebuild faces */
+ iter_done = FALSE;
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_index_get(v) == VERT_INDEX_DO_COLLAPSE) {
+ iter_done |= bm_vert_dissolve_fan(bm, v);
+ }
+ }
+
+ if (iter_done == FALSE) {
+ break;
+ }
+ }
+
+ bm->elem_index_dirty |= BM_VERT;
+
+#ifndef USE_WALKER
+ MEM_freeN(vert_seek_a);
+ MEM_freeN(vert_seek_b);
+#endif
+}
+
+void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations)
+{
+ BM_mesh_decimate_unsubdivide_ex(bm, iterations, FALSE);
+}
diff --git a/source/blender/bmesh/intern/bmesh_inline.h b/source/blender/bmesh/intern/bmesh_inline.h
index 400f4a55b0e..04b214f725a 100644
--- a/source/blender/bmesh/intern/bmesh_inline.h
+++ b/source/blender/bmesh/intern/bmesh_inline.h
@@ -37,6 +37,7 @@
#define BM_elem_flag_set( ele, hflag, val) _bm_elem_flag_set (&(ele)->head, hflag, val)
#define BM_elem_flag_toggle( ele, hflag) _bm_elem_flag_toggle (&(ele)->head, hflag)
#define BM_elem_flag_merge( ele_a, ele_b) _bm_elem_flag_merge (&(ele_a)->head, &(ele_b)->head)
+#define BM_elem_flag_merge_into(ele, ele_a, ele_b)_bm_elem_flag_merge_into (&(ele)->head, &(ele_a)->head, &(ele_b)->head)
BLI_INLINE char _bm_elem_flag_test(const BMHeader *head, const char hflag)
{
@@ -74,6 +75,11 @@ BLI_INLINE void _bm_elem_flag_merge(BMHeader *head_a, BMHeader *head_b)
head_a->hflag = head_b->hflag = head_a->hflag | head_b->hflag;
}
+BLI_INLINE void _bm_elem_flag_merge_into(BMHeader *head, const BMHeader *head_a, const BMHeader *head_b)
+{
+ head->hflag = head_a->hflag | head_b->hflag;
+}
+
/**
* notes on #BM_elem_index_set(...) usage,
* Set index is sometimes abused as temp storage, other times we cant be
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 12fcd51c069..508b3b8fcdf 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -224,10 +224,8 @@ static int compute_mdisp_quad(BMLoop *l, float v1[3], float v2[3], float v3[3],
/* computer center */
BM_face_calc_center_mean(l->f, cent);
- add_v3_v3v3(p, l->prev->v->co, l->v->co);
- mul_v3_fl(p, 0.5);
- add_v3_v3v3(n, l->next->v->co, l->v->co);
- mul_v3_fl(n, 0.5);
+ mid_v3_v3v3(p, l->prev->v->co, l->v->co);
+ mid_v3_v3v3(n, l->next->v->co, l->v->co);
copy_v3_v3(v1, cent);
copy_v3_v3(v2, p);
@@ -257,7 +255,7 @@ static float quad_coord(float aa[3], float bb[3], float cc[3], float dd[3], int
f1 = fabsf(f1);
f2 = fabsf(f2);
- f1 = minf(f1, f2);
+ f1 = min_ff(f1, f2);
CLAMP(f1, 0.0f, 1.0f + FLT_EPSILON);
}
else {
@@ -345,9 +343,9 @@ static int mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, float
float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3];
float eps = FLT_EPSILON * 4000;
- if (len_v3(l->v->no) == 0.0f)
+ if (is_zero_v3(l->v->no))
BM_vert_normal_update_all(l->v);
- if (len_v3(tl->v->no) == 0.0f)
+ if (is_zero_v3(tl->v->no))
BM_vert_normal_update_all(tl->v);
compute_mdisp_quad(tl, v1, v2, v3, v4, e1, e2);
@@ -490,7 +488,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
}
/**
- * smoothes boundaries between multires grids,
+ * smooths boundaries between multires grids,
* including some borders in adjacent faces
*/
void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
@@ -525,8 +523,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
sides = (int)sqrt(mdp->totdisp);
for (y = 0; y < sides; y++) {
- add_v3_v3v3(co1, mdn->disps[y * sides], mdl->disps[y]);
- mul_v3_fl(co1, 0.5);
+ mid_v3_v3v3(co1, mdn->disps[y * sides], mdl->disps[y]);
copy_v3_v3(mdn->disps[y * sides], co1);
copy_v3_v3(mdl->disps[y], co1);
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index 726127fdcad..1cb95d94e9b 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -120,6 +120,21 @@ void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len)
{
BMIter iter;
+ /* we can't rely on coun't being set */
+ switch (itype) {
+ case BM_VERTS_OF_MESH:
+ iter.count = bm->totvert;
+ break;
+ case BM_EDGES_OF_MESH:
+ iter.count = bm->totedge;
+ break;
+ case BM_FACES_OF_MESH:
+ iter.count = bm->totface;
+ break;
+ default:
+ break;
+ }
+
if (BM_iter_init(&iter, bm, itype, data) && iter.count > 0) {
BMElem *ele;
BMElem **array = MEM_mallocN(sizeof(ele) * iter.count, __func__);
@@ -190,10 +205,10 @@ int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const
*/
static void init_iterator(BMIter *iter)
{
- iter->firstvert = iter->nextvert = NULL;
- iter->firstedge = iter->nextedge = NULL;
- iter->firstloop = iter->nextloop = NULL;
- iter->firstpoly = iter->nextpoly = NULL;
+// iter->v_first = iter->v_next = NULL; // UNUSED
+ iter->e_first = iter->e_next = NULL;
+ iter->l_first = iter->l_next = NULL;
+// iter->f_first = iter->f_next = NULL; // UNUSED
iter->ldata = NULL;
}
@@ -229,6 +244,7 @@ void *bmiter__vert_of_mesh_step(BMIter *iter)
void bmiter__edge_of_mesh_begin(BMIter *iter)
{
BLI_mempool_iternew(iter->bm->epool, &iter->pooliter);
+ iter->count = iter->bm->totedge; /* */
}
void *bmiter__edge_of_mesh_step(BMIter *iter)
@@ -256,19 +272,19 @@ void bmiter__edge_of_vert_begin(BMIter *iter)
{
init_iterator(iter);
if (iter->vdata->e) {
- iter->firstedge = iter->vdata->e;
- iter->nextedge = iter->vdata->e;
+ iter->e_first = iter->vdata->e;
+ iter->e_next = iter->vdata->e;
}
}
void *bmiter__edge_of_vert_step(BMIter *iter)
{
- BMEdge *current = iter->nextedge;
+ BMEdge *current = iter->e_next;
- if (iter->nextedge)
- iter->nextedge = bmesh_disk_edge_next(iter->nextedge, iter->vdata);
+ if (iter->e_next)
+ iter->e_next = bmesh_disk_edge_next(iter->e_next, iter->vdata);
- if (iter->nextedge == iter->firstedge) iter->nextedge = NULL;
+ if (iter->e_next == iter->e_first) iter->e_next = NULL;
return current;
}
@@ -284,27 +300,27 @@ void bmiter__face_of_vert_begin(BMIter *iter)
if (iter->vdata->e)
iter->count = bmesh_disk_facevert_count(iter->vdata);
if (iter->count) {
- iter->firstedge = bmesh_disk_faceedge_find_first(iter->vdata->e, iter->vdata);
- iter->nextedge = iter->firstedge;
- iter->firstloop = bmesh_radial_faceloop_find_first(iter->firstedge->l, iter->vdata);
- iter->nextloop = iter->firstloop;
+ iter->e_first = bmesh_disk_faceedge_find_first(iter->vdata->e, iter->vdata);
+ iter->e_next = iter->e_first;
+ iter->l_first = bmesh_radial_faceloop_find_first(iter->e_first->l, iter->vdata);
+ iter->l_next = iter->l_first;
}
}
void *bmiter__face_of_vert_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->count && iter->nextloop) {
+ if (iter->count && iter->l_next) {
iter->count--;
- iter->nextloop = bmesh_radial_faceloop_find_next(iter->nextloop, iter->vdata);
- if (iter->nextloop == iter->firstloop) {
- iter->nextedge = bmesh_disk_faceedge_find_next(iter->nextedge, iter->vdata);
- iter->firstloop = bmesh_radial_faceloop_find_first(iter->nextedge->l, iter->vdata);
- iter->nextloop = iter->firstloop;
+ iter->l_next = bmesh_radial_faceloop_find_next(iter->l_next, iter->vdata);
+ if (iter->l_next == iter->l_first) {
+ iter->e_next = bmesh_disk_faceedge_find_next(iter->e_next, iter->vdata);
+ iter->l_first = bmesh_radial_faceloop_find_first(iter->e_next->l, iter->vdata);
+ iter->l_next = iter->l_first;
}
}
- if (!iter->count) iter->nextloop = NULL;
+ if (!iter->count) iter->l_next = NULL;
return current ? current->f : NULL;
}
@@ -322,27 +338,27 @@ void bmiter__loop_of_vert_begin(BMIter *iter)
if (iter->vdata->e)
iter->count = bmesh_disk_facevert_count(iter->vdata);
if (iter->count) {
- iter->firstedge = bmesh_disk_faceedge_find_first(iter->vdata->e, iter->vdata);
- iter->nextedge = iter->firstedge;
- iter->firstloop = bmesh_radial_faceloop_find_first(iter->firstedge->l, iter->vdata);
- iter->nextloop = iter->firstloop;
+ iter->e_first = bmesh_disk_faceedge_find_first(iter->vdata->e, iter->vdata);
+ iter->e_next = iter->e_first;
+ iter->l_first = bmesh_radial_faceloop_find_first(iter->e_first->l, iter->vdata);
+ iter->l_next = iter->l_first;
}
}
void *bmiter__loop_of_vert_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
if (iter->count) {
iter->count--;
- iter->nextloop = bmesh_radial_faceloop_find_next(iter->nextloop, iter->vdata);
- if (iter->nextloop == iter->firstloop) {
- iter->nextedge = bmesh_disk_faceedge_find_next(iter->nextedge, iter->vdata);
- iter->firstloop = bmesh_radial_faceloop_find_first(iter->nextedge->l, iter->vdata);
- iter->nextloop = iter->firstloop;
+ iter->l_next = bmesh_radial_faceloop_find_next(iter->l_next, iter->vdata);
+ if (iter->l_next == iter->l_first) {
+ iter->e_next = bmesh_disk_faceedge_find_next(iter->e_next, iter->vdata);
+ iter->l_first = bmesh_radial_faceloop_find_first(iter->e_next->l, iter->vdata);
+ iter->l_next = iter->l_first;
}
}
- if (!iter->count) iter->nextloop = NULL;
+ if (!iter->count) iter->l_next = NULL;
if (current) {
@@ -362,19 +378,19 @@ void bmiter__loops_of_edge_begin(BMIter *iter)
/* note sure why this sets ldata ... */
init_iterator(iter);
- iter->firstloop = iter->nextloop = l;
+ iter->l_first = iter->l_next = l;
}
void *bmiter__loops_of_edge_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->nextloop) {
- iter->nextloop = iter->nextloop->radial_next;
+ if (iter->l_next) {
+ iter->l_next = iter->l_next->radial_next;
}
- if (iter->nextloop == iter->firstloop) {
- iter->nextloop = NULL;
+ if (iter->l_next == iter->l_first) {
+ iter->l_next = NULL;
}
if (current) {
@@ -393,23 +409,23 @@ void bmiter__loops_of_loop_begin(BMIter *iter)
/* note sure why this sets ldata ... */
init_iterator(iter);
- iter->firstloop = l;
- iter->nextloop = iter->firstloop->radial_next;
+ iter->l_first = l;
+ iter->l_next = iter->l_first->radial_next;
- if (iter->nextloop == iter->firstloop)
- iter->nextloop = NULL;
+ if (iter->l_next == iter->l_first)
+ iter->l_next = NULL;
}
void *bmiter__loops_of_loop_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->nextloop) {
- iter->nextloop = iter->nextloop->radial_next;
+ if (iter->l_next) {
+ iter->l_next = iter->l_next->radial_next;
}
- if (iter->nextloop == iter->firstloop) {
- iter->nextloop = NULL;
+ if (iter->l_next == iter->l_first) {
+ iter->l_next = NULL;
}
if (current) {
@@ -428,20 +444,20 @@ void bmiter__face_of_edge_begin(BMIter *iter)
init_iterator(iter);
if (iter->edata->l) {
- iter->firstloop = iter->edata->l;
- iter->nextloop = iter->edata->l;
+ iter->l_first = iter->edata->l;
+ iter->l_next = iter->edata->l;
}
}
void *bmiter__face_of_edge_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->nextloop) {
- iter->nextloop = iter->nextloop->radial_next;
+ if (iter->l_next) {
+ iter->l_next = iter->l_next->radial_next;
}
- if (iter->nextloop == iter->firstloop) iter->nextloop = NULL;
+ if (iter->l_next == iter->l_first) iter->l_next = NULL;
return current ? current->f : NULL;
}
@@ -476,15 +492,15 @@ void *bmiter__vert_of_edge_step(BMIter *iter)
void bmiter__vert_of_face_begin(BMIter *iter)
{
init_iterator(iter);
- iter->firstloop = iter->nextloop = BM_FACE_FIRST_LOOP(iter->pdata);
+ iter->l_first = iter->l_next = BM_FACE_FIRST_LOOP(iter->pdata);
}
void *bmiter__vert_of_face_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->nextloop) iter->nextloop = iter->nextloop->next;
- if (iter->nextloop == iter->firstloop) iter->nextloop = NULL;
+ if (iter->l_next) iter->l_next = iter->l_next->next;
+ if (iter->l_next == iter->l_first) iter->l_next = NULL;
return current ? current->v : NULL;
}
@@ -496,15 +512,15 @@ void *bmiter__vert_of_face_step(BMIter *iter)
void bmiter__edge_of_face_begin(BMIter *iter)
{
init_iterator(iter);
- iter->firstloop = iter->nextloop = BM_FACE_FIRST_LOOP(iter->pdata);
+ iter->l_first = iter->l_next = BM_FACE_FIRST_LOOP(iter->pdata);
}
void *bmiter__edge_of_face_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->nextloop) iter->nextloop = iter->nextloop->next;
- if (iter->nextloop == iter->firstloop) iter->nextloop = NULL;
+ if (iter->l_next) iter->l_next = iter->l_next->next;
+ if (iter->l_next == iter->l_first) iter->l_next = NULL;
return current ? current->e : NULL;
}
@@ -516,15 +532,15 @@ void *bmiter__edge_of_face_step(BMIter *iter)
void bmiter__loop_of_face_begin(BMIter *iter)
{
init_iterator(iter);
- iter->firstloop = iter->nextloop = BM_FACE_FIRST_LOOP(iter->pdata);
+ iter->l_first = iter->l_next = BM_FACE_FIRST_LOOP(iter->pdata);
}
void *bmiter__loop_of_face_step(BMIter *iter)
{
- BMLoop *current = iter->nextloop;
+ BMLoop *current = iter->l_next;
- if (iter->nextloop) iter->nextloop = iter->nextloop->next;
- if (iter->nextloop == iter->firstloop) iter->nextloop = NULL;
+ if (iter->l_next) iter->l_next = iter->l_next->next;
+ if (iter->l_next == iter->l_first) iter->l_next = NULL;
return current;
}
diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h
index 8d0eeca31ed..3c42b3d610c 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.h
+++ b/source/blender/bmesh/intern/bmesh_iterators.h
@@ -95,23 +95,27 @@ extern const char bm_iter_itype_htype_map[BM_ITYPE_MAX];
for (ele = BM_iter_new(iter, NULL, itype, data), indexvar = 0; ele; ele = BM_iter_step(iter), (indexvar)++)
/* Iterator Structure */
+/* note: some of these vars are not used,
+ * so they have beem commented to save stack space since this struct is used all over */
typedef struct BMIter {
BLI_mempool_iter pooliter;
- BMVert *firstvert, *nextvert, *vdata;
- BMEdge *firstedge, *nextedge, *edata;
- BMLoop *firstloop, *nextloop, *ldata, *l;
- BMFace *firstpoly, *nextpoly, *pdata;
+ BMVert /* *v_first, *v_next, */ *vdata;
+ BMEdge *e_first, *e_next, *edata;
+ BMLoop *l_first, *l_next, *ldata;
+ BMFace /* *f_first, *f_next, */ *pdata;
BMesh *bm;
void (*begin)(struct BMIter *iter);
void *(*step)(struct BMIter *iter);
+ /*
union {
void *p;
int i;
long l;
float f;
} filter;
- int count;
+ */
+ int count; /* note, only some iterators set this, don't rely on it */
char itype;
} BMIter;
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index e4a838fe893..9af65d7dd7e 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -584,8 +584,7 @@ void BM_editselection_center(BMEditSelection *ese, float r_center[3])
}
else if (ese->htype == BM_EDGE) {
BMEdge *eed = (BMEdge *)ese->ele;
- add_v3_v3v3(r_center, eed->v1->co, eed->v2->co);
- mul_v3_fl(r_center, 0.5);
+ mid_v3_v3v3(r_center, eed->v1->co, eed->v2->co);
}
else if (ese->htype == BM_FACE) {
BMFace *efa = (BMFace *)ese->ele;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 0d072da5327..d3e3bcd3556 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -57,7 +57,7 @@ static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize)
bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER);
#ifdef USE_BMESH_HOLES
- bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE);
+ bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), 512, 512, 0);
#endif
/* allocate one flag pool that we don't get rid of. */
@@ -85,6 +85,11 @@ BMesh *BM_mesh_create(BMAllocTemplate *allocsize)
bm->stackdepth = 1;
bm->totflags = 1;
+ CustomData_reset(&bm->vdata);
+ CustomData_reset(&bm->edata);
+ CustomData_reset(&bm->ldata);
+ CustomData_reset(&bm->pdata);
+
return bm;
}
@@ -295,7 +300,7 @@ static void UNUSED_FUNCTION(bm_mdisps_space_set)(Object *ob, BMesh *bm, int from
/* switch multires data out of tangent space */
if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
BMEditMesh *em = BMEdit_Create(bm, FALSE);
- DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
+ DerivedMesh *dm = CDDM_from_editbmesh(em, TRUE, FALSE);
MDisps *mdisps;
BMFace *f;
BMIter iter;
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index b0a9168ffda..62abf43829b 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -536,7 +536,9 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
oldverts = me->mvert;
/* don't free this yet */
- CustomData_set_layer(&me->vdata, CD_MVERT, NULL);
+ if (oldverts) {
+ CustomData_set_layer(&me->vdata, CD_MVERT, NULL);
+ }
/* free custom data */
CustomData_free(&me->vdata, me->totvert);
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 3195899ef01..dc8b52423ab 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -118,7 +118,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
e = v->e;
do {
e = bmesh_disk_edge_next(e, v);
- if (!(BM_edge_share_face_count(e, v->e))) {
+ if (!(BM_edge_share_face_check(e, v->e))) {
keepedge = e;
baseedge = v->e;
break;
@@ -130,6 +130,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
/* this code for handling 2 and 3-valence verts
* may be totally bad */
if (keepedge == NULL && len == 3) {
+#if 0
/* handle specific case for three-valence. solve it by
* increasing valence to four. this may be hackish. . */
BMLoop *loop = e->l;
@@ -140,6 +141,13 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
if (!BM_disk_dissolve(bm, v)) {
return FALSE;
}
+#else
+ BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE);
+
+ if (!BM_vert_collapse_faces(bm, v->e, v, 1.0, FALSE, TRUE)) {
+ return FALSE;
+ }
+#endif
return TRUE;
}
else if (keepedge == NULL && len == 2) {
@@ -188,8 +196,9 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
} while (e != v->e);
}
- /* collapse the verte */
- e = BM_vert_collapse_faces(bm, baseedge, v, 1.0, TRUE, TRUE);
+ /* collapse the vertex */
+ /* note, the baseedge can be a boundary of manifold, use this as join_faces arg */
+ e = BM_vert_collapse_faces(bm, baseedge, v, 1.0, !BM_edge_is_boundary(baseedge), TRUE);
if (!e) {
return FALSE;
@@ -428,7 +437,7 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[
/* bmesh_semv returns in newe the edge going from newv to tv */
copy_v3_v3(newv->co, cos[i]);
- /* interpolate the loop data for the loops with v==newv, using orig face */
+ /* interpolate the loop data for the loops with (v == newv), using orig face */
for (j = 0; j < 2; j++) {
BMEdge *e_iter = (j == 0) ? e : newe;
BMLoop *l_iter = e_iter->l;
@@ -461,9 +470,6 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[
* both collapse a vertex and return a new edge.
* Except this takes a factor and merges custom data.
*
- * BMESH_TODO:
- * Insert error checking for KV valance.
- *
* \param bm The bmesh
* \param ke The edge to collapse
* \param kv The vertex to collapse into the edge
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 362157ad71b..398e6bbedcf 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -114,6 +114,26 @@ static BMOpDefine bmo_smooth_vert_def = {
};
/*
+ * Vertext Smooth Laplacian
+ * Smooths vertices by using Laplacian smoothing propose by.
+ * Desbrun, et al. Implicit Fairing of Irregular Meshes using Diffusion and Curvature Flow
+*/
+static BMOpDefine bmo_smooth_laplacian_vert_def = {
+ "smooth_laplacian_vert",
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
+ {BMO_OP_SLOT_FLT, "lambda"}, //lambda param
+ {BMO_OP_SLOT_FLT, "lambda_border"}, //lambda param in border
+ {BMO_OP_SLOT_BOOL, "use_x"}, //Smooth object along X axis
+ {BMO_OP_SLOT_BOOL, "use_y"}, //Smooth object along Y axis
+ {BMO_OP_SLOT_BOOL, "use_z"}, //Smooth object along Z axis
+ {BMO_OP_SLOT_BOOL, "volume_preservation"}, //Apply volume preservation after smooth
+ {0} /* null-terminating sentinel */,
+ },
+ bmo_smooth_laplacian_vert_exec,
+ 0
+};
+
+/*
* Right-Hand Faces
*
* Computes an "outside" normal for the specified input faces.
@@ -679,6 +699,7 @@ static BMOpDefine bmo_dissolve_faces_def = {
static BMOpDefine bmo_dissolve_limit_def = {
"dissolve_limit",
{{BMO_OP_SLOT_FLT, "angle_limit"}, /* total rotation angle (degrees) */
+ {BMO_OP_SLOT_BOOL, "use_dissolve_boundaries"},
{BMO_OP_SLOT_ELEMENT_BUF, "verts"},
{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
{0} /* null-terminating sentinel */},
@@ -698,6 +719,15 @@ static BMOpDefine bmo_triangulate_def = {
BMO_OP_FLAG_UNTAN_MULTIRES
};
+static BMOpDefine bmo_unsubdivide_def = {
+ "unsubdivide",
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
+ {BMO_OP_SLOT_INT, "iterations"},
+ {0} /* null-terminating sentinel */},
+ bmo_unsubdivide_exec,
+ BMO_OP_FLAG_UNTAN_MULTIRES
+};
+
static BMOpDefine bmo_subdivide_edges_def = {
"subdivide_edges",
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
@@ -792,10 +822,11 @@ static BMOpDefine bmo_spin_def = {
*/
static BMOpDefine bmo_similar_faces_def = {
"similar_faces",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
- {BMO_OP_SLOT_INT, "type"}, /* type of selection */
- {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
+ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
+ {BMO_OP_SLOT_INT, "type"}, /* type of selection */
+ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
+ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */
{0} /* null-terminating sentinel */},
bmo_similar_faces_exec,
0
@@ -808,10 +839,11 @@ static BMOpDefine bmo_similar_faces_def = {
*/
static BMOpDefine bmo_similar_edges_def = {
"similar_edges",
- {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */
- {BMO_OP_SLOT_INT, "type"}, /* type of selection */
- {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
+ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */
+ {BMO_OP_SLOT_INT, "type"}, /* type of selection */
+ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
+ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */
{0} /* null-terminating sentinel */},
bmo_similar_edges_exec,
0
@@ -824,10 +856,11 @@ static BMOpDefine bmo_similar_edges_def = {
*/
static BMOpDefine bmo_similar_verts_def = {
"similar_verts",
- {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */
- {BMO_OP_SLOT_INT, "type"}, /* type of selection */
- {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
+ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */
+ {BMO_OP_SLOT_INT, "type"}, /* type of selection */
+ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
+ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */
{0} /* null-terminating sentinel */},
bmo_similar_verts_exec,
0
@@ -1031,6 +1064,7 @@ static BMOpDefine bmo_create_cube_def = {
0,
};
+#define NEW_BEVEL 1
/*
* Bevel
*
@@ -1038,6 +1072,12 @@ static BMOpDefine bmo_create_cube_def = {
*/
static BMOpDefine bmo_bevel_def = {
"bevel",
+#ifdef NEW_BEVEL
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */
+ {BMO_OP_SLOT_FLT, "offset"}, /* amount to offset beveled edge */
+ {BMO_OP_SLOT_INT, "segments"}, /* number of segments in bevel */
+ {0} /* null-terminating sentinel */},
+#else
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */
{BMO_OP_SLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */
{BMO_OP_SLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */
@@ -1048,6 +1088,7 @@ static BMOpDefine bmo_bevel_def = {
{BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */
{BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand beveled edge */
{0} /* null-terminating sentinel */},
+#endif
bmo_bevel_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
@@ -1152,6 +1193,7 @@ static BMOpDefine bmo_slide_vert_def = {
BMO_OP_FLAG_UNTAN_MULTIRES
};
+#ifdef WITH_BULLET
/*
* Convex Hull
*
@@ -1181,6 +1223,30 @@ static BMOpDefine bmo_convex_hull_def = {
bmo_convex_hull_exec,
0
};
+#endif
+
+/*
+ * Symmetrize
+ *
+ * Mekes the mesh elements in the "input" slot symmetrical. Unlike
+ * normal mirroring, it only copies in one direction, as specified by
+ * the "direction" slot. The edges and faces that cross the plane of
+ * symmetry are split as needed to enforce symmetry.
+ *
+ * All new vertices, edges, and faces are added to the "geomout" slot.
+ */
+static BMOpDefine bmo_symmetrize_def = {
+ "symmetrize",
+ {{BMO_OP_SLOT_ELEMENT_BUF, "input"},
+ {BMO_OP_SLOT_INT, "direction"},
+
+ /* Outputs */
+ {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},
+
+ {0} /* null-terminating sentinel */},
+ bmo_symmetrize_exec,
+ 0
+};
BMOpDefine *opdefines[] = {
&bmo_automerge_def,
@@ -1194,7 +1260,9 @@ BMOpDefine *opdefines[] = {
&bmo_collapse_uvs_def,
&bmo_connect_verts_def,
&bmo_contextual_create_def,
+#ifdef WITH_BULLET
&bmo_convex_hull_def,
+#endif
&bmo_create_circle_def,
&bmo_create_cone_def,
&bmo_create_cube_def,
@@ -1241,15 +1309,18 @@ BMOpDefine *opdefines[] = {
&bmo_similar_verts_def,
&bmo_slide_vert_def,
&bmo_smooth_vert_def,
+ &bmo_smooth_laplacian_vert_def,
&bmo_solidify_def,
&bmo_spin_def,
&bmo_split_def,
&bmo_split_edges_def,
&bmo_subdivide_edges_def,
+ &bmo_symmetrize_def,
&bmo_transform_def,
&bmo_translate_def,
&bmo_triangle_fill_def,
&bmo_triangulate_def,
+ &bmo_unsubdivide_def,
&bmo_weld_verts_def,
&bmo_wireframe_def,
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 0674103162c..671cfbbc55e 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -266,6 +266,16 @@ enum {
DEL_ONLYTAGGED
};
+typedef enum {
+ BMO_SYMMETRIZE_NEGATIVE_X,
+ BMO_SYMMETRIZE_NEGATIVE_Y,
+ BMO_SYMMETRIZE_NEGATIVE_Z,
+
+ BMO_SYMMETRIZE_POSITIVE_X,
+ BMO_SYMMETRIZE_POSITIVE_Y,
+ BMO_SYMMETRIZE_POSITIVE_Z,
+} BMO_SymmDirection;
+
void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag);
void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag);
@@ -275,6 +285,8 @@ void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i);
int BMO_slot_int_get(BMOperator *op, const char *slot_name);
void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i);
int BMO_slot_bool_get(BMOperator *op, const char *slot_name);
+void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len);
+
/* don't pass in arrays that are supposed to map to elements this way.
*
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 2100cd2bd0b..9d1054dc042 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -36,6 +36,8 @@
#include "BLI_listbase.h"
#include "BLI_array.h"
+#include "BLF_translation.h"
+
#include "bmesh.h"
#include "intern/bmesh_private.h"
@@ -49,16 +51,16 @@ static int bmo_opname_to_opcode(const char *opname);
static const char *bmo_error_messages[] = {
NULL,
- "Self intersection error",
- "Could not dissolve vert",
- "Could not connect vertices",
- "Could not traverse mesh",
- "Could not dissolve faces",
- "Could not dissolve vertices",
- "Tessellation error",
- "Can not deal with non-manifold geometry",
- "Invalid selection",
- "Internal mesh error",
+ N_("Self intersection error"),
+ N_("Could not dissolve vert"),
+ N_("Could not connect vertices"),
+ N_("Could not traverse mesh"),
+ N_("Could not dissolve faces"),
+ N_("Could not dissolve vertices"),
+ N_("Tessellation error"),
+ N_("Cannot deal with non-manifold geometry"),
+ N_("Invalid selection"),
+ N_("Internal mesh error"),
};
@@ -352,7 +354,7 @@ void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, i
else {
fprintf(stderr, "%s: invalid size argument %d (bmesh internal error)\n", __func__, size);
- memset(slot->data.p, 0, sizeof(float) * 4 * 4);
+ zero_m4(slot->data.p);
}
}
@@ -363,7 +365,12 @@ void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4])
if (!(slot->slot_type == BMO_OP_SLOT_MAT))
return;
- copy_m4_m4(r_mat, (float (*)[4])slot->data.p);
+ if (slot->data.p) {
+ copy_m4_m4(r_mat, (float (*)[4])slot->data.p);
+ }
+ else {
+ unit_m4(r_mat);
+ }
}
void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3])
@@ -373,7 +380,12 @@ void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3])
if (!(slot->slot_type == BMO_OP_SLOT_MAT))
return;
- copy_m3_m4(r_mat, slot->data.p);
+ if (slot->data.p) {
+ copy_m3_m4(r_mat, slot->data.p);
+ }
+ else {
+ unit_m3(r_mat);
+ }
}
void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p)
@@ -427,6 +439,20 @@ int BMO_slot_bool_get(BMOperator *op, const char *slot_name)
return slot->data.i;
}
+/* if you want a copy of the elem buffer */
+void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len)
+{
+ BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ void *ret;
+
+ /* could add support for mapping type */
+ BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
+
+ ret = MEM_mallocN(sizeof(void *) * slot->len, __func__);
+ memcpy(ret, slot->data.buf, sizeof(void *) * slot->len);
+ *len = slot->len;
+ return ret;
+}
void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name)
{
@@ -1024,7 +1050,7 @@ static void bmo_flag_layer_alloc(BMesh *bm)
int i;
BMIter iter;
- BLI_mempool *oldpool = bm->toolflagpool; /* old flag pool */
+ BLI_mempool *oldpool = bm->toolflagpool; /* old flag pool */
BLI_mempool *newpool;
void *oldflags;
@@ -1241,7 +1267,9 @@ void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg)
BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error");
err->errorcode = errcode;
- if (!msg) msg = bmo_error_messages[errcode];
+ if (!msg) {
+ msg = bmo_error_messages[errcode];
+ }
err->msg = msg;
err->op = owner;
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index b1da8ecb275..14da93302b9 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -46,11 +46,18 @@ enum {
SUBDIV_SELECT_LOOPCUT
};
+enum {
+ SIM_CMP_EQ = 0,
+ SIM_CMP_GT,
+ SIM_CMP_LT
+};
+
/* similar face selection slot values */
enum {
SIMFACE_MATERIAL = 201,
SIMFACE_IMAGE,
SIMFACE_AREA,
+ SIMFACE_SIDES,
SIMFACE_PERIMETER,
SIMFACE_NORMAL,
SIMFACE_COPLANAR
diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h
index dc1bdaa4689..65c9cf0c421 100644
--- a/source/blender/bmesh/intern/bmesh_operators_private.h
+++ b/source/blender/bmesh/intern/bmesh_operators_private.h
@@ -91,15 +91,18 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op);
void bmo_similar_verts_exec(BMesh *bm, BMOperator *op);
void bmo_slide_vert_exec(BMesh *bm, BMOperator *op);
void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op);
+void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op);
void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op);
void bmo_spin_exec(BMesh *bm, BMOperator *op);
void bmo_split_edges_exec(BMesh *bm, BMOperator *op);
void bmo_split_exec(BMesh *bm, BMOperator *op);
void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op);
+void bmo_symmetrize_exec(BMesh *bm, BMOperator *op);
void bmo_transform_exec(BMesh *bm, BMOperator *op);
void bmo_translate_exec(BMesh *bm, BMOperator *op);
void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op);
void bmo_triangulate_exec(BMesh *bm, BMOperator *op);
+void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op);
void bmo_weld_verts_exec(BMesh *bm, BMOperator *op);
void bmo_wireframe_exec(BMesh *bm, BMOperator *op);
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index eb2b7721bdc..98edceb30a2 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -313,7 +313,7 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nvert
float up[3] = {0.0f, 0.0f, 1.0f}, axis[3], q[4];
float mat[3][3];
- double angle;
+ float angle;
int i;
cross_v3_v3v3(axis, normal, up);
@@ -329,7 +329,7 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nvert
axis[2] = 0.0f;
}
- axis_angle_to_quat(q, axis, (float)angle);
+ axis_angle_to_quat(q, axis, angle);
quat_to_mat3(mat, q);
for (i = 0; i < nverts; i++)
@@ -507,8 +507,8 @@ static int line_crosses_v2f(const float v1[2], const float v2[2], const float v3
#define GETMIN2_AXIS(a, b, ma, mb, axis) \
{ \
- ma[axis] = minf(a[axis], b[axis]); \
- mb[axis] = maxf(a[axis], b[axis]); \
+ ma[axis] = min_ff(a[axis], b[axis]); \
+ mb[axis] = max_ff(a[axis], b[axis]); \
} (void)0
#define GETMIN2(a, b, ma, mb) \
@@ -994,8 +994,8 @@ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) {
p1 = projverts[i];
- out[0] = maxf(out[0], p1[0]);
- out[1] = maxf(out[1], p1[1]);
+ out[0] = max_ff(out[0], p1[0]);
+ out[1] = max_ff(out[1], p1[1]);
/* out[2] = 0.0f; */ /* keep at zero */
p1[2] = 0.0f;
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index d850eb34477..1e1d7d1becb 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -298,6 +298,14 @@ int BM_edge_in_face(BMFace *f, BMEdge *e)
}
/**
+ * Returns whether or not a given edge is is part of a given loop.
+ */
+int BM_edge_in_loop(BMEdge *e, BMLoop *l)
+{
+ return (l->e == e || l->prev->e == e);
+}
+
+/**
* Returns whether or not two vertices are in
* a given edge
*/
@@ -316,6 +324,97 @@ BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v)
}
/**
+ * Given a edge and a loop (assumes the edge is manifold). returns
+ * the other faces loop, sharing the same vertex.
+ *
+ * <pre>
+ * +-------------------+
+ * | |
+ * | |
+ * |l_other <-- return |
+ * +-------------------+ <-- A manifold edge between 2 faces
+ * |l e <-- edge |
+ * |^ <-------- loop |
+ * | |
+ * +-------------------+
+ * </pre>
+ */
+BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l)
+{
+ BMLoop *l_other;
+
+ // BLI_assert(BM_edge_is_manifold(e)); // TOO strict, just check if we have another radial face
+ BLI_assert(e->l && e->l->radial_next != e->l);
+ BLI_assert(BM_vert_in_edge(e, l->v));
+
+ l_other = (l->e == e) ? l : l->prev;
+ l_other = l_other->radial_next;
+ BLI_assert(l_other->e == e);
+
+ if (l_other->v == l->v) {
+ /* pass */
+ }
+ else if (l_other->next->v == l->v) {
+ l_other = l_other->next;
+ }
+ else {
+ BLI_assert(0);
+ }
+
+ return l_other;
+}
+
+/**
+ * Utility function to step around a fan of loops,
+ * using an edge to mark the previous side.
+ *
+ * \note all edges must be manifold,
+ * once a non manifold edge is hit, return NULL.
+ *
+ * <pre>
+ * ,.,-->|
+ * _,-' |
+ * ,' | (notice how 'e_step'
+ * / | and 'l' define the
+ * / | direction the arrow
+ * | return | points).
+ * | loop --> |
+ * ---------------------+---------------------
+ * ^ l --> |
+ * | |
+ * assign e_step |
+ * |
+ * begin e_step ----> |
+ * |
+ * </pre>
+ */
+
+BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step)
+{
+ BMEdge *e_prev = *e_step;
+ BMEdge *e_next;
+ if (l->e == e_prev) {
+ e_next = l->prev->e;
+ }
+ else if (l->prev->e == e_prev) {
+ e_next = l->e;
+ }
+ else {
+ BLI_assert(0);
+ return NULL;
+ }
+
+ if (BM_edge_is_manifold(e_next)) {
+ return BM_edge_other_loop((*e_step = e_next), l);
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+
+/**
* The function takes a vertex at the center of a fan and returns the opposite edge in the fan.
* All edges in the fan must be manifold, otherwise return NULL.
*
@@ -626,6 +725,47 @@ int BM_edge_is_boundary(BMEdge *e)
#endif
/**
+ * Returns the number of faces that are adjacent to both f1 and f2,
+ * \note Could be sped up a bit by not using iterators and by tagging
+ * faces on either side, then count the tags rather then searching.
+ */
+int BM_face_share_face_count(BMFace *f1, BMFace *f2)
+{
+ BMIter iter1, iter2;
+ BMEdge *e;
+ BMFace *f;
+ int count = 0;
+
+ 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))
+ count++;
+ }
+ }
+
+ return count;
+}
+
+/**
+ * same as #BM_face_share_face_count but returns a bool
+ */
+int BM_face_share_face_check(BMFace *f1, BMFace *f2)
+{
+ BMIter iter1, iter2;
+ BMEdge *e;
+ BMFace *f;
+
+ 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))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
* Counts the number of edges two faces share (if any)
*/
int BM_face_share_edge_count(BMFace *f1, BMFace *f2)
@@ -645,9 +785,27 @@ int BM_face_share_edge_count(BMFace *f1, BMFace *f2)
}
/**
+ * Returns TRUE if the faces share an edge
+ */
+int BM_face_share_edge_check(BMFace *f1, BMFace *f2)
+{
+ BMLoop *l_iter;
+ BMLoop *l_first;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f1);
+ do {
+ if (bmesh_radial_face_find(l_iter->e, f2)) {
+ return TRUE;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+
+ return FALSE;
+}
+
+/**
* Test if e1 shares any faces with e2
*/
-int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2)
+int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2)
{
BMLoop *l;
BMFace *f;
@@ -668,7 +826,7 @@ int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2)
/**
* Tests to see if e1 shares a vertex with e2
*/
-int BM_edge_share_vert_count(BMEdge *e1, BMEdge *e2)
+int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2)
{
return (e1->v1 == e2->v1 ||
e1->v1 == e2->v2 ||
@@ -925,7 +1083,12 @@ float BM_vert_calc_shell_factor(BMVert *v)
accum_angle += face_angle;
}
- return accum_shell / accum_angle;
+ if (accum_angle != 0.0f) {
+ return accum_shell / accum_angle;
+ }
+ else {
+ return 1.0f;
+ }
}
/**
@@ -946,7 +1109,12 @@ float BM_vert_calc_mean_tagged_edge_length(BMVert *v)
}
}
- return length / (float)tot;
+ if (tot) {
+ return length / (float)tot;
+ }
+ else {
+ return 0.0f;
+ }
}
@@ -1018,6 +1186,28 @@ BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2)
}
/**
+ * Returns an edge sharing the same vertices as this one.
+ * This isn't an invalid state but tools should clean up these cases before
+ * returning the mesh to the user.
+ */
+BMEdge *BM_edge_find_double(BMEdge *e)
+{
+ BMVert *v = e->v1;
+ BMVert *v_other = e->v2;
+
+ BMEdge *e_iter;
+
+ e_iter = e;
+ while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e) {
+ if (UNLIKELY(BM_vert_in_edge(e_iter, v_other))) {
+ return e_iter;
+ }
+ }
+
+ return NULL;
+}
+
+/**
* Given a set of vertices \a varr, find out if
* all those vertices overlap an existing face.
*
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 36ffc296759..579a1397b0c 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -31,6 +31,7 @@ int BM_vert_in_face(BMFace *f, BMVert *v);
int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len);
int BM_edge_in_face(BMFace *f, BMEdge *e);
+int BM_edge_in_loop(BMEdge *e, BMLoop *l);
int BM_vert_in_edge(BMEdge *e, BMVert *v);
int BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e);
@@ -39,9 +40,11 @@ float BM_edge_calc_length(BMEdge *e);
int BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb);
int BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb);
BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v);
+BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l);
BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v);
BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v);
BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v);
+BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step);
BMLoop *BM_vert_find_first_loop(BMVert *v);
int BM_vert_edge_count_nonwire(BMVert *v);
@@ -72,6 +75,7 @@ BMLoop *BM_face_find_shortest_loop(BMFace *f);
BMLoop *BM_face_find_longest_loop(BMFace *f);
BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2);
+BMEdge *BM_edge_find_double(BMEdge *e);
int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);
@@ -80,9 +84,13 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);
int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len);
int BM_face_exists_multi_edge(BMEdge **earr, int len);
+int BM_face_share_face_count(BMFace *f1, BMFace *f2);
int BM_face_share_edge_count(BMFace *f1, BMFace *f2);
-int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2);
-int BM_edge_share_vert_count(BMEdge *e1, BMEdge *e2);
+
+int BM_face_share_face_check(BMFace *f1, BMFace *f2);
+int BM_face_share_edge_check(BMFace *f1, BMFace *f2);
+int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2);
+int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2);
BMVert *BM_edge_share_vert(BMEdge *e1, BMEdge *e2);
BMLoop *BM_face_vert_share_loop(BMFace *f, BMVert *v);
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index a72bfe47127..bb013e6428e 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -303,8 +303,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
if (!BM_vert_is_manifold(v)) {
BMW_reset(walker);
BMO_error_raise(walker->bm, NULL, BMERR_WALKER_FAILED,
- "Non-manifold vert "
- "while searching region boundary");
+ "Non-manifold vert while searching region boundary");
return NULL;
}
@@ -499,7 +498,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
BMEdge *e = lwalk->cur, *nexte = NULL;
BMLoop *l;
BMVert *v;
- int i;
+ int i = 0;
owalk = *lwalk;
BMW_state_remove(walker);
@@ -534,7 +533,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
}
else if (l) { /* NORMAL EDGE WITH FACES */
int vert_edge_tot;
- int stopi;
+ int stopi = 0;
v = BM_edge_other_vert(e, lwalk->lastv);
@@ -599,7 +598,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
}
}
}
- else { /* WIRE EDGE */
+ else { /* WIRE EDGE */
BMIter eiter;
/* match trunk: mark all connected wire edges */
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 10a9d511c77..7df5aa8fe9c 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor(s): Joseph Eagar.
+ * Contributor(s): Joseph Eagar, Aleksandr Mokhov, Howard Trickey
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_array.h"
#include "BLI_math.h"
#include "BLI_smallhash.h"
@@ -36,14 +37,1358 @@
#include "intern/bmesh_operators_private.h" /* own include */
-#define BEVEL_FLAG 1
-#define BEVEL_DEL 2
-#define FACE_NEW 4
-#define EDGE_OLD 8
-#define FACE_OLD 16
-#define VERT_OLD 32
-#define FACE_SPAN 64
-#define FACE_HOLE 128
+#define NEW_BEVEL 1
+
+#ifdef NEW_BEVEL
+#define BEVEL_FLAG 1
+#define EDGE_SELECTED 2
+
+#define BEVEL_EPSILON 1e-6
+
+/* Constructed vertex, sometimes later instantiated as BMVert */
+typedef struct NewVert {
+ float co[3];
+ BMVert *v;
+} NewVert;
+
+struct BoundVert;
+
+/* Data for one end of an edge involved in a bevel */
+typedef struct EdgeHalf {
+ struct EdgeHalf *next, *prev; /* in CCW order */
+ BMEdge *e; /* original mesh edge */
+ int isbev; /* is this edge beveled? */
+ int isrev; /* is e->v2 the vertex at this end? */
+ int seg; /* how many segments for the bevel */
+ float offset; /* offset for this edge */
+ BMFace *fprev; /* face between this edge and previous, if any */
+ BMFace *fnext; /* face between this edge and next, if any */
+ struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */
+ struct BoundVert *rightv; /* right boundary vert, if beveled */
+} EdgeHalf;
+
+/* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
+typedef struct BoundVert {
+ struct BoundVert *next, *prev; /* in CCW order */
+ int index; /* used for vmesh indexing */
+ NewVert nv;
+ EdgeHalf *efirst; /* first of edges attached here: in CCW order */
+ EdgeHalf *elast;
+ EdgeHalf *ebev; /* beveled edge whose left side is attached here, if any */
+} BoundVert;
+
+/* Mesh structure replacing a vertex */
+typedef struct VMesh {
+ enum {
+ M_NONE, /* no polygon mesh needed */
+ M_POLY, /* a simple polygon */
+ M_ADJ, /* "adjacent edges" mesh pattern */
+ M_CROSS, /* "cross edges" mesh pattern */
+ } mesh_kind;
+ int count; /* number of vertices in the boundary */
+ int seg; /* common # of segments for segmented edges */
+ BoundVert *boundstart; /* start of boundary double-linked list */
+ NewVert *mesh; /* allocated array - size and structure depends on kind */
+} VMesh;
+
+/* Data for a vertex involved in a bevel */
+typedef struct BevVert {
+ struct BevVert *next, *prev;
+ BMVert *v; /* original mesh vertex */
+ int edgecount; /* total number of edges around the vertex */
+ int selcount; /* number of selected edges around the vertex */
+ EdgeHalf *edges; /* array of size edgecount; CCW order from vertex normal side */
+ VMesh *vmesh; /* mesh structure for replacing vertex */
+} BevVert;
+
+/*
+ * Bevel parameters and state
+ */
+typedef struct BevelParams {
+ ListBase vertList; /* list of BevVert for each vertex involved in bevel */
+ float offset; /* blender units to offset each side of a beveled edge */
+ int seg; /* number of segments in beveled edge profile */
+
+ BMOperator *op;
+} BevelParams;
+
+/* Make a new BoundVert of the given kind, insert it at the end of the circular linked
+ * list with entry point bv->boundstart, and return it. */
+static BoundVert *add_new_bound_vert(VMesh *vm, float co[3])
+{
+ BoundVert *ans = (BoundVert *) MEM_callocN(sizeof(BoundVert), "BoundVert");
+ copy_v3_v3(ans->nv.co, co);
+ if (!vm->boundstart) {
+ ans->index = 0;
+ vm->boundstart = ans;
+ ans->next = ans->prev = ans;
+ }
+ else {
+ BoundVert *tail = vm->boundstart->prev;
+ ans->index = tail->index + 1;
+ ans->prev = tail;
+ ans->next = vm->boundstart;
+ tail->next = ans;
+ vm->boundstart->prev = ans;
+ }
+ vm->count++;
+ return ans;
+}
+
+/* Mesh verts are indexed (i, j, k) where
+ * i = boundvert index (0 <= i < nv)
+ * j = ring index (0 <= j <= ns2)
+ * k = segment index (0 <= k <= ns)
+ * Not all of these are used, and some will share BMVerts */
+static NewVert *mesh_vert(VMesh *vm, int i, int j, int k)
+{
+ int nj = (vm->seg / 2) + 1;
+ int nk = vm->seg + 1;
+
+ return &vm->mesh[i * nk * nj + j * nk + k];
+}
+
+static void create_mesh_bmvert(BMesh *bm, VMesh *vm, int i, int j, int k, BMVert *eg)
+{
+ NewVert *nv = mesh_vert(vm, i, j, k);
+ nv->v = BM_vert_create(bm, nv->co, eg);
+}
+
+static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto,
+ int ifrom, int jfrom, int kfrom)
+{
+ NewVert *nvto, *nvfrom;
+
+ nvto = mesh_vert(vm, ito, jto, kto);
+ nvfrom = mesh_vert(vm, ifrom, jfrom, kfrom);
+ nvto->v = nvfrom->v;
+ copy_v3_v3(nvto->co, nvfrom->co);
+}
+
+/* find the EdgeHalf in bv's array that has edge bme */
+static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
+{
+ int i;
+
+ for (i = 0; i < bv->edgecount; i++) {
+ if (bv->edges[i].e == bme)
+ return &bv->edges[i];
+ }
+ return NULL;
+}
+
+/* Return the next EdgeHalf after from_e that is beveled.
+ * If from_e is NULL, find the first beveled edge. */
+static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
+{
+ EdgeHalf *e;
+
+ if (from_e == NULL)
+ from_e = &bv->edges[bv->edgecount - 1];
+ e = from_e;
+ do {
+ if (e->isbev)
+ return e;
+ e = e->next;
+ } while (e != from_e);
+ return NULL;
+}
+
+/* find the BevVert corresponding to BMVert bmv */
+static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
+{
+ BevVert *bv;
+
+ for (bv = bp->vertList.first; bv; bv = bv->next) {
+ if (bv->v == bmv)
+ return bv;
+ }
+ return NULL;
+}
+
+/* Return a good respresentative face (for materials, etc.) for faces
+ * created around/near BoundVert v */
+static BMFace *boundvert_rep_face(BoundVert *v)
+{
+ BMFace *fans = NULL;
+ BMFace *firstf = NULL;
+ BMEdge *e1, *e2;
+ BMFace *f1, *f2;
+ BMIter iter1, iter2;
+
+ BLI_assert(v->efirst != NULL && v->elast != NULL);
+ e1 = v->efirst->e;
+ e2 = v->elast->e;
+ BM_ITER_ELEM (f1, &iter1, e1, BM_FACES_OF_EDGE) {
+ if (!firstf)
+ firstf = f1;
+ BM_ITER_ELEM (f2, &iter2, e2, BM_FACES_OF_EDGE) {
+ if (f1 == f2) {
+ fans = f1;
+ break;
+ }
+ }
+ }
+ if (!fans)
+ fans = firstf;
+
+ return fans;
+}
+
+/* Make ngon from verts alone.
+ * Make sure to properly copy face attributes and do custom data interpolation from
+ * example face, facerep. */
+static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, int totv, BMFace *facerep)
+{
+ BMIter iter;
+ BMLoop *l;
+ BMFace *f;
+
+ if (totv == 3) {
+ f = BM_face_create_quad_tri(bm,
+ vert_arr[0], vert_arr[1], vert_arr[2], NULL, facerep, 0);
+ }
+ else if (totv == 4) {
+ f = BM_face_create_quad_tri(bm,
+ vert_arr[0], vert_arr[1], vert_arr[2], vert_arr[3], facerep, 0);
+ }
+ else {
+ int i;
+ BMEdge *e;
+ BMEdge **ee = NULL;
+ BLI_array_staticdeclare(ee, 30);
+
+ for (i = 0; i < totv; i++) {
+ e = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, TRUE);
+ BLI_array_append(ee, e);
+ }
+ f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, FALSE);
+ BLI_array_free(ee);
+ }
+ if (facerep && f) {
+ int has_mdisps = CustomData_has_layer(&bm->ldata, CD_MDISPS);
+ BM_elem_attrs_copy(bm, bm, facerep, f);
+ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ BM_loop_interp_from_face(bm, l, facerep, TRUE, TRUE);
+ if (has_mdisps)
+ BM_loop_interp_multires(bm, l, facerep);
+ }
+ }
+ return f;
+}
+
+static BMFace *bev_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
+ BMFace *facerep)
+{
+ BMVert *varr[4];
+
+ varr[0] = v1;
+ varr[1] = v2;
+ varr[2] = v3;
+ varr[3] = v4;
+ return bev_create_ngon(bm, varr, v4 ? 4 : 3, facerep);
+}
+
+/*
+ * Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
+ * e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
+ * the bevel vertex, e1 precedes e2 in CCW order.
+ * If on_right is true, offset edge is on right of both edges, where e1 enters v and
+ * e2 leave it. If on_right is false, then the offset edge is on the left.
+ * When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2),
+ * but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
+ * lead to different offsets) then meeting point can be found be intersecting offset lines.
+ */
+static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
+ int on_right, float meetco[3])
+{
+ float dir1[3], dir2[3], norm_v[3], norm_perp1[3], norm_perp2[3],
+ off1a[3], off1b[3], off2a[3], off2b[3], isect2[3];
+
+ /* get direction vectors for two offset lines */
+ sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
+ sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
+
+ /* get normal to plane where meet point should be */
+ cross_v3_v3v3(norm_v, dir2, dir1);
+ normalize_v3(norm_v);
+ if (!on_right)
+ negate_v3(norm_v);
+ if (is_zero_v3(norm_v)) {
+ /* special case: e1 and e2 are parallel; put offset point perp to both, from v.
+ * need to find a suitable plane.
+ * if offsets are different, we're out of luck: just use e1->offset */
+ if (f)
+ copy_v3_v3(norm_v, f->no);
+ else
+ copy_v3_v3(norm_v, v->no);
+ cross_v3_v3v3(norm_perp1, dir1, norm_v);
+ normalize_v3(norm_perp1);
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ copy_v3_v3(meetco, off1a);
+ }
+ else {
+ /* get vectors perp to each edge, perp to norm_v, and pointing into face */
+ if (f) {
+ copy_v3_v3(norm_v, f->no);
+ normalize_v3(norm_v);
+ }
+ cross_v3_v3v3(norm_perp1, dir1, norm_v);
+ cross_v3_v3v3(norm_perp2, dir2, norm_v);
+ normalize_v3(norm_perp1);
+ normalize_v3(norm_perp2);
+
+ /* get points that are offset distances from each line, then another point on each line */
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ add_v3_v3v3(off1b, off1a, dir1);
+ copy_v3_v3(off2a, v->co);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset);
+ add_v3_v3v3(off2b, off2a, dir2);
+
+ /* intersect the lines; by construction they should be on the same plane and not parallel */
+ if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
+ BLI_assert(!"offset_meet failure");
+ copy_v3_v3(meetco, off1a); /* just to do something */
+ }
+ }
+}
+
+/* Like offset_meet, but here f1 and f2 must not be NULL and give the
+ * planes in which to run the offset lines. They may not meet exactly,
+ * but the line intersection routine will find the closest approach point. */
+static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v,
+ BMFace *f1, BMFace *f2, float meetco[3])
+{
+ float dir1[3], dir2[3], norm_perp1[3], norm_perp2[3],
+ off1a[3], off1b[3], off2a[3], off2b[3], isect2[3];
+
+ BLI_assert(f1 != NULL && f2 != NULL);
+
+ /* get direction vectors for two offset lines */
+ sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
+ sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
+
+ /* get directions into offset planes */
+ cross_v3_v3v3(norm_perp1, dir1, f1->no);
+ normalize_v3(norm_perp1);
+ cross_v3_v3v3(norm_perp2, dir2, f2->no);
+ normalize_v3(norm_perp2);
+
+ /* get points that are offset distances from each line, then another point on each line */
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ add_v3_v3v3(off1b, off1a, dir1);
+ copy_v3_v3(off2a, v->co);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset);
+ add_v3_v3v3(off2b, off2a, dir2);
+
+ /* intersect the lines; by construction they should be on the same plane and not parallel */
+ if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
+ BLI_assert(!"offset_meet failure");
+ copy_v3_v3(meetco, off1a); /* just to do something */
+ }
+}
+
+/* Offset by e->offset in plane with normal plane_no, on left if left==TRUE,
+ * else on right. If no is NULL, choose an arbitrary plane different
+ * from eh's direction. */
+static void offset_in_plane(EdgeHalf *e, float plane_no[3], int left, float r[3])
+{
+ float dir[3], no[3];
+ BMVert *v;
+
+ v = e->isrev ? e->e->v1 : e->e->v2;
+
+ sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co);
+ normalize_v3(dir);
+ if (plane_no) {
+ copy_v3_v3(no, plane_no);
+ }
+ else {
+ zero_v3(no);
+ if (fabs(dir[0]) < fabs(dir[1]))
+ no[0] = 1.0f;
+ else
+ no[1] = 1.0f;
+ }
+ if (left)
+ cross_v3_v3v3(r, no, dir);
+ else
+ cross_v3_v3v3(r, dir, no);
+ normalize_v3(r);
+ mul_v3_fl(r, e->offset);
+}
+
+/* Calculate coordinates of a point a distance d from v on e->e and return it in slideco */
+static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
+{
+ float dir[3], len;
+
+ sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
+ len = len_v3(dir);
+ normalize_v3(dir);
+ if (d > len)
+ d = len - (float)(50 * BEVEL_EPSILON);
+ copy_v3_v3(slideco, v->co);
+ madd_v3_v3fl(slideco, dir, -d);
+}
+
+/* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */
+static void project_to_edge(BMEdge *e, float co_a[3], float co_b[3], float projco[3])
+{
+ float otherco[3];
+
+ if (!isect_line_line_v3(e->v1->co, e->v2->co, co_a, co_b,
+ projco, otherco)) {
+ BLI_assert(!"project meet failure");
+ copy_v3_v3(projco, e->v1->co);
+ }
+}
+
+
+/* return 1 if a and b are in CCW order on the normal side of f,
+ * and -1 if they are reversed, and 0 if there is no shared face f */
+static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
+{
+ BMLoop *la, *lb;
+
+ if (!f)
+ return 0;
+ la = BM_face_edge_share_loop(f, a);
+ lb = BM_face_edge_share_loop(f, b);
+ if (!la || !lb)
+ return 0;
+ return lb->next == la ? 1 : -1;
+}
+
+/*
+ * calculation of points on the round profile
+ * r - result, coordinate of point on round profile
+ * method:
+ * Inscribe a circle in angle va - v -vb
+ * such that it touches the arms at offset from v.
+ * Rotate the center-va segment by (i/n) of the
+ * angle va - center -vb, and put the endpoint
+ * of that segment in r.
+ */
+static void get_point_on_round_profile(float r[3], float offset, int i, int count,
+ float va[3], float v[3], float vb[3])
+{
+ float vva[3], vvb[3], angle, center[3], rv[3], axis[3], co[3];
+
+ sub_v3_v3v3(vva, va, v);
+ sub_v3_v3v3(vvb, vb, v);
+ normalize_v3(vva);
+ normalize_v3(vvb);
+ angle = angle_v3v3(vva, vvb);
+
+ add_v3_v3v3(center, vva, vvb);
+ normalize_v3(center);
+ mul_v3_fl(center, offset * (1.0f / cosf(0.5f * angle)));
+ add_v3_v3(center, v); /* coordinates of the center of the inscribed circle */
+
+
+ sub_v3_v3v3(rv, va, center); /* radius vector */
+
+
+ sub_v3_v3v3(co, v, center);
+ cross_v3_v3v3(axis, rv, co); /* calculate axis */
+
+ sub_v3_v3v3(vva, va, center);
+ sub_v3_v3v3(vvb, vb, center);
+ angle = angle_v3v3(vva, vvb);
+
+ rotate_v3_v3v3fl(co, rv, axis, angle * (float)(i) / (float)(count));
+
+ add_v3_v3(co, center);
+ copy_v3_v3(r, co);
+}
+
+/*
+ * Find the point (i/n) of the way around the round profile for e,
+ * where start point is va, midarc point is vmid, and end point is vb.
+ * Return the answer in profileco.
+ * Method:
+ * Adjust va and vb (along edge direction) so that they are perpendicular
+ * to edge at v, then use get_point_on_round_profile, then project
+ * back onto original va - vmid - vb plane.
+ * If va, vmid, and vb are all on the same plane, just interpolate between va and vb.
+ */
+static void get_point_on_round_edge(EdgeHalf *e, int i,
+ float va[3], float vmid[3], float vb[3], float profileco[3])
+{
+ float vva[3], vvb[3], point[3], dir[3], vaadj[3], vbadj[3], p2[3], pn[3];
+ int n = e->seg;
+
+ sub_v3_v3v3(vva, va, vmid);
+ sub_v3_v3v3(vvb, vb, vmid);
+ if (e->isrev)
+ sub_v3_v3v3(dir, e->e->v1->co, e->e->v2->co);
+ else
+ sub_v3_v3v3(dir, e->e->v2->co, e->e->v1->co);
+ normalize_v3(dir);
+ if (fabsf(angle_v3v3(vva, vvb) - (float)M_PI) > (float)BEVEL_EPSILON) {
+ copy_v3_v3(vaadj, va);
+ madd_v3_v3fl(vaadj, dir, -len_v3(vva) * cosf(angle_v3v3(vva, dir)));
+ copy_v3_v3(vbadj, vb);
+ madd_v3_v3fl(vbadj, dir, -len_v3(vvb) * cosf(angle_v3v3(vvb, dir)));
+
+ get_point_on_round_profile(point, e->offset, i, n, vaadj, vmid, vbadj);
+
+ add_v3_v3v3(p2, profileco, dir);
+ cross_v3_v3v3(pn, vva, vvb);
+ if (!isect_line_plane_v3(profileco, point, p2, vmid, pn, 0)) {
+ BLI_assert(!"bevel: unexpected non-intersection");
+ copy_v3_v3(profileco, point);
+ }
+ }
+ else {
+ /* planar case */
+ interp_v3_v3v3(profileco, va, vb, (float) i / (float) n);
+ }
+}
+
+static void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
+{
+ v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
+ v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
+ v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
+}
+
+/* Make a circular list of BoundVerts for bv, each of which has the coordinates
+ * of a vertex on the the boundary of the beveled vertex bv->v.
+ * Also decide on the mesh pattern that will be used inside the boundary.
+ * Doesn't make the actual BMVerts */
+static void build_boundary(BevVert *bv)
+{
+ EdgeHalf *efirst, *e;
+ BoundVert *v;
+ VMesh *vm;
+ float co[3], *no;
+ float lastd;
+
+ e = efirst = next_bev(bv, NULL);
+ vm = bv->vmesh;
+
+ BLI_assert(bv->edgecount >= 2); /* since bevel edges incident to 2 faces */
+
+ if (bv->edgecount == 2 && bv->selcount == 1) {
+ /* special case: beveled edge meets non-beveled one at valence 2 vert */
+ no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
+ offset_in_plane(e, no, TRUE, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = v->elast = v->ebev = e;
+ e->leftv = v;
+ no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
+ offset_in_plane(e, no, FALSE, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = v->elast = e;
+ e->rightv = v;
+ /* make artifical extra point along unbeveled edge, and form triangle */
+ slide_dist(e->next, bv->v, e->offset, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = v->elast = e->next;
+ vm->mesh_kind = M_POLY;
+ return;
+ }
+
+ lastd = e->offset;
+ vm->boundstart = NULL;
+ do {
+ if (e->isbev) {
+ /* handle only left side of beveled edge e here: next iteration should do right side */
+ if (e->prev->isbev) {
+ BLI_assert(e->prev != e); /* see: wire edge special case */
+ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = e->prev;
+ v->elast = v->ebev = e;
+ e->leftv = v;
+ e->prev->rightv = v;
+ }
+ else {
+ /* e->prev is not beveled */
+ if (e->prev->prev->isbev) {
+ BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */
+ /* find meet point between e->prev->prev and e and attach e->prev there */
+ /* TODO: fix case when one or both faces in following are NULL */
+ offset_in_two_planes(e->prev->prev, e, bv->v,
+ e->prev->prev->fnext, e->fprev, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = e->prev->prev;
+ v->elast = v->ebev = e;
+ e->leftv = v;
+ e->prev->leftv = v;
+ e->prev->prev->rightv = v;
+ }
+ else {
+ /* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */
+ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = e->prev;
+ v->elast = v->ebev = e;
+ e->leftv = v;
+ e->prev->leftv = v;
+ }
+ }
+ lastd = len_v3v3(bv->v->co, v->nv.co);
+ }
+ else {
+ /* e is not beveled */
+ if (e->next->isbev) {
+ /* next iteration will place e between beveled previous and next edges */
+ e = e->next;
+ continue;
+ }
+ if (e->prev->isbev) {
+ /* on-edge meet between e->prev and e */
+ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = e->prev;
+ v->elast = e;
+ e->leftv = v;
+ e->prev->rightv = v;
+ }
+ else {
+ /* None of e->prev, e, e->next are beveled.
+ * could either leave alone or add slide points to make
+ * one polygon around bv->v. For now, we choose latter.
+ * Could slide to make an even bevel plane but for now will
+ * just use last distance a meet point moved from bv->v. */
+ slide_dist(e, bv->v, lastd, co);
+ v = add_new_bound_vert(vm, co);
+ v->efirst = v->elast = e;
+ e->leftv = v;
+ }
+ }
+ e = e->next;
+ } while (e != efirst);
+
+ BLI_assert(vm->count >= 2);
+ if (vm->count == 2 && bv->edgecount == 3)
+ vm->mesh_kind = M_NONE;
+ else if (efirst->seg == 1 || bv->selcount < 3)
+ vm->mesh_kind = M_POLY;
+ else
+ vm->mesh_kind = M_ADJ;
+ /* TODO: if vm->count == 4 and bv->selcount == 4, use M_CROSS pattern */
+}
+
+/*
+ * Given that the boundary is built and the boundary BMVerts have been made,
+ * calculate the positions of the interior mesh points for the M_ADJ pattern,
+ * then make the BMVerts and the new faces. */
+static void bevel_build_rings(BMesh *bm, BevVert *bv)
+{
+ int k, ring, i, n, ns, ns2, nn;
+ VMesh *vm = bv->vmesh;
+ BoundVert *v, *vprev, *vnext;
+ NewVert *nv, *nvprev, *nvnext;
+ BMVert *bmv, *bmv1, *bmv2, *bmv3, *bmv4;
+ BMFace *f;
+ float co[3], coa[3], cob[3], midco[3];
+
+ n = vm->count;
+ ns = vm->seg;
+ ns2 = ns / 2;
+ BLI_assert(n > 2 && ns > 1);
+
+ /* Make initial rings, going between points on neighbors */
+ for (ring = 1; ring <= ns2; ring++) {
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ /* get points coords of points a and b, on outer rings
+ * of prev and next edges, k away from this edge */
+ vprev = v->prev;
+ vnext = v->next;
+
+ if (vprev->ebev)
+ nvprev = mesh_vert(vm, vprev->index, 0, ns - ring);
+ else
+ nvprev = mesh_vert(vm, vprev->index, 0, ns);
+ copy_v3_v3(coa, nvprev->co);
+ nv = mesh_vert(vm, i, ring, 0);
+ copy_v3_v3(nv->co, coa);
+ nv->v = nvprev->v;
+
+ if (vnext->ebev)
+ nvnext = mesh_vert(vm, vnext->index, 0, ring);
+ else
+ nvnext = mesh_vert(vm, vnext->index, 0, 0);
+ copy_v3_v3(cob, nvnext->co);
+ nv = mesh_vert(vm, i, ring, ns);
+ copy_v3_v3(nv->co, cob);
+ nv->v = nvnext->v;
+
+ /* TODO: better calculation of new midarc point? */
+ project_to_edge(v->ebev->e, coa, cob, midco);
+
+ for (k = 1; k < ns; k++) {
+ get_point_on_round_edge(v->ebev, k, coa, midco, cob, co);
+ copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co);
+ }
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+ }
+
+ /* Now make sure cross points of rings share coordinates and vertices */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ vprev = v->prev;
+ vnext = v->next;
+ if (vprev->ebev) {
+ for (ring = 1; ring <= ns2; ring++) {
+ for (k = 1; k <= ns2; k++) {
+ if (ns % 2 == 0 && (k == ns2 || ring == ns2))
+ continue; /* center line is special case: do after the rest are done */
+ nv = mesh_vert(vm, i, ring, k);
+ nvprev = mesh_vert(vm, vprev->index, k, ns - ring);
+ mid_v3_v3v3(co, nv->co, nvprev->co);
+ copy_v3_v3(nv->co, co);
+ BLI_assert(nv->v == NULL && nvprev->v == NULL);
+ create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
+ copy_mesh_vert(vm, vprev->index, k, ns - ring, i, ring, k);
+ }
+ }
+ if (!vprev->prev->ebev) {
+ for (ring = 1; ring <= ns2; ring++) {
+ for (k = 1; k <= ns2; k++) {
+ if (ns % 2 == 0 && (k == ns2 || ring == ns2))
+ continue;
+ create_mesh_bmvert(bm, vm, vprev->index, ring, k, bv->v);
+ }
+ }
+ }
+ if (!vnext->ebev) {
+ for (ring = 1; ring <= ns2; ring++) {
+ for (k = ns - ns2; k < ns; k++) {
+ if (ns % 2 == 0 && (k == ns2 || ring == ns2))
+ continue;
+ create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
+ }
+ }
+ }
+ }
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+
+ if (ns % 2 == 0) {
+ /* do special case center lines */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ vprev = v->prev;
+ vnext = v->next;
+ for (k = 1; k < ns2; k++) {
+ nv = mesh_vert(vm, i, k, ns2);
+ if (vprev->ebev)
+ nvprev = mesh_vert(vm, vprev->index, ns2, ns - k);
+ if (vnext->ebev)
+ nvnext = mesh_vert(vm, vnext->index, ns2, k);
+ if (vprev->ebev && vnext->ebev) {
+ mid_v3_v3v3v3(co, nvprev->co, nv->co, nvnext->co);
+ copy_v3_v3(nv->co, co);
+ create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
+ copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
+ copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
+
+ }
+ else if (vprev->ebev) {
+ mid_v3_v3v3(co, nvprev->co, nv->co);
+ copy_v3_v3(nv->co, co);
+ create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
+ copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
+ }
+ else if (vnext->ebev) {
+ mid_v3_v3v3(co, nv->co, nvnext->co);
+ copy_v3_v3(nv->co, co);
+ create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
+ copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
+ }
+ }
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+
+ /* center point need to be average of all centers of rings */
+ /* TODO: this is wrong if not all verts have ebev: could have
+ * several disconnected sections of mesh. */
+ zero_v3(midco);
+ nn = 0;
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ nv = mesh_vert(vm, i, ns2, ns2);
+ add_v3_v3(midco, nv->co);
+ nn++;
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+ mul_v3_fl(midco, 1.0f / nn);
+ bmv = BM_vert_create(bm, midco, NULL);
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ nv = mesh_vert(vm, i, ns2, ns2);
+ copy_v3_v3(nv->co, midco);
+ nv->v = bmv;
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+ }
+
+ /* Make the ring quads */
+ for (ring = 0; ring < ns2; ring++) {
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ f = boundvert_rep_face(v);
+ if (v->ebev && (v->prev->ebev || v->next->ebev)) {
+ for (k = 0; k < ns2 + (ns % 2); k++) {
+ bmv1 = mesh_vert(vm, i, ring, k)->v;
+ bmv2 = mesh_vert(vm, i, ring, k + 1)->v;
+ bmv3 = mesh_vert(vm, i, ring + 1, k + 1)->v;
+ bmv4 = mesh_vert(vm, i, ring + 1, k)->v;
+ BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
+ if (bmv3 == bmv4 || bmv1 == bmv4)
+ bmv4 = NULL;
+ bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f);
+ }
+ }
+ else if (v->prev->ebev && v->prev->prev->ebev) {
+ /* finish off a sequence of beveled edges */
+ i = v->prev->index;
+ f = boundvert_rep_face(v->prev);
+ for (k = ns2 + (ns % 2); k < ns; k++) {
+ bmv1 = mesh_vert(vm, i, ring + 1, k)->v;
+ bmv2 = mesh_vert(vm, i, ring, k)->v;
+ bmv3 = mesh_vert(vm, i, ring, k + 1)->v;
+ BLI_assert(bmv1 && bmv2 && bmv3);
+ bev_create_quad_tri(bm, bmv1, bmv2, bmv3, NULL, f);
+ }
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+ }
+
+ /* Make center ngon if odd number of segments and fully beveled */
+ if (ns % 2 == 1 && vm->count == bv->selcount) {
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ BLI_assert(v->ebev);
+ BLI_array_append(vv, mesh_vert(vm, i, ns2, ns2)->v);
+ v = v->next;
+ } while (v != vm->boundstart);
+ f = boundvert_rep_face(vm->boundstart);
+ bev_create_ngon(bm, vv, BLI_array_count(vv), f);
+
+ BLI_array_free(vv);
+ }
+
+ /* Make 'rest-of-vmesh' polygon if not fully beveled */
+ if (vm->count > bv->selcount) {
+ int j;
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ v = vm->boundstart;
+ f = boundvert_rep_face(v);
+ j = 0;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ if (!v->prev->ebev) {
+ for (k = 0; k < ns2; k++) {
+ bmv1 = mesh_vert(vm, i, ns2, k)->v;
+ if (!(j > 0 && bmv1 == vv[j - 1])) {
+ BLI_array_append(vv, bmv1);
+ j++;
+ }
+ }
+ }
+ bmv1 = mesh_vert(vm, i, ns2, ns2)->v;
+ if (!(j > 0 && bmv1 == vv[j - 1])) {
+ BLI_array_append(vv, bmv1);
+ j++;
+ }
+ if (!v->next->ebev) {
+ for (k = ns - ns2; k < ns; k++) {
+ bmv1 = mesh_vert(vm, i, ns2, k)->v;
+ if (!(j > 0 && bmv1 == vv[j - 1])) {
+ BLI_array_append(vv, bmv1);
+ j++;
+ }
+ }
+ }
+ }
+ else {
+ BLI_array_append(vv, mesh_vert(vm, i, 0, 0)->v);
+ j++;
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+ if (vv[0] == vv[j - 1])
+ j--;
+ bev_create_ngon(bm, vv, j, f);
+
+ BLI_array_free(vv);
+ }
+}
+
+static void bevel_build_poly(BMesh *bm, BevVert *bv)
+{
+ int n, k;
+ VMesh *vm = bv->vmesh;
+ BoundVert *v;
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ v = vm->boundstart;
+ n = 0;
+ do {
+ /* accumulate vertices for vertex ngon */
+ BLI_array_append(vv, v->nv.v);
+ n++;
+ if (v->ebev && v->ebev->seg > 1) {
+ for (k = 1; k < v->ebev->seg; k++) {
+ BLI_array_append(vv, mesh_vert(vm, v->index, 0, k)->v);
+ n++;
+ }
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+ if (n > 2)
+ bev_create_ngon(bm, vv, n, boundvert_rep_face(v));
+ BLI_array_free(vv);
+}
+
+/* Given that the boundary is built, now make the actual BMVerts
+ * for the boundary and the interior of the vertex mesh. */
+static void build_vmesh(BMesh *bm, BevVert *bv)
+{
+ VMesh *vm = bv->vmesh;
+ BoundVert *v, *weld1, *weld2;
+ int n, ns, ns2, i, k, weld;
+ float *va, *vb, co[3], midco[3];
+
+ n = vm->count;
+ ns = vm->seg;
+ ns2 = ns / 2;
+
+ vm->mesh = (NewVert *)MEM_callocN(n * (ns2 + 1) * (ns + 1) * sizeof(NewVert), "NewVert");
+
+ /* special case: two beveled ends welded together */
+ weld = (bv->selcount == 2) && (vm->count == 2);
+ weld1 = weld2 = NULL; /* will hold two BoundVerts involved in weld */
+
+ /* make (i, 0, 0) mesh verts for all i */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ copy_v3_v3(mesh_vert(vm, i, 0, 0)->co, v->nv.co);
+ 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)
+ weld1 = v;
+ else
+ weld2 = v;
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+
+ /* copy other ends to (i, 0, ns) for all i, and fill in profiles for beveled edges */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ copy_mesh_vert(vm, i, 0, ns, v->next->index, 0, 0);
+ if (v->ebev) {
+ va = mesh_vert(vm, i, 0, 0)->co;
+ vb = mesh_vert(vm, i, 0, ns)->co;
+ project_to_edge(v->ebev->e, va, vb, midco);
+ for (k = 1; k < ns; k++) {
+ get_point_on_round_edge(v->ebev, k, va, midco, vb, co);
+ copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
+ if (!weld)
+ create_mesh_bmvert(bm, vm, i, 0, k, bv->v);
+ }
+ }
+ v = v->next;
+ } while (v != vm->boundstart);
+
+ if (weld) {
+ for (k = 1; k < ns; k++) {
+ mid_v3_v3v3(co, mesh_vert(vm, weld1->index, 0, k)->co,
+ mesh_vert(vm, weld2->index, 0, ns - k)->co);
+ 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++)
+ copy_mesh_vert(vm, weld2->index, 0, ns - k, weld1->index, 0, k);
+ }
+
+ if (vm->mesh_kind == M_ADJ)
+ bevel_build_rings(bm, bv);
+ else if (vm->mesh_kind == M_POLY)
+ bevel_build_poly(bm, bv);
+}
+
+/*
+ * Construction around the vertex
+ */
+static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMOperator *op, BMVert *v)
+{
+
+ BMOIter siter;
+ BMEdge *bme;
+ BevVert *bv;
+ BMEdge *bme2, *unflagged_bme;
+ BMFace *f;
+ BMIter iter, iter2;
+ EdgeHalf *e;
+ int i, ntot, found_shared_face, ccw_test_sum;
+ int nsel = 0;
+
+ /* Gather input selected edges.
+ * Only bevel selected edges that have exactly two incident faces. */
+ BMO_ITER (bme, &siter, bm, op, "geom", BM_EDGE) {
+ if ((bme->v1 == v) || (BM_edge_other_vert(bme, bme->v1) == v)) {
+ if (BM_edge_face_count(bme) == 2) {
+ BMO_elem_flag_enable(bm, bme, EDGE_SELECTED);
+ nsel++;
+ }
+ }
+ }
+
+ if (nsel == 0)
+ return;
+
+ ntot = BM_vert_edge_count(v);
+ bv = (BevVert *)MEM_callocN(sizeof(BevVert), "BevVert");
+ bv->v = v;
+ bv->edgecount = ntot;
+ bv->selcount = nsel;
+ bv->edges = (EdgeHalf *)MEM_callocN(ntot * sizeof(EdgeHalf), "EdgeHalf");
+ bv->vmesh = (VMesh *)MEM_callocN(sizeof(VMesh), "VMesh");
+ bv->vmesh->seg = bp->seg;
+ BLI_addtail(&bp->vertList, bv);
+
+ /* add edges to bv->edges in order that keeps adjacent edges sharing
+ * a face, if possible */
+ i = 0;
+ bme = v->e;
+ BMO_elem_flag_enable(bm, bme, BEVEL_FLAG);
+ e = &bv->edges[0];
+ e->e = bme;
+ for (i = 0; i < ntot; i++) {
+ if (i > 0) {
+ /* find an unflagged edge bme2 that shares a face f with previous bme */
+ found_shared_face = 0;
+ unflagged_bme = NULL;
+ BM_ITER_ELEM (bme2, &iter, v, BM_EDGES_OF_VERT) {
+ if (BMO_elem_flag_test(bm, bme2, BEVEL_FLAG))
+ continue;
+ if (!unflagged_bme)
+ unflagged_bme = bme2;
+ BM_ITER_ELEM (f, &iter2, bme2, BM_FACES_OF_EDGE) {
+ if (BM_face_edge_share_loop(f, bme)) {
+ found_shared_face = 1;
+ break;
+ }
+ }
+ if (found_shared_face)
+ break;
+ }
+ e = &bv->edges[i];
+ if (found_shared_face) {
+ e->e = bme2;
+ e->fprev = f;
+ bv->edges[i - 1].fnext = f;
+ }
+ else {
+ e->e = unflagged_bme;
+ }
+ }
+ bme = e->e;
+ BMO_elem_flag_enable(bm, bme, BEVEL_FLAG);
+ if (BMO_elem_flag_test(bm, bme, EDGE_SELECTED)) {
+ e->isbev = 1;
+ e->seg = bp->seg;
+ }
+ else {
+ e->isbev = 0;
+ e->seg = 0;
+ }
+ e->isrev = (bme->v2 == v);
+ e->offset = e->isbev ? bp->offset : 0.0f;
+ }
+ /* find wrap-around shared face */
+ BM_ITER_ELEM (f, &iter2, bme, BM_FACES_OF_EDGE) {
+ if (BM_face_edge_share_loop(f, bv->edges[0].e)) {
+ if (bv->edges[0].fnext == f)
+ continue; /* if two shared faces, want the other one now */
+ bv->edges[ntot - 1].fnext = f;
+ bv->edges[0].fprev = f;
+ break;
+ }
+ }
+
+ /* remove BEVEL_FLAG now that we are finished with it*/
+ for (i = 0; i < ntot; i++)
+ BMO_elem_flag_disable(bm, bv->edges[i].e, BEVEL_FLAG);
+
+ /* if edge array doesn't go CCW around vertex from average normal side,
+ * reverse the array, being careful to reverse face pointers too */
+ if (ntot > 1) {
+ ccw_test_sum = 0;
+ 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]);
+ SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
+ SWAP(BMFace *, bv->edges[ntot - i - 1].fprev, bv->edges[ntot - i - 1].fnext);
+ }
+ if (ntot % 2 == 1) {
+ i = ntot / 2;
+ SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
+ }
+ }
+ }
+
+ for (i = 0; i < ntot; i++) {
+ e = &bv->edges[i];
+ e->next = &bv->edges[(i + 1) % ntot];
+ e->prev = &bv->edges[(i + ntot - 1) % ntot];
+ }
+
+ build_boundary(bv);
+ build_vmesh(bm, bv);
+}
+
+/* Face f has at least one beveled vertex. Rebuild f */
+static void rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
+{
+ BMIter liter;
+ BMLoop *l, *lprev;
+ BevVert *bv;
+ BoundVert *v, *vstart, *vend;
+ EdgeHalf *e, *eprev;
+ VMesh *vm;
+ int i, k;
+ BMVert *bmv;
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ bv = find_bevvert(bp, l->v);
+ if (bv) {
+ lprev = l->prev;
+ e = find_edge_half(bv, l->e);
+ eprev = find_edge_half(bv, lprev->e);
+ BLI_assert(e != NULL && eprev != NULL);
+ vstart = eprev->leftv;
+ if (e->isbev)
+ vend = e->rightv;
+ else
+ vend = e->leftv;
+ v = vstart;
+ vm = bv->vmesh;
+ BLI_array_append(vv, v->nv.v);
+ while (v != vend) {
+ if (vm->mesh_kind == M_NONE && v->ebev && v->ebev->seg > 1 && v->ebev != e && v->ebev != eprev) {
+ /* case of 3rd face opposite a beveled edge, with no vmesh */
+ i = v->index;
+ e = v->ebev;
+ for (k = 1; k < e->seg; k++) {
+ bmv = mesh_vert(vm, i, 0, k)->v;
+ BLI_array_append(vv, bmv);
+ }
+ }
+ v = v->prev;
+ BLI_array_append(vv, v->nv.v);
+ }
+ }
+ else {
+ BLI_array_append(vv, l->v);
+ }
+ }
+ bev_create_ngon(bm, vv, BLI_array_count(vv), f);
+ BLI_array_free(vv);
+}
+
+/* All polygons touching v need rebuilding because beveling v has made new vertices */
+static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert *v)
+{
+ BMFace *f;
+ BMIter iter;
+
+ /* TODO: don't iterate through all faces, but just local geometry around v */
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ BMLoop *l = f->l_first;
+ do {
+ if (l->v == v) {
+ rebuild_polygon(bm, bp, f);
+ BM_face_kill(bm, f);
+ }
+ l = l->next;
+ } while (l != f->l_first);
+ }
+}
+
+
+
+/*
+ * Build the polygons along the selected Edge
+ */
+static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
+{
+ BevVert *bv1, *bv2;
+ BMVert *bmv1, *bmv2, *bmv3, *bmv4, *bmv1i, *bmv2i, *bmv3i, *bmv4i;
+ VMesh *vm1, *vm2;
+ EdgeHalf *e1, *e2;
+ BMFace *f1, *f2, *f;
+ int k, nseg, i1, i2;
+
+ if (BM_edge_face_count(bme) != 2)
+ return;
+
+ bv1 = find_bevvert(bp, bme->v1);
+ bv2 = find_bevvert(bp, bme->v2);
+
+ BLI_assert(bv1 && bv2);
+
+ e1 = find_edge_half(bv1, bme);
+ e2 = find_edge_half(bv2, bme);
+
+ BLI_assert(e1 && e2);
+
+ /* v4 v3
+ * \ /
+ * e->v1 - e->v2
+ * / \
+ * v1 v2 */
+
+ nseg = e1->seg;
+ BLI_assert(nseg > 0 && nseg == e2->seg);
+
+ bmv1 = e1->leftv->nv.v;
+ bmv4 = e1->rightv->nv.v;
+ bmv2 = e2->rightv->nv.v;
+ bmv3 = e2->leftv->nv.v;
+
+ BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
+
+ f1 = boundvert_rep_face(e1->leftv);
+ f2 = boundvert_rep_face(e1->rightv);
+
+ if (nseg == 1) {
+ bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f1);
+ }
+ else {
+ i1 = e1->leftv->index;
+ i2 = e2->leftv->index;
+ vm1 = bv1->vmesh;
+ vm2 = bv2->vmesh;
+ bmv1i = bmv1;
+ bmv2i = bmv2;
+ for (k = 1; k <= nseg; k++) {
+ bmv4i = mesh_vert(vm1, i1, 0, k)->v;
+ bmv3i = mesh_vert(vm2, i2, 0, nseg - k)->v;
+ f = (k <= nseg / 2 + (nseg % 2)) ? f1 : f2;
+ bev_create_quad_tri(bm, bmv1i, bmv2i, bmv3i, bmv4i, f);
+ bmv1i = bmv4i;
+ bmv2i = bmv3i;
+ }
+ }
+}
+
+
+static void free_bevel_params(BevelParams *bp)
+{
+ BevVert *bv;
+ VMesh *vm;
+ BoundVert *v, *vnext;
+
+ for (bv = bp->vertList.first; bv; bv = bv->next) {
+ MEM_freeN(bv->edges);
+ vm = bv->vmesh;
+ v = vm->boundstart;
+ if (v) {
+ do {
+ vnext = v->next;
+ MEM_freeN(v);
+ v = vnext;
+ } while (v != vm->boundstart);
+ }
+ if (vm->mesh)
+ MEM_freeN(vm->mesh);
+ MEM_freeN(vm);
+ }
+ BLI_freelistN(&bp->vertList);
+}
+
+void bmo_bevel_exec(BMesh *bm, BMOperator *op)
+{
+ BMOIter siter;
+ BMVert *v;
+ BMEdge *e;
+ BevelParams bp;
+
+ bp.offset = BMO_slot_float_get(op, "offset");
+ bp.op = op;
+ bp.seg = BMO_slot_int_get(op, "segments");
+
+ if (bp.offset > 0) {
+ bp.vertList.first = bp.vertList.last = NULL;
+
+ /* The analysis of the input vertices and execution additional constructions */
+ BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+ bevel_vert_construct(bm, &bp, op, v);
+ }
+ /* Build polygons for edges */
+ BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) {
+ bevel_build_edge_polygons(bm, &bp, e);
+ }
+
+ BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+ bevel_rebuild_existing_polygons(bm, &bp, v);
+ }
+
+ BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+ if (find_bevvert(&bp, v))
+ BM_vert_kill(bm, v);
+ }
+ free_bevel_params(&bp);
+ }
+
+}
+
+#else
+#define BEVEL_FLAG 1
+#define BEVEL_DEL 2
+#define FACE_NEW 4
+#define EDGE_OLD 8
+#define FACE_OLD 16
+#define VERT_OLD 32
+#define FACE_SPAN 64
+#define FACE_HOLE 128
typedef struct LoopTag {
BMVert *newv;
@@ -56,7 +1401,7 @@ typedef struct EdgeTag {
static void calc_corner_co(BMLoop *l, const float fac, float r_co[3],
const short do_dist, const short do_even)
{
- float no[3], l_vec_prev[3], l_vec_next[3], l_co_prev[3], l_co[3], l_co_next[3], co_ofs[3];
+ float no[3], l_vec_prev[3], l_vec_next[3], l_co_prev[3], l_co[3], l_co_next[3], co_ofs[3];
int is_concave;
/* first get the prev/next verts */
@@ -126,7 +1471,7 @@ static void calc_corner_co(BMLoop *l, const float fac, float r_co[3],
* gives nicer, move even output.
*
* Use the minimum rather then the middle value so skinny faces don't flip along the short axis */
- float min_fac = minf(normalize_v3(l_vec_prev), normalize_v3(l_vec_next));
+ float min_fac = min_ff(normalize_v3(l_vec_prev), normalize_v3(l_vec_next));
float angle;
if (do_even) {
@@ -233,7 +1578,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
}
#if 0
- //a bit of cleaner code that, alas, doens't work.
+ /* a bit of cleaner code that, alas, doens't work. */
/* build edge tag */
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_elem_flag_test(bm, e->v1, BEVEL_FLAG) || BMO_elem_flag_test(bm, e->v2, BEVEL_FLAG)) {
@@ -299,7 +1644,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
/* find all faces surrounding e->v1 and, e->v2 */
for (i = 0; i < 2; i++) {
- BM_ITER_ELEM (l, &liter, i ? e->v2:e->v1, BM_LOOPS_OF_VERT) {
+ BM_ITER_ELEM (l, &liter, i ? e->v2 : e->v1, BM_LOOPS_OF_VERT) {
BMLoop *l2;
BMIter liter2;
@@ -886,3 +2231,4 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, op, "face_spans", BM_FACE, FACE_SPAN);
BMO_slot_buffer_from_enabled_flag(bm, op, "face_holes", BM_FACE, FACE_HOLE);
}
+#endif /* NEW_BEVEL */
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index fde475c2d6a..ebd848ff8b2 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -425,8 +425,8 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
/* merge loops of bridge faces */
if (use_merge) {
- const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2)) - ((cl1 || cl2) ? 1 : 0);
- const int edge_len = mini(BLI_array_count(ee1), BLI_array_count(ee2));
+ const int vert_len = min_ii(BLI_array_count(vv1), BLI_array_count(vv2)) - ((cl1 || cl2) ? 1 : 0);
+ const int edge_len = min_ii(BLI_array_count(ee1), BLI_array_count(ee2));
if (merge_factor <= 0.0f) {
/* 2 --> 1 */
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index 731170f963c..093f567d995 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -84,7 +84,7 @@ static int count_edge_faces(BMesh *bm, BMEdge *e);
BLI_INLINE BMDiskLink *rs_edge_link_get(BMEdge *e, BMVert *v, EdgeData *e_data)
{
return v == ((BMEdge *)e)->v1 ? &(((EdgeData *)e_data)->v1_disk_link) :
- &(((EdgeData *)e_data)->v2_disk_link) ;
+ &(((EdgeData *)e_data)->v2_disk_link);
}
static int rotsys_append_edge(BMEdge *e, BMVert *v,
@@ -1177,10 +1177,10 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
}
if (edges1 && BLI_array_count(edges1) > 2 &&
- BM_edge_share_vert_count(edges1[0], edges1[BLI_array_count(edges1) - 1]))
+ BM_edge_share_vert_check(edges1[0], edges1[BLI_array_count(edges1) - 1]))
{
if (edges2 && BLI_array_count(edges2) > 2 &&
- BM_edge_share_vert_count(edges2[0], edges2[BLI_array_count(edges2) - 1]))
+ BM_edge_share_vert_check(edges2[0], edges2[BLI_array_count(edges2) - 1]))
{
BLI_array_free(edges1);
BLI_array_free(edges2);
@@ -1193,7 +1193,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
}
if (edges2 && BLI_array_count(edges2) > 2 &&
- BM_edge_share_vert_count(edges2[0], edges2[BLI_array_count(edges2) - 1]))
+ BM_edge_share_vert_check(edges2[0], edges2[BLI_array_count(edges2) - 1]))
{
edges2 = NULL;
}
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 84f6cb27b3b..9addb1b1657 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -477,182 +477,15 @@ void dummy_exec(BMesh *bm, BMOperator *op)
#endif
/* Limited Dissolve */
-
-#define UNIT_TO_ANGLE DEG2RADF(90.0f)
-#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE)
-
-/* multiply vertex edge angle by face angle
- * this means we are not left with sharp corners between _almost_ planer faces
- * convert angles [0-PI/2] -> [0-1], multiply together, then convert back to radians. */
-static float bm_vert_edge_face_angle(BMVert *v)
-{
- const float angle = BM_vert_calc_edge_angle(v);
- /* note: could be either edge, it doesn't matter */
- if (v->e && BM_edge_is_manifold(v->e)) {
- return ((angle * ANGLE_TO_UNIT) * (BM_edge_calc_face_angle(v->e) * ANGLE_TO_UNIT)) * UNIT_TO_ANGLE;
- }
- else {
- return angle;
- }
-}
-
-#undef UNIT_TO_ANGLE
-#undef ANGLE_TO_UNIT
-
-typedef struct DissolveElemWeight {
- BMHeader *ele;
- float weight;
-} DissolveElemWeight;
-
-static int dissolve_elem_cmp(const void *a1, const void *a2)
-{
- const struct DissolveElemWeight *d1 = a1, *d2 = a2;
-
- if (d1->weight > d2->weight) return 1;
- else if (d1->weight < d2->weight) return -1;
- return 0;
-}
-
void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
{
BMOpSlot *einput = BMO_slot_get(op, "edges");
BMOpSlot *vinput = BMO_slot_get(op, "verts");
const float angle_max = (float)M_PI / 2.0f;
- const float angle_limit = minf(angle_max, BMO_slot_float_get(op, "angle_limit"));
- DissolveElemWeight *weight_elems = MEM_mallocN(MAX2(einput->len, vinput->len) *
- sizeof(DissolveElemWeight), __func__);
- int i, tot_found;
-
- BMIter iter;
- BMEdge *e_iter;
- BMEdge **earray;
-
- int *vert_reverse_lookup;
-
- BMEdge **einput_arr = (BMEdge **)einput->data.p;
- BMVert **vinput_arr = (BMVert **)vinput->data.p;
-
- /* --- first edges --- */
-
- /* wire -> tag */
- BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) {
- BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter));
- }
-
- /* go through and split edge */
- for (i = 0, tot_found = 0; i < einput->len; i++) {
- BMEdge *e = einput_arr[i];
- const float angle = BM_edge_calc_face_angle(e);
-
- if (angle < angle_limit) {
- tot_found++;
- }
- weight_elems[i].ele = (BMHeader *)e;
- weight_elems[i].weight = angle;
- }
-
- if (tot_found != 0) {
- qsort(weight_elems, einput->len, sizeof(DissolveElemWeight), dissolve_elem_cmp);
-
- for (i = 0; i < tot_found; i++) {
- BMEdge *e = (BMEdge *)weight_elems[i].ele;
-
- if (/* may have become non-manifold */
- BM_edge_is_manifold(e) &&
- /* check twice because cumulative effect could dissolve over angle limit */
- (BM_edge_calc_face_angle(e) < angle_limit))
- {
- BMFace *nf = BM_faces_join_pair(bm, e->l->f,
- e->l->radial_next->f,
- e,
- FALSE); /* join faces */
-
- /* there may be some errors, we don't mind, just move on */
- if (nf) {
- BM_face_normal_update(nf);
- }
- else {
- BMO_error_clear(bm);
- }
- }
- }
- }
-
- /* prepare for cleanup */
- BM_mesh_elem_index_ensure(bm, BM_VERT);
- vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__);
- fill_vn_i(vert_reverse_lookup, bm->totvert, -1);
- for (i = 0, tot_found = 0; i < vinput->len; i++) {
- BMVert *v = vinput_arr[i];
- vert_reverse_lookup[BM_elem_index_get(v)] = i;
- }
-
- /* --- cleanup --- */
- earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__);
- BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
- earray[i] = e_iter;
- }
- /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */
- for (i = bm->totedge - 1; i != -1; i--) {
- e_iter = earray[i];
-
- if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) {
- /* edge has become wire */
- int vidx_reverse;
- BMVert *v1 = e_iter->v1;
- BMVert *v2 = e_iter->v2;
- 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;
- 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;
- BM_vert_kill(bm, v2);
- }
- }
- }
- MEM_freeN(vert_reverse_lookup);
-
- MEM_freeN(earray);
-
-
- /* --- second verts --- */
- for (i = 0, tot_found = 0; i < vinput->len; i++) {
- BMVert *v = vinput_arr[i];
- const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit;
-
- if (angle < angle_limit) {
- weight_elems[i].ele = (BMHeader *)v;
- weight_elems[i].weight = angle;
- tot_found++;
- }
- else {
- weight_elems[i].ele = NULL;
- weight_elems[i].weight = angle_max;
- }
- }
-
- if (tot_found != 0) {
- qsort(weight_elems, vinput->len, sizeof(DissolveElemWeight), dissolve_elem_cmp);
-
- for (i = 0; i < tot_found; i++) {
- BMVert *v = (BMVert *)weight_elems[i].ele;
- if (/* topology changes may cause this to be un-collapsable */
- (BM_vert_edge_count(v) == 2) &&
- /* check twice because cumulative effect could dissolve over angle limit */
- bm_vert_edge_face_angle(v) < angle_limit)
- {
- BMEdge *ne = BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */
-
- if (ne && ne->l) {
- BM_edge_normals_update(ne);
- }
- }
- }
- }
+ const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op, "angle_limit"));
+ const int do_dissolve_boundaries = BMO_slot_bool_get(op, "use_dissolve_boundaries");
- MEM_freeN(weight_elems);
+ BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
+ vinput->data.p, vinput->len,
+ einput->data.p, einput->len);
}
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 81cad277bee..627351ead11 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -88,7 +88,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, FALSE);
if (UNLIKELY(f2 == NULL)) {
- BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed; could not create face");
+ BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed: could not create face");
BLI_array_free(edges);
return;
}
@@ -132,46 +132,36 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
* This function won't crash if its not but won't work right either.
* \a e_b is the new edge.
*
- * \note this function could be exposed as an api call if other areas need it,
- * so far only extrude does.
+ * \note The edge this face comes from needs to be from the first and second verts fo the face.
+ * The caller must ensure this else we will copy from the wrong source.
*/
-static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e_a, BMEdge *e_b)
+static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f)
{
- /* 'a' is the starting edge #e, 'b' is the final edge #newedge */
- BMLoop *l_dst_a = BM_face_edge_share_loop(f, e_a);
- BMLoop *l_dst_b = BM_face_edge_share_loop(f, e_b);
- /* we could only have a face on one-or the other edges,
- * check if either side of the face has an adjacent face */
- BMLoop *l_src_1;
- BMLoop *l_src_2;
-
- /* there is no l_src_b */
-
- /* sanity */
- BLI_assert(l_dst_a->f == l_dst_b->f);
-
- if (l_dst_a != l_dst_a->radial_next) {
- l_src_1 = l_dst_a->radial_next;
- l_src_2 = l_src_1->next;
- }
- else if (l_dst_b != l_dst_b->radial_next) {
- l_src_2 = l_dst_b->radial_next;
- l_src_1 = l_src_2->next;
- }
- else {
- /* no new faces on either edge, nothing to copy from */
+ /* edge we are extruded from */
+ BMLoop *l_first_0 = BM_FACE_FIRST_LOOP(f);
+ BMLoop *l_first_1 = l_first_0->next;
+ BMLoop *l_first_2 = l_first_1->next;
+ BMLoop *l_first_3 = l_first_2->next;
+
+ BMLoop *l_other_0;
+ BMLoop *l_other_1;
+
+ if (UNLIKELY(l_first_0 == l_first_0->radial_next)) {
return;
}
- BM_elem_attrs_copy(bm, bm, l_src_1->f, l_dst_a->f);
- BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */
+ l_other_0 = BM_edge_other_loop(l_first_0->e, l_first_0);
+ l_other_1 = BM_edge_other_loop(l_first_0->e, l_first_1);
/* copy data */
- BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_a);
- BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_b->next);
+ BM_elem_attrs_copy(bm, bm, l_other_0->f, f);
+ BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */
- BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_a->next);
- BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_b);
+ BM_elem_attrs_copy(bm, bm, l_other_0, l_first_0);
+ BM_elem_attrs_copy(bm, bm, l_other_0, l_first_3);
+
+ BM_elem_attrs_copy(bm, bm, l_other_1, l_first_1);
+ BM_elem_attrs_copy(bm, bm, l_other_1, l_first_2);
}
/* Disable the skin root flag on the input vert, assumes that the vert
@@ -188,9 +178,8 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
{
BMOIter siter;
BMOperator dupeop;
- BMVert *v1, *v2, *v3, *v4;
- BMEdge *e, *e2;
BMFace *f;
+ BMEdge *e, *e_new;
BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
BMO_elem_flag_enable(bm, e, EXT_INPUT);
@@ -203,33 +192,34 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
/* disable root flag on all new skin nodes */
if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
- BMO_ITER(v1, &siter, bm, &dupeop, "newout", BM_VERT) {
- bm_extrude_disable_skin_root(bm, v1);
+ BMVert *v;
+ BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) {
+ bm_extrude_disable_skin_root(bm, v);
}
}
for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) {
- e2 = BMO_iter_map_value(&siter);
- e2 = *(BMEdge **)e2;
+ BMVert *f_verts[4];
+ e_new = *(BMEdge **)BMO_iter_map_value(&siter);
if (e->l && e->v1 != e->l->v) {
- v1 = e->v1;
- v2 = e->v2;
- v3 = e2->v2;
- v4 = e2->v1;
+ f_verts[0] = e->v1;
+ f_verts[1] = e->v2;
+ f_verts[2] = e_new->v2;
+ f_verts[3] = e_new->v1;
}
else {
- v1 = e2->v1;
- v2 = e2->v2;
- v3 = e->v2;
- v4 = e->v1;
+ f_verts[0] = e->v2;
+ f_verts[1] = e->v1;
+ f_verts[2] = e_new->v1;
+ f_verts[3] = e_new->v2;
}
/* not sure what to do about example face, pass NULL for now */
- f = BM_face_create_quad_tri(bm, v1, v2, v3, v4, NULL, FALSE);
- bm_extrude_copy_face_loop_attributes(bm, f, e, e2);
+ f = BM_face_create_quad_tri_v(bm, f_verts, 4, NULL, FALSE);
+ bm_extrude_copy_face_loop_attributes(bm, f);
if (BMO_elem_flag_test(bm, e, EXT_INPUT))
- e = e2;
+ e = e_new;
BMO_elem_flag_enable(bm, f, EXT_KEEP);
BMO_elem_flag_enable(bm, e, EXT_KEEP);
@@ -270,8 +260,8 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
BMOperator dupeop, delop;
BMOIter siter;
BMIter iter, fiter, viter;
- BMEdge *e, *newedge;
- BMVert *verts[4], *v, *v2;
+ BMEdge *e, *e_new;
+ BMVert *v, *v2;
BMFace *f;
int found, fwd, delorig = FALSE;
@@ -378,6 +368,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
BMO_slot_copy(&dupeop, op, "newout", "geomout");
for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) {
+ BMVert *f_verts[4];
/* this should always be wire, so this is mainly a speedup to avoid map lookup */
if (BM_edge_is_wire(e) && BMO_slot_map_contains(bm, op, "exclude", e)) {
@@ -396,37 +387,37 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
continue;
}
- newedge = *(BMEdge **)BMO_iter_map_value(&siter);
+ e_new = *(BMEdge **)BMO_iter_map_value(&siter);
- if (!newedge) {
+ if (!e_new) {
continue;
}
/* orient loop to give same normal as a loop of newedge
* if it exists (will be an extruded face),
* else same normal as a loop of e, if it exists */
- if (!newedge->l)
+ if (!e_new->l)
fwd = !e->l || !(e->l->v == e->v1);
else
- fwd = (newedge->l->v == newedge->v1);
+ fwd = (e_new->l->v == e_new->v1);
if (fwd) {
- verts[0] = e->v1;
- verts[1] = e->v2;
- verts[2] = newedge->v2;
- verts[3] = newedge->v1;
+ f_verts[0] = e->v1;
+ f_verts[1] = e->v2;
+ f_verts[2] = e_new->v2;
+ f_verts[3] = e_new->v1;
}
else {
- verts[3] = e->v1;
- verts[2] = e->v2;
- verts[1] = newedge->v2;
- verts[0] = newedge->v1;
+ f_verts[0] = e->v2;
+ f_verts[1] = e->v1;
+ f_verts[2] = e_new->v1;
+ f_verts[3] = e_new->v2;
}
/* not sure what to do about example face, pass NULL for now */
- f = BM_face_create_quad_tri_v(bm, verts, 4, NULL, FALSE);
- bm_extrude_copy_face_loop_attributes(bm, f, e, newedge);
+ f = BM_face_create_quad_tri_v(bm, f_verts, 4, NULL, FALSE);
+ bm_extrude_copy_face_loop_attributes(bm, f);
}
/* link isolated vert */
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index d97d901777c..b9c9398fbfa 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -24,19 +24,17 @@
* \ingroup bmesh
*/
+#ifdef WITH_BULLET
+
#include "MEM_guardedalloc.h"
+#include "BLI_array.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
-/*XXX: This operator doesn't work well (at all?) for flat surfaces with
- * >3 sides - creating overlapping faces at times.
- * An easy workaround is to add in some noise but this is
- * weak and unreliable, ideally this would detect flat surfaces
- * (possibly making them into ngons) - see
- */
+#include "Bullet-C-Api.h"
/* XXX: using 128 for totelem and pchunk of mempool, no idea what good
* values would be though */
@@ -46,21 +44,15 @@
#include "intern/bmesh_operators_private.h" /* own include */
-#define HULL_EPSILON_FLT 0.0001f
-/* values above 0.0001 cause errors, see below for details, don't increase
- * without checking against bug [#32027] */
-#define HULL_EPSILON_DOT_FLT 0.00000001f
-
/* Internal operator flags */
typedef enum {
HULL_FLAG_INPUT = (1 << 0),
- HULL_FLAG_TETRA_VERT = (1 << 1),
- HULL_FLAG_INTERIOR_ELE = (1 << 2),
- HULL_FLAG_OUTPUT_GEOM = (1 << 3),
+ HULL_FLAG_INTERIOR_ELE = (1 << 1),
+ HULL_FLAG_OUTPUT_GEOM = (1 << 2),
- HULL_FLAG_DEL = (1 << 4),
- HULL_FLAG_HOLE = (1 << 5)
+ HULL_FLAG_DEL = (1 << 3),
+ HULL_FLAG_HOLE = (1 << 4)
} HullFlags;
/* Store hull triangles separate from BMesh faces until the end; this
@@ -72,63 +64,6 @@ typedef struct HullTriangle {
int skip;
} HullTriangle;
-/* These edges define the hole created in the hull by deleting faces
- * that can "see" a new vertex (the boundary edges then form the edge
- * of a new triangle fan that has the new vertex as its center) */
-typedef struct HullBoundaryEdge {
- struct HullBoundaryEdge *next, *prev;
- BMVert *v[2];
-} HullBoundaryEdge;
-
-
-
-/*************************** Boundary Edges ***************************/
-
-static int edge_match(BMVert *e1_v1, BMVert *e1_v2, BMVert *e2[2])
-{
- return (e1_v1 == e2[0] && e1_v2 == e2[1]) ||
- (e1_v1 == e2[1] && e1_v2 == e2[0]);
-}
-
-/* Returns true if the edge (e1, e2) is already in edges; that edge is
- * deleted here as well. if not found just returns 0 */
-static int check_for_dup(ListBase *edges, BLI_mempool *pool,
- BMVert *v1, BMVert *v2)
-{
- HullBoundaryEdge *e, *e_next;
-
- for (e = edges->first; e; e = e_next) {
- e_next = e->next;
-
- if (edge_match(v1, v2, e->v)) {
- /* remove the interior edge */
- BLI_remlink(edges, e);
- BLI_mempool_free(pool, e);
- return 1;
- }
- }
-
- return 0;
-}
-
-static void expand_boundary_edges(ListBase *edges, BLI_mempool *edge_pool,
- const HullTriangle *t)
-{
- HullBoundaryEdge *e_new;
- int i;
-
- /* Insert each triangle edge into the boundary list; if any of
- * its edges are already in there, remove the edge entirely */
- for (i = 0; i < 3; i++) {
- if (!check_for_dup(edges, edge_pool, t->v[i], t->v[(i + 1) % 3])) {
- e_new = BLI_mempool_calloc(edge_pool);
- e_new->v[0] = t->v[i];
- e_new->v[1] = t->v[(i + 1) % 3];
- BLI_addtail(edges, e_new);
- }
- }
-}
-
/*************************** Hull Triangles ***************************/
@@ -152,75 +87,6 @@ static void hull_add_triangle(BMesh *bm, GHash *hull_triangles, BLI_mempool *poo
normal_tri_v3(t->no, v1->co, v2->co, v3->co);
}
-static int hull_point_tri_side(const HullTriangle *t, const float co[3])
-{
- /* Added epsilon to fix bug [#31941], improves output when some
- * vertices are nearly coplanar. Might need further tweaking for
- * other cases though.
- * ...
- * Update: epsilon of 0.0001 causes [#32027], use HULL_EPSILON_DOT_FLT
- * and give it a much smaller value
- * */
- float p[3], d;
- sub_v3_v3v3(p, co, t->v[0]->co);
- d = dot_v3v3(t->no, p);
- if (d < -HULL_EPSILON_DOT_FLT) return -1;
- else if (d > HULL_EPSILON_DOT_FLT) return 1;
- else return 0;
-}
-
-/* Get all hull triangles that vertex 'v' is outside of */
-static GHash *hull_triangles_v_outside(GHash *hull_triangles, const BMVert *v)
-{
- GHash *outside;
- GHashIterator iter;
-
- outside = BLI_ghash_ptr_new("outside");
-
- GHASH_ITER (iter, hull_triangles) {
- HullTriangle *t = BLI_ghashIterator_getKey(&iter);
-
- if (hull_point_tri_side(t, v->co) > 0)
- BLI_ghash_insert(outside, t, NULL);
- }
-
- return outside;
-}
-
-/* For vertex 'v', find which triangles must be deleted to extend the
- * hull; find the boundary edges of that hole so that it can be filled
- * with connections to the new vertex, and update the hull_triangles
- * to delete the marked triangles */
-static void add_point(BMesh *bm, GHash *hull_triangles, BLI_mempool *hull_pool,
- BLI_mempool *edge_pool, GHash *outside, BMVert *v)
-{
- ListBase edges = {NULL, NULL};
- HullBoundaryEdge *e, *e_next;
- GHashIterator iter;
-
- GHASH_ITER (iter, outside) {
- HullTriangle *t = BLI_ghashIterator_getKey(&iter);
- int i;
-
- expand_boundary_edges(&edges, edge_pool, t);
-
- /* Mark triangle's vertices as interior */
- for (i = 0; i < 3; i++)
- BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_INTERIOR_ELE);
-
- /* Delete the triangle */
- BLI_ghash_remove(hull_triangles, t, NULL, NULL);
- BLI_mempool_free(hull_pool, t);
- }
-
- /* Fill hole boundary with triangles to new point */
- for (e = edges.first; e; e = e_next) {
- e_next = e->next;
- hull_add_triangle(bm, hull_triangles, hull_pool, e->v[0], e->v[1], v);
- BLI_mempool_free(edge_pool, e);
- }
-}
-
static BMFace *hull_find_example_face(BMesh *bm, BMEdge *e)
{
BMIter iter;
@@ -243,6 +109,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
GHASH_ITER (iter, hull_triangles) {
HullTriangle *t = BLI_ghashIterator_getKey(&iter);
+ int i;
if (!t->skip) {
BMEdge *edges[3] = {
@@ -251,25 +118,53 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
BM_edge_create(bm, t->v[2], t->v[0], NULL, TRUE)
};
BMFace *f, *example = NULL;
- int i;
- /* Look for an adjacent face that existed before the hull */
- for (i = 0; i < 3; i++) {
- if (!example)
- example = hull_find_example_face(bm, edges[i]);
+ if (BM_face_exists(bm, t->v, 3, &f)) {
+ /* If the operator is run with "use_existing_faces"
+ * disabled, but an output face in the hull is the
+ * same as a face in the existing mesh, it should not
+ * be marked as unused or interior. */
+ BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM);
+ BMO_elem_flag_disable(bm, f, HULL_FLAG_HOLE);
+ BMO_elem_flag_disable(bm, f, HULL_FLAG_INTERIOR_ELE);
}
+ else {
+ /* Look for an adjacent face that existed before the hull */
+ for (i = 0; i < 3; i++) {
+ if (!example)
+ example = hull_find_example_face(bm, edges[i]);
+ }
- f = BM_face_create_quad_tri_v(bm, t->v, 3, example, FALSE);
- BM_face_copy_shared(bm, f);
-
- /* Mark face/verts/edges for 'geomout' slot and select */
+ /* Create new hull face */
+ f = BM_face_create_quad_tri_v(bm, t->v, 3, example, TRUE);
+ BM_face_copy_shared(bm, f);
+ }
+ /* Mark face for 'geomout' slot and select */
BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM);
BM_face_select_set(bm, f, TRUE);
+
+ /* Mark edges for 'geomout' slot */
for (i = 0; i < 3; i++) {
- BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM);
BMO_elem_flag_enable(bm, edges[i], HULL_FLAG_OUTPUT_GEOM);
}
}
+ else {
+ /* Mark input edges for 'geomout' slot */
+ for (i = 0; i < 3; i++) {
+ const int next = (i == 2 ? 0 : i + 1);
+ BMEdge *e = BM_edge_exists(t->v[i], t->v[next]);
+ if (e &&
+ BMO_elem_flag_test(bm, e, HULL_FLAG_INPUT) &&
+ !BMO_elem_flag_test(bm, e, HULL_FLAG_HOLE)) {
+ BMO_elem_flag_enable(bm, e, HULL_FLAG_OUTPUT_GEOM);
+ }
+ }
+ }
+
+ /* Mark verts for 'geomout' slot */
+ for (i = 0; i < 3; i++) {
+ BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM);
+ }
}
}
@@ -362,158 +257,6 @@ static void hull_final_edges_free(HullFinalEdges *final_edges)
-/************************* Initial Tetrahedron ************************/
-
-static void hull_add_tetrahedron(BMesh *bm, GHash *hull_triangles, BLI_mempool *pool,
- BMVert *tetra[4])
-{
- float center[3];
- int i, indices[4][3] = {
- {0, 1, 2},
- {0, 2, 3},
- {1, 0, 3},
- {2, 1, 3}
- };
-
- /* Calculate center */
- zero_v3(center);
- for (i = 0; i < 4; i++)
- add_v3_v3(center, tetra[i]->co);
- mul_v3_fl(center, 0.25f);
-
- for (i = 0; i < 4; i++) {
- BMVert *v1 = tetra[indices[i][0]];
- BMVert *v2 = tetra[indices[i][1]];
- BMVert *v3 = tetra[indices[i][2]];
- float no[3], d[3];
-
- normal_tri_v3(no, v1->co, v2->co, v3->co);
- sub_v3_v3v3(d, center, v1->co);
- if (dot_v3v3(no, d) > 0)
- SWAP(BMVert *, v1, v3);
-
- hull_add_triangle(bm, hull_triangles, pool, v1, v2, v3);
- }
-}
-
-/* For each axis, get the minimum and maximum input vertices */
-static void hull_get_min_max(BMesh *bm, BMOperator *op,
- BMVert *min[3], BMVert *max[3])
-{
- BMOIter oiter;
- BMVert *v;
-
- min[0] = min[1] = min[2] = NULL;
- max[0] = max[1] = max[2] = NULL;
-
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
- int i;
-
- for (i = 0; i < 3; i++) {
- if (!min[i] || v->co[i] < min[i]->co[i])
- min[i] = v;
- if (!max[i] || v->co[i] > max[i]->co[i])
- max[i] = v;
- }
- }
-}
-
-/* Returns true if input is coplanar */
-static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op,
- BMVert *tetra[4])
-{
- BMVert *min[3], *max[3], *v;
- BMOIter oiter;
- float widest_axis_len, largest_dist, plane_normal[3];
- int i, j, widest_axis;
-
- tetra[0] = tetra[1] = tetra[2] = tetra[3] = NULL;
- hull_get_min_max(bm, op, min, max);
-
- /* Check for flat axis */
- for (i = 0; i < 3; i++) {
- if (min[i] == max[i]) {
- return TRUE;
- }
- }
-
- /* Find widest axis */
- widest_axis_len = 0.0f;
- widest_axis = 0; /* set here in the unlikey case this isn't set below */
- for (i = 0; i < 3; i++) {
- float len = (max[i]->co[i] - min[i]->co[i]);
- if (len >= widest_axis_len) {
- widest_axis_len = len;
- widest_axis = i;
- }
- }
-
- /* Use widest axis for first two points */
- tetra[0] = min[widest_axis];
- tetra[1] = max[widest_axis];
- BMO_elem_flag_enable(bm, tetra[0], HULL_FLAG_TETRA_VERT);
- BMO_elem_flag_enable(bm, tetra[1], HULL_FLAG_TETRA_VERT);
-
- /* Choose third vertex farthest from existing line segment */
- largest_dist = 0;
- for (i = 0; i < 3; i++) {
- BMVert *v;
- float dist;
-
- if (i == widest_axis)
- continue;
-
- v = min[i];
- for (j = 0; j < 2; j++) {
- dist = dist_to_line_segment_v3(v->co, tetra[0]->co, tetra[1]->co);
- if (dist > largest_dist) {
- largest_dist = dist;
- tetra[2] = v;
- }
-
- v = max[i];
- }
- }
-
- if (tetra[2]) {
- BMO_elem_flag_enable(bm, tetra[2], HULL_FLAG_TETRA_VERT);
- }
- else {
- return TRUE;
- }
-
- /* Check for colinear vertices */
- if (largest_dist < HULL_EPSILON_FLT)
- return TRUE;
-
- /* Choose fourth point farthest from existing plane */
- largest_dist = 0;
- normal_tri_v3(plane_normal, tetra[0]->co, tetra[1]->co, tetra[2]->co);
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
- if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) {
- float dist = fabsf(dist_to_plane_v3(v->co, tetra[0]->co, plane_normal));
- if (dist > largest_dist) {
- largest_dist = dist;
- tetra[3] = v;
- }
- }
- }
-
- if (tetra[3]) {
- BMO_elem_flag_enable(bm, tetra[3], HULL_FLAG_TETRA_VERT);
- }
- else {
- return TRUE;
- }
-
- if (largest_dist < HULL_EPSILON_FLT)
- return TRUE;
-
- return FALSE;
-}
-
-
-
/**************************** Final Output ****************************/
static void hull_remove_overlapping(BMesh *bm, GHash *hull_triangles,
@@ -650,44 +393,175 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op)
}
}
- /* Mark edges too if all adjacent faces are holes */
+ /* Mark edges too if all adjacent faces are holes and the edge is
+ * not already isolated */
BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
int hole = TRUE;
+ int any_faces = FALSE;
BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
+ any_faces = TRUE;
if (!BMO_elem_flag_test(bm, f, HULL_FLAG_HOLE)) {
hole = FALSE;
break;
}
}
- if (hole)
+ if (hole && any_faces)
BMO_elem_flag_enable(bm, e, HULL_FLAG_HOLE);
}
}
+static int hull_input_vert_count(BMesh *bm, BMOperator *op)
+{
+ BMOIter oiter;
+ BMVert *v;
+ int count = 0;
+
+ BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ count++;
+ }
+
+ return count;
+}
+
+static BMVert **hull_input_verts_copy(BMesh *bm, BMOperator *op,
+ const int num_input_verts)
+{
+ BMOIter oiter;
+ BMVert *v;
+ BMVert **input_verts = MEM_callocN(sizeof(*input_verts) *
+ num_input_verts, AT);
+ int i = 0;
+
+ BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ input_verts[i++] = v;
+ }
+
+ return input_verts;
+}
+
+static float (*hull_verts_for_bullet(BMVert **input_verts,
+ const int num_input_verts))[3]
+{
+ float (*coords)[3] = MEM_callocN(sizeof(*coords) * num_input_verts, AT);
+ int i;
+
+ for (i = 0; i < num_input_verts; i++) {
+ copy_v3_v3(coords[i], input_verts[i]->co);
+ }
+
+ return coords;
+}
+
+static BMVert **hull_verts_from_bullet(plConvexHull hull,
+ BMVert **input_verts,
+ const int num_input_verts)
+{
+ const int num_verts = plConvexHullNumVertices(hull);
+ BMVert **hull_verts = MEM_mallocN(sizeof(*hull_verts) *
+ num_verts, AT);
+ int i;
+
+ for (i = 0; i < num_verts; i++) {
+ float co[3];
+ int original_index;
+ plConvexHullGetVertex(hull, i, co, &original_index);
+
+ if (original_index >= 0 && original_index < num_input_verts) {
+ hull_verts[i] = input_verts[original_index];
+ }
+ else
+ BLI_assert(!"Unexpected new vertex in hull output");
+ }
+
+ return hull_verts;
+}
+
+static void hull_from_bullet(BMesh *bm, BMOperator *op,
+ GHash *hull_triangles,
+ BLI_mempool *pool)
+{
+ int *fvi = NULL;
+ BLI_array_declare(fvi);
+
+ BMVert **input_verts;
+ float (*coords)[3];
+ BMVert **hull_verts;
+
+ plConvexHull hull;
+ int i, count = 0;
+
+ const int num_input_verts = hull_input_vert_count(bm, op);
+
+ input_verts = hull_input_verts_copy(bm, op, num_input_verts);
+ coords = hull_verts_for_bullet(input_verts, num_input_verts);
+
+ hull = plConvexHullCompute(coords, num_input_verts);
+ hull_verts = hull_verts_from_bullet(hull, input_verts, num_input_verts);
+
+ count = plConvexHullNumFaces(hull);
+ for (i = 0; i < count; i++) {
+ const int len = plConvexHullGetFaceSize(hull, i);
+
+ if (len > 2) {
+ BMVert *fv[3];
+ int j;
+
+ /* Get face vertex indices */
+ BLI_array_empty(fvi);
+ BLI_array_grow_items(fvi, len);
+ plConvexHullGetFaceVertices(hull, i, fvi);
+
+ /* Note: here we throw away any NGons from Bullet and turn
+ * them into triangle fans. Would be nice to use these
+ * directly, but will have to wait until HullTriangle goes
+ * away (TODO) */
+ fv[0] = hull_verts[fvi[0]];
+ for (j = 2; j < len; j++) {
+ fv[1] = hull_verts[fvi[j - 1]];
+ fv[2] = hull_verts[fvi[j]];
+
+ hull_add_triangle(bm, hull_triangles, pool,
+ fv[0], fv[1], fv[2]);
+ }
+ }
+ }
+
+ BLI_array_free(fvi);
+ MEM_freeN(hull_verts);
+ MEM_freeN(coords);
+ MEM_freeN(input_verts);
+}
+
+/* Check that there are at least three vertices in the input */
+static int hull_num_input_verts_is_ok(BMesh *bm, BMOperator *op)
+{
+ BMOIter oiter;
+ BMVert *v;
+ int partial_num_verts = 0;
+
+ BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ partial_num_verts++;
+ if (partial_num_verts >= 3)
+ break;
+ }
+
+ return (partial_num_verts >= 3);
+}
+
void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
{
HullFinalEdges *final_edges;
- BLI_mempool *hull_pool, *edge_pool;
- BMVert *v, *tetra[4];
+ BLI_mempool *hull_pool;
BMElemF *ele;
BMOIter oiter;
GHash *hull_triangles;
- /* Verify that at least four verts in the input */
- if (BMO_slot_get(op, "input")->len < 4) {
- BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED,
- "Requires at least four vertices");
- return;
- }
-
- /* Initialize the convex hull by building a tetrahedron. A
- * degenerate tetrahedron can cause problems, so report error and
- * fail if the result is coplanar */
- if (hull_find_large_tetrahedron(bm, op, tetra)) {
+ /* Verify that at least three verts in the input */
+ if (!hull_num_input_verts_is_ok(bm, op)) {
BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED,
- "Input vertices are coplanar");
+ "Requires at least three vertices");
return;
}
@@ -700,26 +574,11 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_enable(bm, ele, HULL_FLAG_INTERIOR_ELE);
}
- edge_pool = BLI_mempool_create(sizeof(HullBoundaryEdge), 128, 128, 0);
hull_pool = BLI_mempool_create(sizeof(HullTriangle), 128, 128, 0);
hull_triangles = BLI_ghash_ptr_new("hull_triangles");
- /* Add tetrahedron triangles */
- hull_add_tetrahedron(bm, hull_triangles, hull_pool, tetra);
+ hull_from_bullet(bm, op, hull_triangles, hull_pool);
- /* Expand hull to cover new vertices outside the existing hull */
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
- if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) {
- GHash *outside = hull_triangles_v_outside(hull_triangles, v);
- if (BLI_ghash_size(outside)) {
- /* Expand hull and delete interior triangles */
- add_point(bm, hull_triangles, hull_pool, edge_pool, outside, v);
- }
- BLI_ghash_free(outside, NULL, NULL);
- }
- }
-
- BLI_mempool_destroy(edge_pool);
final_edges = hull_final_edges(hull_triangles);
hull_mark_interior_elements(bm, op, final_edges);
@@ -762,3 +621,5 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL,
HULL_FLAG_OUTPUT_GEOM);
}
+
+#endif /* WITH_BULLET */
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 7191aa7a7b6..3dbc0d0a5eb 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -199,7 +199,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
{
BMIter iter, liter;
BMOIter siter;
- BMFace *f1, *f2;
+ BMFace *f;
BMLoop *l;
BMEdge *e;
BLI_array_declare(jedges);
@@ -213,15 +213,16 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
int i, totedge;
/* flag all edges of all input face */
- BMO_ITER (f1, &siter, bm, op, "faces", BM_FACE) {
- BMO_elem_flag_enable(bm, f1, FACE_INPUT);
- BM_ITER_ELEM (l, &liter, f1, BM_LOOPS_OF_FACE) {
+ BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_elem_flag_enable(bm, f, FACE_INPUT);
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
BMO_elem_flag_enable(bm, l->e, EDGE_MARK);
}
}
/* unflag edges that are invalid; e.g. aren't surrounded by triangle */
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ BMFace *f1, *f2;
if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
continue;
@@ -300,6 +301,8 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
}
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ BMFace *f1, *f2;
+
if (!BMO_elem_flag_test(bm, e, EDGE_CHOSEN))
continue;
@@ -310,6 +313,8 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
+ BMFace *f1, *f2;
+
/* ok, this edge wasn't merged, check if it's
* in a 2-tri-pair island, and if so merg */
diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c
index c6b228b988e..937601712b0 100644
--- a/source/blender/bmesh/operators/bmo_mirror.c
+++ b/source/blender/bmesh/operators/bmo_mirror.c
@@ -88,7 +88,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
for (i = 0; i < ototvert; i++) {
- if (ABS(v->co[axis]) <= dist) {
+ if (fabsf(v->co[axis]) <= dist) {
BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", vmap[i], v);
}
v = BM_iter_step(&iter);
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index 30561e47d20..d7b163cb760 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -365,7 +365,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
len2 = len_v3v3(vec, vec2);
/* use shortest segment length divided by 3 as merge threshold */
- BMO_op_callf(bm, op->flag, "remove_doubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f);
+ BMO_op_callf(bm, op->flag, "remove_doubles verts=%fv dist=%f", VERT_MARK, min_ff(len, len2) / 3.0f);
}
/* and now do imat */
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index d3e98dd96c1..ea6cd747037 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -371,7 +371,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
BMIter iter;
BMEdge *e, **edges = NULL;
BLI_array_declare(edges);
- float min[3], max[3];
+ float min[3], max[3], center[3];
int i, tot;
BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
@@ -400,13 +400,12 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
minmax_v3v3_v3(min, max, e->v2->co);
}
- add_v3_v3v3(min, min, max);
- mul_v3_fl(min, 0.5f);
+ mid_v3_v3v3(center, min, max);
/* snap edges to a point. for initial testing purposes anyway */
for (i = 0; i < tot; i++) {
- copy_v3_v3(edges[i]->v1->co, min);
- copy_v3_v3(edges[i]->v2->co, min);
+ copy_v3_v3(edges[i]->v1->co, center);
+ copy_v3_v3(edges[i]->v2->co, center);
if (edges[i]->v1 != edges[0]->v1)
BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", edges[i]->v1, edges[0]->v1);
@@ -489,72 +488,71 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op)
static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname)
{
- BMOIter oiter;
- BMVert *v, *v2;
- BMVert **verts = NULL;
- BLI_array_declare(verts);
- float dist, dist3;
- int i, j, len, keepvert = 0;
-
- dist = BMO_slot_float_get(op, "dist");
- dist3 = dist * 3.0f;
-
- i = 0;
- BMO_ITER (v, &oiter, bm, op, "verts", BM_VERT) {
- BLI_array_grow_one(verts);
- verts[i++] = v;
- }
+ BMVert **verts;
+ int verts_len;
+
+ int i, j, keepvert = 0;
+
+ const float dist = BMO_slot_float_get(op, "dist");
+ const float dist3 = dist * 3.0f;
/* Test whether keep_verts arg exists and is non-empty */
if (BMO_slot_exists(op, "keep_verts")) {
+ BMOIter oiter;
keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL;
}
+ /* get the verts as an array we can sort */
+ verts = BMO_slot_as_arrayN(op, "verts", &verts_len);
+
/* sort by vertex coordinates added together */
- qsort(verts, BLI_array_count(verts), sizeof(void *), vergaverco);
+ qsort(verts, verts_len, sizeof(BMVert *), vergaverco);
/* Flag keep_verts */
if (keepvert) {
BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP);
}
- len = BLI_array_count(verts);
- for (i = 0; i < len; i++) {
- v = verts[i];
- if (BMO_elem_flag_test(bm, v, VERT_DOUBLE)) {
+ for (i = 0; i < verts_len; i++) {
+ BMVert *v_check = verts[i];
+
+ if (BMO_elem_flag_test(bm, v_check, VERT_DOUBLE)) {
continue;
}
- for (j = i + 1; j < len; j++) {
- v2 = verts[j];
+ for (j = i + 1; j < verts_len; j++) {
+ BMVert *v_other = verts[j];
/* Compare sort values of the verts using 3x tolerance (allowing for the tolerance
* on each of the three axes). This avoids the more expensive length comparison
* for most vertex pairs. */
- if ((v2->co[0] + v2->co[1] + v2->co[2]) - (v->co[0] + v->co[1] + v->co[2]) > dist3)
+ if ((v_other->co[0] + v_other->co[1] + v_other->co[2]) -
+ (v_check->co[0] + v_check->co[1] + v_check->co[2]) > dist3)
+ {
break;
+ }
if (keepvert) {
- if (BMO_elem_flag_test(bm, v2, VERT_KEEP) == BMO_elem_flag_test(bm, v, VERT_KEEP))
+ if (BMO_elem_flag_test(bm, v_other, VERT_KEEP) == BMO_elem_flag_test(bm, v_check, VERT_KEEP))
continue;
}
- if (compare_len_v3v3(v->co, v2->co, dist)) {
+ if (compare_len_v3v3(v_check->co, v_other->co, dist)) {
/* If one vert is marked as keep, make sure it will be the target */
- if (BMO_elem_flag_test(bm, v2, VERT_KEEP)) {
- SWAP(BMVert *, v, v2);
+ if (BMO_elem_flag_test(bm, v_other, VERT_KEEP)) {
+ SWAP(BMVert *, v_check, v_other);
}
- BMO_elem_flag_enable(bm, v2, VERT_DOUBLE);
- BMO_elem_flag_enable(bm, v, VERT_TARGET);
+ BMO_elem_flag_enable(bm, v_other, VERT_DOUBLE);
+ BMO_elem_flag_enable(bm, v_check, VERT_TARGET);
- BMO_slot_map_ptr_insert(bm, optarget, targetmapname, v2, v);
+ BMO_slot_map_ptr_insert(bm, optarget, targetmapname, v_other, v_check);
}
}
}
- BLI_array_free(verts);
+ MEM_freeN(verts);
}
void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op)
diff --git a/source/blender/bmesh/operators/bmo_similar.c b/source/blender/bmesh/operators/bmo_similar.c
new file mode 100644
index 00000000000..df03e50d2c4
--- /dev/null
+++ b/source/blender/bmesh/operators/bmo_similar.c
@@ -0,0 +1,614 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Joseph Eagar, Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/operators/bmo_similar.c
+ * \ingroup bmesh
+ *
+ * bmesh operators to select based on
+ * comparisons with the existing selection.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_math.h"
+
+#include "BKE_customdata.h"
+#include "BKE_deform.h"
+
+#include "bmesh.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+/* in fact these could all be the same */
+
+/*
+ * extra face data (computed data)
+ */
+typedef struct SimSel_FaceExt {
+ BMFace *f; /* the face */
+ float c[3]; /* center */
+ union {
+ float area; /* area */
+ float perim; /* perimeter */
+ float d; /* 4th component of plane (the first three being the normal) */
+ struct Image *t; /* image pointer */
+ };
+} SimSel_FaceExt;
+
+static int bm_sel_similar_cmp_fl(const float delta, const float thresh, const int compare)
+{
+ switch (compare) {
+ case SIM_CMP_EQ:
+ return (fabsf(delta) <= thresh);
+ case SIM_CMP_GT:
+ return ((delta + thresh) >= 0.0f);
+ case SIM_CMP_LT:
+ return ((delta - thresh) <= 0.0f);
+ default:
+ BLI_assert(0);
+ return 0;
+ }
+}
+
+static int bm_sel_similar_cmp_i(const int delta, const int compare)
+{
+ switch (compare) {
+ case SIM_CMP_EQ:
+ return (delta == 0);
+ case SIM_CMP_GT:
+ return (delta > 0);
+ case SIM_CMP_LT:
+ return (delta < 0);
+ default:
+ BLI_assert(0);
+ return 0;
+ }
+}
+
+/*
+ * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h
+ * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces
+ */
+void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
+{
+#define FACE_MARK 1
+
+ BMIter fm_iter;
+ BMFace *fs, *fm;
+ BMOIter fs_iter;
+ int num_sels = 0, num_total = 0, i = 0, idx = 0;
+ float angle = 0.0f;
+ SimSel_FaceExt *f_ext = NULL;
+ int *indices = NULL;
+ float t_no[3]; /* temporary normal */
+ const int type = BMO_slot_int_get(op, "type");
+ const float thresh = BMO_slot_float_get(op, "thresh");
+ const float thresh_radians = thresh * (float)M_PI;
+ const int compare = BMO_slot_int_get(op, "compare");
+
+ /* initial_elem - other_elem */
+ float delta_fl;
+ int delta_i;
+
+ num_total = BM_mesh_elem_count(bm, BM_FACE);
+
+ /*
+ * The first thing to do is to iterate through all the the selected items and mark them since
+ * they will be in the selection anyway.
+ * This will increase performance, (especially when the number of originally selected faces is high)
+ * so the overall complexity will be less than $O(mn)$ where is the total number of selected faces,
+ * and n is the total number of faces
+ */
+ BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
+ if (!BMO_elem_flag_test(bm, fs, FACE_MARK)) { /* is this really needed ? */
+ BMO_elem_flag_enable(bm, fs, FACE_MARK);
+ num_sels++;
+ }
+ }
+
+ /* allocate memory for the selected faces indices and for all temporary faces */
+ indices = (int *)MEM_callocN(sizeof(int) * num_sels, "face indices util.c");
+ f_ext = (SimSel_FaceExt *)MEM_callocN(sizeof(SimSel_FaceExt) * num_total, "f_ext util.c");
+
+ /* loop through all the faces and fill the faces/indices structure */
+ BM_ITER_MESH (fm, &fm_iter, bm, BM_FACES_OF_MESH) {
+ f_ext[i].f = fm;
+ if (BMO_elem_flag_test(bm, fm, FACE_MARK)) {
+ indices[idx] = i;
+ idx++;
+ }
+ i++;
+ }
+
+ /*
+ * Save us some computation burden: In case of perimeter/area/coplanar selection we compute
+ * only once.
+ */
+ if (type == SIMFACE_PERIMETER || type == SIMFACE_AREA || type == SIMFACE_COPLANAR || type == SIMFACE_IMAGE) {
+ for (i = 0; i < num_total; i++) {
+ switch (type) {
+ case SIMFACE_PERIMETER:
+ /* set the perimeter */
+ f_ext[i].perim = BM_face_calc_perimeter(f_ext[i].f);
+ break;
+
+ case SIMFACE_COPLANAR:
+ /* compute the center of the polygon */
+ BM_face_calc_center_mean(f_ext[i].f, f_ext[i].c);
+
+ /* normalize the polygon normal */
+ copy_v3_v3(t_no, f_ext[i].f->no);
+ normalize_v3(t_no);
+
+ /* compute the plane distance */
+ f_ext[i].d = dot_v3v3(t_no, f_ext[i].c);
+ break;
+
+ case SIMFACE_AREA:
+ f_ext[i].area = BM_face_calc_area(f_ext[i].f);
+ break;
+
+ case SIMFACE_IMAGE:
+ f_ext[i].t = NULL;
+ if (CustomData_has_layer(&(bm->pdata), CD_MTEXPOLY)) {
+ MTexPoly *mtpoly = CustomData_bmesh_get(&bm->pdata, f_ext[i].f->head.data, CD_MTEXPOLY);
+ f_ext[i].t = mtpoly->tpage;
+ }
+ break;
+ }
+ }
+ }
+
+ /* now select the rest (if any) */
+ for (i = 0; i < num_total; i++) {
+ fm = f_ext[i].f;
+ if (!BMO_elem_flag_test(bm, fm, FACE_MARK) && !BM_elem_flag_test(fm, BM_ELEM_HIDDEN)) {
+ int cont = TRUE;
+ for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
+ fs = f_ext[indices[idx]].f;
+ switch (type) {
+ case SIMFACE_MATERIAL:
+ if (fm->mat_nr == fs->mat_nr) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMFACE_IMAGE:
+ if (f_ext[i].t == f_ext[indices[idx]].t) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMFACE_NORMAL:
+ angle = angle_normalized_v3v3(fs->no, fm->no); /* if the angle between the normals -> 0 */
+ if (angle <= thresh_radians) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMFACE_COPLANAR:
+ angle = angle_normalized_v3v3(fs->no, fm->no); /* angle -> 0 */
+ if (angle <= thresh_radians) { /* and dot product difference -> 0 */
+ delta_fl = f_ext[i].d - f_ext[indices[idx]].d;
+ if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ }
+ break;
+
+ case SIMFACE_AREA:
+ delta_fl = f_ext[i].area - f_ext[indices[idx]].area;
+ if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMFACE_SIDES:
+ delta_i = fm->len - fs->len;
+ if (bm_sel_similar_cmp_i(delta_i, compare)) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMFACE_PERIMETER:
+ delta_fl = f_ext[i].perim - f_ext[indices[idx]].perim;
+ if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
+ BMO_elem_flag_enable(bm, fm, FACE_MARK);
+ cont = FALSE;
+ }
+ break;
+ default:
+ BLI_assert(0);
+ }
+ }
+ }
+ }
+
+ MEM_freeN(f_ext);
+ MEM_freeN(indices);
+
+ /* transfer all marked faces to the output slot */
+ BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_MARK);
+#undef FACE_MARK
+}
+
+/**************************************************************************** *
+ * Similar Edges
+ **************************************************************************** */
+
+/*
+ * extra edge information
+ */
+typedef struct SimSel_EdgeExt {
+ BMEdge *e;
+ union {
+ float dir[3];
+ float angle; /* angle between the face */
+ };
+
+ union {
+ float length; /* edge length */
+ int faces; /* faces count */
+ };
+} SimSel_EdgeExt;
+
+/*
+ * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h
+ * choices are length, direction, face, ...
+ */
+void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
+{
+#define EDGE_MARK 1
+
+ BMOIter es_iter; /* selected edges iterator */
+ BMIter e_iter; /* mesh edges iterator */
+ BMEdge *es; /* selected edge */
+ BMEdge *e; /* mesh edge */
+ int idx = 0, i = 0 /* , f = 0 */;
+ int *indices = NULL;
+ SimSel_EdgeExt *e_ext = NULL;
+ // float *angles = NULL;
+ float angle;
+
+ int num_sels = 0, num_total = 0;
+ const int type = BMO_slot_int_get(op, "type");
+ const float thresh = BMO_slot_float_get(op, "thresh");
+ const int compare = BMO_slot_int_get(op, "compare");
+
+ /* initial_elem - other_elem */
+ float delta_fl;
+ int delta_i;
+
+ /* sanity checks that the data we need is available */
+ switch (type) {
+ case SIMEDGE_CREASE:
+ if (!CustomData_has_layer(&bm->edata, CD_CREASE)) {
+ return;
+ }
+ break;
+ case SIMEDGE_BEVEL:
+ if (!CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
+ return;
+ }
+ break;
+ }
+
+ num_total = BM_mesh_elem_count(bm, BM_EDGE);
+
+ /* iterate through all selected edges and mark them */
+ BMO_ITER (es, &es_iter, bm, op, "edges", BM_EDGE) {
+ BMO_elem_flag_enable(bm, es, EDGE_MARK);
+ num_sels++;
+ }
+
+ /* allocate memory for the selected edges indices and for all temporary edges */
+ indices = (int *)MEM_callocN(sizeof(int) * num_sels, __func__);
+ e_ext = (SimSel_EdgeExt *)MEM_callocN(sizeof(SimSel_EdgeExt) * num_total, __func__);
+
+ /* loop through all the edges and fill the edges/indices structure */
+ BM_ITER_MESH (e, &e_iter, bm, BM_EDGES_OF_MESH) {
+ e_ext[i].e = e;
+ if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
+ indices[idx] = i;
+ idx++;
+ }
+ i++;
+ }
+
+ /* save us some computation time by doing heavy computation once */
+ if (type == SIMEDGE_LENGTH || type == SIMEDGE_FACE || type == SIMEDGE_DIR || type == SIMEDGE_FACE_ANGLE) {
+ for (i = 0; i < num_total; i++) {
+ switch (type) {
+ case SIMEDGE_LENGTH: /* compute the length of the edge */
+ e_ext[i].length = len_v3v3(e_ext[i].e->v1->co, e_ext[i].e->v2->co);
+ break;
+
+ case SIMEDGE_DIR: /* compute the direction */
+ sub_v3_v3v3(e_ext[i].dir, e_ext[i].e->v1->co, e_ext[i].e->v2->co);
+ normalize_v3(e_ext[i].dir);
+ break;
+
+ case SIMEDGE_FACE: /* count the faces around the edge */
+ e_ext[i].faces = BM_edge_face_count(e_ext[i].e);
+ break;
+
+ case SIMEDGE_FACE_ANGLE:
+ e_ext[i].faces = BM_edge_face_count(e_ext[i].e);
+ if (e_ext[i].faces == 2)
+ e_ext[i].angle = BM_edge_calc_face_angle(e_ext[i].e);
+ break;
+ }
+ }
+ }
+
+ /* select the edges if any */
+ for (i = 0; i < num_total; i++) {
+ e = e_ext[i].e;
+ if (!BMO_elem_flag_test(bm, e, EDGE_MARK) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
+ int cont = TRUE;
+ for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
+ es = e_ext[indices[idx]].e;
+ switch (type) {
+ case SIMEDGE_LENGTH:
+ delta_fl = e_ext[i].length - e_ext[indices[idx]].length;
+ if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMEDGE_DIR:
+ /* compute the angle between the two edges */
+ angle = angle_normalized_v3v3(e_ext[i].dir, e_ext[indices[idx]].dir);
+
+ if (angle > (float)(M_PI / 2.0)) /* use the smallest angle between the edges */
+ angle = fabsf(angle - (float)M_PI);
+
+ if (angle / (float)(M_PI / 2.0) <= thresh) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMEDGE_FACE:
+ delta_i = e_ext[i].faces - e_ext[indices[idx]].faces;
+ if (bm_sel_similar_cmp_i(delta_i, compare)) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMEDGE_FACE_ANGLE:
+ if (e_ext[i].faces == 2) {
+ if (e_ext[indices[idx]].faces == 2) {
+ if (fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ }
+ }
+ else {
+ cont = FALSE;
+ }
+ break;
+
+ case SIMEDGE_CREASE:
+ {
+ float *c1, *c2;
+
+ c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE);
+ c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_CREASE);
+ delta_fl = *c1 - *c2;
+
+ if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ }
+ break;
+
+ case SIMEDGE_BEVEL:
+ {
+ float *c1, *c2;
+
+ c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT);
+ c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_BWEIGHT);
+ delta_fl = *c1 - *c2;
+
+ if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ }
+ break;
+
+ case SIMEDGE_SEAM:
+ if (BM_elem_flag_test(e, BM_ELEM_SEAM) == BM_elem_flag_test(es, BM_ELEM_SEAM)) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMEDGE_SHARP:
+ if (BM_elem_flag_test(e, BM_ELEM_SMOOTH) == BM_elem_flag_test(es, BM_ELEM_SMOOTH)) {
+ BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ cont = FALSE;
+ }
+ break;
+ default:
+ BLI_assert(0);
+ }
+ }
+ }
+ }
+
+ MEM_freeN(e_ext);
+ MEM_freeN(indices);
+
+ /* transfer all marked edges to the output slot */
+ BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_MARK);
+
+#undef EDGE_MARK
+}
+
+/**************************************************************************** *
+ * Similar Vertices
+ **************************************************************************** */
+
+typedef struct SimSel_VertExt {
+ BMVert *v;
+ union {
+ int num_faces; /* adjacent faces */
+ int num_edges; /* adjacent edges */
+ MDeformVert *dvert; /* deform vertex */
+ };
+} SimSel_VertExt;
+
+/*
+ * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h
+ * choices are normal, face, vertex group...
+ */
+void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
+{
+#define VERT_MARK 1
+
+ BMOIter vs_iter; /* selected verts iterator */
+ BMIter v_iter; /* mesh verts iterator */
+ BMVert *vs; /* selected vertex */
+ BMVert *v; /* mesh vertex */
+ SimSel_VertExt *v_ext = NULL;
+ int *indices = NULL;
+ int num_total = 0, num_sels = 0, i = 0, idx = 0;
+ const int type = BMO_slot_int_get(op, "type");
+ const float thresh = BMO_slot_float_get(op, "thresh");
+ const float thresh_radians = thresh * (float)M_PI;
+ const int compare = BMO_slot_int_get(op, "compare");
+
+ /* initial_elem - other_elem */
+// float delta_fl;
+ int delta_i;
+
+ num_total = BM_mesh_elem_count(bm, BM_VERT);
+
+ /* iterate through all selected edges and mark them */
+ BMO_ITER (vs, &vs_iter, bm, op, "verts", BM_VERT) {
+ BMO_elem_flag_enable(bm, vs, VERT_MARK);
+ num_sels++;
+ }
+
+ /* allocate memory for the selected vertices indices and for all temporary vertices */
+ indices = (int *)MEM_mallocN(sizeof(int) * num_sels, "vertex indices");
+ v_ext = (SimSel_VertExt *)MEM_mallocN(sizeof(SimSel_VertExt) * num_total, "vertex extra");
+
+ /* loop through all the vertices and fill the vertices/indices structure */
+ BM_ITER_MESH (v, &v_iter, bm, BM_VERTS_OF_MESH) {
+ v_ext[i].v = v;
+ if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
+ indices[idx] = i;
+ idx++;
+ }
+
+ switch (type) {
+ case SIMVERT_FACE:
+ /* calling BM_vert_face_count every time is time consumming, so call it only once per vertex */
+ v_ext[i].num_faces = BM_vert_face_count(v);
+ break;
+
+ case SIMVERT_VGROUP:
+ if (CustomData_has_layer(&(bm->vdata), CD_MDEFORMVERT)) {
+ v_ext[i].dvert = CustomData_bmesh_get(&bm->vdata, v_ext[i].v->head.data, CD_MDEFORMVERT);
+ }
+ else {
+ v_ext[i].dvert = NULL;
+ }
+ break;
+ case SIMVERT_EDGE:
+ v_ext[i].num_edges = BM_vert_edge_count(v);
+ break;
+ }
+
+ i++;
+ }
+
+ /* select the vertices if any */
+ for (i = 0; i < num_total; i++) {
+ v = v_ext[i].v;
+ if (!BMO_elem_flag_test(bm, v, VERT_MARK) && !BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
+ int cont = TRUE;
+ for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
+ vs = v_ext[indices[idx]].v;
+ switch (type) {
+ case SIMVERT_NORMAL:
+ /* compare the angle between the normals */
+ if (angle_normalized_v3v3(v->no, vs->no) <= thresh_radians) {
+ BMO_elem_flag_enable(bm, v, VERT_MARK);
+ cont = FALSE;
+ }
+ break;
+ case SIMVERT_FACE:
+ /* number of adjacent faces */
+ delta_i = v_ext[i].num_faces - v_ext[indices[idx]].num_faces;
+ if (bm_sel_similar_cmp_i(delta_i, compare)) {
+ BMO_elem_flag_enable(bm, v, VERT_MARK);
+ cont = FALSE;
+ }
+ break;
+
+ case SIMVERT_VGROUP:
+ if (v_ext[i].dvert != NULL && v_ext[indices[idx]].dvert != NULL) {
+ if (defvert_find_shared(v_ext[i].dvert, v_ext[indices[idx]].dvert) != -1) {
+ BMO_elem_flag_enable(bm, v, VERT_MARK);
+ cont = FALSE;
+ }
+ }
+ break;
+ case SIMVERT_EDGE:
+ /* number of adjacent edges */
+ delta_i = v_ext[i].num_edges - v_ext[indices[idx]].num_edges;
+ if (bm_sel_similar_cmp_i(delta_i, compare)) {
+ BMO_elem_flag_enable(bm, v, VERT_MARK);
+ cont = FALSE;
+ }
+ break;
+ default:
+ BLI_assert(0);
+ }
+ }
+ }
+ }
+
+ MEM_freeN(indices);
+ MEM_freeN(v_ext);
+
+ BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+
+#undef VERT_MARK
+}
diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c
index 0036f095d00..6db76119205 100644
--- a/source/blender/bmesh/operators/bmo_slide.c
+++ b/source/blender/bmesh/operators/bmo_slide.c
@@ -63,7 +63,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op)
if (G.debug & G_DEBUG) {
fprintf(stderr, "slide_vert: No vertex selected...");
}
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection.");
+ BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide error: invalid selection");
return;
}
@@ -83,7 +83,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op)
if (G.debug & G_DEBUG) {
fprintf(stderr, "slide_vert: select a single edge\n");
}
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection.");
+ BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide error: invalid selection");
return;
}
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
new file mode 100644
index 00000000000..362123e412d
--- /dev/null
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -0,0 +1,619 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Alexander Pinzon
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/operators/bmo_smooth_laplacian.c
+ * \ingroup bmesh
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_meshdata_types.h"
+
+#include "BLI_array.h"
+#include "BLI_heap.h"
+#include "BLI_math.h"
+#include "BLI_math_geom.h"
+#include "BLI_smallhash.h"
+
+#include "BKE_customdata.h"
+#include "BKE_mesh.h"
+
+#include "bmesh.h"
+
+#include "ONL_opennl.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+// #define SMOOTH_LAPLACIAN_AREA_FACTOR 4.0f /* UNUSED */
+// #define SMOOTH_LAPLACIAN_EDGE_FACTOR 2.0f /* UNUSED */
+#define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE 1.8f
+#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15f
+
+struct BLaplacianSystem {
+ float *eweights; /* Length weights per Edge */
+ float (*fweights)[3]; /* Cotangent weights per face */
+ float *ring_areas; /* Total area per ring*/
+ float *vlengths; /* Total sum of lengths(edges) per vertice*/
+ float *vweights; /* Total sum of weights per vertice*/
+ int numEdges; /* Number of edges*/
+ int numFaces; /* Number of faces*/
+ int numVerts; /* Number of verts*/
+ short *zerola; /* Is zero area or length*/
+
+ /* Pointers to data*/
+ BMesh *bm;
+ BMOperator *op;
+ NLContext *context;
+
+ /*Data*/
+ float min_area;
+};
+typedef struct BLaplacianSystem LaplacianSystem;
+
+static float compute_volume(BMesh *bm);
+static float cotan_weight(float *v1, float *v2, float *v3);
+static int vert_is_boundary(BMVert *v);
+static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts);
+static void init_laplacian_matrix(LaplacianSystem *sys);
+static void delete_laplacian_system(LaplacianSystem *sys);
+static void delete_void_pointer(void *data);
+static void fill_laplacian_matrix(LaplacianSystem *sys);
+static void memset_laplacian_system(LaplacianSystem *sys, int val);
+static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int volumepreservation);
+static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez);
+
+static void delete_void_pointer(void *data)
+{
+ if (data) {
+ MEM_freeN(data);
+ data = NULL;
+ }
+}
+
+static void delete_laplacian_system(LaplacianSystem *sys)
+{
+ delete_void_pointer(sys->eweights);
+ delete_void_pointer(sys->fweights);
+ delete_void_pointer(sys->ring_areas);
+ delete_void_pointer(sys->vlengths);
+ delete_void_pointer(sys->vweights);
+ delete_void_pointer(sys->zerola);
+ if (sys->context) {
+ nlDeleteContext(sys->context);
+ }
+ sys->bm = NULL;
+ sys->op = NULL;
+ MEM_freeN(sys);
+}
+
+static void memset_laplacian_system(LaplacianSystem *sys, int val)
+{
+ memset(sys->eweights, val, sizeof(float) * sys->numEdges);
+ memset(sys->fweights, val, sizeof(float) * sys->numFaces * 3);
+ memset(sys->ring_areas, val, sizeof(float) * sys->numVerts);
+ memset(sys->vlengths, val, sizeof(float) * sys->numVerts);
+ memset(sys->vweights, val, sizeof(float) * sys->numVerts);
+ memset(sys->zerola, val, sizeof(short) * sys->numVerts);
+}
+
+static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts)
+{
+ LaplacianSystem *sys;
+ sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem");
+ sys->numEdges = a_numEdges;
+ sys->numFaces = a_numFaces;
+ sys->numVerts = a_numVerts;
+
+ sys->eweights = MEM_callocN(sizeof(float) * sys->numEdges, "ModLaplSmoothEWeight");
+ if (!sys->eweights) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight");
+ if (!sys->fweights) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->ring_areas = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothRingAreas");
+ if (!sys->ring_areas) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->vlengths = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVlengths");
+ if (!sys->vlengths) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->vweights = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVweights");
+ if (!sys->vweights) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->zerola = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothZeloa");
+ if (!sys->zerola) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ return sys;
+}
+
+/* Compute weigth between vertice v_i and all your neighbors
+ * weight between v_i and v_neighbor
+ * Wij = cot(alpha) + cot(beta) / (4.0 * total area of all faces * sum all weight)
+ * v_i *
+ * / | \
+ * / | \
+ * v_beta* | * v_alpha
+ * \ | /
+ * \ | /
+ * * v_neighbor
+ */
+
+static void init_laplacian_matrix(LaplacianSystem *sys)
+{
+ float areaf;
+ float *v1, *v2, *v3, *v4;
+ float w1, w2, w3, w4;
+ int i, j;
+ int has_4_vert;
+ unsigned int idv1, idv2, idv3, idv4, idv[4];
+ BMEdge *e;
+ BMFace *f;
+ BMIter eiter;
+ BMIter fiter;
+ BMIter vi;
+ BMVert *vn;
+ BMVert *vf[4];
+
+ BM_ITER_MESH_INDEX (e, &eiter, sys->bm, BM_EDGES_OF_MESH, j) {
+ if (!BM_elem_flag_test(e, BM_ELEM_SELECT) && BM_edge_is_boundary(e)) {
+ v1 = e->v1->co;
+ v2 = e->v2->co;
+ idv1 = BM_elem_index_get(e->v1);
+ idv2 = BM_elem_index_get(e->v2);
+
+ w1 = len_v3v3(v1, v2);
+ if (w1 > sys->min_area) {
+ w1 = 1.0f / w1;
+ i = BM_elem_index_get(e);
+ sys->eweights[i] = w1;
+ sys->vlengths[idv1] += w1;
+ sys->vlengths[idv2] += w1;
+ }
+ else {
+ sys->zerola[idv1] = 1;
+ sys->zerola[idv2] = 1;
+ }
+ }
+ }
+
+ BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+
+ BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
+ vf[i] = vn;
+ }
+ has_4_vert = (i == 4) ? 1 : 0;
+ idv1 = BM_elem_index_get(vf[0]);
+ idv2 = BM_elem_index_get(vf[1]);
+ idv3 = BM_elem_index_get(vf[2]);
+ idv4 = has_4_vert ? BM_elem_index_get(vf[3]) : 0;
+
+ v1 = vf[0]->co;
+ v2 = vf[1]->co;
+ v3 = vf[2]->co;
+ v4 = has_4_vert ? vf[3]->co : 0;
+
+ if (has_4_vert) {
+ areaf = area_quad_v3(v1, v2, v3, v4);
+ }
+ else {
+ areaf = area_tri_v3(v1, v2, v3);
+ }
+
+ if (fabsf(areaf) < sys->min_area) {
+ sys->zerola[idv1] = 1;
+ sys->zerola[idv2] = 1;
+ sys->zerola[idv3] = 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) {
+
+ idv[0] = idv1;
+ idv[1] = idv2;
+ idv[2] = idv3;
+ idv[3] = idv4;
+
+ for (j = 0; j < 4; j++) {
+ idv1 = idv[j];
+ idv2 = idv[(j + 1) % 4];
+ idv3 = idv[(j + 2) % 4];
+ idv4 = idv[(j + 3) % 4];
+
+ v1 = vf[j]->co;
+ v2 = vf[(j + 1) % 4]->co;
+ v3 = vf[(j + 2) % 4]->co;
+ v4 = vf[(j + 3) % 4]->co;
+
+ w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
+ w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
+ w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
+
+ sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f;
+ }
+ }
+ else {
+ i = BM_elem_index_get(f);
+
+ w1 = cotan_weight(v1, v2, v3);
+ w2 = cotan_weight(v2, v3, v1);
+ w3 = cotan_weight(v3, v1, v2);
+
+ sys->fweights[i][0] += w1;
+ sys->fweights[i][1] += w2;
+ sys->fweights[i][2] += w3;
+
+ sys->vweights[idv1] += w2 + w3;
+ sys->vweights[idv2] += w1 + w3;
+ sys->vweights[idv3] += w1 + w2;
+ }
+ }
+ }
+}
+
+static void fill_laplacian_matrix(LaplacianSystem *sys)
+{
+ float *v1, *v2, *v3, *v4;
+ float w2, w3, w4;
+ int i, j;
+ int has_4_vert;
+ unsigned int idv1, idv2, idv3, idv4, idv[4];
+
+ BMEdge *e;
+ BMFace *f;
+ BMIter eiter;
+ BMIter fiter;
+ BMIter vi;
+ BMVert *vn;
+ BMVert *vf[4];
+
+ BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
+ vf[i] = vn;
+ }
+ has_4_vert = (i == 4) ? 1 : 0;
+ if (has_4_vert) {
+ idv[0] = BM_elem_index_get(vf[0]);
+ idv[1] = BM_elem_index_get(vf[1]);
+ idv[2] = BM_elem_index_get(vf[2]);
+ idv[3] = BM_elem_index_get(vf[3]);
+ for (j = 0; j < 4; j++) {
+ idv1 = idv[j];
+ idv2 = idv[(j + 1) % 4];
+ idv3 = idv[(j + 2) % 4];
+ idv4 = idv[(j + 3) % 4];
+
+ v1 = vf[j]->co;
+ v2 = vf[(j + 1) % 4]->co;
+ v3 = vf[(j + 2) % 4]->co;
+ v4 = vf[(j + 3) % 4]->co;
+
+ w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
+ w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
+ w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
+
+ w2 = w2 / 4.0f;
+ w3 = w3 / 4.0f;
+ w4 = w4 / 4.0f;
+
+ if (!vert_is_boundary(vf[j]) && sys->zerola[idv1] == 0) {
+ nlMatrixAdd(idv1, idv2, w2 * sys->vweights[idv1]);
+ nlMatrixAdd(idv1, idv3, w3 * sys->vweights[idv1]);
+ nlMatrixAdd(idv1, idv4, w4 * sys->vweights[idv1]);
+ }
+ }
+ }
+ else {
+ idv1 = BM_elem_index_get(vf[0]);
+ idv2 = BM_elem_index_get(vf[1]);
+ idv3 = BM_elem_index_get(vf[2]);
+ /* Is ring if number of faces == number of edges around vertice*/
+ i = BM_elem_index_get(f);
+ if (!vert_is_boundary(vf[0]) && sys->zerola[idv1] == 0) {
+ nlMatrixAdd(idv1, idv2, sys->fweights[i][2] * sys->vweights[idv1]);
+ nlMatrixAdd(idv1, idv3, sys->fweights[i][1] * sys->vweights[idv1]);
+ }
+ if (!vert_is_boundary(vf[1]) && sys->zerola[idv2] == 0) {
+ nlMatrixAdd(idv2, idv1, sys->fweights[i][2] * sys->vweights[idv2]);
+ nlMatrixAdd(idv2, idv3, sys->fweights[i][0] * sys->vweights[idv2]);
+ }
+ if (!vert_is_boundary(vf[2]) && sys->zerola[idv3] == 0) {
+ nlMatrixAdd(idv3, idv1, sys->fweights[i][1] * sys->vweights[idv3]);
+ nlMatrixAdd(idv3, idv2, sys->fweights[i][0] * sys->vweights[idv3]);
+ }
+ }
+ }
+ }
+ BM_ITER_MESH (e, &eiter, sys->bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(e, BM_ELEM_SELECT) && BM_edge_is_boundary(e) ) {
+ v1 = e->v1->co;
+ v2 = e->v2->co;
+ idv1 = BM_elem_index_get(e->v1);
+ idv2 = BM_elem_index_get(e->v2);
+ if (sys->zerola[idv1] == 0 && sys->zerola[idv2] == 0) {
+ i = BM_elem_index_get(e);
+ nlMatrixAdd(idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]);
+ nlMatrixAdd(idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]);
+ }
+ }
+ }
+}
+
+static float cotan_weight(float *v1, float *v2, float *v3)
+{
+ float a[3], b[3], c[3], clen;
+
+ sub_v3_v3v3(a, v2, v1);
+ sub_v3_v3v3(b, v3, v1);
+ cross_v3_v3v3(c, a, b);
+
+ clen = len_v3(c);
+
+ if (clen == 0.0f)
+ return 0.0f;
+
+ return dot_v3v3(a, b) / clen;
+}
+
+static int vert_is_boundary(BMVert *v)
+{
+ BMEdge *ed;
+ BMFace *f;
+ BMIter ei;
+ BMIter fi;
+ BM_ITER_ELEM (ed, &ei, v, BM_EDGES_OF_VERT) {
+ if (BM_edge_is_boundary(ed)) {
+ return 1;
+ }
+ }
+ BM_ITER_ELEM (f, &fi, v, BM_FACES_OF_VERT) {
+ if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static float compute_volume(BMesh *bm)
+{
+ float vol = 0.0f;
+ float x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
+ int i;
+ BMFace *f;
+ BMIter fiter;
+ BMIter vi;
+ BMVert *vn;
+ BMVert *vf[4];
+
+ BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
+ BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
+ vf[i] = vn;
+ }
+ x1 = vf[0]->co[0];
+ y1 = vf[0]->co[1];
+ z1 = vf[0]->co[2];
+
+ x2 = vf[1]->co[0];
+ y2 = vf[1]->co[1];
+ z2 = vf[1]->co[2];
+
+ x3 = vf[2]->co[0];
+ y3 = vf[2]->co[1];
+ z3 = vf[2]->co[2];
+
+ vol += (1.0f / 6.0f) * (0.0f - x3 * y2 * z1 + x2 * y3 * z1 + x3 * y1 * z2 - x1 * y3 * z2 - x2 * y1 * z3 + x1 * y2 * z3);
+
+ if (i == 4) {
+ x4 = vf[3]->co[0];
+ y4 = vf[3]->co[1];
+ z4 = vf[3]->co[2];
+ vol += (1.0f / 6.0f) * (x1 * y3 * z4 - x1 * y4 * z3 - x3 * y1 * z4 + x3 * z1 * y4 + y1 * x4 * z3 - x4 * y3 * z1);
+ }
+ }
+ return fabs(vol);
+}
+
+static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez)
+{
+ float beta;
+ BMOIter siter;
+ BMVert *v;
+
+ if (vend != 0.0f) {
+ beta = pow(vini / vend, 1.0f / 3.0f);
+ BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ if (usex) {
+ v->co[0] *= beta;
+ }
+ if (usey) {
+ v->co[1] *= beta;
+ }
+ if (usez) {
+ v->co[2] *= beta;
+ }
+
+ }
+ }
+}
+
+static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int volumepreservation)
+{
+ int m_vertex_id;
+ float leni, lene;
+ float vini, vend;
+ float *vi1, *vi2, ve1[3], ve2[3];
+ unsigned int idv1, idv2;
+ BMOIter siter;
+ BMVert *v;
+ BMEdge *e;
+ BMIter eiter;
+
+ BM_ITER_MESH (e, &eiter, sys->bm, BM_EDGES_OF_MESH) {
+ idv1 = BM_elem_index_get(e->v1);
+ idv2 = BM_elem_index_get(e->v2);
+ vi1 = e->v1->co;
+ vi2 = e->v2->co;
+ ve1[0] = nlGetVariable(0, idv1);
+ ve1[1] = nlGetVariable(1, idv1);
+ ve1[2] = nlGetVariable(2, idv1);
+ ve2[0] = nlGetVariable(0, idv2);
+ ve2[1] = nlGetVariable(1, idv2);
+ ve2[2] = nlGetVariable(2, idv2);
+ leni = len_v3v3(vi1, vi2);
+ lene = len_v3v3(ve1, ve2);
+ if (lene > leni * SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE || lene < leni * SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE) {
+ sys->zerola[idv1] = 1;
+ sys->zerola[idv2] = 1;
+ }
+ }
+
+ if (volumepreservation) {
+ vini = compute_volume(sys->bm);
+ }
+ BMO_ITER (v, &siter, sys->bm, sys->op, "verts", BM_VERT) {
+ m_vertex_id = BM_elem_index_get(v);
+ if (sys->zerola[m_vertex_id] == 0) {
+ if (usex) {
+ v->co[0] = nlGetVariable(0, m_vertex_id);
+ }
+ if (usey) {
+ v->co[1] = nlGetVariable(1, m_vertex_id);
+ }
+ if (usez) {
+ v->co[2] = nlGetVariable(2, m_vertex_id);
+ }
+ }
+ }
+ if (volumepreservation) {
+ vend = compute_volume(sys->bm);
+ volume_preservation(sys->bm, sys->op, vini, vend, usex, usey, usez);
+ }
+
+}
+
+void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
+{
+ int i;
+ int m_vertex_id;
+ int usex, usey, usez, volumepreservation;
+ float lambda, lambda_border;
+ float w;
+ BMOIter siter;
+ BMVert *v;
+ LaplacianSystem *sys;
+
+ sys = init_laplacian_system(bm->totedge, bm->totface, bm->totvert);
+ if (!sys) return;
+ sys->bm = bm;
+ sys->op = op;
+
+ memset_laplacian_system(sys, 0);
+
+ BM_mesh_elem_index_ensure(bm, BM_VERT);
+ lambda = BMO_slot_float_get(op, "lambda");
+ lambda_border = BMO_slot_float_get(op, "lambda_border");
+ sys->min_area = 0.00001f;
+ usex = BMO_slot_bool_get(op, "use_x");
+ usey = BMO_slot_bool_get(op, "use_y");
+ usez = BMO_slot_bool_get(op, "use_z");
+ volumepreservation = BMO_slot_bool_get(op, "volume_preservation");
+
+
+ nlNewContext();
+ sys->context = nlGetCurrent();
+
+ nlSolverParameteri(NL_NB_VARIABLES, bm->totvert);
+ nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE);
+ nlSolverParameteri(NL_NB_ROWS, bm->totvert);
+ nlSolverParameteri(NL_NB_RIGHT_HAND_SIDES, 3);
+
+ nlBegin(NL_SYSTEM);
+ for (i = 0; i < bm->totvert; i++) {
+ nlLockVariable(i);
+ }
+ BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ m_vertex_id = BM_elem_index_get(v);
+ nlUnlockVariable(m_vertex_id);
+ nlSetVariable(0, m_vertex_id, v->co[0]);
+ nlSetVariable(1, m_vertex_id, v->co[1]);
+ nlSetVariable(2, m_vertex_id, v->co[2]);
+ }
+
+ nlBegin(NL_MATRIX);
+ init_laplacian_matrix(sys);
+ BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ m_vertex_id = BM_elem_index_get(v);
+ nlRightHandSideAdd(0, m_vertex_id, v->co[0]);
+ nlRightHandSideAdd(1, m_vertex_id, v->co[1]);
+ nlRightHandSideAdd(2, m_vertex_id, v->co[2]);
+ i = m_vertex_id;
+ if (sys->zerola[i] == 0) {
+ w = sys->vweights[i] * sys->ring_areas[i];
+ sys->vweights[i] = (w == 0.0f) ? 0.0f : -lambda / (4.0f * w);
+ w = sys->vlengths[i];
+ sys->vlengths[i] = (w == 0.0f) ? 0.0f : -lambda_border * 2.0f / w;
+
+ if (!vert_is_boundary(v)) {
+ nlMatrixAdd(i, i, 1.0f + lambda / (4.0f * sys->ring_areas[i]));
+ }
+ else {
+ nlMatrixAdd(i, i, 1.0f + lambda_border * 2.0f);
+ }
+ }
+ else {
+ nlMatrixAdd(i, i, 1.0f);
+ }
+ }
+ fill_laplacian_matrix(sys);
+
+ nlEnd(NL_MATRIX);
+ nlEnd(NL_SYSTEM);
+
+ if (nlSolveAdvanced(NULL, NL_TRUE) ) {
+ validate_solution(sys, usex, usey, usez, volumepreservation);
+ }
+
+ delete_laplacian_system(sys);
+}
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 4ec3d3471e6..f6b9b18d716 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -54,7 +54,7 @@
#define ELE_SPLIT 16
/* see bug [#32665], 0.00005 means a we get face splits at a little under 1.0 degrees */
-#define FLT_FACE_SPLIT_EPSILON 0.00005
+#define FLT_FACE_SPLIT_EPSILON 0.00005f
/*
* NOTE: beauty has been renamed to flag!
@@ -825,7 +825,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
/* make sure the two edges have a valid angle to each other */
- if (totesel == 2 && BM_edge_share_vert_count(e1, e2)) {
+ if (totesel == 2 && BM_edge_share_vert_check(e1, e2)) {
sub_v3_v3v3(vec1, e1->v2->co, e1->v1->co);
sub_v3_v3v3(vec2, e2->v2->co, e2->v1->co);
normalize_v3(vec1);
@@ -982,7 +982,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
* This edge pair could be used by more then one face,
* in this case it used to (2.63), split both faces along the same verts
* while it could be calculated which face should do the split,
- * its ambigious, so in this case we're better off to skip them as exceptional cases
+ * it's ambiguous, so in this case we're better off to skip them as exceptional cases
* and not try to be clever guessing which face to cut up.
*
* To avoid this case we need to check:
diff --git a/source/blender/bmesh/operators/bmo_symmetrize.c b/source/blender/bmesh/operators/bmo_symmetrize.c
new file mode 100644
index 00000000000..a428405fb8b
--- /dev/null
+++ b/source/blender/bmesh/operators/bmo_symmetrize.c
@@ -0,0 +1,663 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Nicholas Bishop
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_array.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "bmesh.h"
+#include "intern/bmesh_operators_private.h"
+
+enum {
+ SYMM_OUTPUT_GEOM = (1 << 0)
+};
+
+/* Note: don't think there's much need to make these user-adjustable? */
+#define SYMM_AXIS_THRESHOLD 0.00002f
+#define SYMM_VERT_THRESHOLD 0.00002f
+
+typedef enum {
+ /* Coordinate lies on the side being copied from */
+ SYMM_SIDE_KEEP,
+ /* Coordinate lies on the side being copied from and within the
+ * axis threshold */
+ SYMM_SIDE_AXIS,
+ /* Coordinate lies on the side being copied to */
+ SYMM_SIDE_KILL
+} SymmSide;
+
+typedef struct {
+ BMesh *bm;
+ BMOperator *op;
+
+ int axis;
+ BMO_SymmDirection direction;
+
+ /* Maps from input vertices to their mirrors. If the vertex
+ * doesn't have a mirror, it's not in this map. If the vertex is
+ * within the axis threshold, it's mapped to itself. */
+ GHash *vert_symm_map;
+
+ /* Edges that cross the symmetry plane and are asymmetric get
+ * split. This map goes from input edges to output vertices. If an
+ * edge is not split, it's not in this map. */
+ GHash *edge_split_map;
+} Symm;
+
+/* Return which side the coordinate lies on */
+static SymmSide symm_co_side(const Symm *symm,
+ const float *co)
+{
+ float comp = co[symm->axis];
+ if (ELEM3(symm->direction,
+ BMO_SYMMETRIZE_NEGATIVE_X,
+ BMO_SYMMETRIZE_NEGATIVE_Y,
+ BMO_SYMMETRIZE_NEGATIVE_Z))
+ {
+ comp = -comp;
+ }
+
+ if (comp >= 0) {
+ if (comp < SYMM_AXIS_THRESHOLD)
+ return SYMM_SIDE_AXIS;
+ else
+ return SYMM_SIDE_KEEP;
+ }
+ else
+ return SYMM_SIDE_KILL;
+}
+
+/* Output vertices and the vert_map array */
+static void symm_verts_mirror(Symm *symm)
+{
+ BMOIter oiter;
+ BMVert *src_v, *dst_v;
+
+ symm->vert_symm_map = BLI_ghash_ptr_new(AT);
+
+ BMO_ITER (src_v, &oiter, symm->bm, symm->op, "input", BM_VERT) {
+ SymmSide side = symm_co_side(symm, src_v->co);
+ float co[3];
+
+ switch (side) {
+ case SYMM_SIDE_KEEP:
+ /* The vertex is outside the axis area; output its mirror */
+ copy_v3_v3(co, src_v->co);
+ co[symm->axis] = -co[symm->axis];
+
+ dst_v = BM_vert_create(symm->bm, co, src_v);
+ BMO_elem_flag_enable(symm->bm, dst_v, SYMM_OUTPUT_GEOM);
+ BLI_ghash_insert(symm->vert_symm_map, src_v, dst_v);
+ break;
+
+ case SYMM_SIDE_AXIS:
+ /* The vertex is within the axis area, snap to center */
+ src_v->co[symm->axis] = 0;
+ /* Vertex isn't copied, map to itself */
+ BLI_ghash_insert(symm->vert_symm_map, src_v, src_v);
+ break;
+
+ case SYMM_SIDE_KILL:
+ /* The vertex does not lie in the half-space being
+ * copied from, nothing to do */
+ break;
+ }
+ }
+}
+
+static int symm_edge_crosses_axis(const Symm *symm, const BMEdge *e)
+{
+ const int sides[2] = {symm_co_side(symm, e->v1->co),
+ symm_co_side(symm, e->v2->co)};
+
+ return ((sides[0] != SYMM_SIDE_AXIS) &&
+ (sides[1] != SYMM_SIDE_AXIS) &&
+ (sides[0] != sides[1]));
+}
+
+/* Output edge split vertices for asymmetric edges and the edge_splits
+ * mapping array */
+static void symm_split_asymmetric_edges(Symm *symm)
+{
+ BMOIter oiter;
+ BMEdge *e;
+
+ symm->edge_split_map = BLI_ghash_ptr_new(AT);
+
+ BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) {
+ float flipped[3];
+
+ copy_v3_v3(flipped, e->v1->co);
+ flipped[symm->axis] = -flipped[symm->axis];
+
+ if (symm_edge_crosses_axis(symm, e) &&
+ (!compare_v3v3(e->v2->co, flipped, SYMM_VERT_THRESHOLD)))
+ {
+ /* Endpoints lie on opposite sides and are asymmetric */
+
+ BMVert *v;
+ float lambda = 0, edge_dir[3], co[3];
+ float plane_co[3][3][3] = {
+ /* axis == 0 */
+ {{0, 0, 0}, {0, 1, 0}, {0, 0, 1}},
+ /* axis == 1 */
+ {{0, 0, 0}, {1, 0, 0}, {0, 0, 1}},
+ /* axis == 2 */
+ {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}},
+ };
+ int r;
+
+ /* Find intersection of edge with symmetry plane */
+ sub_v3_v3v3(edge_dir, e->v2->co, e->v1->co);
+ normalize_v3(edge_dir);
+ r = isect_ray_plane_v3(e->v1->co,
+ edge_dir,
+ plane_co[symm->axis][0],
+ plane_co[symm->axis][1],
+ plane_co[symm->axis][2],
+ &lambda, TRUE);
+ BLI_assert(r);
+
+ madd_v3_v3v3fl(co, e->v1->co, edge_dir, lambda);
+ co[symm->axis] = 0;
+
+ /* Edge is asymmetric, split it with a new vertex */
+ v = BM_vert_create(symm->bm, co, e->v1);
+ BMO_elem_flag_enable(symm->bm, v, SYMM_OUTPUT_GEOM);
+ BLI_ghash_insert(symm->edge_split_map, e, v);
+ }
+ }
+}
+
+static void symm_mirror_edges(Symm *symm)
+{
+ BMOIter oiter;
+ BMEdge *e;
+
+ BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) {
+ BMVert *v1 = NULL, *v2 = NULL;
+ BMEdge *e_new;
+
+ v1 = BLI_ghash_lookup(symm->vert_symm_map, e->v1);
+ v2 = BLI_ghash_lookup(symm->vert_symm_map, e->v2);
+
+ if (v1 && v2) {
+ e_new = BM_edge_create(symm->bm, v1, v2, e, TRUE);
+ BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
+ }
+ else if (v1 || v2) {
+ if (BLI_ghash_haskey(symm->edge_split_map, e)) {
+ BMVert *v_split = BLI_ghash_lookup(symm->edge_split_map, e);
+
+ /* Output the keep side of the split edge */
+ if (!v1) {
+ e_new = BM_edge_create(symm->bm, v_split, e->v2, e, TRUE);
+ BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
+ v1 = v_split;
+ }
+ else {
+ e_new = BM_edge_create(symm->bm, e->v1, v_split, e, TRUE);
+ BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
+ v2 = v_split;
+ }
+
+ /* Output the kill side of the split edge */
+ e_new = BM_edge_create(symm->bm, v1, v2, e, TRUE);
+ BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
+ }
+ }
+ }
+}
+
+/****************************** SymmPoly ******************************/
+
+typedef struct {
+ /* Indices into the source mvert array (or -1 if not in that array) */
+ BMVert **src_verts;
+ /* Indices into the destination mvert array, these are vertices
+ * created by an edge split (-1 for vertices not created by edge
+ * split) */
+ BMVert **edge_verts;
+
+ /* Number of vertices in the polygon */
+ int len;
+
+ /* True only if none of the polygon's edges were split */
+ int already_symmetric;
+} SymmPoly;
+
+static void symm_poly_with_splits(const Symm *symm,
+ BMFace *f,
+ SymmPoly *out)
+{
+ BMIter iter;
+ BMLoop *l;
+ int i;
+
+ /* Count vertices and check for edge splits */
+ out->len = f->len;
+ out->already_symmetric = TRUE;
+ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ if (BLI_ghash_haskey(symm->edge_split_map, l->e)) {
+ out->len++;
+ out->already_symmetric = FALSE;
+ }
+ }
+
+ i = 0;
+ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ BMVert *split = BLI_ghash_lookup(symm->edge_split_map, l->e);
+
+ out->src_verts[i] = l->v;
+ out->edge_verts[i] = NULL;
+ i++;
+
+ if (split) {
+ out->src_verts[i] = NULL;
+ out->edge_verts[i] = split;
+ i++;
+ }
+ }
+}
+
+static const float *symm_poly_co(const SymmPoly *sp, int v)
+{
+ if (sp->src_verts[v])
+ return sp->src_verts[v]->co;
+ else if (sp->edge_verts[v])
+ return sp->edge_verts[v]->co;
+ else
+ return NULL;
+}
+
+static SymmSide symm_poly_co_side(const Symm *symm,
+ const SymmPoly *sp,
+ int v)
+{
+ return symm_co_side(symm, symm_poly_co(sp, v));
+}
+
+/* Return the index of the vertex in the destination array at corner
+ * 'v' of the polygon, or -1 if not in that array */
+static BMVert *symm_poly_dst(const SymmPoly *sp, int v)
+{
+ if (sp->edge_verts[v])
+ return sp->edge_verts[v];
+ else if (sp->src_verts[v])
+ return sp->src_verts[v];
+ else
+ return NULL;
+}
+
+/* Same as above, but returns the index of the mirror if available, or
+ * the same index if on the axis, or -1 otherwise */
+static BMVert *symm_poly_mirror_dst(const Symm *symm,
+ const SymmPoly *sp,
+ int v)
+{
+ if (sp->edge_verts[v])
+ return sp->edge_verts[v];
+ else if (sp->src_verts[v]) {
+ if (BLI_ghash_haskey(symm->vert_symm_map, sp->src_verts[v]))
+ return BLI_ghash_lookup(symm->vert_symm_map, sp->src_verts[v]);
+ else
+ return sp->src_verts[v];
+ }
+ else
+ return NULL;
+}
+
+static int symm_poly_next_crossing(const Symm *symm,
+ const SymmPoly *sp,
+ int start,
+ int *l1,
+ int *l2)
+{
+ int i;
+
+ for (i = 0; i < sp->len; i++) {
+ (*l1) = (start + i) % sp->len;
+ (*l2) = ((*l1) + 1) % sp->len;
+
+ if ((symm_poly_co_side(symm, sp, *l1) == SYMM_SIDE_KILL) ^
+ (symm_poly_co_side(symm, sp, *l2) == SYMM_SIDE_KILL))
+ {
+ return TRUE;
+ }
+ }
+
+ BLI_assert(!"symm_poly_next_crossing failed");
+ return FALSE;
+}
+
+static BMFace *symm_face_create_v(BMesh *bm, BMVert **fv, BMEdge **fe, int len)
+{
+ BMFace *f_new;
+ int i;
+
+ for (i = 0; i < len; i++) {
+ int j = (i + 1) % len;
+ fe[i] = BM_edge_exists(fv[i], fv[j]);
+ if (!fe[i]) {
+ fe[i] = BM_edge_create(bm, fv[i], fv[j], NULL, FALSE);
+ BMO_elem_flag_enable(bm, fe[i], SYMM_OUTPUT_GEOM);
+ }
+ }
+ f_new = BM_face_create(bm, fv, fe, len, TRUE);
+ BM_face_select_set(bm, f_new, TRUE);
+ BMO_elem_flag_enable(bm, f_new, SYMM_OUTPUT_GEOM);
+ return f_new;
+}
+
+static void symm_mesh_output_poly_zero_splits(Symm *symm,
+ SymmPoly *sp,
+ BMVert **fv,
+ BMEdge **fe,
+ int segment_len,
+ int start)
+{
+ int i, j;
+
+ j = 0;
+
+ /* Output the keep side of the input polygon */
+ for (i = 0; i < segment_len; i++) {
+ const int offset = (start + i) % sp->len;
+ BLI_assert(sp->src_verts[offset]);
+ fv[j++] = sp->src_verts[offset];
+ }
+
+ /* Output the kill side of the polygon */
+ for (i = segment_len - 1; i >= 0; i--) {
+ const int offset = (start + i) % sp->len;
+
+ if (symm_poly_co_side(symm, sp, offset) == SYMM_SIDE_KEEP) {
+ BLI_assert(sp->src_verts[offset]);
+ fv[j++] = BLI_ghash_lookup(symm->vert_symm_map,
+ sp->src_verts[offset]);
+ }
+ }
+
+ symm_face_create_v(symm->bm, fv, fe, j);
+}
+
+static void symm_mesh_output_poly_with_splits(Symm *symm,
+ SymmPoly *sp,
+ BMVert **fv,
+ BMEdge **fe,
+ int segment_len,
+ int start)
+{
+ int i;
+
+ /* Output the keep side of the input polygon */
+
+ for (i = 0; i < segment_len; i++) {
+ const int offset = (start + i) % sp->len;
+ BMVert *v = symm_poly_dst(sp, offset);
+
+ BLI_assert(v);
+
+ fv[i] = v;
+ }
+
+ symm_face_create_v(symm->bm, fv, fe, segment_len);
+
+ /* Output the kill side of the input polygon */
+
+ for (i = 0; i < segment_len; i++) {
+ const int offset = (start + i) % sp->len;
+ BMVert *v = symm_poly_mirror_dst(symm, sp, offset);
+
+ fv[segment_len - i - 1] = v;
+
+ }
+
+ symm_face_create_v(symm->bm, fv, fe, segment_len);
+}
+
+static void symm_mirror_polygons(Symm *symm)
+{
+ BMOIter oiter;
+ BMFace *f;
+ BMVert **pv = NULL;
+ BMVert **fv = NULL;
+ BMEdge **fe = NULL;
+ BLI_array_declare(pv);
+ BLI_array_declare(fv);
+ BLI_array_declare(fe);
+
+ BMO_ITER (f, &oiter, symm->bm, symm->op, "input", BM_FACE) {
+ BMIter iter;
+ BMLoop *l;
+ int mirror_all = TRUE, ignore_all = TRUE;
+
+ /* Check if entire polygon can be mirrored or ignored */
+ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ const SymmSide side = symm_co_side(symm, l->v->co);
+ if (side == SYMM_SIDE_KILL)
+ mirror_all = FALSE;
+ else if (side == SYMM_SIDE_KEEP)
+ ignore_all = FALSE;
+ }
+
+ if (mirror_all) {
+ int i;
+
+ /* Make a mirrored copy of the polygon */
+
+ BLI_array_empty(fv);
+ BLI_array_empty(fe);
+ BLI_array_grow_items(fv, f->len);
+ BLI_array_grow_items(fe, f->len);
+
+ i = f->len;
+ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ i--;
+
+ if (symm_co_side(symm, l->v->co) == SYMM_SIDE_KEEP)
+ fv[i] = BLI_ghash_lookup(symm->vert_symm_map, l->v);
+ else
+ fv[i] = l->v;
+ }
+
+ symm_face_create_v(symm->bm, fv, fe, f->len);
+ }
+ else if (ignore_all) {
+ BM_face_kill(symm->bm, f);
+ }
+ else {
+ SymmPoly sp;
+ int l1, l2, l3, l4;
+ int double_l2, double_l3;
+ int segment_len;
+
+ BLI_array_empty(pv);
+ BLI_array_grow_items(pv, f->len * 4);
+ sp.src_verts = pv;
+ sp.edge_verts = pv + f->len * 2;
+ symm_poly_with_splits(symm, f, &sp);
+
+ /* Find first loop edge crossing the axis */
+ symm_poly_next_crossing(symm, &sp, 0, &l1, &l2);
+
+ /* If crossing isn't kill to keep, find the next one */
+ if (symm_poly_co_side(symm, &sp, l1) != SYMM_SIDE_KILL) {
+ symm_poly_next_crossing(symm, &sp, l2, &l1, &l2);
+ }
+
+ /* Find next crossing (keep to kill) */
+ symm_poly_next_crossing(symm, &sp, l2, &l3, &l4);
+
+ if (l2 == l3)
+ segment_len = 0;
+ else if (l2 < l3)
+ segment_len = l3 - l2 + 1;
+ else
+ segment_len = (sp.len - l2 + 1) + l3;
+
+ double_l2 = symm_poly_co_side(symm, &sp, l2) == SYMM_SIDE_KEEP;
+ double_l3 = symm_poly_co_side(symm, &sp, l3) == SYMM_SIDE_KEEP;
+
+ /* Calculate number of new polygons/loops */
+ if (segment_len == 0) {
+ }
+ else if (sp.already_symmetric) {
+ int new_loops;
+
+ if (double_l2 && double_l3)
+ new_loops = segment_len * 2;
+ else if (!double_l2 && !double_l3)
+ new_loops = segment_len * 2 - 2;
+ else
+ new_loops = segment_len * 2 - 1;
+
+ BLI_array_empty(fv);
+ BLI_array_empty(fe);
+ BLI_array_grow_items(fv, new_loops);
+ BLI_array_grow_items(fe, new_loops);
+
+ symm_mesh_output_poly_zero_splits(symm, &sp,
+ fv, fe,
+ segment_len, l2);
+ BM_face_kill(symm->bm, f);
+ }
+ else if (!double_l2 && !double_l3) {
+ BLI_array_empty(fv);
+ BLI_array_empty(fe);
+ BLI_array_grow_items(fv, segment_len);
+ BLI_array_grow_items(fe, segment_len);
+
+ symm_mesh_output_poly_with_splits(symm, &sp,
+ fv, fe,
+ segment_len,
+ l2);
+
+ BM_face_kill(symm->bm, f);
+ }
+ else {
+ BLI_array_empty(fv);
+ BLI_array_empty(fe);
+ BLI_array_grow_items(fv, segment_len);
+ BLI_array_grow_items(fe, segment_len);
+
+ symm_mesh_output_poly_with_splits(symm, &sp,
+ fv, fe,
+ segment_len,
+ l2);
+
+ BM_face_kill(symm->bm, f);
+
+ /* Output bridge triangle */
+
+ BLI_array_empty(fv);
+ BLI_array_empty(fe);
+ BLI_array_grow_items(fv, 3);
+ BLI_array_grow_items(fe, 3);
+
+ if (double_l2) {
+ fv[0] = symm_poly_dst(&sp, l2);
+ fv[1] = symm_poly_mirror_dst(symm, &sp, l2);
+ fv[2] = symm_poly_dst(&sp, l3);
+ }
+ else if (double_l3) {
+ fv[0] = symm_poly_dst(&sp, l3);
+ fv[1] = symm_poly_mirror_dst(symm, &sp, l3);
+ fv[2] = symm_poly_dst(&sp, l2);
+ }
+
+ BLI_assert(fv[0] && fv[1] && fv[2]);
+
+ symm_face_create_v(symm->bm, fv, fe, 3);
+ }
+ }
+ }
+
+ BLI_array_free(pv);
+ BLI_array_free(fv);
+ BLI_array_free(fe);
+}
+
+/* Remove unused edges and vertices from the side being copied to */
+static void symm_kill_unused(Symm *symm)
+{
+ BMOIter oiter;
+ BMEdge *e;
+ BMVert *v;
+
+ /* Kill unused edges */
+ BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) {
+ const int crosses = symm_edge_crosses_axis(symm, e);
+ const int symmetric = (crosses &&
+ (!BLI_ghash_haskey(symm->edge_split_map, e)));
+
+ if (((symm_co_side(symm, e->v1->co) == SYMM_SIDE_KILL) ||
+ (symm_co_side(symm, e->v2->co) == SYMM_SIDE_KILL)) &&
+ !symmetric)
+ {
+ /* The edge might be used by a face outside the input set */
+ if (BM_edge_face_count(e) == 0)
+ BM_edge_kill(symm->bm, e);
+ }
+ }
+
+ /* Kill unused vertices */
+ BMO_ITER (v, &oiter, symm->bm, symm->op, "input", BM_VERT) {
+ if (symm_co_side(symm, v->co) == SYMM_SIDE_KILL) {
+ if (BM_vert_edge_count(v) == 0)
+ BM_vert_kill(symm->bm, v);
+ }
+ }
+}
+
+void bmo_symmetrize_exec(BMesh *bm, BMOperator *op)
+{
+ Symm symm;
+ BMO_SymmDirection direction = BMO_slot_int_get(op, "direction");
+
+ symm.bm = bm;
+ symm.op = op;
+ symm.axis = (ELEM(direction,
+ BMO_SYMMETRIZE_NEGATIVE_X,
+ BMO_SYMMETRIZE_POSITIVE_X) ? 0 :
+ ELEM(direction,
+ BMO_SYMMETRIZE_NEGATIVE_Y,
+ BMO_SYMMETRIZE_POSITIVE_Y) ? 1 :
+ ELEM(direction,
+ BMO_SYMMETRIZE_NEGATIVE_Z,
+ BMO_SYMMETRIZE_POSITIVE_Z) ? 2 : 0);
+ symm.direction = direction;
+
+ symm_verts_mirror(&symm);
+ symm_split_asymmetric_edges(&symm);
+ symm_mirror_edges(&symm);
+ symm_mirror_polygons(&symm);
+ symm_kill_unused(&symm);
+
+ BLI_ghash_free(symm.vert_symm_map, NULL, NULL);
+ BLI_ghash_free(symm.edge_split_map, NULL, NULL);
+
+ BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL,
+ SYMM_OUTPUT_GEOM);
+}
diff --git a/source/blender/bmesh/operators/bmo_unsubdivide.c b/source/blender/bmesh/operators/bmo_unsubdivide.c
new file mode 100644
index 00000000000..3d44feac380
--- /dev/null
+++ b/source/blender/bmesh/operators/bmo_unsubdivide.c
@@ -0,0 +1,59 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/operators/bmo_unsubdivide.c
+ * \ingroup bmesh
+ */
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "bmesh.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+/* - BMVert.flag & BM_ELEM_TAG: shows we touched this vert
+ * - BMVert.index == -1: shows we will remove this vert
+ */
+void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op)
+{
+ BMVert *v;
+ BMIter iter;
+
+ const int iterations = max_ii(1, BMO_slot_int_get(op, "iterations"));
+
+ BMOpSlot *vinput = BMO_slot_get(op, "verts");
+ BMVert **vinput_arr = (BMVert **)vinput->data.p;
+ int v_index;
+
+ /* tag verts */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_flag_disable(v, BM_ELEM_TAG);
+ }
+ for (v_index = 0; v_index < vinput->len; v_index++) {
+ v = vinput_arr[v_index];
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
+ }
+
+ /* do all the real work here */
+ BM_mesh_decimate_unsubdivide_ex(bm, iterations, TRUE);
+}
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 88ed1250264..aa514a5c0a7 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -282,7 +282,7 @@ void bmo_region_extend_exec(BMesh *bm, BMOperator *op)
#define FACE_VIS 1
#define FACE_FLAG 2
-#define FACE_MARK 4
+// #define FACE_MARK 4 /* UNUSED */
#define FACE_FLIP 8
/* NOTE: these are the original recalc_face_normals comment in editmesh_mods.c,
@@ -479,550 +479,15 @@ void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op)
BLI_array_free(cos);
}
-/*
- * compute the fake surface of an ngon
- * This is done by decomposing the ngon into triangles who share the centroid of the ngon
- * while this method is far from being exact, it should guarantee an invariance.
- *
- * NOTE: This should probably go to bmesh_polygon.c
- */
-static float ngon_fake_area(BMFace *f)
-{
- BMIter liter;
- BMLoop *l;
- int num_verts = 0;
- float v[3], sv[3], c[3];
- float area = 0.0f;
-
- BM_face_calc_center_mean(f, c);
-
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- if (num_verts == 0) {
- copy_v3_v3(v, l->v->co);
- copy_v3_v3(sv, l->v->co);
- num_verts++;
- }
- else {
- area += area_tri_v3(v, c, l->v->co);
- copy_v3_v3(v, l->v->co);
- num_verts++;
- }
- }
-
- area += area_tri_v3(v, c, sv);
-
- return area;
-}
-
-/*
- * extra face data (computed data)
- */
-typedef struct SimSel_FaceExt {
- BMFace *f; /* the face */
- float c[3]; /* center */
- union {
- float area; /* area */
- float perim; /* perimeter */
- float d; /* 4th component of plane (the first three being the normal) */
- struct Image *t; /* image pointer */
- };
-} SimSel_FaceExt;
-
-/*
- * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h
- * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces
- */
-void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
-{
- BMIter fm_iter;
- BMFace *fs, *fm;
- BMOIter fs_iter;
- int num_sels = 0, num_total = 0, i = 0, idx = 0;
- float angle = 0.0f;
- SimSel_FaceExt *f_ext = NULL;
- int *indices = NULL;
- float t_no[3]; /* temporary normal */
- int type = BMO_slot_int_get(op, "type");
- const float thresh = BMO_slot_float_get(op, "thresh");
- const float thresh_radians = thresh * (float)M_PI;
-
- num_total = BM_mesh_elem_count(bm, BM_FACE);
-
- /*
- * The first thing to do is to iterate through all the the selected items and mark them since
- * they will be in the selection anyway.
- * This will increase performance, (especially when the number of originally selected faces is high)
- * so the overall complexity will be less than $O(mn)$ where is the total number of selected faces,
- * and n is the total number of faces
- */
- BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
- if (!BMO_elem_flag_test(bm, fs, FACE_MARK)) { /* is this really needed ? */
- BMO_elem_flag_enable(bm, fs, FACE_MARK);
- num_sels++;
- }
- }
-
- /* allocate memory for the selected faces indices and for all temporary faces */
- indices = (int *)MEM_callocN(sizeof(int) * num_sels, "face indices util.c");
- f_ext = (SimSel_FaceExt *)MEM_callocN(sizeof(SimSel_FaceExt) * num_total, "f_ext util.c");
-
- /* loop through all the faces and fill the faces/indices structure */
- BM_ITER_MESH (fm, &fm_iter, bm, BM_FACES_OF_MESH) {
- f_ext[i].f = fm;
- if (BMO_elem_flag_test(bm, fm, FACE_MARK)) {
- indices[idx] = i;
- idx++;
- }
- i++;
- }
-
- /*
- * Save us some computation burden: In case of perimeter/area/coplanar selection we compute
- * only once.
- */
- if (type == SIMFACE_PERIMETER || type == SIMFACE_AREA || type == SIMFACE_COPLANAR || type == SIMFACE_IMAGE) {
- for (i = 0; i < num_total; i++) {
- switch (type) {
- case SIMFACE_PERIMETER:
- /* set the perimeter */
- f_ext[i].perim = BM_face_calc_perimeter(f_ext[i].f);
- break;
-
- case SIMFACE_COPLANAR:
- /* compute the center of the polygon */
- BM_face_calc_center_mean(f_ext[i].f, f_ext[i].c);
-
- /* normalize the polygon normal */
- copy_v3_v3(t_no, f_ext[i].f->no);
- normalize_v3(t_no);
-
- /* compute the plane distance */
- f_ext[i].d = dot_v3v3(t_no, f_ext[i].c);
- break;
-
- case SIMFACE_AREA:
- f_ext[i].area = ngon_fake_area(f_ext[i].f);
- break;
-
- case SIMFACE_IMAGE:
- f_ext[i].t = NULL;
- if (CustomData_has_layer(&(bm->pdata), CD_MTEXPOLY)) {
- MTexPoly *mtpoly = CustomData_bmesh_get(&bm->pdata, f_ext[i].f->head.data, CD_MTEXPOLY);
- f_ext[i].t = mtpoly->tpage;
- }
- break;
- }
- }
- }
-
- /* now select the rest (if any) */
- for (i = 0; i < num_total; i++) {
- fm = f_ext[i].f;
- if (!BMO_elem_flag_test(bm, fm, FACE_MARK) && !BM_elem_flag_test(fm, BM_ELEM_HIDDEN)) {
- int cont = TRUE;
- for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
- fs = f_ext[indices[idx]].f;
- switch (type) {
- case SIMFACE_MATERIAL:
- if (fm->mat_nr == fs->mat_nr) {
- BMO_elem_flag_enable(bm, fm, FACE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMFACE_IMAGE:
- if (f_ext[i].t == f_ext[indices[idx]].t) {
- BMO_elem_flag_enable(bm, fm, FACE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMFACE_NORMAL:
- angle = angle_normalized_v3v3(fs->no, fm->no); /* if the angle between the normals -> 0 */
- if (angle <= thresh_radians) {
- BMO_elem_flag_enable(bm, fm, FACE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMFACE_COPLANAR:
- angle = angle_normalized_v3v3(fs->no, fm->no); /* angle -> 0 */
- if (angle <= thresh_radians) { /* and dot product difference -> 0 */
- if (fabsf(f_ext[i].d - f_ext[indices[idx]].d) <= thresh) {
- BMO_elem_flag_enable(bm, fm, FACE_MARK);
- cont = FALSE;
- }
- }
- break;
-
- case SIMFACE_AREA:
- if (fabsf(f_ext[i].area - f_ext[indices[idx]].area) <= thresh) {
- BMO_elem_flag_enable(bm, fm, FACE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMFACE_PERIMETER:
- if (fabsf(f_ext[i].perim - f_ext[indices[idx]].perim) <= thresh) {
- BMO_elem_flag_enable(bm, fm, FACE_MARK);
- cont = FALSE;
- }
- break;
- }
- }
- }
- }
-
- MEM_freeN(f_ext);
- MEM_freeN(indices);
-
- /* transfer all marked faces to the output slot */
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_MARK);
-}
-
-/**************************************************************************** *
- * Similar Edges
- **************************************************************************** */
-#define EDGE_MARK 1
-
-/*
- * extra edge information
- */
-typedef struct SimSel_EdgeExt {
- BMEdge *e;
- union {
- float dir[3];
- float angle; /* angle between the face */
- };
-
- union {
- float length; /* edge length */
- int faces; /* faces count */
- };
-} SimSel_EdgeExt;
-
-/*
- * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h
- * choices are length, direction, face, ...
- */
-void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
-{
- BMOIter es_iter; /* selected edges iterator */
- BMIter e_iter; /* mesh edges iterator */
- BMEdge *es; /* selected edge */
- BMEdge *e; /* mesh edge */
- int idx = 0, i = 0 /* , f = 0 */;
- int *indices = NULL;
- SimSel_EdgeExt *e_ext = NULL;
- // float *angles = NULL;
- float angle;
-
- int num_sels = 0, num_total = 0;
- int type = BMO_slot_int_get(op, "type");
- const float thresh = BMO_slot_float_get(op, "thresh");
-
- /* sanity checks that the data we need is available */
- switch (type) {
- case SIMEDGE_CREASE:
- if (!CustomData_has_layer(&bm->edata, CD_CREASE)) {
- return;
- }
- break;
- case SIMEDGE_BEVEL:
- if (!CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
- return;
- }
- break;
- }
-
- num_total = BM_mesh_elem_count(bm, BM_EDGE);
-
- /* iterate through all selected edges and mark them */
- BMO_ITER (es, &es_iter, bm, op, "edges", BM_EDGE) {
- BMO_elem_flag_enable(bm, es, EDGE_MARK);
- num_sels++;
- }
-
- /* allocate memory for the selected edges indices and for all temporary edges */
- indices = (int *)MEM_callocN(sizeof(int) * num_sels, __func__);
- e_ext = (SimSel_EdgeExt *)MEM_callocN(sizeof(SimSel_EdgeExt) * num_total, __func__);
-
- /* loop through all the edges and fill the edges/indices structure */
- BM_ITER_MESH (e, &e_iter, bm, BM_EDGES_OF_MESH) {
- e_ext[i].e = e;
- if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
- indices[idx] = i;
- idx++;
- }
- i++;
- }
-
- /* save us some computation time by doing heavy computation once */
- if (type == SIMEDGE_LENGTH || type == SIMEDGE_FACE || type == SIMEDGE_DIR || type == SIMEDGE_FACE_ANGLE) {
- for (i = 0; i < num_total; i++) {
- switch (type) {
- case SIMEDGE_LENGTH: /* compute the length of the edge */
- e_ext[i].length = len_v3v3(e_ext[i].e->v1->co, e_ext[i].e->v2->co);
- break;
-
- case SIMEDGE_DIR: /* compute the direction */
- sub_v3_v3v3(e_ext[i].dir, e_ext[i].e->v1->co, e_ext[i].e->v2->co);
- normalize_v3(e_ext[i].dir);
- break;
-
- case SIMEDGE_FACE: /* count the faces around the edge */
- e_ext[i].faces = BM_edge_face_count(e_ext[i].e);
- break;
-
- case SIMEDGE_FACE_ANGLE:
- e_ext[i].faces = BM_edge_face_count(e_ext[i].e);
- if (e_ext[i].faces == 2)
- e_ext[i].angle = BM_edge_calc_face_angle(e_ext[i].e);
- break;
- }
- }
- }
-
- /* select the edges if any */
- for (i = 0; i < num_total; i++) {
- e = e_ext[i].e;
- if (!BMO_elem_flag_test(bm, e, EDGE_MARK) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
- int cont = TRUE;
- for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
- es = e_ext[indices[idx]].e;
- switch (type) {
- case SIMEDGE_LENGTH:
- if (fabsf(e_ext[i].length - e_ext[indices[idx]].length) <= thresh) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMEDGE_DIR:
- /* compute the angle between the two edges */
- angle = angle_normalized_v3v3(e_ext[i].dir, e_ext[indices[idx]].dir);
-
- if (angle > (float)(M_PI / 2.0)) /* use the smallest angle between the edges */
- angle = fabsf(angle - (float)M_PI);
-
- if (angle / (float)(M_PI / 2.0) <= thresh) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMEDGE_FACE:
- if (e_ext[i].faces == e_ext[indices[idx]].faces) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMEDGE_FACE_ANGLE:
- if (e_ext[i].faces == 2) {
- if (e_ext[indices[idx]].faces == 2) {
- if (fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- }
- }
- else {
- cont = FALSE;
- }
- break;
-
- case SIMEDGE_CREASE:
- {
- float *c1, *c2;
-
- c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE);
- c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_CREASE);
-
- if (fabsf(*c1 - *c2) <= thresh) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- }
- break;
-
- case SIMEDGE_BEVEL:
- {
- float *c1, *c2;
-
- c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT);
- c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_BWEIGHT);
-
- if (fabsf(*c1 - *c2) <= thresh) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- }
- break;
-
- case SIMEDGE_SEAM:
- if (BM_elem_flag_test(e, BM_ELEM_SEAM) == BM_elem_flag_test(es, BM_ELEM_SEAM)) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMEDGE_SHARP:
- if (BM_elem_flag_test(e, BM_ELEM_SMOOTH) == BM_elem_flag_test(es, BM_ELEM_SMOOTH)) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
- cont = FALSE;
- }
- break;
- }
- }
- }
- }
-
- MEM_freeN(e_ext);
- MEM_freeN(indices);
-
- /* transfer all marked edges to the output slot */
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_MARK);
-}
-
-/**************************************************************************** *
- * Similar Vertices
- **************************************************************************** */
-#define VERT_MARK 1
-
-typedef struct SimSel_VertExt {
- BMVert *v;
- union {
- int num_faces; /* adjacent faces */
- int num_edges; /* adjacent edges */
- MDeformVert *dvert; /* deform vertex */
- };
-} SimSel_VertExt;
-
-/*
- * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h
- * choices are normal, face, vertex group...
- */
-void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
-{
- BMOIter vs_iter; /* selected verts iterator */
- BMIter v_iter; /* mesh verts iterator */
- BMVert *vs; /* selected vertex */
- BMVert *v; /* mesh vertex */
- SimSel_VertExt *v_ext = NULL;
- int *indices = NULL;
- int num_total = 0, num_sels = 0, i = 0, idx = 0;
- int type = BMO_slot_int_get(op, "type");
- const float thresh = BMO_slot_float_get(op, "thresh");
- const float thresh_radians = thresh * (float)M_PI;
-
- num_total = BM_mesh_elem_count(bm, BM_VERT);
-
- /* iterate through all selected edges and mark them */
- BMO_ITER (vs, &vs_iter, bm, op, "verts", BM_VERT) {
- BMO_elem_flag_enable(bm, vs, VERT_MARK);
- num_sels++;
- }
-
- /* allocate memory for the selected vertices indices and for all temporary vertices */
- indices = (int *)MEM_mallocN(sizeof(int) * num_sels, "vertex indices");
- v_ext = (SimSel_VertExt *)MEM_mallocN(sizeof(SimSel_VertExt) * num_total, "vertex extra");
-
- /* loop through all the vertices and fill the vertices/indices structure */
- BM_ITER_MESH (v, &v_iter, bm, BM_VERTS_OF_MESH) {
- v_ext[i].v = v;
- if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
- indices[idx] = i;
- idx++;
- }
-
- switch (type) {
- case SIMVERT_FACE:
- /* calling BM_vert_face_count every time is time consumming, so call it only once per vertex */
- v_ext[i].num_faces = BM_vert_face_count(v);
- break;
-
- case SIMVERT_VGROUP:
- if (CustomData_has_layer(&(bm->vdata), CD_MDEFORMVERT)) {
- v_ext[i].dvert = CustomData_bmesh_get(&bm->vdata, v_ext[i].v->head.data, CD_MDEFORMVERT);
- }
- else {
- v_ext[i].dvert = NULL;
- }
- break;
- case SIMVERT_EDGE:
- v_ext[i].num_edges = BM_vert_edge_count(v);
- break;
- }
-
- i++;
- }
-
- /* select the vertices if any */
- for (i = 0; i < num_total; i++) {
- v = v_ext[i].v;
- if (!BMO_elem_flag_test(bm, v, VERT_MARK) && !BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
- int cont = TRUE;
- for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
- vs = v_ext[indices[idx]].v;
- switch (type) {
- case SIMVERT_NORMAL:
- /* compare the angle between the normals */
- if (angle_normalized_v3v3(v->no, vs->no) <= thresh_radians) {
- BMO_elem_flag_enable(bm, v, VERT_MARK);
- cont = FALSE;
- }
- break;
- case SIMVERT_FACE:
- /* number of adjacent faces */
- if (v_ext[i].num_faces == v_ext[indices[idx]].num_faces) {
- BMO_elem_flag_enable(bm, v, VERT_MARK);
- cont = FALSE;
- }
- break;
-
- case SIMVERT_VGROUP:
- if (v_ext[i].dvert != NULL && v_ext[indices[idx]].dvert != NULL) {
- int v1, v2;
- for (v1 = 0; v1 < v_ext[i].dvert->totweight && cont == 1; v1++) {
- for (v2 = 0; v2 < v_ext[indices[idx]].dvert->totweight; v2++) {
- if (v_ext[i].dvert->dw[v1].def_nr == v_ext[indices[idx]].dvert->dw[v2].def_nr) {
- BMO_elem_flag_enable(bm, v, VERT_MARK);
- cont = FALSE;
- break;
- }
- }
- }
- }
- break;
- case SIMVERT_EDGE:
- /* number of adjacent edges */
- if (v_ext[i].num_edges == v_ext[indices[idx]].num_edges) {
- BMO_elem_flag_enable(bm, v, VERT_MARK);
- cont = FALSE;
- }
- break;
- }
- }
- }
- }
-
- MEM_freeN(indices);
- MEM_freeN(v_ext);
-
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
-}
-
/**************************************************************************** *
* Cycle UVs for a face
**************************************************************************** */
void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
{
- BMOIter fs_iter; /* selected faces iterator */
- BMFace *fs; /* current face */
- BMIter l_iter; /* iteration loop */
- // int n;
+ BMOIter fs_iter; /* selected faces iterator */
+ BMFace *fs; /* current face */
+ BMIter l_iter; /* iteration loop */
int dir = BMO_slot_int_get(op, "dir");
@@ -1077,7 +542,6 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
}
}
}
-
}
/**************************************************************************** *
@@ -1126,10 +590,9 @@ void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op)
void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
{
- BMOIter fs_iter; /* selected faces iterator */
- BMFace *fs; /* current face */
- BMIter l_iter; /* iteration loop */
- // int n;
+ BMOIter fs_iter; /* selected faces iterator */
+ BMFace *fs; /* current face */
+ BMIter l_iter; /* iteration loop */
int dir = BMO_slot_int_get(op, "dir");
@@ -1234,6 +697,8 @@ typedef struct ElemNode {
HeapNode *hn; /* heap node */
} ElemNode;
+#define VERT_MARK 1
+
void bmo_shortest_path_exec(BMesh *bm, BMOperator *op)
{
BMOIter vs_iter /* , vs2_iter */; /* selected verts iterator */
@@ -1245,7 +710,7 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op)
ElemNode *vert_list = NULL;
int num_total = 0 /*, num_sels = 0 */, i = 0;
- int type = BMO_slot_int_get(op, "type");
+ const int type = BMO_slot_int_get(op, "type");
BMO_ITER (vs, &vs_iter, bm, op, "startv", BM_VERT) {
sv = vs;
@@ -1284,7 +749,7 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op)
vert_list[i].hn = BLI_heap_insert(h, vert_list[i].weight, vert_list[i].v);
}
- while (!BLI_heap_empty(h)) {
+ while (!BLI_heap_is_empty(h)) {
BMEdge *e;
BMIter e_i;
float v_weight;
diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c
index 98f270abd16..a632a4446ed 100644
--- a/source/blender/bmesh/tools/BME_bevel.c
+++ b/source/blender/bmesh/tools/BME_bevel.c
@@ -1096,10 +1096,9 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option
return bm;
}
-BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle,
- BME_TransData_Head **rtd, int do_tessface)
+BMesh *BME_bevel(BMesh *bm, float value, int res, int options, int defgrp_index, float angle,
+ BME_TransData_Head **rtd)
{
- BMesh *bm = em->bm;
BMVert *v;
BMIter iter;
@@ -1126,12 +1125,6 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i
BMO_pop(bm);
}
- /* possibly needed when running as a tool (which is no longer functional)
- * but keep as an option for now */
- if (do_tessface) {
- BMEdit_RecalcTessellation(em);
- }
-
/* interactive preview? */
if (rtd) {
*rtd = td;
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 0e8ead61437..26b5edf7ea6 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -184,7 +184,7 @@ std::string AnimationExporter::getObjectBoneName(Object *ob, const FCurve *fcu)
if (boneName != NULL)
return /*id_name(ob) + "_" +*/ std::string(boneName);
- else
+ else
return id_name(ob);
}
@@ -265,7 +265,7 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
MEM_freeN(eul);
MEM_freeN(eul_axis);
}
- else if(!strcmp(transformName, "lens") && (ob->type == OB_CAMERA)) {
+ else if (!strcmp(transformName, "lens") && (ob->type == OB_CAMERA)) {
output_id = create_lens_source_from_fcurve((Camera *) ob->data, COLLADASW::InputSemantic::OUTPUT, fcu, anim_id);
}
else {
@@ -584,8 +584,8 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman
values[0] = convert_time(bezt->vec[0][0]);
if (bezt->ipo != BEZT_IPO_BEZ) {
// We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data
- values[0] = 0;
- values[1] = 0;
+ values[0] = 0;
+ values[1] = 0;
}
else if (is_rotation) {
values[1] = RAD2DEGF(bezt->vec[0][1]);
@@ -600,8 +600,8 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman
values[0] = convert_time(bezt->vec[2][0]);
if (bezt->ipo != BEZT_IPO_BEZ) {
// We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data
- values[0] = 0;
- values[1] = 0;
+ values[0] = 0;
+ values[1] = 0;
}
else if (is_rotation) {
values[1] = RAD2DEGF(bezt->vec[2][1]);
@@ -634,11 +634,11 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti
switch (semantic) {
case COLLADASW::InputSemantic::INPUT:
case COLLADASW::InputSemantic::OUTPUT:
- source.setAccessorStride(1);
+ source.setAccessorStride(1);
break;
case COLLADASW::InputSemantic::IN_TANGENT:
case COLLADASW::InputSemantic::OUT_TANGENT:
- source.setAccessorStride(2);
+ source.setAccessorStride(2);
break;
default:
break;
@@ -1082,13 +1082,13 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co
break;
case 6:
tm_name = "diffuse";
- break;
+ break;
case 7:
tm_name = "transparency";
- break;
+ break;
case 8:
tm_name = "index_of_refraction";
- break;
+ break;
default:
tm_name = "";
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 7fd39765cc9..349930dea8f 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -35,10 +35,19 @@ extern "C"
#include "DNA_armature_types.h"
#include "DNA_material_types.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_listbase.h"
+#include "BLI_utildefines.h"
+
#include "BKE_DerivedMesh.h"
#include "BKE_fcurve.h"
#include "BKE_animsys.h"
#include "BKE_scene.h"
+#include "BKE_action.h" // pose functions
+#include "BKE_armature.h"
+#include "BKE_object.h"
+
#ifdef NAN_BUILDINFO
extern char build_rev[];
#endif
@@ -46,14 +55,6 @@ extern char build_rev[];
#include "MEM_guardedalloc.h"
-#include "BKE_action.h" // pose functions
-#include "BKE_armature.h"
-#include "BKE_object.h"
-
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_listbase.h"
-
#include "RNA_access.h"
#include "COLLADASWSource.h"
@@ -122,7 +123,7 @@ protected:
float convert_angle(float angle);
- std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic);
+ 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 char *axis, bool transform);
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index b2748a55b6a..374f6385ea7 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -136,7 +136,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
bez.ipo = BEZT_IPO_BEZ;
else
bez.ipo = BEZT_IPO_CONST;
- //bez.h1 = bez.h2 = HD_AUTO;
+ //bez.h1 = bez.h2 = HD_AUTO;
}
else {
bez.h1 = bez.h2 = HD_AUTO;
@@ -617,7 +617,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
- BLI_addtail(AnimCurves, fcu);
+ BLI_addtail(AnimCurves, fcu);
}
}
@@ -854,14 +854,13 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
{
double aspect = camera->getAspectRatio().getValue();
- if(aspect == 0)
- {
+ if (aspect == 0) {
const double yfov = camera->getYFov().getValue();
- if(yfov == 0)
- aspect=1; // assume yfov and xfov are equal
- else
- {
+ if (yfov == 0) {
+ aspect = 1; // assume yfov and xfov are equal
+ }
+ else {
const double xfov = camera->getXFov().getValue();
if (xfov==0)
aspect = 1;
@@ -885,7 +884,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid];
Object *ob;
- if(is_joint)
+ if (is_joint)
ob = armature_importer->get_armature_for_joint(root);
else
ob = object_map.find(uid) == object_map.end() ? NULL : object_map.find(uid)->second;
@@ -938,7 +937,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
if (is_matrix) {
apply_matrix_curves(ob, animcurves, root, node, transform);
}
- else {
+ else {
if (is_joint) {
@@ -1094,7 +1093,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
}
}
}
- }
+ }
}
}
@@ -1114,8 +1113,8 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurv
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
- fcurve_deg_to_rad(fcu);
- }
+ fcurve_deg_to_rad(fcu);
+ }
}
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index db61692484b..293b992f219 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -169,7 +169,7 @@ public:
int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition);
- void modify_fcurve(std::vector<FCurve*>* curves, const char* rna_path, int array_index );
+ void modify_fcurve(std::vector<FCurve*>* curves, const char *rna_path, int array_index );
void unused_fcurve(std::vector<FCurve*>* curves );
// prerequisites:
// animlist_map - map animlist id -> animlist
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 30e9baccbf1..134fd639a73 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -346,7 +346,7 @@ void ArmatureExporter::export_controller(Object *ob, Object *ob_arm)
if (this->export_settings->apply_modifiers) {
me = bc_to_mesh_apply_modifiers(scene, ob, this->export_settings->export_mesh_type);
- }
+ }
else {
me = (Mesh *)ob->data;
}
diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h
index eead45353af..a6b37287479 100644
--- a/source/blender/collada/ArmatureImporter.h
+++ b/source/blender/collada/ArmatureImporter.h
@@ -104,7 +104,7 @@ private:
#endif
void create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBone *parent, int totchild,
- float parent_mat[][4], bArmature *arm);
+ float parent_mat[][4], bArmature *arm);
void create_unskinned_bone(COLLADAFW::Node *node, EditBone *parent, int totchild,
float parent_mat[][4], Object * ob_arm);
diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt
index 3b7a38eb950..0091df3c502 100644
--- a/source/blender/collada/CMakeLists.txt
+++ b/source/blender/collada/CMakeLists.txt
@@ -70,7 +70,7 @@ set(SRC
collada_utils.cpp
AnimationImporter.h
- AnimationExporter.h
+ AnimationExporter.h
ArmatureExporter.h
ArmatureImporter.h
CameraExporter.h
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 7683ec1e9cd..c491326519f 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -79,36 +79,38 @@ extern "C"
#include "DNA_modifier_types.h"
#include "DNA_userdef_types.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_fcurve.h"
-#include "BKE_animsys.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
-#include "ED_keyframing.h"
-#ifdef WITH_BUILDINFO
-extern char build_rev[];
-#endif
-
-#include "MEM_guardedalloc.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_listbase.h"
+#include "BLI_utildefines.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_action.h" // pose functions
+#include "BKE_animsys.h"
+#include "BKE_armature.h"
#include "BKE_blender.h" // version info
-#include "BKE_scene.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
-#include "BKE_action.h" // pose functions
-#include "BKE_armature.h"
-#include "BKE_image.h"
#include "BKE_object.h"
+#include "BKE_scene.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_listbase.h"
+#include "ED_keyframing.h"
+#ifdef WITH_BUILDINFO
+extern char build_rev[];
+#endif
+
+#include "MEM_guardedalloc.h"
#include "RNA_access.h"
}
#include "collada_internal.h"
+#include "collada_utils.h"
#include "DocumentExporter.h"
extern bool bc_has_object_type(LinkNode *export_set, short obtype);
@@ -160,7 +162,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
clear_global_id_map();
COLLADABU::NativeString native_filename =
- COLLADABU::NativeString(std::string(this->export_settings->filepath));
+ COLLADABU::NativeString(std::string(this->export_settings->filepath), COLLADABU::NativeString::ENCODING_UTF8);
COLLADASW::StreamWriter sw(native_filename);
fprintf(stdout, "Collada export: %s\n", this->export_settings->filepath);
diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h
index 05620087d76..84c0610282e 100644
--- a/source/blender/collada/DocumentExporter.h
+++ b/source/blender/collada/DocumentExporter.h
@@ -40,7 +40,7 @@ class DocumentExporter
public:
DocumentExporter(const ExportSettings *export_settings);
void exportCurrentScene(Scene *sce);
- void exportScenes(const char* filename);
+ void exportScenes(const char *filename);
private:
const ExportSettings *export_settings;
};
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index f37f065b03b..1c4f0974c6d 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -311,7 +311,7 @@ bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene)
Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
{
const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId();
- if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {
+ if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {
// fprintf(stderr, "Couldn't find camera by UID.\n");
return NULL;
}
@@ -329,7 +329,7 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
{
const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId();
- if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {
+ if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {
fprintf(stderr, "Couldn't find lamp by UID.\n");
return NULL;
}
@@ -524,7 +524,7 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent
}
// if node has child nodes write them
COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
- for (unsigned int i = 0; i < child_nodes.getCount(); i++) {
+ for (unsigned int i = 0; i < child_nodes.getCount(); i++) {
write_node(child_nodes[i], node, sce, ob, is_library_node);
}
}
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index dd59fb9fb91..e4a654dc99a 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -255,7 +255,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) {
cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f);
ep.setSpecular(cot, false, "specular");
- }
+ }
// XXX make this more readable if possible
@@ -381,7 +381,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
}
std::set<Image *>::iterator uv_t_iter;
- for(uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++ ) {
+ for (uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++ ) {
Image *ima = *uv_t_iter;
std::string key(id_name(ima));
key = translate_id(key);
@@ -405,7 +405,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
ep.closeProfile();
if (twoSided)
mSW->appendTextBlock("<extra><technique profile=\"MAX3D\"><double_sided>1</double_sided></technique></extra>");
- closeEffect();
+ closeEffect();
}
COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index e2332b7cd55..f33f0fa110d 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -38,6 +38,8 @@
#include "DNA_meshdata_types.h"
extern "C" {
+ #include "BLI_utildefines.h"
+
#include "BKE_DerivedMesh.h"
#include "BKE_main.h"
#include "BKE_global.h"
@@ -78,7 +80,7 @@ void GeometryExporter::operator()(Object *ob)
Mesh *me;
if (this->export_settings->apply_modifiers) {
me = bc_to_mesh_apply_modifiers(mScene, ob, this->export_settings->export_mesh_type);
- }
+ }
else {
me = (Mesh *)ob->data;
}
@@ -364,7 +366,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
//appends data to <float_array>
int i = 0;
for (i = 0; i < totverts; i++) {
- source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
+ source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
}
source.finish();
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index a15dadda8cf..2e0c0f1ea57 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -62,7 +62,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
if (not_yet_exported) {
ImBuf *imbuf = BKE_image_get_ibuf(image, NULL);
- if(!imbuf) {
+ if (!imbuf) {
fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->name);
return;
}
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 47ee35f0268..8337a977b3b 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -478,7 +478,7 @@ void MeshImporter::allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_t
int total_facecount = 0;
// collect edge_count and face_count from all parts
- for (int i = 0; i < prim_arr.getCount(); i++) {
+ for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
switch (type) {
@@ -506,7 +506,7 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) {
int loose_edge_count = 0;
// collect edge_count and face_count from all parts
- for (int i = 0; i < prim_arr.getCount(); i++) {
+ for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
switch (type) {
@@ -998,7 +998,7 @@ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
if (ob1->totcol != ob2->totcol) return false; // not same number of materials
if (ob1->totcol == 0) return false; // no material at all
- for(int index=0; index < ob1->totcol; index++) {
+ for (int index=0; index < ob1->totcol; index++) {
if (ob1->matbits[index] != ob2->matbits[index]) return false; // shouldn't happen
if (ob1->matbits[index] == 0) return false; // shouldn't happen
if (ob1->mat[index] != ob2->mat[index]) return false; // different material assignment
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 4aaff024cac..6d239ae0fb1 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -24,9 +24,13 @@
* \ingroup collada
*/
+extern "C" {
+ #include "BLI_utildefines.h"
+ #include "BKE_object.h"
+}
+
#include "SceneExporter.h"
#include "collada_utils.h"
-#include "BKE_object.h"
SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings)
: COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm), export_settings(export_settings)
diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h
index c1f75f996ce..6eec6a1675e 100644
--- a/source/blender/collada/collada_internal.h
+++ b/source/blender/collada/collada_internal.h
@@ -88,6 +88,7 @@ extern std::string translate_id(const std::string &id);
extern std::string id_name(void *id);
+extern std::string get_geometry_id(Object *ob);
extern std::string get_geometry_id(Object *ob, bool use_instantiation);
extern std::string get_light_id(Object *ob);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 018d66c6f55..35844b549de 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -35,7 +35,6 @@
#include "collada_utils.h"
extern "C" {
-
#include "DNA_modifier_types.h"
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
@@ -44,6 +43,7 @@ extern "C" {
#include "DNA_armature_types.h"
#include "BLI_math.h"
+#include "BLI_linklist.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
@@ -51,10 +51,7 @@ extern "C" {
#include "BKE_object.h"
#include "BKE_mesh.h"
#include "BKE_scene.h"
-
#include "BKE_DerivedMesh.h"
-#include "BLI_linklist.h"
-
#include "WM_api.h" // XXX hrm, see if we can do without this
#include "WM_types.h"
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index b52115722fe..b8990c3fcdd 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -35,18 +35,19 @@
#include <vector>
#include <map>
+extern "C" {
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_customdata_types.h"
#include "DNA_texture_types.h"
-#include "BKE_context.h"
-#include "BKE_object.h"
-
#include "DNA_scene_types.h"
-extern "C" {
-#include "BKE_DerivedMesh.h"
#include "BLI_linklist.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_object.h"
+#include "BKE_DerivedMesh.h"
}
#include "ExportSettings.h"
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index e1fc8908bbf..ceb91e5a3ec 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 14444 2008-04-16 22:40:48Z hos $
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
@@ -272,6 +271,11 @@ set(SRC
operations/COM_NormalizeOperation.cpp
operations/COM_NormalizeOperation.h
+ nodes/COM_PixelateNode.cpp
+ nodes/COM_PixelateNode.h
+ operations/COM_PixelateOperation.cpp
+ operations/COM_PixelateOperation.h
+
# Filter nodes
nodes/COM_BilateralBlurNode.cpp
nodes/COM_BilateralBlurNode.h
@@ -650,6 +654,6 @@ list(APPEND INC
${CMAKE_CURRENT_BINARY_DIR}/operations
)
data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/operations/COM_OpenCLKernels.cl
- ${CMAKE_CURRENT_BINARY_DIR}/operations/COM_OpenCLKernels.cl.h SRC)
+ ${CMAKE_CURRENT_BINARY_DIR}/operations/COM_OpenCLKernels.cl.h SRC)
blender_add_lib(bf_compositor "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 71067ac8f15..2b09c9d5b8c 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -119,6 +119,7 @@
#include "COM_ViewLevelsNode.h"
#include "COM_ViewerNode.h"
#include "COM_ZCombineNode.h"
+#include "COM_PixelateNode.h"
Node *Converter::convert(bNode *b_node, bool fast)
{
@@ -390,6 +391,9 @@ Node *Converter::convert(bNode *b_node, bool fast)
node = new TrackPositionNode(b_node);
break;
/* not inplemented yet */
+ case CMP_NODE_PIXELATE:
+ node = new PixelateNode(b_node);
+ break;
default:
node = new MuteNode(b_node);
break;
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index 5c891705089..0553aebbba6 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -204,7 +204,7 @@ void ExecutionGroup::determineNumberOfChunks()
this->m_numberOfXChunks = 1;
this->m_numberOfYChunks = 1;
this->m_numberOfChunks = 1;
- }
+ }
else {
const float chunkSizef = this->m_chunkSize;
this->m_numberOfXChunks = ceil(this->m_width / chunkSizef);
@@ -475,10 +475,10 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
int maxxchunk = ceil((area->xmax - 1) / chunkSizef);
int minychunk = floor(area->ymin / chunkSizef);
int maxychunk = ceil((area->ymax - 1) / chunkSizef);
- minxchunk = MAX2(minxchunk, 0);
- minychunk = MAX2(minychunk, 0);
- maxxchunk = MIN2(maxxchunk, this->m_numberOfXChunks);
- maxychunk = MIN2(maxychunk, this->m_numberOfYChunks);
+ minxchunk = max(minxchunk, 0);
+ minychunk = max(minychunk, 0);
+ maxxchunk = min(maxxchunk, (int)this->m_numberOfXChunks);
+ maxychunk = min(maxychunk, (int)this->m_numberOfYChunks);
bool result = true;
for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index a13717c9d86..c6e0f6c2cfb 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -25,6 +25,7 @@
#include <sstream>
#include "PIL_time.h"
+#include "BLI_utildefines.h"
#include "BKE_node.h"
#include "COM_Converter.h"
@@ -50,7 +51,7 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool re
this->m_context.setbNodeTree(editingtree);
this->m_context.setFastCalculation(fastcalculation);
bNode *gnode;
- for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) {
+ for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = gnode->next) {
if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) {
this->m_context.setActivegNode(gnode);
break;
@@ -240,12 +241,32 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
}
}
+#ifndef NDEBUG
+/* if this fails, there are still connection to/from this node,
+ * which have not been properly relinked to operations!
+ */
+static void debug_check_node_connections(Node *node)
+{
+ for (int i = 0; i < node->getNumberOfInputSockets(); ++i) {
+ BLI_assert(!node->getInputSocket(i)->isConnected());
+ }
+ for (int i = 0; i < node->getNumberOfOutputSockets(); ++i) {
+ BLI_assert(!node->getOutputSocket(i)->isConnected());
+ }
+}
+#else
+/* stub */
+#define debug_check_node_connections(node)
+#endif
+
void ExecutionSystem::convertToOperations()
{
unsigned int index;
for (index = 0; index < this->m_nodes.size(); index++) {
Node *node = (Node *)this->m_nodes[index];
node->convertToOperations(this, &this->m_context);
+
+ debug_check_node_connections(node);
}
for (index = 0; index < this->m_connections.size(); index++) {
@@ -315,6 +336,16 @@ void ExecutionSystem::addSocketConnection(SocketConnection *connection)
this->m_connections.push_back(connection);
}
+void ExecutionSystem::removeSocketConnection(SocketConnection *connection)
+{
+ for (vector<SocketConnection *>::iterator it = m_connections.begin(); it != m_connections.end(); ++it) {
+ if (*it == connection) {
+ this->m_connections.erase(it);
+ return;
+ }
+ }
+}
+
void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const
{
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 56a60bf7a03..25f06108d96 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -189,6 +189,11 @@ public:
void addSocketConnection(SocketConnection *connection);
/**
+ * Remove a socket connection from the system.
+ */
+ void removeSocketConnection(SocketConnection *connection);
+
+ /**
* @brief Convert all nodes to operations
*/
void convertToOperations();
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
index 33a5cafebbe..506bd42ace3 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
@@ -51,7 +51,7 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star
while (node != NULL) {
Node *nnode = addNode(nodes, node, isActiveGroup, system.getContext().isFastCalculation());
nnode->setbNodeGroup(groupnode);
- node = (bNode *)node->next;
+ node = node->next;
}
NodeRange node_range(nodes.begin() + nodes_start, nodes.end());
@@ -60,7 +60,7 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star
bNodeLink *nodelink = (bNodeLink *)tree->links.first;
while (nodelink != NULL) {
addNodeLink(node_range, links, nodelink);
- nodelink = (bNodeLink *)nodelink->next;
+ nodelink = nodelink->next;
}
/* Expand group nodes */
diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp
index a9c280e0367..2493d4e5a27 100644
--- a/source/blender/compositor/intern/COM_InputSocket.cpp
+++ b/source/blender/compositor/intern/COM_InputSocket.cpp
@@ -122,6 +122,17 @@ void InputSocket::relinkConnections(InputSocket *relinkToSocket, int editorNode
}
}
+void InputSocket::unlinkConnections(ExecutionSystem *system)
+{
+ SocketConnection *connection = getConnection();
+ if (connection) {
+ system->removeSocketConnection(connection);
+ connection->getFromSocket()->removeConnection(connection);
+ setConnection(NULL);
+ delete connection;
+ }
+}
+
bool InputSocket::isStatic()
{
if (isConnected()) {
diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h
index 259479015aa..5cd4cf3beb7 100644
--- a/source/blender/compositor/intern/COM_InputSocket.h
+++ b/source/blender/compositor/intern/COM_InputSocket.h
@@ -87,17 +87,11 @@ public:
/**
* @brief determine the resolution of this data going through this socket
* @param resolution the result of this operation
- * @param preferredResolution the preferrable resolution as no resolution could be determined
+ * @param preferredResolution the preferable resolution as no resolution could be determined
*/
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
/**
- * @brief Notifies the Input of the data type (via a SocketConnection)
- * @param datatype the datatype to evaluate
- */
- void notifyActualInputType(DataType datatype);
-
- /**
* @brief move all connections of this input socket to another socket
* only use this method when already checked the availability of a SocketConnection
* @param relinkToSocket the socket to move to connections to
@@ -114,7 +108,8 @@ public:
void relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system);
/**
- * @brief move all connections of this input socket to another socket
+ * @brief add a connection of this input socket to another socket
+ * @warning make sure to remove the original connection with \a unlinkConnections afterward.
* @param relinkToSocket the socket to move to connections to
* @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
* @param system ExecutionSystem to update to
@@ -122,6 +117,13 @@ public:
void relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system);
/**
+ * @brief remove all connections of this input socket.
+ * @warning \a relinkConnectionsDuplicate should be used to ensure this socket is still connected.
+ * @param system ExecutionSystem to update to
+ */
+ void unlinkConnections(ExecutionSystem *system);
+
+ /**
* @brief set the resize mode
* @param resizeMode the new resize mode.
*/
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index bdbe21f82ea..357a4c1d4c0 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -160,7 +160,7 @@ void MemoryBuffer::writePixel(int x, int y, const float color[4])
if (x >= this->m_rect.xmin && x < this->m_rect.xmax &&
y >= this->m_rect.ymin && y < this->m_rect.ymax)
{
- const int offset = (this->m_chunkWidth * (y-this->m_rect.ymin) + x-this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS;
+ const int offset = (this->m_chunkWidth * (y - this->m_rect.ymin) + x - this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS;
copy_v4_v4(&this->m_buffer[offset], color);
}
}
@@ -170,7 +170,7 @@ void MemoryBuffer::addPixel(int x, int y, const float color[4])
if (x >= this->m_rect.xmin && x < this->m_rect.xmax &&
y >= this->m_rect.ymin && y < this->m_rect.ymax)
{
- const int offset = (this->m_chunkWidth * (y-this->m_rect.ymin) + x-this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS;
+ const int offset = (this->m_chunkWidth * (y - this->m_rect.ymin) + x - this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS;
add_v4_v4(&this->m_buffer[offset], color);
}
}
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 5922b0e6b08..300d7ef1952 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -51,7 +51,7 @@ Node::Node(bNode *editorNode, bool create_sockets): NodeBase()
if (input->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
this->addInputSocket(dt, (InputSocketResizeMode)input->resizemode, input);
- input = (bNodeSocket *)input->next;
+ input = input->next;
}
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
while (output != NULL) {
@@ -60,14 +60,14 @@ Node::Node(bNode *editorNode, bool create_sockets): NodeBase()
if (output->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
this->addOutputSocket(dt, output);
- output = (bNodeSocket *)output->next;
+ output = output->next;
}
}
}
void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket *)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocket *bSock = this->getEditorInputSocket(editorNodeInputSocketIndex);
SetValueOperation *operation = new SetValueOperation();
bNodeSocketValueFloat *val = (bNodeSocketValueFloat *)bSock->default_value;
operation->setValue(val->value);
@@ -114,7 +114,7 @@ SocketConnection *Node::addLink(ExecutionSystem *graph, OutputSocket *outputSock
void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket *)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocket *bSock = this->getEditorInputSocket(editorNodeInputSocketIndex);
SetColorOperation *operation = new SetColorOperation();
bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA *)bSock->default_value;
operation->setChannel1(val->value[0]);
@@ -127,7 +127,7 @@ void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket
void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket *)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocket *bSock = this->getEditorInputSocket(editorNodeInputSocketIndex);
bNodeSocketValueVector *val = (bNodeSocketValueVector *)bSock->default_value;
SetVectorOperation *operation = new SetVectorOperation();
operation->setX(val->value[0]);
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index e8fd936e749..468a95ed434 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -20,8 +20,8 @@
* Monique Dewanchand
*/
-#ifndef _COM_Node_h
-#define _COM_Node_h
+#ifndef __COM_NODE_H__
+#define __COM_NODE_H__
#include "COM_NodeBase.h"
#include "COM_InputSocket.h"
@@ -152,4 +152,4 @@ protected:
private:
};
-#endif
+#endif /* __COM_NODE_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h
index 64d669b5e9a..e386b5e08a0 100644
--- a/source/blender/compositor/intern/COM_NodeBase.h
+++ b/source/blender/compositor/intern/COM_NodeBase.h
@@ -20,8 +20,8 @@
* Monique Dewanchand
*/
-#ifndef _COM_NodeBase_h
-#define _COM_NodeBase_h
+#ifndef __COM_NODEBASE_H__
+#define __COM_NODEBASE_H__
#include "COM_InputSocket.h"
#include "COM_OutputSocket.h"
@@ -166,4 +166,4 @@ protected:
#endif
};
-#endif
+#endif /* __COM_NODEBASE_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index 4ae114bd031..a05c37e1b09 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -126,7 +126,7 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper
else {
rcti tempOutput;
bool first = true;
- for (int i = 0 ; i < getNumberOfInputSockets() ; i ++) {
+ for (int i = 0; i < getNumberOfInputSockets(); i ++) {
NodeOperation * inputOperation = this->getInputOperation(i);
if (inputOperation && inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
if (first) {
@@ -137,10 +137,10 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper
first = false;
}
else {
- output->xmin = MIN2(output->xmin, tempOutput.xmin);
- output->ymin = MIN2(output->ymin, tempOutput.ymin);
- output->xmax = MAX2(output->xmax, tempOutput.xmax);
- output->ymax = MAX2(output->ymax, tempOutput.ymax);
+ output->xmin = min(output->xmin, tempOutput.xmin);
+ output->ymin = min(output->ymin, tempOutput.ymin);
+ output->xmax = max(output->xmax, tempOutput.xmax);
+ output->ymax = max(output->ymax, tempOutput.ymax);
}
}
}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index dfa22a29e41..42d90eca38f 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -94,7 +94,7 @@ public:
* @brief determine the resolution of this node
* @note this method will not set the resolution, this is the responsibility of the caller
* @param resolution the result of this operation
- * @param preferredResolution the preferrable resolution as no resolution could be determined
+ * @param preferredResolution the preferable resolution as no resolution could be determined
*/
virtual void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
@@ -163,7 +163,10 @@ public:
* @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution
* @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution
*/
- virtual void executeOpenCL(OpenCLDevice *device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {}
+ virtual void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp) {}
virtual void deinitExecution();
bool isResolutionSet() {
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index d23ed245844..d5da079c9fd 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -74,7 +74,7 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
{
cl_int error;
- MemoryBuffer *result = (MemoryBuffer *)reader->getInputMemoryBuffer(inputMemoryBuffers);
+ MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers);
const cl_image_format imageFormat = {
CL_RGBA,
diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp
index f23a48979da..50e9b75b072 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.cpp
+++ b/source/blender/compositor/intern/COM_OutputSocket.cpp
@@ -54,6 +54,16 @@ void OutputSocket::addConnection(SocketConnection *connection)
this->m_connections.push_back(connection);
}
+void OutputSocket::removeConnection(SocketConnection *connection)
+{
+ for (vector<SocketConnection *>::iterator it = m_connections.begin(); it != m_connections.end(); ++it) {
+ if (*it == connection) {
+ m_connections.erase(it);
+ return;
+ }
+ }
+}
+
void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single)
{
if (isConnected()) {
diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h
index c6b7993c561..709005a6de0 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.h
+++ b/source/blender/compositor/intern/COM_OutputSocket.h
@@ -50,6 +50,7 @@ public:
OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex);
OutputSocket(OutputSocket *from);
void addConnection(SocketConnection *connection);
+ void removeConnection(SocketConnection *connection);
SocketConnection *getConnection(unsigned int index) { return this->m_connections[index]; }
const int isConnected() const;
int isOutputSocket() const;
@@ -57,7 +58,7 @@ public:
/**
* @brief determine the resolution of this socket
* @param resolution the result of this operation
- * @param preferredResolution the preferrable resolution as no resolution could be determined
+ * @param preferredResolution the preferable resolution as no resolution could be determined
*/
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index eb9c26d4f43..724abb59bcf 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -106,13 +106,11 @@ void **g_highlightedNodesRead;
void COM_startReadHighlights()
{
- if (!g_highlightInitialized)
- {
+ if (!g_highlightInitialized) {
return;
}
- if (g_highlightedNodesRead)
- {
+ if (g_highlightedNodesRead) {
MEM_freeN(g_highlightedNodesRead);
}
@@ -332,10 +330,10 @@ void WorkScheduler::initialize(bool use_opencl)
const char *cl_str[2] = {datatoc_COM_OpenCLKernels_cl, NULL};
g_program = clCreateProgramWithSource(g_context, 1, cl_str, 0, &error);
error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0);
- if (error != CL_SUCCESS) {
+ if (error != CL_SUCCESS) {
cl_int error2;
size_t ret_val_size = 0;
- printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
char *build_log = (char *)MEM_mallocN(sizeof(char) * ret_val_size + 1, __func__);
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
index 4efb06c9f87..29c6000a245 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
@@ -34,4 +34,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_ChannelMatteNODE_H
+#endif /* COM_ChannelMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
index ddd350aab40..bf5302ccdbb 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
@@ -34,4 +34,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_ChromaMatteNODE_H
+#endif /* COM_ChromaMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
index cdad02fc831..30d22ef2e63 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_ColorBalanceNODE_H
+#endif /* COM_ColorBalanceNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h
index 92a4fa79408..3386476bc85 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h
@@ -34,4 +34,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_ColorMatteNODE_H
+#endif /* COM_ColorMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
index 6c256c09e68..3f00e1c2190 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.h
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_ColorRampNODE_H
+#endif /* COM_ColorRampNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h
index 1d976fc65ae..01722fac826 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.h
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_ColorSpillNODE_H
+#endif /* COM_ColorSpillNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
index 70aeee8fc27..254dfb7b9c7 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
@@ -35,7 +35,7 @@ void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorCon
}
else {
operation = new ConvertKeyToPremulOperation();
- }
+ }
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp
index b80a3e088f2..f09bb7e1c26 100644
--- a/source/blender/compositor/nodes/COM_CropNode.cpp
+++ b/source/blender/compositor/nodes/COM_CropNode.cpp
@@ -40,7 +40,7 @@ void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation = new CropImageOperation();
}
else {
- operation = new CropOperation();
+ operation = new CropOperation();
}
operation->setCropSettings(cropSettings);
operation->setRelative(relative);
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
index 191b7361c3c..0b571889571 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_DifferenceMatteNODE_H
+#endif /* COM_DifferenceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index 5cfc29ecce2..0fb7ea7d264 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -79,7 +79,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
CompositorQuality quality = context->getQuality();
/* initialize node data */
- NodeBlurData *data = (NodeBlurData *)&this->m_alpha_blur;
+ NodeBlurData *data = &this->m_alpha_blur;
memset(data, 0, sizeof(*data));
data->filtertype = R_FILTER_GAUSS;
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
index 4e6682424e8..46ceae7c4f4 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
@@ -34,4 +34,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_DistanceMatteNODE_H
+#endif /* COM_DistanceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
index d65166944d8..9be3bb02494 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.h
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -20,8 +20,8 @@
* Monique Dewanchand
*/
-#ifndef _COM_FilterNode_h_
-#define _COM_FilterNode_h_
+#ifndef __COM_FILTERNODE_H__
+#define __COM_FILTERNODE_H__
#include "COM_Node.h"
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // _COM_FilterNode_h_
+#endif /* __COM_FILTERNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
index 9b55b809212..29e10db0758 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
@@ -50,7 +50,7 @@ void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, Composi
ChangeHSVOperation *changeHSV = new ChangeHSVOperation();
MixBlendOperation *blend = new MixBlendOperation();
- colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 0, graph);
+ colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph);
addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index 6bc9afba32c..51ea2913e65 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -151,7 +151,7 @@ OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext
CompositorQuality quality = context->getQuality();
/* initialize node data */
- NodeBlurData *data = (NodeBlurData *)&this->m_alpha_blur;
+ NodeBlurData *data = &this->m_alpha_blur;
memset(data, 0, sizeof(*data));
data->filtertype = R_FILTER_GAUSS;
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
index 37f3c31113f..a71e68cf636 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
@@ -19,8 +19,8 @@
* Dalai Felinto
*/
-#ifndef _COM_LuminanceMatteNode_h_
-#define _COM_LuminanceMatteNode_h_
+#ifndef __COM_LUMINANCEMATTENODE_H__
+#define __COM_LUMINANCEMATTENODE_H__
#include "COM_Node.h"
@@ -34,4 +34,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // _COM_LuminanceMatteNode_h_
+#endif /* __COM_LUMINANCEMATTENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
index 22aa5459ec0..bd8e3d08e9c 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.h
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -20,8 +20,8 @@
* Monique Dewanchand
*/
-#ifndef _COM_MapValueNode_h_
-#define _COM_MapValueNode_h_
+#ifndef __COM_MAPVALUENODE_H__
+#define __COM_MAPVALUENODE_H__
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // _COM_MapValueNode_h_
+#endif /* __COM_MAPVALUENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h
index cdd5d3c362e..9ef3e5deb50 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.h
+++ b/source/blender/compositor/nodes/COM_MaskNode.h
@@ -21,8 +21,8 @@
* Sergey Sharybin
*/
-#ifndef _COM_MaskNode_h_
-#define _COM_MaskNode_h_
+#ifndef __COM_MASKNODE_H__
+#define __COM_MASKNODE_H__
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -38,4 +38,4 @@ public:
};
-#endif // _COM_MaskNode_h_
+#endif /* __COM_MASKNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
index 52ea11ea8e9..2fb38860a34 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.h
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -20,8 +20,8 @@
* Monique Dewanchand
*/
-#ifndef _COM_MovieClipNode_h_
-#define _COM_MovieClipNode_h_
+#ifndef __COM_MOVIECLIPNODE_H__
+#define __COM_MOVIECLIPNODE_H__
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -36,4 +36,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // _COM_MovieClipNode_h_
+#endif /* __COM_MOVIECLIPNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp
index 1821844c6f5..4502dcf469c 100644
--- a/source/blender/compositor/nodes/COM_MuteNode.cpp
+++ b/source/blender/compositor/nodes/COM_MuteNode.cpp
@@ -108,27 +108,16 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
/* mute node is also used for unknown nodes and couple of nodes in fast mode
* can't use generic routines in that case
*/
- if ((editorNode->flag & NODE_MUTED) && editorNode->typeinfo->internal_connect) {
+ if (editorNode->flag & NODE_MUTED) {
vector<InputSocket *> &inputsockets = this->getInputSockets();
vector<OutputSocket *> relinkedsockets;
- bNodeTree *editorTree;
SocketMap socketMap;
- ListBase intlinks;
bNodeLink *link;
- if (this->getbNodeGroup()) {
- editorTree = (bNodeTree *) getbNodeGroup()->id;
- }
- else {
- editorTree = (bNodeTree *) context->getbNodeTree();
- }
-
- intlinks = editorNode->typeinfo->internal_connect(editorTree, editorNode);
-
this->fillSocketMap<OutputSocket>(outputsockets, socketMap);
this->fillSocketMap<InputSocket>(inputsockets, socketMap);
- for (link = (bNodeLink *) intlinks.first; link; link = link->next) {
+ for (link = (bNodeLink *) editorNode->internal_links.first; link; link = link->next) {
if (link->fromnode == editorNode) {
InputSocket *fromSocket = (InputSocket *) socketMap.find(link->fromsock)->second;
OutputSocket *toSocket = (OutputSocket *) socketMap.find(link->tosock)->second;
@@ -170,8 +159,6 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
createDefaultOutput(graph, output);
}
}
-
- BLI_freelistN(&intlinks);
}
else {
for (unsigned int index = 0; index < outputsockets.size(); index++) {
diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h
index 660d90040bd..64d4e3a3656 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.h
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -35,4 +35,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // COM_NormalNODE_H
+#endif /* COM_NormalNODE_H */
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.cpp b/source/blender/compositor/nodes/COM_PixelateNode.cpp
new file mode 100644
index 00000000000..f1c7c616a30
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_PixelateNode.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_PixelateNode.h"
+
+#include "COM_PixelateOperation.h"
+#include "COM_ExecutionSystem.h"
+
+PixelateNode::PixelateNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+void PixelateNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ DataType datatype = inputSocket->getDataType();
+ if (inputSocket->isConnected()) {
+ SocketConnection * connection = inputSocket->getConnection();
+ OutputSocket* otherOutputSocket = connection->getFromSocket();
+ datatype = otherOutputSocket->getDataType();
+ }
+
+ PixelateOperation *operation = new PixelateOperation(datatype);
+ inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.h b/source/blender/compositor/nodes/COM_PixelateNode.h
new file mode 100644
index 00000000000..c142d2d7a5b
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_PixelateNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_PixelateNode_h_
+#define _COM_PixelateNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief PixelateNode
+ * @ingroup Node
+ */
+class PixelateNode : public Node {
+public:
+ PixelateNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp
index c51782b77af..d535e71a33c 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.cpp
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp
@@ -26,6 +26,7 @@
#include "COM_ExecutionSystem.h"
#include "BKE_node.h"
#include "COM_SetValueOperation.h"
+#include "COM_SetSamplerOperation.h"
ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode)
{
@@ -38,7 +39,9 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
InputSocket *inputXSocket = this->getInputSocket(1);
InputSocket *inputYSocket = this->getInputSocket(2);
OutputSocket *outputSocket = this->getOutputSocket(0);
+ BaseScaleOperation *scaleoperation;
bNode *bnode = this->getbNode();
+
switch (bnode->custom1) {
case CMP_SCALE_RELATIVE: {
ScaleOperation *operation = new ScaleOperation();
@@ -46,8 +49,8 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+
+ scaleoperation = operation;
}
break;
case CMP_SCALE_SCENEPERCENT: {
@@ -57,9 +60,9 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
- outputSocket->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(scaleFactorOperation);
- graph->addOperation(operation);
+
+ scaleoperation = operation;
}
break;
@@ -75,9 +78,9 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
operation->setNewWidth(rd->xsch * rd->size / 100.0f);
operation->setNewHeight(rd->ysch * rd->size / 100.0f);
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
- graph->addOperation(operation);
+
+ scaleoperation = operation;
}
break;
@@ -87,9 +90,12 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+
+ scaleoperation = operation;
}
break;
}
+
+ outputSocket->relinkConnections(scaleoperation->getOutputSocket(0));
+ graph->addOperation(scaleoperation);
}
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
index 67ac6ffc388..7fcdebadb46 100644
--- a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
@@ -70,4 +70,7 @@ void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorCon
outputASocket->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(operation);
}
+
+ /* remove the original connection to the node, this has been duplicated for all operations */
+ imageSocket->unlinkConnections(graph);
}
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
index b28ee3eade1..a579503a829 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -72,6 +72,8 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont
addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+ scaleOperation->setSampler((PixelSampler)this->getbNode()->custom1);
+
addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
addLink(graph, angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
rotateOperation->setDoDegree2RadConversion(false);
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
index 57a7a0229ec..666f2da775e 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.h
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -20,8 +20,8 @@
* Monique Dewanchand
*/
-#ifndef _COM_TransformNode_h_
-#define _COM_TransformNode_h_
+#ifndef __COM_TRANSFORMNODE_H__
+#define __COM_TRANSFORMNODE_H__
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -36,4 +36,4 @@ public:
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
};
-#endif // _COM_TransformNode_h_
+#endif /* __COM_TRANSFORMNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
index 6bb873e0dec..a515bfc7f47 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
@@ -24,6 +24,7 @@
#include "COM_ExecutionSystem.h"
#include "COM_CalculateMeanOperation.h"
#include "COM_CalculateStandardDeviationOperation.h"
+#include "COM_SetValueOperation.h"
ViewLevelsNode::ViewLevelsNode(bNode *editorNode) : Node(editorNode)
{
@@ -64,5 +65,18 @@ void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorConte
graph->addOperation(operation);
}
}
+ else {
+ SetValueOperation *meanOutput = new SetValueOperation();
+ SetValueOperation *stdDevOutput = new SetValueOperation();
+
+ meanOutput->setValue(0.0f);
+ stdDevOutput->setValue(0.0f);
+
+ this->getOutputSocket(0)->relinkConnections(meanOutput->getOutputSocket());
+ this->getOutputSocket(1)->relinkConnections(stdDevOutput->getOutputSocket());
+
+ graph->addOperation(meanOutput);
+ graph->addOperation(stdDevOutput);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index d67e9e274b0..f44470a9b9a 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -52,8 +52,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
viewerOperation->setDisplaySettings(context->getDisplaySettings());
viewerOperation->setResolutionInputSocketIndex(0);
- if (!imageSocket->isConnected())
- {
+ if (!imageSocket->isConnected()) {
if (alphaSocket->isConnected()) {
viewerOperation->setResolutionInputSocketIndex(1);
}
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index 37483d3dc69..74ca6b7b058 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -59,6 +59,9 @@ public:
void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; }
- void executeOpenCL(OpenCLDevice *device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp);
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index 152b10709fb..a8e8cb98564 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -100,7 +100,7 @@ void ColorSpillOperation::executePixel(float output[4], float x, float y, PixelS
}
else {
copy_v4_v4(output, input);
- }
+ }
}
float ColorSpillOperation::calculateMapValue(float fac, float *input)
{
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 88289f12ebb..f39a28b87a8 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -64,8 +64,8 @@ void ConvertDepthToRadiusOperation::initExecution()
this->m_inverseFocalDistance = 1.0f / focalDistance;
this->m_aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight());
this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop;
- float minsz = min(getWidth(), getHeight());
- this->m_dof_sp = (float)minsz / ((cam_sensor / 2.0f) / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
+ const float minsz = min(getWidth(), getHeight());
+ this->m_dof_sp = minsz / ((cam_sensor / 2.0f) / this->m_cam_lens); // <- == aspect * min(img->x, img->y) / tan(0.5f * fov);
if (this->m_blurPostOperation) {
m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius));
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index c33bd2544ac..16c19f3ebaa 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -36,25 +36,28 @@ void CropBaseOperation::updateArea()
SocketReader *inputReference = this->getInputSocketReader(0);
float width = inputReference->getWidth();
float height = inputReference->getHeight();
- if (this->m_relative) {
- this->m_settings->x1 = width * this->m_settings->fac_x1;
- this->m_settings->x2 = width * this->m_settings->fac_x2;
- this->m_settings->y1 = height * this->m_settings->fac_y1;
- this->m_settings->y2 = height * this->m_settings->fac_y2;
- }
- if (width <= this->m_settings->x1 + 1)
- this->m_settings->x1 = width - 1;
- if (height <= this->m_settings->y1 + 1)
- this->m_settings->y1 = height - 1;
- if (width <= this->m_settings->x2 + 1)
- this->m_settings->x2 = width - 1;
- if (height <= this->m_settings->y2 + 1)
- this->m_settings->y2 = height - 1;
- this->m_xmax = MAX2(this->m_settings->x1, this->m_settings->x2) + 1;
- this->m_xmin = MIN2(this->m_settings->x1, this->m_settings->x2);
- this->m_ymax = MAX2(this->m_settings->y1, this->m_settings->y2) + 1;
- this->m_ymin = MIN2(this->m_settings->y1, this->m_settings->y2);
+ if (width > 0.0f && height > 0.0f) {
+ if (this->m_relative) {
+ this->m_settings->x1 = width * this->m_settings->fac_x1;
+ this->m_settings->x2 = width * this->m_settings->fac_x2;
+ this->m_settings->y1 = height * this->m_settings->fac_y1;
+ this->m_settings->y2 = height * this->m_settings->fac_y2;
+ }
+ if (width <= this->m_settings->x1 + 1)
+ this->m_settings->x1 = width - 1;
+ if (height <= this->m_settings->y1 + 1)
+ this->m_settings->y1 = height - 1;
+ if (width <= this->m_settings->x2 + 1)
+ this->m_settings->x2 = width - 1;
+ if (height <= this->m_settings->y2 + 1)
+ this->m_settings->y2 = height - 1;
+
+ this->m_xmax = max(this->m_settings->x1, this->m_settings->x2) + 1;
+ this->m_xmin = min(this->m_settings->x1, this->m_settings->x2);
+ this->m_ymax = max(this->m_settings->y1, this->m_settings->y2) + 1;
+ this->m_ymin = min(this->m_settings->y1, this->m_settings->y2);
+ }
}
void CropBaseOperation::initExecution()
@@ -110,5 +113,10 @@ void CropImageOperation::determineResolution(unsigned int resolution[2], unsigne
void CropImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
- this->m_inputOperation->read(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
+ if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
+ this->m_inputOperation->read(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
+ }
+ else {
+ zero_v4(output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index ddc7f855bf1..d2f2b15aa36 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -37,7 +37,7 @@ protected:
void updateArea();
public:
- CropBaseOperation();
+ CropBaseOperation();
void initExecution();
void deinitExecution();
void setCropSettings(NodeTwoXYs *settings) { this->m_settings = settings; }
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 9c09c9bf034..f0fffa770f8 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -344,28 +344,28 @@ void *DilateStepOperation::initializeTileData(rcti *rect)
for (y = 0; y < bheight; y++) {
for (x = 0; x < bwidth - 1; x++) {
p = rectf + (bwidth * y + x);
- *p = MAX2(*p, *(p + 1));
+ *p = max(*p, *(p + 1));
}
}
for (y = 0; y < bheight; y++) {
for (x = bwidth - 1; x >= 1; x--) {
p = rectf + (bwidth * y + x);
- *p = MAX2(*p, *(p - 1));
+ *p = max(*p, *(p - 1));
}
}
for (x = 0; x < bwidth; x++) {
for (y = 0; y < bheight - 1; y++) {
p = rectf + (bwidth * y + x);
- *p = MAX2(*p, *(p + bwidth));
+ *p = max(*p, *(p + bwidth));
}
}
for (x = 0; x < bwidth; x++) {
for (y = bheight - 1; y >= 1; y--) {
p = rectf + (bwidth * y + x);
- *p = MAX2(*p, *(p - bwidth));
+ *p = max(*p, *(p - bwidth));
}
}
}
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index 31608c88274..1723da11f21 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -92,8 +92,8 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data)
dxt = p_dx - d_dx;
dyt = p_dy - d_dy;
- dxt = signf(dxt) * maxf(fabsf(dxt), DISPLACE_EPSILON) / this->getWidth();
- dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight();
+ dxt = signf(dxt) * max_ff(fabsf(dxt), DISPLACE_EPSILON) / this->getWidth();
+ dyt = signf(dyt) * max_ff(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight();
/* EWA filtering (without nearest it gets blurry with NO distortion) */
this->m_inputColorProgram->read(output, u, v, dxt, dyt, COM_PS_NEAREST);
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 2b2928c98db..4bdb2591cb7 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -128,8 +128,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign
// XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
// so just skiping blur along faulty direction if src's def is below that limit!
- if (src_width < 3) xy &= ~(int) 1;
- if (src_height < 3) xy &= ~(int) 2;
+ if (src_width < 3) xy &= ~1;
+ if (src_height < 3) xy &= ~2;
if (xy < 1) return;
// see "Recursive Gabor Filtering" by Young/VanVliet
@@ -190,7 +190,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign
} (void)0
// intermediate buffers
- sz = MAX2(src_width, src_height);
+ sz = max(src_width, src_height);
X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index 8c5e5faf12a..0efead77cd4 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -102,12 +102,12 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo
int bufferstarty = inputBuffer->getRect()->ymin;
int miny = y;
- int maxy = y;
+ // int maxy = y; // UNUSED
int minx = x - this->m_rad;
- int maxx = x + this->m_rad;
+ int maxx = x + this->m_rad; // UNUSED
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
+ // maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
/* *** this is the main part which is different to 'GaussianXBlurOperation' *** */
@@ -123,7 +123,7 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo
float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
float distfacinv_max = 1.0f; /* 0 to 1 */
- for (int nx = minx; nx < maxx; nx += step) {
+ for (int nx = minx; nx <= maxx; nx += step) {
const int index = (nx - x) + this->m_rad;
float value = finv_test(buffer[bufferindex], do_invert);
float multiplier;
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 197715595ed..1f9cc8e461a 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -104,11 +104,11 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
int miny = y - this->m_rad;
int maxy = y + this->m_rad;
int minx = x;
- int maxx = x;
+ // int maxx = x; // UNUSED
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ maxy = min(maxy, inputBuffer->getRect()->ymax - 1);
+ // maxx = min(maxx, inputBuffer->getRect()->xmax);
/* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
int step = getStep();
@@ -121,7 +121,7 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
float distfacinv_max = 1.0f; /* 0 to 1 */
- for (int ny = miny; ny < maxy; ny += step) {
+ for (int ny = miny; ny <= maxy; ny += step) {
int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
const int index = (ny - y) + this->m_rad;
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index a9bcb2dd752..2d662c1061e 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -236,7 +236,7 @@ void GaussianBlurReferenceOperation::initExecution()
/* horizontal */
m_radx = (float)this->m_data->sizex;
- int imgx = getWidth()/2;
+ int imgx = getWidth() / 2;
if (m_radx > imgx)
m_radx = imgx;
else if (m_radx < 1)
@@ -245,7 +245,7 @@ void GaussianBlurReferenceOperation::initExecution()
/* vertical */
m_rady = (float)this->m_data->sizey;
- int imgy = getHeight()/2;
+ int imgy = getHeight() / 2;
if (m_rady > imgy)
m_rady = imgy;
else if (m_rady < 1)
@@ -257,7 +257,7 @@ void GaussianBlurReferenceOperation::initExecution()
void GaussianBlurReferenceOperation::updateGauss()
{
int i;
- int x = MAX2(m_radx, m_rady);
+ int x = max(m_radx, m_rady);
this->m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array");
for (i = 0; i < x; i++) {
m_maintabs[i] = make_gausstab(i + 1);
@@ -327,11 +327,11 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
void GaussianBlurReferenceOperation::deinitExecution()
{
int x, i;
- x = MAX2(m_radx, m_rady);
+ x = max(this->m_radx, this->m_rady);
for (i = 0; i < x; i++) {
- MEM_freeN(m_maintabs[i]);
+ MEM_freeN(this->m_maintabs[i]);
}
- MEM_freeN(m_maintabs);
+ MEM_freeN(this->m_maintabs);
BlurBaseOperation::deinitExecution();
}
@@ -344,8 +344,8 @@ bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(rcti *inpu
return true;
}
else {
- int addx = this->m_data->sizex+2;
- int addy = this->m_data->sizey+2;
+ int addx = this->m_data->sizex + 2;
+ int addy = this->m_data->sizey + 2;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 3ab60a1faa9..573a19466e8 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -85,18 +85,18 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d
int bufferstarty = inputBuffer->getRect()->ymin;
int miny = y;
- int maxy = y;
+ // int maxy = y; // UNUSED
int minx = x - this->m_rad;
int maxx = x + this->m_rad;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ // maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax - 1);
int step = getStep();
int offsetadd = getOffsetAdd();
int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth);
- for (int nx = minx, index = (minx - x) + this->m_rad; nx < maxx; nx += step, index += step) {
+ for (int nx = minx, index = (minx - x) + this->m_rad; nx <= maxx; nx += step, index += step) {
const float multiplier = this->m_gausstab[index];
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
multiplier_accum += multiplier;
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 7ab00b202e1..0c0a4d8aa4f 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -87,16 +87,16 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d
int miny = y - this->m_rad;
int maxy = y + this->m_rad;
int minx = x;
- int maxx = x;
+ // int maxx = x; // UNUSED
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ maxy = min(maxy, inputBuffer->getRect()->ymax - 1);
+ // maxx = min(maxx, inputBuffer->getRect()->xmax);
int index;
int step = getStep();
- const int bufferIndexx = ((minx - bufferstartx) * 4) ;
- for (int ny = miny; ny < maxy; ny += step) {
+ const int bufferIndexx = ((minx - bufferstartx) * 4);
+ for (int ny = miny; ny <= maxy; ny += step) {
index = (ny - y) + this->m_rad;
int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
const float multiplier = this->m_gausstab[index];
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
index efdf0134c4b..592ad114113 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
@@ -86,8 +86,8 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
fREAL *data_nbd = &data_n[bd];
fREAL *data_bd = &data[bd];
for (k = bl; k < len; k += istep) {
- t1 = fc * data_n[k] + fs * data_nbd[k];
- t2 = fs * data_n[k] - fc * data_nbd[k];
+ t1 = fc * (double)data_n[k] + fs * (double)data_nbd[k];
+ t2 = fs * (double)data_n[k] - fc * (double)data_nbd[k];
data_n[k] = data[k] - t1;
data_nbd[k] = data_bd[k] - t2;
data[k] += t1;
@@ -395,7 +395,7 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile,
// linear window good enough here, visual result counts, not scientific analysis
//w = (1.f-fabs(u))*(1.f-fabs(v));
// actually, Hanning window is ok, cos^2 for some reason is slower
- w = (0.5f + 0.5f * cos((double)u * M_PI)) * (0.5f + 0.5f * cos((double)v * M_PI));
+ w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
mul_v3_fl(fcol, w);
ckrn->writePixel(x, y, fcol);
}
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
index ace04237b29..c4f8b3a0ddb 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
@@ -79,9 +79,9 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
sc = 2.13;
isc = -0.97;
for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
- v = (float)(y + 0.5f) / (float)gbuf->getHeight();
+ v = ((float)y + 0.5f) / (float)gbuf->getHeight();
for (x = 0; x < gbuf->getWidth(); x++) {
- u = (float)(x + 0.5f) / (float)gbuf->getWidth();
+ u = ((float)x + 0.5f) / (float)gbuf->getWidth();
s = (u - 0.5f) * sc + 0.5f, t = (v - 0.5f) * sc + 0.5f;
tbuf1->readCubic(c, s * gbuf->getWidth(), t * gbuf->getHeight());
sm = smoothMask(s, t);
@@ -100,9 +100,9 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
memset(tbuf1->getBuffer(), 0, tbuf1->getWidth() * tbuf1->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
for (n = 1; n < settings->iter && (!breaked); n++) {
for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
- v = (float)(y + 0.5f) / (float)gbuf->getHeight();
+ v = ((float)y + 0.5f) / (float)gbuf->getHeight();
for (x = 0; x < gbuf->getWidth(); x++) {
- u = (float)(x + 0.5f) / (float)gbuf->getWidth();
+ u = ((float)x + 0.5f) / (float)gbuf->getWidth();
tc[0] = tc[1] = tc[2] = 0.f;
for (p = 0; p < 4; p++) {
np = (n << 2) + p;
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index 70d4d987c81..81ca06cfff0 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -133,9 +133,9 @@ void InpaintSimpleOperation::calc_manhatten_distance()
if (this->get_pixel(i, j)[3] < 1.0f) {
r = width + height;
if (i > 0)
- r = mini(r, m[j * width + i - 1] + 1);
+ r = min_ii(r, m[j * width + i - 1] + 1);
if (j > 0)
- r = mini(r, m[(j - 1) * width + i] + 1);
+ r = min_ii(r, m[(j - 1) * width + i] + 1);
}
m[j * width + i] = r;
}
@@ -146,9 +146,9 @@ void InpaintSimpleOperation::calc_manhatten_distance()
int r = m[j * width + i];
if (i + 1 < width)
- r = mini(r, m[j * width + i + 1] + 1);
+ r = min_ii(r, m[j * width + i + 1] + 1);
if (j + 1 < height)
- r = mini(r, m[(j + 1) * width + i] + 1);
+ r = min_ii(r, m[(j + 1) * width + i] + 1);
m[j * width + i] = r;
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
index 4426666f100..01f5c032730 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
@@ -28,18 +28,6 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-static int get_pixel_primary_channel(float *pixel)
-{
- float max_value = MAX3(pixel[0], pixel[1], pixel[2]);
-
- if (max_value == pixel[0])
- return 0;
- else if (max_value == pixel[1])
- return 1;
-
- return 2;
-}
-
KeyingDespillOperation::KeyingDespillOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
@@ -73,12 +61,12 @@ void KeyingDespillOperation::executePixel(float output[4], float x, float y, Pix
this->m_pixelReader->read(pixelColor, x, y, sampler);
this->m_screenReader->read(screenColor, x, y, sampler);
- int screen_primary_channel = get_pixel_primary_channel(screenColor);
- int other_1 = (screen_primary_channel + 1) % 3;
- int other_2 = (screen_primary_channel + 2) % 3;
+ const int screen_primary_channel = max_axis_v3(screenColor);
+ const int other_1 = (screen_primary_channel + 1) % 3;
+ const int other_2 = (screen_primary_channel + 2) % 3;
- int min_channel = MIN2(other_1, other_2);
- int max_channel = MAX2(other_1, other_2);
+ const int min_channel = min(other_1, other_2);
+ const int max_channel = max(other_1, other_2);
float average_value, amount;
@@ -87,7 +75,8 @@ void KeyingDespillOperation::executePixel(float output[4], float x, float y, Pix
copy_v4_v4(output, pixelColor);
- if (this->m_despillFactor * amount > 0) {
- output[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount;
+ const float amount_despill = this->m_despillFactor * amount;
+ if (amount_despill > 0.0f) {
+ output[screen_primary_channel] = pixelColor[screen_primary_channel] - amount_despill;
}
}
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
index 35138cf0b92..baeacb56744 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp
@@ -28,27 +28,15 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-static int get_pixel_primary_channel(float pixelColor[4])
+static float get_pixel_saturation(const float pixelColor[4], float screen_balance, int primary_channel)
{
- float max_value = MAX3(pixelColor[0], pixelColor[1], pixelColor[2]);
+ const int other_1 = (primary_channel + 1) % 3;
+ const int other_2 = (primary_channel + 2) % 3;
- if (max_value == pixelColor[0])
- return 0;
- else if (max_value == pixelColor[1])
- return 1;
+ const int min_channel = min(other_1, other_2);
+ const int max_channel = max(other_1, other_2);
- return 2;
-}
-
-static float get_pixel_saturation(float pixelColor[4], float screen_balance, int primary_channel)
-{
- int other_1 = (primary_channel + 1) % 3;
- int other_2 = (primary_channel + 2) % 3;
-
- int min_channel = MIN2(other_1, other_2);
- int max_channel = MAX2(other_1, other_2);
-
- float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel];
+ const float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel];
return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
}
@@ -85,13 +73,13 @@ void KeyingOperation::executePixel(float output[4], float x, float y, PixelSampl
this->m_pixelReader->read(pixelColor, x, y, sampler);
this->m_screenReader->read(screenColor, x, y, sampler);
- int primary_channel = get_pixel_primary_channel(screenColor);
+ const int primary_channel = max_axis_v3(screenColor);
if (pixelColor[primary_channel] > 1.0f) {
/* overexposure doesn't happen on screen itself and usually happens
* on light sources in the shot, this need to be checked separately
* because saturation and falloff calculation is based on the fact
- * that pixels are not overexposured
+ * that pixels are not overexposed
*/
output[0] = 1.0f;
}
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
index c9b129d8dcf..0874e2f59be 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -151,21 +151,24 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
zero_v3(site->color);
- for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
- if (pattern_ibuf->rect_float) {
- add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
- }
- else {
- unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
- site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
- site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
- site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ if (pattern_ibuf) {
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
}
- }
- mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
- IMB_freeImBuf(pattern_ibuf);
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+ }
site->co[0] = pos[0] * width;
site->co[1] = pos[1] * height;
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index 36b3f2023ae..ba1059c4eb5 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -73,7 +73,7 @@ void MaskOperation::initExecution()
for (masklay = (MaskLayer *)mask_temp->masklayers.first;
masklay;
- masklay = (MaskLayer *)masklay->next)
+ masklay = masklay->next)
{
masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index b492d06a697..febfa9662c6 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -45,7 +45,7 @@ protected:
*/
MathBaseOperation();
- void clampIfNeeded(float *color);
+ void clampIfNeeded(float color[4]);
public:
/**
* the inner loop of this program
diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h
index 4b466d193d6..88d1d00c2bf 100644
--- a/source/blender/compositor/operations/COM_MixBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MixBaseOperation.h
@@ -40,7 +40,7 @@ protected:
bool m_valueAlphaMultiply;
bool m_useClamp;
- inline void clampIfNeeded(float *color)
+ inline void clampIfNeeded(float color[4])
{
if (m_useClamp) {
CLAMP(color[0], 0.0f, 1.0f);
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index a3e00e9325b..68a61dff801 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -33,8 +33,7 @@ vector<DistortionCache *> s_cache;
void deintializeDistortionCache(void)
{
- while (s_cache.size()>0)
- {
+ while (s_cache.size() > 0) {
DistortionCache * cache = s_cache.back();
s_cache.pop_back();
delete cache;
@@ -51,6 +50,7 @@ MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperat
this->m_cache = NULL;
this->m_distortion = distortion;
}
+
void MovieDistortionOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
@@ -61,8 +61,7 @@ void MovieDistortionOperation::initExecution()
BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber);
BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height);
- for (unsigned int i = 0; i < s_cache.size(); i++)
- {
+ for (unsigned int i = 0; i < s_cache.size(); i++) {
DistortionCache *c = (DistortionCache *)s_cache[i];
if (c->isCacheFor(this->m_movieClip, this->m_width, this->m_height,
calibration_width, calibration_height, this->m_distortion))
@@ -86,15 +85,12 @@ void MovieDistortionOperation::deinitExecution()
{
this->m_inputOperation = NULL;
this->m_movieClip = NULL;
- while (s_cache.size() > COM_DISTORTIONCACHE_MAXSIZE)
- {
+ while (s_cache.size() > COM_DISTORTIONCACHE_MAXSIZE) {
double minTime = PIL_check_seconds_timer();
vector<DistortionCache*>::iterator minTimeIterator = s_cache.begin();
- for (vector<DistortionCache*>::iterator it = s_cache.begin(); it < s_cache.end(); it ++)
- {
+ for (vector<DistortionCache*>::iterator it = s_cache.begin(); it < s_cache.end(); it ++) {
DistortionCache * cache = *it;
- if (cache->getTimeLastUsage()<minTime)
- {
+ if (cache->getTimeLastUsage() < minTime) {
minTime = cache->getTimeLastUsage();
minTimeIterator = it;
}
@@ -110,21 +106,9 @@ void MovieDistortionOperation::executePixel(float output[4], float x, float y, P
if (this->m_cache != NULL) {
float u, v;
this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v);
- this->m_inputOperation->read(output, u, v, sampler);
- }
+ this->m_inputOperation->read(output, u, v, COM_PS_BILINEAR);
+ }
else {
- this->m_inputOperation->read(output, x, y, sampler);
+ this->m_inputOperation->read(output, x, y, COM_PS_BILINEAR);
}
}
-
-bool MovieDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
-{
- rcti newInput;
-
- newInput.xmax = input->xmax + 100;
- newInput.xmin = input->xmin - 100;
- newInput.ymax = input->ymax + 100;
- newInput.ymin = input->ymin - 100;
-
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
-}
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index f3eeb2f48ba..9f8aa065e3e 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -115,10 +115,10 @@ public:
if (!this->m_bufferCalculated[offset]) {
//float overscan = 0.0f;
- float w = (float)this->m_width /* / (1 + overscan) */;
- float h = (float)this->m_height /* / (1 + overscan) */;
- float aspx = (float)w / this->m_calibration_width;
- float aspy = (float)h / this->m_calibration_height;
+ const float w = (float)this->m_width /* / (1 + overscan) */;
+ const float h = (float)this->m_height /* / (1 + overscan) */;
+ const float aspx = w / (float)this->m_calibration_width;
+ const float aspy = h / (float)this->m_calibration_height;
float in[2];
float out[2];
@@ -155,7 +155,6 @@ protected:
public:
MovieDistortionOperation(bool distortion);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
index 4d366a864c4..36205bb94cc 100644
--- a/source/blender/compositor/operations/COM_OpenCLKernels.cl
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl
@@ -33,7 +33,7 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima
__read_only image2d_t bokehImage, __write_only image2d_t output,
int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset)
{
- int2 coords = {get_global_id(0), get_global_id(1)};
+ int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
float tempBoundingBox;
float4 color = {0.0f,0.0f,0.0f,0.0f};
@@ -54,10 +54,10 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima
float2 uv;
int2 inputXy;
- for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny +=step, inputXy.y+=step) {
+ for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny += step, inputXy.y += step) {
uv.y = ((realCoordinate.y-ny)/radius2)*bokehImageDim.y+bokehImageCenter.y;
- for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx +=step, inputXy.x+=step) {
+ for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx += step, inputXy.x += step) {
uv.x = ((realCoordinate.x-nx)/radius2)*bokehImageDim.x+bokehImageCenter.x;
bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);
color += bokeh * read_imagef(inputImage, SAMPLER_NEAREST, inputXy);
@@ -124,7 +124,7 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2
}
}
}
- }
+ }
}
color = color_accum * (1.0f / multiplier_accum);
@@ -148,7 +148,7 @@ __kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image
int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,
int2 offset)
{
- int2 coords = {get_global_id(0), get_global_id(1)};
+ int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
const int2 realCoordinate = coords + offsetOutput;
@@ -179,7 +179,7 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2
int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,
int2 offset)
{
- int2 coords = {get_global_id(0), get_global_id(1)};
+ int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
const int2 realCoordinate = coords + offsetOutput;
@@ -210,7 +210,7 @@ __kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_o
int2 offsetOutput, int iterations, float scale, float rotation, float2 translate,
float2 center, int2 offset)
{
- int2 coords = {get_global_id(0), get_global_id(1)};
+ int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
const int2 realCoordinate = coords + offsetOutput;
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index b3c2df7230f..7d05202df96 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -94,8 +94,8 @@ static void write_buffer_rect(rcti *rect, const bNodeTree *tree,
OutputSingleLayerOperation::OutputSingleLayerOperation(
- const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings)
+ const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings)
{
this->m_rd = rd;
this->m_tree = tree;
@@ -149,7 +149,7 @@ void OutputSingleLayerOperation::deinitExecution()
else
printf("Saved: %s\n", filename);
- IMB_freeImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
}
this->m_outputBuffer = NULL;
this->m_imageInput = NULL;
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp
new file mode 100644
index 00000000000..89e7f0093a1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_PixelateOperation.h"
+
+PixelateOperation::PixelateOperation(DataType datatype) : NodeOperation()
+{
+ this->addInputSocket(datatype);
+ this->addOutputSocket(datatype);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+}
+
+void PixelateOperation::initExecution()
+{
+ this->m_inputOperation = this->getInputSocketReader(0);
+}
+
+void PixelateOperation::deinitExecution()
+{
+ this->m_inputOperation = NULL;
+}
+
+void PixelateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+{
+ float nx = round(x);
+ float ny = round(y);
+ this->m_inputOperation->read(output, nx, ny, sampler);
+}
+
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.h b/source/blender/compositor/operations/COM_PixelateOperation.h
new file mode 100644
index 00000000000..b16b21b2ec1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_PixelateOperation.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_PixelateOperation_h_
+#define _COM_PixelateOperation_h_
+
+#include "COM_NodeOperation.h"
+
+/**
+ * @brief Pixelate operation
+ *
+ * The Tile compositor is by default sub-pixel accurate.
+ * For some setups you don want this.
+ * This operation will remove the sub-pixel accuracy
+ */
+class PixelateOperation : public NodeOperation {
+private:
+ /**
+ * @brief cached refeerence to the input operation
+ */
+ SocketReader *m_inputOperation;
+public:
+ /**
+ * @brief PixelateOperation
+ * @param dataType the datatype to create this operator for (saves datatype conversions)
+ */
+ PixelateOperation(DataType dataType);
+
+ /**
+ * @brief initialization of the execution
+ */
+ void initExecution();
+
+ /**
+ * @brief de-initialization of the execution
+ */
+ void deinitExecution();
+
+ /**
+ * @brief executePixel
+ * @param output result
+ * @param x x-coordinate
+ * @param y y-coordinate
+ * @param sampler sampler
+ */
+ void executePixel(float output[4], float x, float y, PixelSampler sampler);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index d92fe04eb15..5cc02a1ed65 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -81,7 +81,7 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *in
}
else {
rcti dispInput;
- BLI_rcti_init(&dispInput, 0,5,0,5);
+ BLI_rcti_init(&dispInput, 0, 5, 0, 5);
if (this->getInputOperation(1)->determineDependingAreaOfInterest(&dispInput, readOperation, output)) {
return true;
}
@@ -104,7 +104,7 @@ void ProjectorLensDistortionOperation::updateDispersion()
float result[4];
this->getInputSocketReader(1)->read(result, 1, 1, COM_PS_NEAREST);
this->m_dispersion = result[0];
- this->m_kr = 0.25f * maxf(minf(this->m_dispersion, 1.0f), 0.0f);
+ this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
this->m_kr2 = this->m_kr * 20;
this->m_dispersionAvailable = true;
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
index a4015c6283f..f4160a5fbcb 100644
--- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
@@ -69,6 +69,46 @@ void RenderLayersBaseProg::initExecution()
}
}
+void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler)
+{
+ unsigned int offset;
+ int ix, iy;
+ int width = this->getWidth(), height = this->getHeight();
+
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ ix = x;
+ iy = y;
+ offset = (iy * width + ix) * this->m_elementsize;
+
+ if (this->m_elementsize == 1)
+ output[0] = this->m_inputBuffer[offset];
+ else if (this->m_elementsize == 3)
+ copy_v3_v3(output, &this->m_inputBuffer[offset]);
+ else
+ copy_v4_v4(output, &this->m_inputBuffer[offset]);
+
+ break;
+
+ case COM_PS_BILINEAR:
+ BLI_bilinear_interpolation(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
+ break;
+
+ case COM_PS_BICUBIC:
+ BLI_bicubic_interpolation(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
+ break;
+ }
+
+ if (this->m_elementsize == 1) {
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 0.0f;
+ }
+ else if (this->m_elementsize == 3) {
+ output[3] = 1.0f;
+ }
+}
+
void RenderLayersBaseProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
int ix = x;
@@ -78,20 +118,7 @@ void RenderLayersBaseProg::executePixel(float output[4], float x, float y, Pixel
zero_v4(output);
}
else {
- unsigned int offset = (iy * this->getWidth() + ix) * this->m_elementsize;
- if (this->m_elementsize == 1) {
- output[0] = this->m_inputBuffer[offset];
- output[1] = 0.0f;
- output[2] = 0.0f;
- output[3] = 0.0f;
- }
- else if (this->m_elementsize == 3) {
- copy_v3_v3(output, &this->m_inputBuffer[offset]);
- output[3] = 1.0f;
- }
- else {
- copy_v4_v4(output, &this->m_inputBuffer[offset]);
- }
+ doInterpolation(output, x, y, sampler);
}
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
index ea57d4bc421..3916862a0b3 100644
--- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
@@ -80,6 +80,7 @@ protected:
*/
inline float *getInputBuffer() { return this->m_inputBuffer; }
+ void doInterpolation(float output[4], float x, float y, PixelSampler sampler);
public:
/**
* setter for the scene field. Will be called from
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 276b2f54b6e..9e8f5af0ef0 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -29,7 +29,16 @@
* note: use bilinear because bicubic makes fuzzy even when not scaling at all (1:1)
*/
-ScaleOperation::ScaleOperation() : NodeOperation()
+BaseScaleOperation::BaseScaleOperation()
+{
+#ifdef USE_FORCE_BILINEAR
+ m_sampler = (int) COM_PS_BILINEAR;
+#else
+ m_sampler = -1;
+#endif
+}
+
+ScaleOperation::ScaleOperation() : BaseScaleOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -59,22 +68,20 @@ void ScaleOperation::deinitExecution()
void ScaleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
-#ifdef USE_FORCE_BILINEAR
- sampler = COM_PS_BILINEAR;
-#endif
+ PixelSampler effective_sampler = getEffectiveSampler(sampler);
float scaleX[4];
float scaleY[4];
- this->m_inputXOperation->read(scaleX, x, y, sampler);
- this->m_inputYOperation->read(scaleY, x, y, sampler);
+ this->m_inputXOperation->read(scaleX, x, y, effective_sampler);
+ this->m_inputYOperation->read(scaleY, x, y, effective_sampler);
const float scx = scaleX[0];
const float scy = scaleY[0];
float nx = this->m_centerX + (x - this->m_centerX) / scx;
float ny = this->m_centerY + (y - this->m_centerY) / scy;
- this->m_inputOperation->read(output, nx, ny, sampler);
+ this->m_inputOperation->read(output, nx, ny, effective_sampler);
}
bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -94,12 +101,12 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe
newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy;
newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
// SCALE ABSOLUTE
-ScaleAbsoluteOperation::ScaleAbsoluteOperation() : NodeOperation()
+ScaleAbsoluteOperation::ScaleAbsoluteOperation() : BaseScaleOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -129,15 +136,13 @@ void ScaleAbsoluteOperation::deinitExecution()
void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
-#ifdef USE_FORCE_BILINEAR
- sampler = COM_PS_BILINEAR;
-#endif
+ PixelSampler effective_sampler = getEffectiveSampler(sampler);
float scaleX[4];
float scaleY[4];
- this->m_inputXOperation->read(scaleX, x, y, sampler);
- this->m_inputYOperation->read(scaleY, x, y, sampler);
+ this->m_inputXOperation->read(scaleX, x, y, effective_sampler);
+ this->m_inputYOperation->read(scaleY, x, y, effective_sampler);
const float scx = scaleX[0]; // target absolute scale
const float scy = scaleY[0]; // target absolute scale
@@ -151,7 +156,7 @@ void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, Pix
float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale;
float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale;
- this->m_inputOperation->read(output, nx, ny, sampler);
+ this->m_inputOperation->read(output, nx, ny, effective_sampler);
}
bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -176,12 +181,12 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB
newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale;
newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
// Absolute fixed siez
-ScaleFixedSizeOperation::ScaleFixedSizeOperation() : NodeOperation()
+ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
@@ -250,17 +255,15 @@ void ScaleFixedSizeOperation::deinitExecution()
void ScaleFixedSizeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
-#ifdef USE_FORCE_BILINEAR
- sampler = COM_PS_BILINEAR;
-#endif
+ PixelSampler effective_sampler = getEffectiveSampler(sampler);
if (this->m_is_offset) {
float nx = ((x - this->m_offsetX) * this->m_relX);
float ny = ((y - this->m_offsetY) * this->m_relY);
- this->m_inputOperation->read(output, nx, ny, sampler);
+ this->m_inputOperation->read(output, nx, ny, effective_sampler);
}
else {
- this->m_inputOperation->read(output, x * this->m_relX, y * this->m_relY, sampler);
+ this->m_inputOperation->read(output, x * this->m_relX, y * this->m_relY, effective_sampler);
}
}
@@ -273,7 +276,7 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read
newInput.ymax = input->ymax * this->m_relY;
newInput.ymin = input->ymin * this->m_relY;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
@@ -281,7 +284,7 @@ void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2], un
unsigned int nr[2];
nr[0] = this->m_newWidth;
nr[1] = this->m_newHeight;
- NodeOperation::determineResolution(resolution, nr);
+ BaseScaleOperation::determineResolution(resolution, nr);
resolution[0] = this->m_newWidth;
resolution[1] = this->m_newHeight;
}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index 4239ff063fb..f42cdbd78ed 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -25,7 +25,19 @@
#include "COM_NodeOperation.h"
-class ScaleOperation : public NodeOperation {
+class BaseScaleOperation : public NodeOperation {
+public:
+ void setSampler(PixelSampler sampler) { this->m_sampler = (int) sampler; }
+
+protected:
+ BaseScaleOperation();
+
+ PixelSampler getEffectiveSampler(PixelSampler sampler) { return (m_sampler == -1) ? sampler : (PixelSampler) m_sampler; }
+
+ int m_sampler;
+};
+
+class ScaleOperation : public BaseScaleOperation {
private:
SocketReader *m_inputOperation;
SocketReader *m_inputXOperation;
@@ -41,7 +53,7 @@ public:
void deinitExecution();
};
-class ScaleAbsoluteOperation : public NodeOperation {
+class ScaleAbsoluteOperation : public BaseScaleOperation {
SocketReader *m_inputOperation;
SocketReader *m_inputXOperation;
SocketReader *m_inputYOperation;
@@ -57,7 +69,7 @@ public:
void deinitExecution();
};
-class ScaleFixedSizeOperation : public NodeOperation {
+class ScaleFixedSizeOperation : public BaseScaleOperation {
SocketReader *m_inputOperation;
int m_newWidth;
int m_newHeight;
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index 193ab669f40..d2c6c833e2e 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -98,7 +98,7 @@ void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y,
const float sd = 1.0f / (float)ds;
for (z = 0; z < ds; ++z) {
- const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd;
+ const float tz = (z + (jit ? BLI_frand() : 0.5f)) * sd;
t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot;
d = 1.0f / (1.0f + sqrtf(t));
const float nx = (u * d + 0.5f) * width - 0.5f;
@@ -116,7 +116,7 @@ void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y,
const float sd = 1.0f / (float)ds;
for (z = 0; z < ds; ++z) {
- const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd;
+ const float tz = (z + (jit ? BLI_frand() : 0.5f)) * sd;
t = 1.0f - (this->m_kg4 + tz * this->m_dgb) * uv_dot;
d = 1.0f / (1.0f + sqrtf(t));
const float nx = (u * d + 0.5f) * width - 0.5f;
@@ -226,7 +226,7 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input
UPDATE_INPUT;
determineUV(coords, input->xmax, input->ymin);
UPDATE_INPUT;
- }
+ }
else {
determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f);
newInput.xmin = coords[0];
@@ -268,11 +268,11 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input
void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion)
{
- this->m_kg = maxf(minf(distortion, 1.0f), -0.999f);
+ this->m_kg = max_ff(min_ff(distortion, 1.0f), -0.999f);
// smaller dispersion range for somewhat more control
- const float d = 0.25f * maxf(minf(dispersion, 1.0f), 0.0f);
- this->m_kr = maxf(minf((this->m_kg + d), 1.0f), -0.999f);
- this->m_kb = maxf(minf((this->m_kg - d), 1.0f), -0.999f);
+ const float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f);
+ this->m_kr = max_ff(min_ff((this->m_kg + d), 1.0f), -0.999f);
+ this->m_kb = max_ff(min_ff((this->m_kg - d), 1.0f), -0.999f);
this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb);
this->m_sc = (this->m_data->fit && (this->m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * this->m_maxk)) :
(1.0f / (1.0f + this->m_maxk));
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
index d41d1c128da..8b5288321c1 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
@@ -92,7 +92,7 @@ void TrackPositionOperation::initExecution()
}
else if (this->m_position == POSITION_RELATIVE_FRAME) {
int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
- this->m_relativeFrame);
+ this->m_relativeFrame);
marker = BKE_tracking_marker_get(track, relative_clip_framenr);
copy_v2_v2(this->m_relativePos, marker->pos);
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 7ccc91072bc..61720c7676d 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -118,7 +118,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
#ifdef COM_DEFOCUS_SEARCH
float search[4];
- this->m_inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y / InverseSearchRadiusOperation::DIVIDER, NULL);
+ this->m_inputSearchProgram->read(search, x / InverseSearchRadiusOperation::DIVIDER, y / InverseSearchRadiusOperation::DIVIDER, NULL);
int minx = search[0];
int miny = search[1];
int maxx = search[2];
@@ -192,13 +192,13 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
cl_int maxBlur;
cl_float threshold = this->m_threshold;
- MemoryBuffer *sizeMemoryBuffer = (MemoryBuffer *)this->m_inputSizeProgram->getInputMemoryBuffer(inputMemoryBuffers);
+ MemoryBuffer *sizeMemoryBuffer = this->m_inputSizeProgram->getInputMemoryBuffer(inputMemoryBuffers);
const float max_dim = max(m_width, m_height);
cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
maxBlur = (cl_int)sizeMemoryBuffer->getMaximumValue() * scalar;
- maxBlur = MIN2(maxBlur, this->m_maxBlur);
+ maxBlur = min(maxBlur, this->m_maxBlur);
device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
@@ -298,9 +298,9 @@ voi *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
int rx = x * DIVIDER;
int ry = y * DIVIDER;
buffer[offset] = MAX2(rx - m_maxBlur, 0);
- buffer[offset+1] = MAX2(ry- m_maxBlur, 0);
- buffer[offset+2] = MIN2(rx+DIVIDER + m_maxBlur, width);
- buffer[offset+3] = MIN2(ry+DIVIDER + m_maxBlur, height);
+ buffer[offset + 1] = MAX2(ry - m_maxBlur, 0);
+ buffer[offset + 2] = MIN2(rx + DIVIDER + m_maxBlur, width);
+ buffer[offset + 3] = MIN2(ry + DIVIDER + m_maxBlur, height);
offset += 4;
}
}
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
index d9ca131721f..4d4c1199f3e 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
@@ -79,8 +79,7 @@ void ViewerBaseOperation::initImage()
BLI_unlock_thread(LOCK_DRAW_IMAGE);
}
- if (m_doDepthBuffer)
- {
+ if (m_doDepthBuffer) {
addzbuffloatImBuf(ibuf);
}
BLI_unlock_thread(LOCK_DRAW_IMAGE);
@@ -96,8 +95,7 @@ void ViewerBaseOperation::initImage()
*/
this->m_ibuf = ibuf;
- if (m_doDepthBuffer)
- {
+ if (m_doDepthBuffer) {
this->m_depthBuffer = ibuf->zbuf_float;
}
@@ -107,7 +105,7 @@ void ViewerBaseOperation:: updateImage(rcti *rect)
{
IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0,
this->m_viewSettings, this->m_displaySettings,
- rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ rect->xmin, rect->ymin, rect->xmax, rect->ymax, FALSE);
WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index 576d5da4d74..d1ac7d74ead 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -96,7 +96,7 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
if (m_depthInput) {
this->m_depthInput->read(depth, x, y, COM_PS_NEAREST);
depthbuffer[offset] = depth[0];
- }
+ }
offset ++;
offset4 += 4;
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index 273c10b60ac..17c8f4d9fd1 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -110,7 +110,8 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber)
memoryBuffer->setCreatedState();
}
-void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer)
+void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device, rcti *rect, unsigned int chunkNumber,
+ MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer)
{
float *outputFloatBuffer = outputBuffer->getBuffer();
cl_int error;
diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c
index a7da037ff16..379658bb4c4 100644
--- a/source/blender/datatoc/datatoc.c
+++ b/source/blender/datatoc/datatoc.c
@@ -49,7 +49,6 @@ static char *basename(char *string)
int main(int argc, char **argv)
{
FILE *fpin, *fpout;
- char sizest[256];
long size;
int i;
@@ -79,8 +78,6 @@ int main(int argc, char **argv)
for (i = 0; i < (int)strlen(argv[1]); i++)
if (argv[1][i] == '.') argv[1][i] = '_';
- sprintf(sizest, "%d", (int)size);
-
fpout = fopen(argv[2], "w");
if (!fpout) {
fprintf(stderr, "Unable to open output <%s>\n", argv[2]);
@@ -88,7 +85,7 @@ int main(int argc, char **argv)
}
fprintf(fpout, "/* DataToC output of file <%s> */\n\n", argv[1]);
- fprintf(fpout, "int datatoc_%s_size = %s;\n", argv[1], sizest);
+ fprintf(fpout, "int datatoc_%s_size = %d;\n", argv[1], (int)size);
fprintf(fpout, "char datatoc_%s[] = {\n", argv[1]);
while (size--) {
/* if we want to open in an editor
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 156b7d9de5c..027ff1a08e8 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -752,7 +752,7 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
/* highlight only for active */
if (ale->flag & AGRP_ACTIVE)
- copy_v3_v3_char((char *)cp, agrp->cs.active);
+ copy_v3_v3_char((char *)cp, agrp->cs.select);
else
copy_v3_v3_char((char *)cp, agrp->cs.solid);
@@ -1186,7 +1186,7 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type)
if (ma->adt)
return GET_ACF_FLAG_PTR(ma->adt->flag, type);
else
- return NULL;
+ return NULL;
default: /* unsupported */
return NULL;
@@ -1263,7 +1263,7 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type)
if (la->adt)
return GET_ACF_FLAG_PTR(la->adt->flag, type);
else
- return NULL;
+ return NULL;
default: /* unsupported */
return NULL;
@@ -1347,7 +1347,7 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type)
if (tex->adt)
return GET_ACF_FLAG_PTR(tex->adt->flag, type);
else
- return NULL;
+ return NULL;
default: /* unsupported */
return NULL;
@@ -3248,7 +3248,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
/* get the flag and the pointer to that flag */
flag = acf->setting_flag(ac, setting, &negflag);
ptr = acf->setting_ptr(ale, setting, &ptrsize);
- /* enabled= ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */
+ /* enabled = ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */
/* get the base icon for the setting */
switch (setting) {
@@ -3263,13 +3263,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
break;
case ACHANNEL_SETTING_EXPAND: /* expanded triangle */
- //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
+ //icon = ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
icon = ICON_TRIA_RIGHT;
tooltip = "Make channels grouped under this channel visible";
break;
case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */
- //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED);
+ //icon = ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED);
icon = ICON_LAYER_USED;
tooltip = "NLA Track is the only one evaluated for the AnimData block it belongs to";
break;
@@ -3278,13 +3278,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
case ACHANNEL_SETTING_PROTECT: /* protected lock */
// TODO: what about when there's no protect needed?
- //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED);
+ //icon = ((enabled)? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
tooltip = "Editability of keyframes for this channel";
break;
case ACHANNEL_SETTING_MUTE: /* muted speaker */
- //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
+ //icon = ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
icon = ICON_MUTE_IPO_OFF;
if (ale->type == ALE_FCURVE)
@@ -3367,7 +3367,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
y = (ymaxc - yminc) / 2 + yminc;
ymid = y - 7;
/* y-coordinates for text is only 4 down from middle */
- /* ytext= y - 4; */
+ /* ytext = y - 4; */
/* no button backdrop behind icons */
uiBlockSetEmboss(block, UI_EMBOSSN);
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index d35f39a48e0..f19dbe740bc 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -464,7 +464,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
/* store this level as the 'old' level now */
prevLevel = level;
- }
+ }
/* if the level is 'greater than' (i.e. less important) than the previous level... */
else if (level > prevLevel) {
/* if previous level was a base-level (i.e. 0 offset / root of one hierarchy),
@@ -600,7 +600,7 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C)
if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
return 0;
- /* NLA TweakMode test */
+ /* NLA TweakMode test */
if (sa->spacetype == SPACE_NLA) {
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
return 0;
@@ -794,7 +794,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr
FCurve *fcu = (FCurve *)channel;
is_sel = SEL_FCU(fcu);
- }
+ }
break;
case ANIMTYPE_NLATRACK:
{
@@ -910,7 +910,7 @@ static void rearrange_nla_channels(bAnimContext *UNUSED(ac), AnimData *adt, shor
if (rearrange_func == NULL)
return;
- /* only consider NLA data if it's accessible */
+ /* only consider NLA data if it's accessible */
//if (EXPANDED_DRVD(adt) == 0)
// return;
@@ -931,7 +931,7 @@ static void rearrange_driver_channels(bAnimContext *UNUSED(ac), AnimData *adt, s
if (rearrange_func == NULL)
return;
- /* only consider drivers if they're accessible */
+ /* only consider drivers if they're accessible */
if (EXPANDED_DRVD(adt) == 0)
return;
@@ -2206,7 +2206,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
- }
+ }
break;
case ANIMTYPE_GROUP:
@@ -2219,7 +2219,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
agrp->flag ^= AGRP_SELECTED;
}
else if (selectmode == -1) {
- /* select all in group (and deselect everthing else) */
+ /* select all in group (and deselect everthing else) */
FCurve *fcu;
/* deselect all other channels */
@@ -2228,7 +2228,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
/* only select channels in group and group itself */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
fcu->flag |= FCURVE_SELECTED;
- agrp->flag |= AGRP_SELECTED;
+ agrp->flag |= AGRP_SELECTED;
}
else {
/* select group by itself */
@@ -2306,7 +2306,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
/* invert selection status of this layer only */
gpl->flag ^= GP_LAYER_SELECT;
}
- else {
+ else {
/* select layer by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
gpl->flag |= GP_LAYER_SELECT;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 45e8777fe8e..81db69f87dc 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -269,8 +269,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d)
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA) {
gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- gpuSingleFilledRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
+ gpuSingleFilledRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ }
else {
gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
@@ -389,7 +389,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
return RAD2DEGF(1.0f); /* radians to degrees */
}
}
-
+
/* TODO: other rotation types here as necessary */
}
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 8b0593d48ac..5e215fbd6a2 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -175,7 +175,7 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction)
return 1;
case SACTCONT_MASK: /* Mask */ /* XXX review how this mode is handled... */
-{
+ {
/* TODO, other methods to get the mask */
// Sequence *seq = BKE_sequencer_active_get(ac->scene);
//MovieClip *clip = ac->scene->clip;
@@ -189,7 +189,7 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return 1;
-}
+ }
case SACTCONT_DOPESHEET: /* DopeSheet */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
@@ -682,7 +682,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
ale->datatype = ALE_ACT;
ale->adt = BKE_animdata_from_id(data);
- }
+ }
break;
case ANIMTYPE_DSSPK:
{
@@ -811,7 +811,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
}
ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE;
}
- }
+ }
break;
case ANIMTYPE_GPLAYER:
@@ -911,14 +911,16 @@ static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_i
/* only consider if F-Curve involves sequence_editor.sequences */
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
- Sequence *seq;
+ Sequence *seq = NULL;
char *seq_name;
-
- /* get strip name, and check if this strip is selected */
- seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
- seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, FALSE);
- if (seq_name) MEM_freeN(seq_name);
-
+
+ if (ed) {
+ /* get strip name, and check if this strip is selected */
+ seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
+ seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, FALSE);
+ if (seq_name) MEM_freeN(seq_name);
+ }
+
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
if ((seq == NULL) || (seq->flag & SELECT) == 0)
@@ -980,6 +982,27 @@ static short skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, ID *owner_id)
return 1;
}
+/* Check if F-Curve has errors and/or is disabled
+ * > returns: (bool) True if F-Curve has errors/is disabled
+ */
+static short fcurve_has_errors(FCurve *fcu)
+{
+ /* F-Curve disabled - path eval error */
+ if (fcu->flag & FCURVE_DISABLED) {
+ return 1;
+ }
+
+ /* driver? */
+ if (fcu->driver) {
+ /* for now, just check if the entire thing got disabled... */
+ if (fcu->driver->flag & DRIVER_FLAG_INVALID)
+ return 1;
+ }
+
+ /* no errors found */
+ return 0;
+}
+
/* find the next F-Curve that is usable for inclusion */
static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id)
{
@@ -1002,7 +1025,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGro
if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode))
continue;
}
- }
+ }
/* only include if visible (Graph Editor check, not channels check) */
if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
@@ -1018,6 +1041,13 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGro
continue;
}
+ /* error-based filtering... */
+ if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
+ /* skip if no errors... */
+ if (fcurve_has_errors(fcu) == 0)
+ continue;
+ }
+
/* this F-Curve can be used, so return it */
return fcu;
}
@@ -1183,7 +1213,7 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
*/
if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) {
/* there isn't really anything editable here, so skip if need editable */
- if ((filter_mode & ANIMFILTER_FOREDIT) == 0) {
+ if ((filter_mode & ANIMFILTER_FOREDIT) == 0) {
/* just add the action track now (this MUST appear for drawing)
* - as AnimData may not have an action, we pass a dummy pointer just to get the list elem created, then
* overwrite this with the real value - REVIEW THIS...
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index bc07bf091de..54c7f7ea30f 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -82,4 +82,4 @@ void ANIM_OT_driver_button_remove(struct wmOperatorType *ot);
void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
-#endif // __ANIM_INTERN_H__
+#endif /* __ANIM_INTERN_H__ */
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index 5295950546d..d8e3349e998 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -89,7 +89,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
* i.e. Bone1.Location.X, or Object.Location.X
* 2) <array-index> <property-name> (<struct name>)
* i.e. X Location (Bone1), or X Location (Object)
- *
+ *
* Currently, option 2 is in use, to try and make it easier to quickly identify F-Curves (it does have
* problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of
* hierarchy though, which isn't so clear with option 2.
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 95117dfce23..a29787cd8d7 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -152,7 +152,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
break;
case TFM_TIME_SCALE:
- {
+ {
/* rescale the distance between the marker and the current frame */
marker->frame = cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f);
changed++;
@@ -251,7 +251,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
min = (float)marker->frame;
if (marker->frame > max)
max = (float)marker->frame;
- }
+ }
}
}
@@ -280,7 +280,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
return;
}
else if (ce->cfra > marker->frame) break;
- }
+ }
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
if (ce) BLI_insertlinkbefore(lb, ce, cen);
@@ -521,7 +521,7 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, wmEvent
else if (op->type->exec)
retval = op->type->exec(C, op);
else
- BKE_report(op->reports, RPT_ERROR, "Programming error: operator doesn't actually have code to do anything!");
+ BKE_report(op->reports, RPT_ERROR, "Programming error: operator does not actually have code to do anything!");
/* return status modifications - for now, make this spacetype dependent as above */
if (sa->spacetype != SPACE_TIME) {
@@ -725,7 +725,7 @@ static int ed_marker_move_cancel(bContext *C, wmOperator *op)
{
RNA_int_set(op->ptr, "frames", 0);
ed_marker_move_apply(op);
- ed_marker_move_exit(C, op);
+ ed_marker_move_exit(C, op);
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
@@ -820,7 +820,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
}
else {
/* we only print the offset */
- if (mm->slink->spacetype == SPACE_TIME) {
+ if (mm->slink->spacetype == SPACE_TIME) {
SpaceTime *stime = (SpaceTime *)mm->slink;
if (stime->flag & TIME_DRAWFRAMES)
BLI_snprintf(str, sizeof(str), "Marker offset %d ", offs);
@@ -1029,7 +1029,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera)
x = evt->x - ar->winrct.xmin;
y = evt->y - ar->winrct.ymin;
- UI_view2d_region_to_view(v2d, x, y, &viewx, NULL);
+ UI_view2d_region_to_view(v2d, x, y, &viewx, NULL);
cfra = ED_markers_find_nearest_marker_time(markers, viewx);
@@ -1376,7 +1376,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
}
if (scene_to == CTX_data_scene(C)) {
- BKE_report(op->reports, RPT_ERROR, "Can't re-link markers into the same scene");
+ BKE_report(op->reports, RPT_ERROR, "Cannot re-link markers into the same scene");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index f2711ec3bb5..ca036a8540e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -172,7 +172,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
ot->poll = change_frame_poll;
/* flags */
- ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO;
+ ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO | OPTYPE_GRAB_POINTER;
/* rna */
RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 672e11ac613..25833c13925 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -91,7 +91,7 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
adt = BKE_animdata_from_id(id);
if ((adt == NULL) && (add))
adt = BKE_id_add_animdata(id);
- if (adt == NULL) {
+ if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
return NULL;
}
@@ -147,7 +147,7 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar
RNA_id_pointer_create(id, &id_ptr);
if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
BKE_reportf(reports, RPT_ERROR,
- "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+ "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
id->name, rna_path);
return 0;
}
@@ -310,7 +310,7 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a
RNA_id_pointer_create(id, &id_ptr);
if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
BKE_reportf(reports, RPT_ERROR,
- "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+ "Could not find driver to copy, as RNA path is invalid for the given ID (ID = %s, path = %s)",
id->name, rna_path);
return 0;
}
@@ -357,14 +357,14 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int
RNA_id_pointer_create(id, &id_ptr);
if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
BKE_reportf(reports, RPT_ERROR,
- "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+ "Could not paste driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
id->name, rna_path);
return 0;
}
/* if the buffer is empty, cannot paste... */
if (channeldriver_copypaste_buf == NULL) {
- BKE_report(reports, RPT_ERROR, "Paste Driver: No Driver to paste");
+ BKE_report(reports, RPT_ERROR, "Paste driver: no driver to paste");
return 0;
}
@@ -478,7 +478,7 @@ static int add_driver_button_exec(bContext *C, wmOperator *op)
char *path = get_driver_path_hack(C, &ptr, prop);
short flags = CREATEDRIVER_WITH_DEFAULT_DVAR;
- if (path) {
+ if (path) {
success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON);
MEM_freeN(path);
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 30e4d8570cb..79a4c9a769d 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -111,6 +111,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
uiBlock *block;
uiBut *but;
PointerRNA ptr;
+ short bwidth = width - 30; /* max button width */
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
@@ -119,10 +120,10 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
/* col = uiLayoutColumn(layout, TRUE); */ /* UNUSED */
block = uiLayoutGetBlock(layout);
uiBlockBeginAlign(block);
- but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL);
+ but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
-
- uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL);
+
+ uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL);
uiBlockEndAlign(block);
/* now add settings for individual modes */
@@ -132,50 +133,62 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s
float *cp = NULL;
char xval[32];
unsigned int i;
+ int maxXWidth;
/* draw polynomial order selector */
row = uiLayoutRow(layout, FALSE);
block = uiLayoutGetBlock(row);
- but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width - 30, 19,
+ but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, bwidth, 20,
&data->poly_order, 1, 100, 0, 0,
TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
+ /* calculate maximum width of label for "x^n" labels */
+ if (data->arraysize > 2) {
+ BLI_snprintf(xval, sizeof(xval), "x^%u", data->arraysize);
+ maxXWidth = UI_GetStringWidth(xval) + 10; /* XXX: UI_GetStringWidth is not accurate */
+ }
+ else {
+ /* basic size (just "x") */
+ maxXWidth = 15;
+ }
+
/* draw controls for each coefficient and a + sign at end of row */
row = uiLayoutRow(layout, TRUE);
block = uiLayoutGetBlock(row);
cp = data->coefficients;
for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
- /* To align with first line */
+ /* To align with first line... */
if (i)
- uiDefBut(block, LABEL, 1, " ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, LABEL, 1, " ", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, "");
else
- uiDefBut(block, LABEL, 1, "y =", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, LABEL, 1, "y =", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, "");
+
/* coefficient */
- uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 150, 20, cp, -UI_FLT_MAX, UI_FLT_MAX,
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, bwidth / 2, 20, cp, -UI_FLT_MAX, UI_FLT_MAX,
10, 3, TIP_("Coefficient for polynomial"));
/* 'x' param (and '+' if necessary) */
if (i == 0)
- strcpy(xval, "");
+ BLI_strncpy(xval, "", sizeof(xval));
else if (i == 1)
- strcpy(xval, "x");
+ BLI_strncpy(xval, "x", sizeof(xval));
else
- sprintf(xval, "x^%u", i);
- uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x"));
+ BLI_snprintf(xval, sizeof(xval), "x^%u", i);
+ uiDefBut(block, LABEL, 1, xval, 0, 0, maxXWidth, 20, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x"));
if ( (i != (data->arraysize - 1)) || ((i == 0) && data->arraysize == 2) ) {
- uiDefBut(block, LABEL, 1, "+", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, LABEL, 1, "+", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, "");
/* next coefficient on a new row */
row = uiLayoutRow(layout, TRUE);
block = uiLayoutGetBlock(row);
}
else {
- /* For alignement in UI! */
- uiDefBut(block, LABEL, 1, " ", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+ /* For alignment in UI! */
+ uiDefBut(block, LABEL, 1, " ", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, "");
}
}
break;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 70d2a8b50d0..c41c71c5fc7 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -322,7 +322,7 @@ static void nupdate_abk_bezt(void *node, void *data)
/* just add the BezTriple to the buffer if there's space, or allocate a new one */
if (abk->numBezts >= MAX_ABK_BUFSIZE) {
// TODO: need to allocate new array to cater...
- //bezts_extra= MEM_callocN(...);
+ //bezts_extra = MEM_callocN(...);
if (G.debug & G_DEBUG)
printf("FIXME: nupdate_abk_bezt() missing case for too many overlapping BezTriples\n");
}
@@ -345,7 +345,7 @@ static BezTriple *abk_get_bezt_with_value(ActBeztColumn *abk, float value)
return NULL;
/* look over each BezTriple in this container */
- for (i = 0; i < abk->numBezts; i++) {
+ for (i = 0; i < abk->numBezts; i++) {
/* only do exact match for now... */
if (/*i >= MAX_ABK_BUFSIZE*/ 0) {
// TODO: this case needs special handling
@@ -551,7 +551,7 @@ static const float _unit_diamond_shape[4][2] = {
void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha)
{
/* tweak size of keyframe shape according to type of keyframe
- * - 'proper' keyframes have key_type=0, so get drawn at full size
+ * - 'proper' keyframes have key_type = 0, so get drawn at full size
*/
hsize -= 0.5f * key_type;
@@ -939,7 +939,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree
if (fcu && fcu->totvert && fcu->bezt) {
/* apply NLA-mapping (if applicable) */
- if (adt)
+ if (adt)
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
/* if getting long keyframes too, grab the BezTriples in a BST for
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index b277d0eccb5..015c2667a93 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -154,7 +154,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi
if (fcu_cb)
fcu_cb(fcu);
- /* done */
+ /* done */
return 0;
}
@@ -639,7 +639,7 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1 = HD_ALIGN;
if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2 = HD_ALIGN;
}
- return 0;
+ return 0;
}
/* value to snap to is stored in the custom data -> first float value slot */
@@ -880,7 +880,7 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
switch (code) {
case BEZT_IPO_CONST: /* constant */
return set_bezt_constant;
- case BEZT_IPO_LIN: /* linear */
+ case BEZT_IPO_LIN: /* linear */
return set_bezt_linear;
default: /* bezier */
return set_bezt_bezier;
@@ -930,7 +930,7 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code)
case BEZT_KEYTYPE_JITTER: /* jitter keyframe */
return set_keytype_jitter;
- case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */
+ case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */
default:
return set_keytype_keyframe;
}
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index b5c0555bf63..9249b912da6 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -188,7 +188,7 @@ void clean_fcurve(FCurve *fcu, float thresh)
/* make a copy of the old BezTriples, and clear F-Curve */
old_bezts = fcu->bezt;
- totCount = fcu->totvert;
+ totCount = fcu->totvert;
fcu->bezt = NULL;
fcu->totvert = 0;
@@ -256,7 +256,7 @@ void clean_fcurve(FCurve *fcu, float thresh)
insert_vert_fcurve(fcu, cur[0], cur[1], 0);
}
}
- else {
+ else {
/* add if value doesn't equal that of previous */
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
/* add new keyframe */
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 0454e88e320..8ba330e7c3c 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -43,6 +43,8 @@
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
@@ -106,7 +108,7 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode)
}
/* only if including settings from the autokeying mode... */
- if (incl_mode) {
+ if (incl_mode) {
/* keyframing mode - only replace existing keyframes */
if (IS_AUTOKEY_MODE(scene, EDITKEYS))
flag |= INSERTKEY_REPLACE;
@@ -129,7 +131,7 @@ bAction *verify_adt_action(ID *id, short add)
adt = BKE_animdata_from_id(id);
if ((adt == NULL) && (add))
adt = BKE_id_add_animdata(id);
- if (adt == NULL) {
+ if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>");
return NULL;
@@ -238,7 +240,7 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag)
i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace);
/* replace an existing keyframe? */
- if (replace) {
+ if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
if ((i >= 0) && (i < fcu->totvert)) {
/* just change the values when replacing, so as to not overwrite handles */
@@ -410,12 +412,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
float prevPosi = 0.0f, prevVal = 0.0f;
float beztPosi = 0.0f, beztVal = 0.0f;
- /* get current time+value */
+ /* get current time+value */
beztPosi = bezt->vec[1][0];
beztVal = bezt->vec[1][1];
if (prev) {
- /* there is a keyframe before the one currently being examined */
+ /* there is a keyframe before the one currently being examined */
/* get previous time+value */
prevPosi = prev->vec[1][0];
@@ -477,10 +479,10 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
/* Frame in which to add a new-keyframe occurs after all other keys
* -> If there are at least two existing keyframes, then if the values of the
- * last two keyframes and the new-keyframe match, the last existing keyframe
- * gets deleted as it is no longer required.
+ * last two keyframes and the new-keyframe match, the last existing keyframe
+ * gets deleted as it is no longer required.
* -> Otherwise, a keyframe is just added. 1.0 is added so that fake-2nd-to-last
- * keyframe is not equal to last keyframe.
+ * keyframe is not equal to last keyframe.
*/
bezt = (fcu->bezt + (fcu->totvert - 1));
valA = bezt->vec[1][1];
@@ -787,14 +789,15 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p
/* F-Curve not editable? */
if (fcurve_is_keyframable(fcu) == 0) {
BKE_reportf(reports, RPT_ERROR,
- "F-Curve with path = '%s' [%d] cannot be keyframed. Ensure that it is not locked or sampled. Also, try removing F-Modifiers",
+ "F-Curve with path '%s[%d]' cannot be keyframed, ensure that it is not locked or sampled, "
+ "and try removing F-Modifiers",
fcu->rna_path, fcu->array_index);
return 0;
}
/* if no property given yet, try to validate from F-Curve info */
if ((ptr.id.data == NULL) && (ptr.data == NULL)) {
- BKE_report(reports, RPT_ERROR, "No RNA-pointer available to retrieve values for keyframing from");
+ BKE_report(reports, RPT_ERROR, "No RNA pointer available to retrieve values for keyframing from");
return 0;
}
if (prop == NULL) {
@@ -803,10 +806,10 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p
/* try to get property we should be affecting */
if ((RNA_path_resolve(&ptr, fcu->rna_path, &tmp_ptr, &prop) == 0) || (prop == NULL)) {
/* property not found... */
- const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : "<No ID-Pointer>";
+ const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : TIP_("<No ID pointer>");
BKE_reportf(reports, RPT_ERROR,
- "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+ "Could not insert keyframe, as RNA path is invalid for the given ID (ID = %s, path = %s)",
idname, fcu->rna_path);
return 0;
}
@@ -906,15 +909,15 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
/* validate pointer first - exit if failure */
if (id == NULL) {
- BKE_reportf(reports, RPT_ERROR, "No ID-block to insert keyframe in (Path = %s)", rna_path);
+ BKE_reportf(reports, RPT_ERROR, "No ID block to insert keyframe in (path = %s)", rna_path);
return 0;
}
RNA_id_pointer_create(id, &id_ptr);
if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
BKE_reportf(reports, RPT_ERROR,
- "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
- (id) ? id->name : "<Missing ID-Block>", rna_path);
+ "Could not insert keyframe, as RNA path is invalid for the given ID (ID = %s, path = %s)",
+ (id) ? id->name : TIP_("<Missing ID block>"), rna_path);
return 0;
}
@@ -927,7 +930,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
if (act == NULL) {
BKE_reportf(reports, RPT_ERROR,
- "Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)",
+ "Could not insert keyframe, as this type does not support animation data (ID = %s, path = %s)",
id->name, rna_path);
return 0;
}
@@ -937,7 +940,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
}
/* key entire array convenience method */
- if (array_index == -1) {
+ if (array_index == -1) {
array_index = 0;
array_index_max = RNA_property_array_length(&ptr, prop);
@@ -997,14 +1000,16 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
/* sanity checks */
if (ELEM(NULL, id, adt)) {
- BKE_report(reports, RPT_ERROR, "No ID-Block and/Or AnimData to delete keyframe from");
+ BKE_report(reports, RPT_ERROR, "No ID block and/or AnimData to delete keyframe from");
return 0;
}
/* validate pointer first - exit if failure */
RNA_id_pointer_create(id, &id_ptr);
if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
- BKE_reportf(reports, RPT_ERROR, "Could not delete keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", id->name, rna_path);
+ BKE_reportf(reports, RPT_ERROR,
+ "Could not delete keyframe, as RNA path is invalid for the given ID (ID = %s, path = %s)",
+ id->name, rna_path);
return 0;
}
@@ -1023,13 +1028,13 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
}
else {
- BKE_reportf(reports, RPT_ERROR, "No Action to delete keyframes from for ID = %s\n", id->name);
+ BKE_reportf(reports, RPT_ERROR, "No action to delete keyframes from for ID = %s", id->name);
return 0;
}
}
/* key entire array convenience method */
- if (array_index == -1) {
+ if (array_index == -1) {
array_index = 0;
array_index_max = RNA_property_array_length(&ptr, prop);
@@ -1059,7 +1064,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
/* try to find index of beztriple to get rid of */
i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
- if (found) {
+ if (found) {
/* delete the key at the index (will sanity check + do recalc afterwards) */
delete_fcurve_key(fcu, i, 1);
@@ -1096,14 +1101,16 @@ static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const cha
/* sanity checks */
if (ELEM(NULL, id, adt)) {
- BKE_report(reports, RPT_ERROR, "No ID-Block and/Or AnimData to delete keyframe from");
+ BKE_report(reports, RPT_ERROR, "No ID block and/or AnimData to delete keyframe from");
return 0;
}
/* validate pointer first - exit if failure */
RNA_id_pointer_create(id, &id_ptr);
if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
- BKE_reportf(reports, RPT_ERROR, "Could not clear keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", id->name, rna_path);
+ BKE_reportf(reports, RPT_ERROR,
+ "Could not clear keyframe, as RNA path is invalid for the given ID (ID = %s, path = %s)",
+ id->name, rna_path);
return 0;
}
@@ -1119,7 +1126,7 @@ static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const cha
act = adt->action;
}
else {
- BKE_reportf(reports, RPT_ERROR, "No Action to delete keyframes from for ID = %s\n", id->name);
+ BKE_reportf(reports, RPT_ERROR, "No action to delete keyframes from for ID = %s", id->name);
return 0;
}
}
@@ -1222,30 +1229,30 @@ static int insert_key_exec(bContext *C, wmOperator *op)
/* report failures */
if (ks == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "No active keying set");
return OPERATOR_CANCELLED;
}
/* try to insert keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
if (G.debug & G_DEBUG)
- BKE_reportf(op->reports, RPT_INFO, "KeyingSet '%s' - Successfully added %d Keyframes\n", ks->name, success);
+ BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes", ks->name, success);
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
- BKE_report(op->reports, RPT_ERROR, "No suitable context info for active Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set");
return OPERATOR_CANCELLED;
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
if (RNA_boolean_get(op->ptr, "confirm_success"))
- BKE_reportf(op->reports, RPT_INFO, "Successfully added %d Keyframes for KeyingSet '%s'", success, ks->name);
+ BKE_reportf(op->reports, RPT_INFO, "Successfully added %d keyframes for keying set '%s'", success, ks->name);
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else
- BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
+ BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes");
/* send updates */
DAG_ids_flush_update(bmain, 0);
@@ -1389,19 +1396,19 @@ static int delete_key_exec(bContext *C, wmOperator *op)
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
- BKE_report(op->reports, RPT_ERROR, "No suitable context info for active Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set");
return OPERATOR_CANCELLED;
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
if (RNA_boolean_get(op->ptr, "confirm_success"))
- BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d Keyframes for KeyingSet '%s'", success, ks->name);
+ BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d keyframes for keying set '%s'", success, ks->name);
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else
- BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes");
+ BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes");
/* send updates */
DAG_ids_flush_update(bmain, 0);
@@ -1626,7 +1633,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
else {
if (G.debug & G_DEBUG)
printf("Button Insert-Key: no path to property\n");
- BKE_report(op->reports, RPT_WARNING, "Failed to resolve path to property. Try using a Keying Set instead");
+ BKE_report(op->reports, RPT_WARNING, "Failed to resolve path to property, try using a keying set instead");
}
}
else if (G.debug & G_DEBUG) {
@@ -1856,7 +1863,7 @@ short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
/* binarysearch_bezt_index will set replace to be 0 or 1
* - obviously, 1 represents a match
*/
- if (replace) {
+ if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
if ((i >= 0) && (i < fcu->totvert))
return 1;
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 04fd7f677b0..28db7bf572d 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -161,11 +161,11 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op)
* - return error if it doesn't exist
*/
if (scene->active_keyingset == 0) {
- BKE_report(op->reports, RPT_ERROR, "No active Keying Set to remove");
+ BKE_report(op->reports, RPT_ERROR, "No active keying set to remove");
return OPERATOR_CANCELLED;
}
else if (scene->active_keyingset < 0) {
- BKE_report(op->reports, RPT_ERROR, "Cannot remove built in Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "Cannot remove built in keying set");
return OPERATOR_CANCELLED;
}
else
@@ -209,7 +209,7 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
* - return error if it doesn't exist
*/
if (scene->active_keyingset == 0) {
- BKE_report(op->reports, RPT_ERROR, "No active Keying Set to add empty path to");
+ BKE_report(op->reports, RPT_ERROR, "No active keying set to add empty path to");
return OPERATOR_CANCELLED;
}
else
@@ -258,12 +258,12 @@ static int remove_active_ks_path_exec(bContext *C, wmOperator *op)
ks->active_path--;
}
else {
- BKE_report(op->reports, RPT_ERROR, "No active Keying Set Path to remove");
+ BKE_report(op->reports, RPT_ERROR, "No active keying set path to remove");
return OPERATOR_CANCELLED;
}
}
else {
- BKE_report(op->reports, RPT_ERROR, "No active Keying Set to remove a path from");
+ BKE_report(op->reports, RPT_ERROR, "No active keying set to remove a path from");
return OPERATOR_CANCELLED;
}
@@ -322,11 +322,12 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
scene->active_keyingset = BLI_countlist(&scene->keyingsets);
}
else if (scene->active_keyingset < 0) {
- BKE_report(op->reports, RPT_ERROR, "Cannot add property to built in Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "Cannot add property to built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* try to add to keyingset using property retrieved from UI */
uiContextActiveProperty(C, &ptr, &prop, &index);
@@ -360,9 +361,10 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
DAG_ids_flush_update(bmain, 0);
-
- /* for now, only send ND_KEYS for KeyingSets */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
+
+ /* show notification/report header, so that users notice that something changed */
+ BKE_reportf(op->reports, RPT_INFO, "Property added to Keying Set: '%s'", ks->name);
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -377,7 +379,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot)
/* callbacks */
ot->exec = add_keyingset_button_exec;
- //op->poll= ???
+ //op->poll = ???
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -404,15 +406,16 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
* - return error if it doesn't exist
*/
if (scene->active_keyingset == 0) {
- BKE_report(op->reports, RPT_ERROR, "No active Keying Set to remove property from");
+ BKE_report(op->reports, RPT_ERROR, "No active keying set to remove property from");
return OPERATOR_CANCELLED;
}
else if (scene->active_keyingset < 0) {
- BKE_report(op->reports, RPT_ERROR, "Cannot remove property from built in Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "Cannot remove property from built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* try to add to keyingset using property retrieved from UI */
uiContextActiveProperty(C, &ptr, &prop, &index);
@@ -425,7 +428,7 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
/* try to find a path matching this description */
ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME);
-
+
if (ksp) {
BKE_keyingset_free_path(ks, ksp);
success = 1;
@@ -440,9 +443,10 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
DAG_ids_flush_update(bmain, 0);
-
- /* for now, only send ND_KEYS for KeyingSets */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
+
+ /* show warning */
+ BKE_report(op->reports, RPT_INFO, "Property removed from Keying Set");
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -457,7 +461,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot)
/* callbacks */
ot->exec = remove_keyingset_button_exec;
- //op->poll= ???
+ //op->poll = ???
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -891,11 +895,13 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
ksi->iter(ksi, C, ks);
/* if we don't have any paths now, then this still qualifies as invalid context */
+ // FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
if (ks->paths.first == NULL)
return MODIFYKEY_INVALID_CONTEXT;
}
else {
/* poll callback tells us that KeyingSet is useless in current context */
+ // FIXME: the poll callback needs to give us more info why
return MODIFYKEY_INVALID_CONTEXT;
}
}
@@ -947,7 +953,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
/* skip path if no ID pointer is specified */
if (ksp->id == NULL) {
BKE_reportf(reports, RPT_WARNING,
- "Skipping path in Keying Set, as it has no ID (KS = '%s', Path = '%s'[%d])",
+ "Skipping path in keying set, as it has no ID (KS = '%s', path = '%s[%d]')",
ks->name, ksp->rna_path, ksp->array_index);
continue;
}
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index c19904d39ac..7c5b75e56ae 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -88,7 +88,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_armature_layers);
WM_operatortype_append(ARMATURE_OT_bone_layers);
- /* SKETCH */
+ /* SKETCH */
WM_operatortype_append(SKETCH_OT_gesture);
WM_operatortype_append(SKETCH_OT_delete);
WM_operatortype_append(SKETCH_OT_draw_stroke);
@@ -221,7 +221,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* Already part of view3d select */
//WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
- /* sketch poll checks mode */
+ /* sketch poll checks mode */
WM_keymap_add_item(keymap, "SKETCH_OT_gesture", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 529d489c37e..8124dd268be 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -117,14 +117,14 @@ void ED_armature_sync_selection(ListBase *edbo)
else
ebo->flag &= ~BONE_SELECTED;
}
- }
+ }
}
void ED_armature_validate_active(struct bArmature *arm)
{
EditBone *ebone = arm->act_edbone;
- if (ebone) {
+ if (ebone) {
if (ebone->flag & BONE_HIDDEN_A)
arm->act_edbone = NULL;
}
@@ -304,7 +304,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->ease2 = curBone->ease2;
eBone->rad_head = curBone->rad_head;
eBone->rad_tail = curBone->rad_tail;
- eBone->segments = curBone->segments;
+ eBone->segments = curBone->segments;
eBone->layer = curBone->layer;
if (curBone->prop)
@@ -654,17 +654,19 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
if (ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
if (BKE_object_obdata_is_libdata(ob)) {
- BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata();
+ BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); /* error_libdata(); */
return OPERATOR_CANCELLED;
}
/* helpful warnings... */
/* TODO: add warnings to be careful about actions, applying deforms first, etc. */
if (ob->adt && ob->adt->action)
- BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose");
+ BKE_report(op->reports, RPT_WARNING,
+ "Actions on this armature will be destroyed by this new rest pose as the "
+ "transforms stored are relative to the old rest pose");
/* Get editbones of active armature to alter */
- ED_armature_to_edit(ob);
+ ED_armature_to_edit(ob);
/* get pose of active object and move it out of posemode */
pose = ob->pose;
@@ -895,7 +897,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* make tar armature be new parent */
ob->parent = tarArm;
}
- }
+ }
}
/* join armature exec is exported for use in object->join objects operator... */
@@ -1111,7 +1113,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
}
- }
+ }
}
/* Helper function for armature separating - remove certain bones from the given armature
@@ -1438,7 +1440,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
/* ignore bone if cannot be selected */
- if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
+ if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
// XXX old cruft! use notifiers instead
//select_actionchannel_by_name (ob->action, curBone->name, !(shift));
@@ -1491,7 +1493,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* props */
+ /* props */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -1548,7 +1550,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e
bone = curBone;
break;
}
- else {
+ else {
bone = NULL;
break;
}
@@ -1591,7 +1593,8 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
/* does bones and points */
/* note that BONE ROOT only gets drawn for root bones (or without IK) */
-static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask)
+static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2],
+ ListBase *edbo, int findunsel, int *selmask)
{
EditBone *ebone;
rcti rect;
@@ -2096,7 +2099,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
sub_v3_v3v3(nor, ebone->tail, ebone->head);
- vec_roll_to_mat3(nor, ebone->roll, mat);
+ vec_roll_to_mat3(nor, ebone->roll, mat);
copy_v3_v3(vec, mat[2]);
}
else { /* Axis */
@@ -2556,7 +2559,8 @@ void updateDuplicateSubtarget(EditBone *dupBone, ListBase *editbones, Object *ob
}
-EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones, Object *src_ob, Object *dst_ob)
+EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones,
+ Object *src_ob, Object *dst_ob)
{
EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone");
@@ -2683,7 +2687,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
updateDuplicateSubtarget(eBone, arm->edbo, obedit);
}
}
- }
+ }
/* correct the active bone */
if (arm->act_edbone) {
@@ -2798,7 +2802,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
}
for (ebp = points->first; ebp; ebp = ebp->next) {
- if (equals_v3v3(ebp->vec, vec)) {
+ if (equals_v3v3(ebp->vec, vec)) {
if (eb_tail) {
if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) {
/* so this bone's tail owner is this bone */
@@ -2882,7 +2886,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
/* Create a bone */
- /* newbone= */ add_points_bone(obedit, ebp->vec, curs);
+ /* newbone = */ add_points_bone(obedit, ebp->vec, curs);
}
else if (count == 2) {
EditBonePoint *ebp, *ebp2;
@@ -2965,8 +2969,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
}
}
else {
- // FIXME.. figure out a method for multiple bones
- BKE_reportf(op->reports, RPT_ERROR, "Too many points selected: %d\n", count);
+ /* FIXME.. figure out a method for multiple bones */
+ BKE_reportf(op->reports, RPT_ERROR, "Too many points selected: %d", count);
BLI_freelistN(&points);
return OPERATOR_CANCELLED;
}
@@ -3036,7 +3040,8 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
newbone->parent = start->parent;
/* TODO, copy more things to the new bone */
- newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
+ newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE |
+ BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
/* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
* - potentially several tips for side chains leading to some tree exist...
@@ -3145,7 +3150,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
/* put back link */
BLI_insertlinkbefore(&chains, nchain, chain);
- }
+ }
armature_tag_unselect(arm);
@@ -3296,7 +3301,9 @@ static void hide_unselected_armature_bones(Scene *scene)
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
bArmature *arm = obedit->data;
if (EBONE_VISIBLE(arm, ebone)) {
- if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) ;
+ if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) {
+ /* pass */
+ }
else {
ebone->flag |= BONE_HIDDEN_A;
}
@@ -3357,12 +3364,17 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (EBONE_VISIBLE(arm, ebone)) {
/* we extrude per definition the tip */
do_extrude = FALSE;
- if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED))
+ if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
do_extrude = TRUE;
+ }
else if (ebone->flag & BONE_ROOTSEL) {
/* but, a bone with parent deselected we do the root... */
- if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) ;
- else do_extrude = 2;
+ if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) {
+ /* pass */
+ }
+ else {
+ do_extrude = 2;
+ }
}
if (do_extrude) {
@@ -3447,7 +3459,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
/* Deselect the old bone */
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
- }
+ }
}
/* if only one bone, make this one active */
if (totbone == 1 && first) arm->act_edbone = first;
@@ -3671,7 +3683,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
parent = ebo->parent;
/* only if selected and editable */
- if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
+ if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
/* swap head and tail coordinates */
SWAP(float, ebo->head[0], ebo->tail[0]);
SWAP(float, ebo->head[1], ebo->tail[1]);
@@ -3711,7 +3723,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
}
/* free chains */
- BLI_freelistN(&chains);
+ BLI_freelistN(&chains);
armature_tag_unselect(arm);
@@ -3768,7 +3780,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
}
}
- if (mode == ARM_PAR_CONNECT) {
+ if (mode == ARM_PAR_CONNECT) {
/* Connected: Child bones will be moved to the parent tip */
selbone->flag |= BONE_CONNECTED;
sub_v3_v3v3(offset, actbone->tail, selbone->head);
@@ -3813,7 +3825,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
/* there must be an active bone */
if (actbone == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Bone");
+ BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
return OPERATOR_CANCELLED;
}
else if (arm->flag & ARM_MIRROR_EDIT) {
@@ -3883,7 +3895,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve
{
if (ebone != actbone) {
if (ebone->parent != actbone) allchildbones = 1;
- }
+ }
}
CTX_DATA_END;
@@ -3891,7 +3903,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve
/* ob becomes parent, make the associated menus */
if (allchildbones)
- uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
+ uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
uiPupMenuEnd(C, pup);
@@ -3984,7 +3996,7 @@ static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
ebone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
- CTX_DATA_END;
+ CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
@@ -4045,7 +4057,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
}
}
}
- CTX_DATA_END;
+ CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
@@ -4207,7 +4219,7 @@ static int armature_select_similar_exec(bContext *C, wmOperator *op)
/* Check for active bone */
if (ebone_act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Bone");
+ BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
return OPERATOR_CANCELLED;
}
@@ -4285,7 +4297,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
break;
}
- }
+ }
else { // BONE_SELECT_CHILD
chbone = editbone_get_child(arm, curbone, 1);
if (chbone == NULL) continue;
@@ -4399,7 +4411,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* there must be an active bone */
if (actbone == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Bone");
+ BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
return OPERATOR_CANCELLED;
}
else if (arm->flag & ARM_MIRROR_EDIT) {
@@ -4476,7 +4488,8 @@ void ARMATURE_OT_align(wmOperatorType *ot)
/* ***************** Pose tools ********************* */
-// XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer
+/* XXX bone_looper is only to be used when we want to access settings
+ * (i.e. editability/visibility/selected) that context doesn't offer */
static int bone_looper(Object *ob, Bone *bone, void *data,
int (*bone_func)(Object *, Bone *, void *))
{
@@ -4506,7 +4519,8 @@ static int bone_looper(Object *ob, Bone *bone, void *data,
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
-int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend, short deselect, short toggle)
+int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits,
+ short extend, short deselect, short toggle)
{
Object *ob = base->object;
Bone *nearBone;
@@ -4554,7 +4568,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_bone = nearBone;
}
- }
+ }
}
if (ob_act) {
@@ -4752,7 +4766,9 @@ static void add_vgroups__mapFunc(void *userData, int index, const float co[3],
copy_v3_v3(verts[index], co);
}
-static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, float scale)
+static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist,
+ bDeformGroup **dgrouplist, bDeformGroup **dgroupflip,
+ float (*root)[3], float (*tip)[3], int *selected, float scale)
{
/* Create vertex group weights from envelopes */
@@ -5104,7 +5120,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
}
}
} /* Duplicated in source/blender/editors/object/object_transform.c */
- else {
+ else {
if (pchan->rotmode == ROT_MODE_QUAT) {
unit_qt(pchan->quat);
}
@@ -5138,7 +5154,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* sanity checks */
if (ELEM(NULL, clear_func, default_ksName)) {
- BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform func or Keying Set Name");
+ BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name");
return OPERATOR_CANCELLED;
}
@@ -5530,7 +5546,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(curcon, &targets, 0);
- }
+ }
}
}
@@ -5617,7 +5633,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
- if (modifiers_usesArmature(ob, arm)) {
+ if (modifiers_usesArmature(ob, arm)) {
bDeformGroup *dg = defgroup_find_name(ob, oldname);
if (dg) {
BLI_strncpy(dg->name, newname, MAXBONENAME);
@@ -5945,7 +5961,7 @@ float arcLengthRatio(ReebArc *arc)
embedLength = arcLength;
}
- return embedLength / arcLength;
+ return embedLength / arcLength;
}
EditBone *test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
@@ -6046,7 +6062,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
arc->flag = 1; /* mark arc direction */
}
- /* Loop over subdivision methods */
+ /* Loop over subdivision methods */
for (i = 0; lastBone == NULL && i < SKGEN_SUB_TOTAL; i++) {
switch (scene->toolsettings->skgen_subdivisions[i]) {
case SKGEN_SUB_LENGTH:
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c
index 23dd3b15476..d9c7e78c01e 100644
--- a/source/blender/editors/armature/editarmature_generate.c
+++ b/source/blender/editors/armature/editarmature_generate.c
@@ -55,7 +55,7 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma
if (no != NULL && !is_zero_v3(no)) {
float normal[3];
- copy_v3_v3(normal, no);
+ copy_v3_v3(normal, no);
mul_m3_v3(tmat, normal);
bone->roll = ED_rollBoneToVector(bone, normal, FALSE);
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index fad06f0d020..68cfc7fb8c0 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -191,7 +191,7 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4]
if (previous->bone) {
sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head);
- }
+ }
else if (previous->prev->bone) {
sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail);
}
@@ -653,7 +653,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
sub_v3_v3v3(offset, ctrl->bone->head, link->head);
- /* if root matches, check for direction too */
+ /* if root matches, check for direction too */
if (dot_v3v3(offset, offset) < 0.0001f) {
float vbone[3], vparent[3];
@@ -802,7 +802,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
- /* if not found yet, check child */
+ /* if not found yet, check child */
if (found == 0) {
RigArc *arc;
RigArc *best_arc = NULL;
@@ -863,7 +863,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
/* SET bone link to ctrl corresponding to pchan */
RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name);
- /* if owner is a control bone, link with it */
+ /* if owner is a control bone, link with it */
if (link && link->link) {
RIG_parentControl(ctrl, link->bone);
found = 1;
@@ -876,7 +876,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
cti->flush_constraint_targets(con, &targets, 0);
}
}
- }
+ }
if (found == 0) {
/* check if parent is already linked */
@@ -1319,12 +1319,12 @@ void RIG_printArc(RigGraph *rg, RigArc *arc)
for (edge = arc->edges.first; edge; edge = edge->next) {
printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]);
printf("\t\tlength %f\n", edge->length);
- printf("\t\tangle %f\n", edge->angle * 180 / M_PI);
+ printf("\t\tangle %f\n", edge->angle * (float)(180 / M_PI));
if (edge->bone) {
printf("\t\t%s\n", edge->bone->name);
RIG_printLinkedCtrl(rg, edge->bone, 3);
}
- }
+ }
printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group);
RIG_printNode((RigNode *)arc->tail, "tail");
@@ -1336,7 +1336,7 @@ void RIG_printGraph(RigGraph *rg)
printf("---- ARCS ----\n");
for (arc = rg->arcs.first; arc; arc = arc->next) {
- RIG_printArc(rg, arc);
+ RIG_printArc(rg, arc);
printf("\n");
}
@@ -1345,7 +1345,7 @@ void RIG_printGraph(RigGraph *rg)
}
else {
printf("HEAD NODE: NONE\n");
- }
+ }
}
/*******************************************************************************************************/
@@ -1584,7 +1584,7 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
repositionTailControl(rigg, ctrl_child);
}
}
- }
+ }
}
static void repositionTailControl(RigGraph *rigg, RigControl *ctrl)
@@ -1840,7 +1840,7 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_
length2 = normalize_v3(vec_second);
- /* Angle cost */
+ /* Angle cost */
if (edge->prev) {
sub_v3_v3v3(vec_first, vec1, vec0);
normalize_v3(vec_first);
@@ -1962,7 +1962,6 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
ReebArcIterator arc_iter;
BArcIterator *iter = (BArcIterator *)&arc_iter;
RigEdge *edge;
- EmbedBucket *bucket = NULL;
ReebNode *node_start, *node_end;
ReebArc *earc = iarc->link_mesh;
float angle_weight = 1.0; // GET FROM CONTEXT
@@ -1996,8 +1995,6 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
/* equal number of joints and potential position, just fill them in */
if (nb_joints == earc->bcount) {
- int i;
-
/* init with first values */
for (i = 0; i < nb_joints; i++) {
best_positions[i] = i + 1;
@@ -2011,7 +2008,6 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
MemoNode *result;
#endif
float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache");
- int i;
positions_cache[0] = node_start->p;
positions_cache[nb_positions + 1] = node_end->p;
@@ -2053,7 +2049,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
{
float *no = NULL;
if (i < nb_joints) {
- bucket = IT_peek(iter, best_positions[i]);
+ EmbedBucket *bucket = IT_peek(iter, best_positions[i]);
vec1 = bucket->p;
no = bucket->no;
}
@@ -2139,7 +2135,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
no = node_end->no;
}
- /* no need to move virtual edges (space between unconnected bones) */
+ /* no need to move virtual edges (space between unconnected bones) */
if (edge->bone) {
repositionBone(C, rigg, edge, vec0, vec1, no);
}
@@ -2177,7 +2173,7 @@ void *exec_retargetArctoArc(void *param)
RetargetParam *p = (RetargetParam *)param;
RigGraph *rigg = p->rigg;
RigArc *iarc = p->iarc;
- bContext *C = p->context;
+ bContext *C = p->context;
RigNode *inode_start = p->inode_start;
ReebArc *earc = iarc->link_mesh;
@@ -2226,7 +2222,7 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t
enode = enode->link_down;
reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
- }
+ }
}
static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
@@ -2277,7 +2273,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc
reebg = reebg->link_up;
enode = next_earc->head;
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
- }
+ }
next_earc->flag = ARC_USED;
next_iarc->link_mesh = next_earc;
@@ -2307,7 +2303,7 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R
enode = reebg->nodes.first;
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
- }
+ }
inode->link_mesh = enode;
}
@@ -2604,7 +2600,7 @@ void BIF_retargetArmature(bContext *C)
ED_undo_push(C, "Retarget Skeleton");
- // XXX
+ // XXX
// allqueue(REDRAWVIEW3D, 0);
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 68295154f40..27b62114bd6 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -442,7 +442,7 @@ static void sk_cancelStroke(SK_Sketch *sketch)
static float sk_clampPointSize(SK_Point *pt, float size)
{
- return MAX2(size * pt->size, size / 2);
+ return max_ff(size * pt->size, size / 2);
}
static void sk_drawPoint(struct GPUprim3 *prim, SK_Point *pt, float size)
@@ -647,7 +647,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
short pval[2];
int pdist;
- if (ED_view3d_project_short_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_short_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -683,7 +683,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
{
copy_v3_v3(vec, bone->head);
mul_m4_v3(ob->obmat, vec);
- if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -700,7 +700,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
copy_v3_v3(vec, bone->tail);
mul_m4_v3(ob->obmat, vec);
- if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -940,7 +940,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
initgrabz(ar->regiondata, fp[0], fp[1], fp[2]);
/* method taken from editview.c - mouse_cursor() */
- if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
VECSUB2D(mval_f, cval, dd->mval);
ED_view3d_win_to_delta(ar, mval_f, dvec);
sub_v3_v3v3(vec, fp, dvec);
@@ -1794,8 +1794,8 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc
short start_val[2], end_val[2];
short dist;
- if ((ED_view3d_project_short_global(ar, gest->stk->points[0].p, start_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
- (ED_view3d_project_short_global(ar, sk_lastStrokePoint(gest->stk)->p, end_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ if ((ED_view3d_project_short_global(ar, gest->stk->points[0].p, start_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_short_global(ar, sk_lastStrokePoint(gest->stk)->p, end_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
{
dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1]));
@@ -2103,15 +2103,15 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
static GPUimmediate *dl = NULL;
float colors[8][3] = {
- {1, 0, 0},
- {0, 1, 0},
- {0, 0, 1},
- {1, 1, 0},
- {1, 0, 1},
- {0, 1, 1},
- {1, 1, 1},
- {0, 0, 0}
- };
+ {1, 0, 0},
+ {0, 1, 0},
+ {0, 0, 1},
+ {1, 1, 0},
+ {1, 0, 1},
+ {0, 1, 1},
+ {1, 1, 1},
+ {0, 0, 0}
+ };
DepthPeel *p;
struct GPUprim3 prim = GPU_PRIM_LORES_SOLID;
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 522622ec5c4..9152ea8e198 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -53,7 +53,6 @@
#include "BKE_modifier.h"
#include "BKE_mesh.h"
-
#ifdef RIGID_DEFORM
#include "BLI_polardecomp.h"
#endif
@@ -563,7 +562,7 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
/* compute H entry */
if (numclosest > 0) {
- mindist = maxf(mindist, 1e-4f);
+ mindist = max_ff(mindist, 1e-4f);
h = numclosest * C_WEIGHT / (mindist * mindist);
}
else
@@ -794,7 +793,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
}
}
else if (*err_str == NULL) {
- *err_str = "Bone Heat Weighting: failed to find solution for one or more bones";
+ *err_str = N_("Bone Heat Weighting: failed to find solution for one or more bones");
break;
}
@@ -1195,7 +1194,7 @@ static int meshdeform_tri_intersect(const float orig[3], const float end[3], con
}
static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
- {
+{
void **data = userdata;
MeshDeformBind *mdb = data[1];
MFace *mface = data[0], *mf;
@@ -1210,7 +1209,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
if (mf->v4)
copy_v3_v3(face[3], mdb->cagecos[mf->v4]);
- add_v3_v3v3(end, isec->start, isec->vec);
+ add_v3_v3v3(end, isec->start, isec->vec);
if (!meshdeform_tri_intersect(ray->origin, end, face[0], face[1], face[2], co, uvw))
if (!mf->v4 || !meshdeform_tri_intersect(ray->origin, end, face[0], face[2], face[3], co, uvw))
@@ -1221,13 +1220,13 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
else
normal_quad_v3(no, face[0], face[1], face[2], face[3]);
- dist = len_v3v3(ray->origin, co)/len_v3(isec->vec);
+ dist = len_v3v3(ray->origin, co) / len_v3(isec->vec);
if (dist < hit->dist) {
hit->index = index;
hit->dist = dist;
copy_v3_v3(hit->co, co);
- isec->isect = dot_v3v3(no, ray->direction) <= 0.0;
+ isec->isect = (dot_v3v3(no, ray->direction) <= 0.0f);
isec->labda = dist;
isec->face = mf;
}
@@ -1254,8 +1253,10 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float
hit.index = -1;
hit.dist = FLT_MAX;
- if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, isect_mdef.vec, 0.0, &hit, harmonic_ray_callback, data) != -1) {
- len= isect_mdef.labda;
+ if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, isect_mdef.vec,
+ 0.0, &hit, harmonic_ray_callback, data) != -1)
+ {
+ len = isect_mdef.labda;
isect_mdef.face = mface = mface1 + hit.index;
/* create MDefBoundIsect */
@@ -1720,7 +1721,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
}
}
else {
- modifier_setError(&mmd->modifier, "%s", TIP_("Failed to find bind solution (increase precision?)."));
+ modifier_setError(&mmd->modifier, "Failed to find bind solution (increase precision?)");
error("Mesh Deform: failed to find bind solution.");
break;
}
diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c
index cdcb3ab4683..3fd65de6c04 100644
--- a/source/blender/editors/armature/poseSlide.c
+++ b/source/blender/editors/armature/poseSlide.c
@@ -105,7 +105,7 @@ typedef struct tPoseSlideOp {
int nextFrame; /* frame after current frame (blend-to) */
int mode; /* sliding mode (ePoseSlide_Modes) */
- int flag; // unused for now, but can later get used for storing runtime settings....
+ int flag; /* unused for now, but can later get used for storing runtime settings.... */
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
} tPoseSlideOp;
@@ -486,7 +486,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_vec3(pso, pfl, pchan->eul, "rotation_euler");
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- // TODO: need to figure out how to do this!
+ /* TODO: need to figure out how to do this! */
}
else {
/* quaternions - use quaternion blending */
@@ -538,7 +538,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
break;
default:
- // unknown
+ /* unknown */
strcpy(mode_str, "Sliding-Tool");
break;
}
@@ -606,7 +606,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
}
/* initial apply for operator... */
- // TODO: need to calculate percentage for initial round too...
+ /* TODO: need to calculate percentage for initial round too... */
pose_slide_apply(C, pso);
/* depsgraph updates + redraws */
@@ -631,6 +631,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, wmEvent *evt)
switch (evt->type) {
case LEFTMOUSE: /* confirm */
+ case RETKEY:
{
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
@@ -1151,7 +1152,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
}
/* just flatten handles, since values will now be the same either side... */
- // TODO: perhaps a fade-out modulation of the value is required here (optional once again)?
+ /* TODO: perhaps a fade-out modulation of the value is required here (optional once again)? */
bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal;
/* select keyframe to indicate that it's been changed */
@@ -1246,13 +1247,13 @@ void POSE_OT_propagate(wmOperatorType *ot)
/* callbacks */
ot->exec = pose_propagate_exec;
- ot->poll = ED_operator_posemode; // XXX: needs selected bones!
+ ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- // TODO: add "fade out" control for tapering off amount of propagation as time goes by?
+ /* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
ot->prop = RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes");
RNA_def_float(ot->srna, "end_frame", 250.0, FLT_MIN, FLT_MAX, "End Frame", "Frame to stop propagating frames to (for 'Before Frame' mode)", 1.0, 250.0);
}
diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c
index e2e3c49e7e0..f3c32399ad6 100644
--- a/source/blender/editors/armature/poseUtils.c
+++ b/source/blender/editors/armature/poseUtils.c
@@ -274,7 +274,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con
/* check if paths match */
if (strcmp(path, fcu->rna_path) == 0)
return ld;
- }
+ }
/* none found */
return NULL;
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index eea7424c59a..ae3d496b641 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -298,7 +298,7 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
/* validate action */
if (act == NULL) {
- BKE_report(op->reports, RPT_WARNING, "No Action to validate");
+ BKE_report(op->reports, RPT_WARNING, "No action to validate");
return OPERATOR_CANCELLED;
}
@@ -547,7 +547,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
/* check if valid poselib */
if (act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data");
+ BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
@@ -562,7 +562,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, marker_index);
if (marker == NULL) {
- BKE_reportf(op->reports, RPT_ERROR, "Invalid Pose specified %d", marker_index);
+ BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index);
return OPERATOR_CANCELLED;
}
@@ -628,14 +628,14 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, wmEvent *evt)
/* check if valid poselib */
if (act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data");
+ BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, act->active_marker - 1);
if (marker == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
+ BKE_report(op->reports, RPT_ERROR, "Invalid index for pose");
return OPERATOR_CANCELLED;
}
else {
@@ -657,14 +657,14 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
/* check if valid poselib */
if (act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data");
+ BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
if (marker == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
+ BKE_report(op->reports, RPT_ERROR, "Invalid index for pose");
return OPERATOR_CANCELLED;
}
@@ -871,7 +871,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
if (pld->marker)
frame = pld->marker->frame;
else
- return;
+ return;
/* init settings for testing groups for keyframes */
@@ -887,7 +887,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
/* has keyframe on this frame, so try to get a PoseChannel with this name */
pchan = BKE_pose_channel_find_name(pose, agrp->name);
- if (pchan) {
+ if (pchan) {
short ok = 0;
/* check if this bone should get any animation applied */
@@ -1079,7 +1079,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
}
/* check if any matches */
- if (pld->searchp.first == NULL) {
+ if (pld->searchp.first == NULL) {
pld->marker = NULL;
return;
}
@@ -1152,7 +1152,7 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
return;
- }
+ }
break;
case DELKEY:
@@ -1424,12 +1424,12 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
/* check if valid poselib */
if (ELEM3(NULL, pld->ob, pld->pose, pld->arm)) {
- BKE_report(op->reports, RPT_ERROR, "PoseLib is only for Armatures in PoseMode");
+ BKE_report(op->reports, RPT_ERROR, "Pose lib is only for armatures in pose mode");
pld->state = PL_PREVIEW_ERROR;
return;
}
if (pld->act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Object doesn't have a valid PoseLib");
+ BKE_report(op->reports, RPT_ERROR, "Object does not have a valid pose lib");
pld->state = PL_PREVIEW_ERROR;
return;
}
@@ -1438,10 +1438,10 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
/* just use first one then... */
pld->marker = pld->act->markers.first;
if (pose_index > -2)
- BKE_report(op->reports, RPT_WARNING, "PoseLib had no active pose");
+ BKE_report(op->reports, RPT_WARNING, "Pose lib had no active pose");
}
else {
- BKE_report(op->reports, RPT_ERROR, "PoseLib has no poses to preview/apply");
+ BKE_report(op->reports, RPT_ERROR, "Pose lib has no poses to preview/apply");
pld->state = PL_PREVIEW_ERROR;
return;
}
@@ -1639,7 +1639,7 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
- /* properties */
+ /* properties */
// TODO: make the pose_index into a proper enum instead of a cryptic int...
ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX);
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 189b2e977c2..576e5983d16 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -105,7 +105,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
Object *ob = base->object;
if (ob->id.lib) {
- BKE_report(reports, RPT_WARNING, "Can't pose libdata");
+ BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
return;
}
@@ -134,7 +134,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base)
ob->mode &= ~OB_MODE_POSE;
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
- }
+ }
}
/* if a selected or active bone is protected, throw error (oonly if warn == 1) and return 1 */
@@ -500,7 +500,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
found = 1;
break;
}
- }
+ }
else { /* direction == BONE_SELECT_CHILD */
/* the child member is only assigned to connected bones, see [#30340] */
#if 0
@@ -992,7 +992,7 @@ static void pose_copy_menu(Scene *scene)
}
}
}
- }
+ }
else { /* constraints, optional (note: max we can have is 24 constraints) */
bConstraint *con, *con_back;
int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */
@@ -1018,7 +1018,7 @@ static void pose_copy_menu(Scene *scene)
con_back = con->next;
BLI_freelinkN(&const_copy, con);
con = con_back;
- }
+ }
else
con = con->next;
}
@@ -1035,7 +1035,7 @@ static void pose_copy_menu(Scene *scene)
* appending to list of constraints for this channel
*/
copy_constraints(&tmp_constraints, &const_copy, TRUE);
- if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
+ if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
/* add proxy-local tags */
for (con = tmp_constraints.first; con; con = con->next)
con->flag |= CONSTRAINT_PROXY_LOCAL;
@@ -1097,7 +1097,7 @@ static void set_pose_keys(Object *ob)
for (chan = ob->pose->chanbase.first; chan; chan = chan->next) {
Bone *bone = chan->bone;
if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer))
- chan->flag |= POSE_KEY;
+ chan->flag |= POSE_KEY;
else
chan->flag &= ~POSE_KEY;
}
@@ -1236,7 +1236,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op)
/* sanity checking */
if (ELEM(NULL, ob, ob->pose)) {
- BKE_report(op->reports, RPT_ERROR, "No Pose to Copy");
+ BKE_report(op->reports, RPT_ERROR, "No pose to copy");
return OPERATOR_CANCELLED;
}
@@ -1399,7 +1399,7 @@ void POSE_OT_group_remove(wmOperatorType *ot)
/* identifiers */
ot->name = "Remove Bone Group";
ot->idname = "POSE_OT_group_remove";
- ot->description = "Removes the active bone group";
+ ot->description = "Remove the active bone group";
/* api callbacks */
ot->exec = pose_group_remove_exec;
@@ -1511,7 +1511,7 @@ void POSE_OT_group_assign(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- RNA_def_int(ot->srna, "type", 0, 0, 10, "Bone Group Index", "", 0, INT_MAX);
+ RNA_def_int(ot->srna, "type", 0, 0, INT_MAX, "Bone Group Index", "", 0, 10);
}
@@ -1916,7 +1916,7 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
int mode = RNA_enum_get(op->ptr, "type");
- /* set rotation mode of selected bones */
+ /* set rotation mode of selected bones */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
pchan->rotmode = mode;
@@ -2100,7 +2100,7 @@ static int pose_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt)
{
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
- /* get layers that are active already */
+ /* get layers that are active already */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
short bit;
@@ -2299,10 +2299,10 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
* just pose values should change, so this should be fine
*/
bPose *dummyPose = NULL;
- Object workob = {{0}};
+ Object workob = {{0}};
bPoseChannel *pchan;
- /* execute animation step for current frame using a dummy copy of the pose */
+ /* execute animation step for current frame using a dummy copy of the pose */
BKE_pose_copy_data(&dummyPose, ob->pose, 0);
BLI_strncpy(workob.id.name, "OB<ClearTfmWorkOb>", sizeof(workob.id.name));
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index 37f7fcfe5b7..d782d30e1f0 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -340,7 +340,7 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
cp_arc->edges.first = NULL;
cp_arc->edges.last = NULL;
- /* copy buckets */
+ /* copy buckets */
cp_arc->buckets = MEM_callocN(sizeof(EmbedBucket) * cp_arc->bcount, "embed bucket");
memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount);
@@ -377,7 +377,7 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level)
cp_rg->link_up = rg;
cp_rg->multi_level = level;
- /* Copy nodes */
+ /* Copy nodes */
for (node = rg->nodes.first; node; node = node->next)
{
ReebNode *cp_node = copyNode(cp_rg, node);
@@ -889,7 +889,7 @@ static void calculateArcLength(ReebArc *arc)
vec0 = vec1;
}
- arc->length += len_v3v3(arc->tail->p, vec1);
+ arc->length += len_v3v3(arc->tail->p, vec1);
}
static void calculateGraphLength(ReebGraph *rg)
@@ -948,7 +948,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
bucket1 = IT_next(iter1);
bucket2 = IT_next(iter2);
- /* Make sure they both start at the same value */
+ /* Make sure they both start at the same value */
while (bucket1 && bucket2 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
@@ -1005,7 +1005,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
bucket1 = IT_next(iter1);
bucket2 = IT_next(iter2);
- /* Make sure they both start at the same value */
+ /* Make sure they both start at the same value */
while (bucket1 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
@@ -1016,7 +1016,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
- /* copy and mirror back to bucket2 */
+ /* copy and mirror back to bucket2 */
bucket2->nv = bucket1->nv;
copy_v3_v3(bucket2->p, bucket1->p);
BLI_mirrorAlongAxis(bucket2->p, node->p, normal);
@@ -1062,7 +1062,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr
bucket1 = IT_next(iter1);
bucket2 = IT_next(iter2);
- /* Make sure they both start at the same value */
+ /* Make sure they both start at the same value */
while (bucket1 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
@@ -1080,7 +1080,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr
/* add bucket2 in bucket1 */
interp_v3_v3v3(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv));
- /* copy and mirror back to bucket2 */
+ /* copy and mirror back to bucket2 */
bucket2->nv = bucket1->nv;
copy_v3_v3(bucket2->p, bucket1->p);
BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor);
@@ -1212,7 +1212,7 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float
reweightArc(rg, next_arc, node, end_weight);
}
- /* update only if needed */
+ /* update only if needed */
if (arc->head->weight != start_weight || arc->tail->weight != end_weight)
{
old_weight = arc->head->weight; /* backup head weight, other arcs need it intact, it will be fixed by the source arc */
@@ -1318,7 +1318,7 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
}
joined = 1;
- }
+ }
}
return joined;
@@ -1450,7 +1450,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
arc->tail = newNode;
}
- // Remove looped arcs
+ // Remove looped arcs
if (arc->head == arc->tail) {
// v1 or v2 was already newNode, since we're removing an arc, decrement degree
NodeDegreeDecrement(rg, newNode);
@@ -1648,7 +1648,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
BLI_sortlist(&rg->arcs, compareArcs);
#ifdef DEBUG_REEB
- {
+ {
EditFace *efa;
for (efa = G.editMesh->faces.first; efa; efa = efa->next) {
efa->tmp.fp = -1;
@@ -1731,7 +1731,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
efa->tmp.fp = saacos(fabs(angle));
#endif
#else
- add_v3_v3(avg_vec, efa->n);
+ add_v3_v3(avg_vec, efa->n);
#endif
}
@@ -1873,7 +1873,7 @@ static int compareVerts(const void *a, const void *b)
value = 1;
}
- return value;
+ return value;
}
static void spreadWeight(EditMesh *em)
@@ -1947,7 +1947,7 @@ void REEB_exportGraph(ReebGraph *rg, int count)
fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_size(arc->faces));
exportNode(f, "v2", arc->tail);
- }
+ }
fclose(f);
}
@@ -1983,7 +1983,7 @@ void removeNormalNodes(ReebGraph *rg)
/* If arcs are one after the other */
if (arc->head == connectedArc->tail) {
- /* remove furthest arc */
+ /* remove furthest arc */
if (arc->tail->weight < connectedArc->head->weight) {
mergeConnectedArcs(rg, arc, connectedArc);
nextArc = arc->next;
@@ -2006,7 +2006,7 @@ void removeNormalNodes(ReebGraph *rg)
/* If arcs are one after the other */
if (arc->tail == connectedArc->head) {
- /* remove furthest arc */
+ /* remove furthest arc */
if (arc->head->weight < connectedArc->tail->weight) {
mergeConnectedArcs(rg, arc, connectedArc);
nextArc = arc->next;
@@ -2092,7 +2092,7 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d
newEdge->nextEdge = e;
- // if edge was the first in the list, point the edit edge to the new reeb edge instead.
+ // if edge was the first in the list, point the edit edge to the new reeb edge instead.
if (*p == e) {
*p = (void *)newEdge;
}
@@ -2289,12 +2289,12 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
arc->faces = BLI_ghash_ptr_new("createArc gh");
if (node1->weight <= node2->weight) {
- v1 = node1;
- v2 = node2;
+ v1 = node1;
+ v2 = node2;
}
else {
- v1 = node2;
- v2 = node1;
+ v1 = node2;
+ v2 = node1;
}
arc->head = v1;
@@ -2857,7 +2857,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
/* Apply dijkstra spf for each selected vert */
for (eve = em->verts.first; eve; eve = eve->next) {
if (eve->f & SELECT) {
- shortestPathsFromVert(em, eve, indexed_edges);
+ shortestPathsFromVert(em, eve, indexed_edges);
}
}
@@ -2927,7 +2927,7 @@ static void initIteratorFct(ReebArcIterator *iter)
iter->next = nextBucket;
iter->nextN = nextNBucket;
iter->previous = previousBucket;
- iter->stopped = iteratorStopped;
+ iter->stopped = iteratorStopped;
}
static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket)
diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h
index bb8b3003baf..b0e1fd3ae34 100644
--- a/source/blender/editors/armature/reeb.h
+++ b/source/blender/editors/armature/reeb.h
@@ -114,7 +114,7 @@ typedef struct ReebArc {
int bcount;
struct EmbedBucket *buckets;
- struct GHash *faces;
+ struct GHash *faces;
float angle;
struct ReebArc *link_up; /* for multi resolution filtering, points to higher levels */
} ReebArc;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index afd6bc4c4b5..957dcfbd848 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -162,9 +162,9 @@ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, shor
bezt->f1 |= flag;
bezt->f2 |= flag;
bezt->f3 |= flag;
- return 1;
+ return 1;
}
- else { /* deselects */
+ else { /* deselects */
bezt->f1 &= ~flag;
bezt->f2 &= ~flag;
bezt->f3 &= ~flag;
@@ -1361,7 +1361,7 @@ static int separate_exec(bContext *C, wmOperator *op)
oldedit = oldcu->editnurb;
if (oldcu->key) {
- BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys");
+ BKE_report(op->reports, RPT_ERROR, "Cannot separate a curve with vertex keys");
return OPERATOR_CANCELLED;
}
@@ -1579,8 +1579,9 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag)
BPoint *bp, *bpn, *newbp;
int a, b, newu, newv, sel;
- if (obedit->type == OB_SURF) ;
- else return OPERATOR_CANCELLED;
+ if (obedit->type != OB_SURF) {
+ return OPERATOR_CANCELLED;
+ }
cu->lastsel = NULL;
@@ -1593,8 +1594,12 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag)
a = nu->pntsu * nu->pntsv;
while (a) {
a--;
- if (bp->f1 & flag) ;
- else break;
+ if (bp->f1 & flag) {
+ /* pass */
+ }
+ else {
+ break;
+ }
bp++;
}
if (a == 0) {
@@ -1715,8 +1720,12 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
bp = nu->bp;
a = nu->pntsu;
while (a) {
- if (bp->f1 & flag) ;
- else break;
+ if (bp->f1 & flag) {
+ /* pass */
+ }
+ else {
+ break;
+ }
bp++;
a--;
}
@@ -2054,7 +2063,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
bp->weight = weight;
}
}
- }
+ }
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -2106,7 +2115,7 @@ static int set_radius_exec(bContext *C, wmOperator *op)
bp->radius = radius;
}
}
- }
+ }
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DAG_id_tag_update(obedit->data, 0);
@@ -2399,7 +2408,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
for (nu = editnurb->first; nu; nu = nu->next) {
lastsel = 0;
- if (nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a = nu->pntsu;
bezt = nu->bezt;
if (next < 0) bezt = &nu->bezt[a - 1];
@@ -2416,7 +2425,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
bezt += next;
lastsel = 0;
}
- /* move around in zigzag way so that we go through each */
+ /* move around in zigzag way so that we go through each */
bezt -= (next - next / abs(next));
}
}
@@ -2431,7 +2440,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
if (!(bp->f1 & SELECT) || (selstatus == 0)) {
short sel = select_bpoint(bp, selstatus, 1, VISIBLE);
if ((sel == 1) && (cont == 0)) lastsel = 1;
- }
+ }
}
else {
bp += next;
@@ -2697,7 +2706,7 @@ static int hide_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void CURVE_OT_hide(wmOperatorType *ot)
@@ -2758,7 +2767,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void CURVE_OT_reveal(wmOperatorType *ot)
@@ -3082,7 +3091,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
nu->pntsv = (number_cuts + 1) * nu->pntsv - number_cuts;
BKE_nurb_knot_calc_u(nu);
BKE_nurb_knot_calc_v(nu);
- } /* End of 'if (sel == nu->pntsu*nu->pntsv)' (subdivide entire NURB) */
+ } /* End of 'if (sel == nu->pntsu * nu->pntsv)' (subdivide entire NURB) */
else {
/* subdivide in v direction? */
sel = 0;
@@ -3191,7 +3200,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DAG_id_tag_update(obedit->data, 0);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void CURVE_OT_subdivide(wmOperatorType *ot)
@@ -3217,12 +3226,12 @@ void CURVE_OT_subdivide(wmOperatorType *ot)
/******************** find nearest ************************/
-static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
+static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
{
- struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int dist, hpoint, select, mval[2]; } *data = userData;
+ struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; float dist; int hpoint, select; float mval_fl[2]; } *data = userData;
short flag;
- short temp;
+ float dist_test;
if (bp) {
flag = bp->f1;
@@ -3239,12 +3248,12 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp,
}
}
- temp = abs(data->mval[0] - x) + abs(data->mval[1] - y);
- if ((flag & 1) == data->select) temp += 5;
- if (bezt && beztindex == 1) temp += 3; /* middle points get a small disadvantage */
+ 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 (temp < data->dist) {
- data->dist = temp;
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
data->bp = bp;
data->bezt = bezt;
@@ -3258,16 +3267,16 @@ static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2],
/* (sel == 1): selected gets a disadvantage */
/* in nurb and bezt or bp the nearest is written */
/* return 0 1 2: handlepunt */
- struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int dist, hpoint, select, mval[2]; } data = {NULL};
+ struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; float dist; int hpoint, select; float mval_fl[2]; } data = {NULL};
data.dist = 100;
data.hpoint = 0;
data.select = sel;
- data.mval[0] = mval[0];
- data.mval[1] = mval[1];
+ data.mval_fl[0] = mval[0];
+ data.mval_fl[1] = mval[1];
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- nurbs_foreachScreenVert(vc, findnearestNurbvert__doClosest, &data);
+ nurbs_foreachScreenVert(vc, findnearestNurbvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
*nurb = data.nurb;
*bezt = data.bezt;
@@ -3492,7 +3501,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
int changed = 0, type = RNA_enum_get(op->ptr, "type");
if (type == CU_CARDINAL || type == CU_BSPLINE) {
- BKE_report(op->reports, RPT_ERROR, "Not implemented yet");
+ BKE_report(op->reports, RPT_ERROR, "Not yet implemented");
return OPERATOR_CANCELLED;
}
@@ -3762,20 +3771,28 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
/* first nurbs: u = resolu-1 selected */
- if (is_u_selected(nu1, nu1->pntsu - 1) ) ;
+ if (is_u_selected(nu1, nu1->pntsu - 1) ) {
+ /* pass */
+ }
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;
rotate_direction_nurb(nu1);
- if (is_u_selected(nu1, nu1->pntsu - 1)) ;
+ if (is_u_selected(nu1, nu1->pntsu - 1)) {
+ /* pass */
+ }
else {
rotate_direction_nurb(nu1);
- if (is_u_selected(nu1, nu1->pntsu - 1)) ;
+ if (is_u_selected(nu1, nu1->pntsu - 1)) {
+ /* pass */
+ }
else {
rotate_direction_nurb(nu1);
- if (is_u_selected(nu1, nu1->pntsu - 1)) ;
+ if (is_u_selected(nu1, nu1->pntsu - 1)) {
+ /* pass */
+ }
else {
/* rotate again, now its OK! */
if (nu1->pntsv != 1) rotate_direction_nurb(nu1);
@@ -3786,17 +3803,25 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
}
/* 2nd nurbs: u = 0 selected */
- if (is_u_selected(nu2, 0) ) ;
+ if (is_u_selected(nu2, 0) ) {
+ /* pass */
+ }
else {
if (nu2->orderv == 0) nu2->orderv = 1;
rotate_direction_nurb(nu2);
- if (is_u_selected(nu2, 0)) ;
+ if (is_u_selected(nu2, 0)) {
+ /* pass */
+ }
else {
rotate_direction_nurb(nu2);
- if (is_u_selected(nu2, 0)) ;
+ if (is_u_selected(nu2, 0)) {
+ /* pass */
+ }
else {
rotate_direction_nurb(nu2);
- if (is_u_selected(nu2, 0)) ;
+ if (is_u_selected(nu2, 0)) {
+ /* pass */
+ }
else {
/* rotate again, now its OK! */
if (nu1->pntsu == 1) rotate_direction_nurb(nu1);
@@ -3808,7 +3833,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
}
if (nu1->pntsv != nu2->pntsv) {
- BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match");
+ BKE_report(op->reports, RPT_ERROR, "Resolution does not match");
return;
}
@@ -3892,21 +3917,33 @@ static int merge_nurb(bContext *C, wmOperator *op)
/* resolution match, to avoid uv rotations */
if (nus1->nu->pntsv == 1) {
- if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) ;
- else ok = 0;
+ if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) {
+ /* pass */
+ }
+ else {
+ ok = 0;
+ }
}
else if (nus2->nu->pntsv == 1) {
- if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) ;
- else ok = 0;
+ if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) {
+ /* pass */
+ }
+ else {
+ ok = 0;
+ }
+ }
+ else if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsv == nus2->nu->pntsv) {
+ /* pass */
+ }
+ else if (nus1->nu->pntsu == nus2->nu->pntsv || nus1->nu->pntsv == nus2->nu->pntsu) {
+ /* pass */
}
- else if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsv == nus2->nu->pntsv) ;
- else if (nus1->nu->pntsu == nus2->nu->pntsv || nus1->nu->pntsv == nus2->nu->pntsu) ;
else {
ok = 0;
}
if (ok == 0) {
- BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match");
+ BKE_report(op->reports, RPT_ERROR, "Resolution does not match");
BLI_freelistN(&nsortbase);
return OPERATOR_CANCELLED;
}
@@ -3949,8 +3986,12 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if (isNurbsel_count(cu, nu) == 1) {
/* only 1 selected, not first or last, a little complex, but intuitive */
if (nu->pntsv == 1) {
- if ( (nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) ;
- else break;
+ if ( (nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) {
+ /* pass */
+ }
+ else {
+ break;
+ }
}
}
}
@@ -4082,7 +4123,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
if (!ok) {
- BKE_report(op->reports, RPT_ERROR, "Can't make segment");
+ BKE_report(op->reports, RPT_ERROR, "Cannot make segment");
return OPERATOR_CANCELLED;
}
@@ -4335,7 +4376,7 @@ static int spin_exec(bContext *C, wmOperator *op)
unit_m4(viewmat);
if (!spin_nurb(viewmat, obedit, axis, cent)) {
- BKE_report(op->reports, RPT_ERROR, "Can't spin");
+ BKE_report(op->reports, RPT_ERROR, "Cannot spin");
return OPERATOR_CANCELLED;
}
@@ -4380,7 +4421,7 @@ void CURVE_OT_spin(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
- RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX);
+ RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX, "Axis", "Axis in global view space", -1.0f, 1.0f);
}
/***************** add vertex operator **********************/
@@ -5211,10 +5252,10 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
tempbp = bp + 1;
if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE);
if (sel) {
- bp++;
+ bp++;
a--;
}
- }
+ }
}
bp++;
@@ -5272,8 +5313,8 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
sel = 0;
- /* check if neighbors have been selected */
- /* edges of surface are an exception */
+ /* check if neighbors have been selected */
+ /* edges of surface are an exception */
if ((a + 1) % nu->pntsu == 0) sel++;
else {
bp--;
@@ -5305,7 +5346,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
if (sel != 4) {
select_bpoint(bp, DESELECT, 1, VISIBLE);
selbpoints[a] = 1;
- }
+ }
}
else lastsel = 0;
@@ -5319,7 +5360,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
for (nu = editnurb->first; nu; nu = nu->next) {
lastsel = 0;
/* check what type of curve/nurb it is */
- if (nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a = nu->pntsu;
bezt = nu->bezt;
while (a--) {
@@ -5327,10 +5368,10 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
if (lastsel == 1) sel = 1;
else sel = 0;
- /* check if neighbors have been selected */
- /* first and last are exceptions */
+ /* check if neighbors have been selected */
+ /* first and last are exceptions */
if (a == nu->pntsu - 1) sel++;
- else {
+ else {
bezt--;
if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++;
bezt++;
@@ -5344,14 +5385,14 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
}
if (sel != 2) {
- select_beztriple(bezt, DESELECT, 1, VISIBLE);
+ select_beztriple(bezt, DESELECT, 1, VISIBLE);
lastsel = 1;
}
else lastsel = 0;
}
else lastsel = 0;
- bezt++;
+ bezt++;
}
}
else {
@@ -5362,9 +5403,9 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
if (lastsel != 0) sel = 1;
else sel = 0;
- /* first and last are exceptions */
+ /* first and last are exceptions */
if (a == nu->pntsu * nu->pntsv - 1) sel++;
- else {
+ else {
bp--;
if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
bp++;
@@ -5378,9 +5419,9 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
}
if (sel != 2) {
- select_bpoint(bp, DESELECT, 1, VISIBLE);
+ select_bpoint(bp, DESELECT, 1, VISIBLE);
lastsel = 1;
- }
+ }
else lastsel = 0;
}
else lastsel = 0;
@@ -5441,7 +5482,7 @@ static void selectrandom_curve(ListBase *editnurb, float randfac)
select_bpoint(bp, SELECT, 1, VISIBLE);
bp++;
}
- }
+ }
}
}
@@ -5583,10 +5624,10 @@ static int select_nth_exec(bContext *C, wmOperator *op)
if (!CU_select_nth(obedit, nth)) {
if (obedit->type == OB_SURF) {
- BKE_report(op->reports, RPT_ERROR, "Surface hasn't got active point");
+ BKE_report(op->reports, RPT_ERROR, "Surface has not got active point");
}
else {
- BKE_report(op->reports, RPT_ERROR, "Curve hasn't got active point");
+ BKE_report(op->reports, RPT_ERROR, "Curve has not got active point");
}
return OPERATOR_CANCELLED;
@@ -5600,8 +5641,8 @@ static int select_nth_exec(bContext *C, wmOperator *op)
void CURVE_OT_select_nth(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Select Nth";
- ot->description = "";
+ ot->name = "Checker Deselect";
+ ot->description = "Deselect every other vertex";
ot->idname = "CURVE_OT_select_nth";
/* api callbacks */
@@ -5611,7 +5652,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "nth", 2, 2, 100, "Nth Selection", "", 1, INT_MAX);
+ RNA_def_int(ot->srna, "nth", 2, 2, INT_MAX, "Nth Selection", "", 2, 100);
}
/********************** add duplicate operator *********************/
@@ -5684,8 +5725,12 @@ static int delete_exec(bContext *C, wmOperator *op)
a = nu->pntsu;
if (a) {
while (a) {
- if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) ;
- else break;
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ /* pass */
+ }
+ else {
+ break;
+ }
a--;
bezt++;
}
@@ -5704,8 +5749,12 @@ static int delete_exec(bContext *C, wmOperator *op)
a = nu->pntsu * nu->pntsv;
if (a) {
while (a) {
- if (bp->f1 & SELECT) ;
- else break;
+ if (bp->f1 & SELECT) {
+ /* pass */
+ }
+ else {
+ break;
+ }
a--;
bp++;
}
@@ -6416,8 +6465,8 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type
fac = (float)b - 1.5f;
bp->vec[1] += fac * grid;
if (a == 1 || a == 2) if (b == 1 || b == 2) {
- bp->vec[2] += grid;
- }
+ bp->vec[2] += grid;
+ }
mul_m4_v3(mat, bp->vec);
bp->vec[3] = 1.0;
bp++;
@@ -6437,12 +6486,7 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type
vec[0] = vec[1] = 0.0;
vec[2] = -grid;
- if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
- /* pass */
- }
- else {
- mul_mat3_m4_v3(mat, vec);
- }
+ mul_mat3_m4_v3(mat, vec);
translateflagNurb(editnurb, 1, vec);
extrudeflagNurb(cu->editnurb, 1);
@@ -6583,7 +6627,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
if (obedit == NULL || obedit->type != OB_SURF) {
obedit = ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer);
newob = 1;
- }
+ }
else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
}
@@ -6603,7 +6647,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
if (newob && enter_editmode)
ED_undo_push(C, "Enter Editmode");
- ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
+ ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, TRUE);
nu = add_nurbs_primitive(C, obedit, mat, type, newob);
editnurb = object_editcurve_get(obedit);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index b11d640256c..fd87e6752f2 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -94,7 +94,8 @@ static char findaccent(char char1, unsigned int code)
}
else if (char1 == 'c') {
if (code == ',') new = 231;
- if (code == '|') new = 162;
+ else if (code == '|') new = 162;
+ else if (code == 'o') new = 169;
}
else if (char1 == 'e') {
if (code == '`') new = 232;
@@ -120,10 +121,18 @@ static char findaccent(char char1, unsigned int code)
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;
}
else if (char1 == 's') {
if (code == 's') new = 167;
}
+ else if (char1 == 't') {
+ if (code == 'm') new = 153;
+ }
else if (char1 == 'u') {
if (code == '`') new = 249;
else if (code == 39) new = 250;
@@ -310,7 +319,7 @@ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op))
lastlorem = ED_lorem;
insert_into_textbuf(obedit, '\n');
- insert_into_textbuf(obedit, '\n');
+ insert_into_textbuf(obedit, '\n');
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -441,8 +450,9 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float
obedit = BKE_object_add(scene, OB_FONT);
base = scene->basact;
-
- ED_object_base_init_transform(C, base, NULL, rot); /* seems to assume view align ? TODO - look into this, could be an operator option */
+ /* seems to assume view align ? TODO - look into this, could be an operator option */
+ ED_object_base_init_transform(C, base, NULL, rot);
+
BKE_object_where_is_calc(scene, obedit);
obedit->loc[0] += offset[0];
@@ -457,7 +467,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float
nchars += strlen(tmp->line) + 1;
if (cu->str) MEM_freeN(cu->str);
- if (cu->strinfo) MEM_freeN(cu->strinfo);
+ if (cu->strinfo) MEM_freeN(cu->strinfo);
cu->str = MEM_callocN(nchars + 4, "str");
cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo");
@@ -756,7 +766,7 @@ static int paste_selection(Object *obedit, ReportList *reports)
/* Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT */
if (cu->len + len <= MAXTEXT) {
- if (len) {
+ if (len) {
int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t);
memmove(ef->textbuf + cu->pos + len, ef->textbuf + cu->pos, size);
memcpy(ef->textbuf + cu->pos, ef->copybuf, len * sizeof(wchar_t));
@@ -834,7 +844,7 @@ static int move_cursor(bContext *C, int type, int select)
if (ef->textbuf[cu->pos - 1] == '\n') break;
if (ef->textbufinfo[cu->pos - 1].flag & CU_CHINFO_WRAP) break;
cu->pos--;
- }
+ }
cursmove = FO_CURS;
break;
@@ -867,7 +877,7 @@ static int move_cursor(bContext *C, int type, int select)
cursmove = FO_CURS;
break;
- case NEXT_CHAR:
+ case NEXT_CHAR:
if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1;
cu->pos++;
cursmove = FO_CURS;
@@ -1250,8 +1260,12 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
else
ascii = 9;
}
- else if (event == BACKSPACEKEY)
- ascii = 0;
+
+ if (event == BACKSPACEKEY) {
+ if (alt && cu->len != 0 && cu->pos > 0)
+ accentcode = 1;
+ return OPERATOR_PASS_THROUGH;
+ }
if (val && (ascii || evt->utf8_buf[0])) {
/* handle case like TAB (== 9) */
@@ -1262,44 +1276,18 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
(evt->utf8_buf[0]))
{
- if (evt->utf8_buf[0]) {
- BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1);
- ascii = inserted_text[0];
- insert_into_textbuf(obedit, ascii);
- accentcode = 0;
- }
- else if (accentcode) {
+ if (accentcode) {
if (cu->pos > 0) {
inserted_text[0] = findaccent(ef->textbuf[cu->pos - 1], ascii);
ef->textbuf[cu->pos - 1] = inserted_text[0];
}
accentcode = 0;
}
- else if (cu->len < MAXTEXT - 1) {
- if (alt) {
- /* might become obsolete, apple has default values for this, other OS's too? */
- if (ascii == 't') ascii = 137;
- else if (ascii == 'c') ascii = 169;
- else if (ascii == 'f') ascii = 164;
- else if (ascii == 'g') ascii = 176;
- else if (ascii == 'l') ascii = 163;
- else if (ascii == 'r') ascii = 174;
- else if (ascii == 's') ascii = 223;
- else if (ascii == 'y') ascii = 165;
- else if (ascii == '.') ascii = 138;
- else if (ascii == '1') ascii = 185;
- else if (ascii == '2') ascii = 178;
- else if (ascii == '3') ascii = 179;
- else if (ascii == '%') ascii = 139;
- else if (ascii == '?') ascii = 191;
- else if (ascii == '!') ascii = 161;
- else if (ascii == 'x') ascii = 215;
- else if (ascii == '>') ascii = 187;
- else if (ascii == '<') ascii = 171;
- }
-
- inserted_text[0] = ascii;
+ else if (evt->utf8_buf[0]) {
+ BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1);
+ ascii = inserted_text[0];
insert_into_textbuf(obedit, ascii);
+ accentcode = 0;
}
kill_selection(obedit, 1);
@@ -1311,12 +1299,6 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
text_update_edited(C, scene, obedit, 1, FO_EDIT);
}
}
- else if (val && event == BACKSPACEKEY) {
- if (alt && cu->len != 0 && cu->pos > 0)
- accentcode = 1;
-
- return OPERATOR_PASS_THROUGH;
- }
else
return OPERATOR_PASS_THROUGH;
@@ -1329,7 +1311,8 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
}
/* reset property? */
- accentcode = 0;
+ if (val == 0)
+ accentcode = 0;
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 18b7eb56d39..0ee2c96e322 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -99,8 +99,8 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn
if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
return;
- /* if drawing a single point, draw it larger */
- if (totpoints == 1) {
+ /* if drawing a single point, draw it larger */
+ if (totpoints == 1) {
/* draw point */
gpuBegin(GL_POINTS);
gpuVertex2f(points->x, points->y);
@@ -151,7 +151,8 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn
/* ----- Existing Strokes Drawing (3D and Point) ------ */
/* draw a given stroke - just a single dot (only one point) */
-static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy)
+static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag,
+ int offsx, int offsy, int winx, int winy)
{
/* draw point */
if (sflag & GP_STROKE_3DSPACE) {
@@ -306,7 +307,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
s0[1] = (pt1->y / 100 * winy) + offsy;
s1[0] = (pt2->x / 100 * winx) + offsx;
s1[1] = (pt2->y / 100 * winy) + offsy;
- }
+ }
/* calculate gradient and normal - 'angle'=(ny/nx) */
m1[1] = s1[1] - s0[1];
@@ -322,7 +323,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
if (i == 0) {
/* draw start cap first
* - make points slightly closer to center (about halfway across)
- */
+ */
mt[0] = m2[0] * pthick * 0.5f;
mt[1] = m2[1] * pthick * 0.5f;
sc[0] = s0[0] - (m1[0] * pthick * 0.75f);
@@ -373,7 +374,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) {
mt[0] += (mb[0] * dfac);
mt[1] += (mb[1] * dfac);
- }
+ }
/* calculate points for start of segment */
t0[0] = s0[0] - mt[0];
@@ -411,7 +412,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
/* draw end cap as last step
* - make points slightly closer to center (about halfway across)
- */
+ */
mt[0] = m2[0] * pthick * 0.5f;
mt[1] = m2[1] * pthick * 0.5f;
sc[0] = s1[0] + (m1[0] * pthick * 0.75f);
@@ -500,7 +501,8 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
glDepthMask(0);
glEnable(GL_DEPTH_TEST);
- /* first arg is normally rv3d->dist, but this isn't available here and seems to work quite well without */
+ /* first arg is normally rv3d->dist, but this isn't
+ * available here and seems to work quite well without */
bglPolygonOffset(1.0f, 1.0f);
#if 0
glEnable(GL_POLYGON_OFFSET_LINE);
@@ -521,7 +523,7 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
#endif
}
}
- else if (gps->totpoints > 1)
+ else if (gps->totpoints > 1)
gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
}
}
@@ -572,7 +574,8 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
/* draw 'onionskins' (frame left + right) */
if (gpl->flag & GP_LAYER_ONIONSKIN) {
- /* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/
+ /* drawing method - only immediately surrounding (gstep = 0),
+ * or within a frame range on either side (gstep > 0)*/
if (gpl->gstep) {
bGPDframe *gf;
float fac;
@@ -601,7 +604,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
}
else
break;
- }
+ }
/* restore alpha */
gpuCurrentColor4fv(color);
@@ -633,7 +636,8 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
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. */
+ /* Buffer stroke needs to be drawn with a different linestyle
+ * to help differentiate them from normal strokes. */
gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag);
}
}
@@ -651,11 +655,11 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
/* ----- Grease Pencil Sketches Drawing API ------ */
-// ............................
-// XXX
-// We need to review the calls below, since they may be/are not that suitable for
-// the new ways that we intend to be drawing data...
-// ............................
+/* ............................
+ * XXX
+ * We need to review the calls below, since they may be/are not that suitable for
+ * the new ways that we intend to be drawing data...
+ * ............................ */
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
void draw_gpencil_2dimage(const bContext *C)
@@ -718,8 +722,8 @@ void draw_gpencil_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=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes
- */
+ * Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes,
+ * second time with onlyv2d=0 for screen-aligned strokes */
void draw_gpencil_view2d(const bContext *C, short onlyv2d)
{
ScrArea *sa = CTX_wm_area(C);
@@ -748,9 +752,8 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d)
}
/* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly
- * Note: this gets called twice - first time with only3d=1 to draw 3d-strokes, second time with only3d=0 for screen-aligned strokes
- */
-
+ * Note: this gets called twice - first time with only3d=1 to draw 3d-strokes,
+ * second time with only3d=0 for screen-aligned strokes */
void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d)
{
bGPdata *gpd;
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index b69db0040b5..a59a3f7a5ec 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -393,7 +393,7 @@ void paste_gpdata(Scene *scene)
ScrArea *sa;
/* get area that gp-data comes from */
- //sa= gpencil_data_findowner((bGPdata *)ale->owner);
+ //sa = gpencil_data_findowner((bGPdata *)ale->owner);
sa = NULL;
/* this should be the right frame... as it may be a pre-existing frame,
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 46df8ba5fac..ed8a1ea8280 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -212,7 +212,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
if (gpd_ptr == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go");
+ BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
}
else {
@@ -260,7 +260,7 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op)
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
if (gpd_ptr == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go");
+ BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
}
else {
@@ -299,7 +299,7 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
/* if there's no existing Grease-Pencil data there, add some */
if (gpd_ptr == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go");
+ BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
}
if (*gpd_ptr == NULL)
@@ -348,7 +348,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
/* if there's no existing Grease-Pencil data there, add some */
if (gpd == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
+ BKE_report(op->reports, RPT_ERROR, "No grease pencil data");
return OPERATOR_CANCELLED;
}
if (ELEM(NULL, gpl, gpf)) {
@@ -634,7 +634,7 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op)
/* check if there's data to work with */
if (gpd == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data to work on");
+ BKE_report(op->reports, RPT_ERROR, "No grease pencil data to work on");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 16262765888..432292c259d 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -281,7 +281,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
/* method taken from editview.c - mouse_cursor() */
/* TODO, use ED_view3d_project_float_global */
- if (ED_view3d_project_int_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
VECSUB2D(mval_f, mval_prj, mval);
ED_view3d_win_to_delta(p->ar, mval_f, dvec);
sub_v3_v3v3(out, rvec, dvec);
@@ -397,8 +397,10 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure)
pts = &gps->points[gps->totpoints - 1];
- /* special case for poly lines: normally, depth is needed only when creating new stroke from buffer,
- * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates
+ /* special case for poly lines: normally,
+ * depth is needed only when creating new stroke from buffer,
+ * but poly lines are converting to stroke instantly,
+ * so initialize depth buffer before converting coordinates
*/
if (gpencil_project_check(p)) {
View3D *v3d = p->sa->spacedata.first;
@@ -536,7 +538,7 @@ static void gp_stroke_simplify(tGPsdata *p)
j += 2;
}
- }
+ }
/* free old buffer */
MEM_freeN(old_points);
@@ -787,13 +789,49 @@ static short gp_stroke_eraser_strokeinside(const int mval[], const int UNUSED(mv
int rad, int x0, int y0, int x1, int y1)
{
/* simple within-radius check for now */
- if (edge_inside_circle(mval[0], mval[1], rad, x0, y0, x1, y1))
- return 1;
+ const float mval_fl[2] = {mval[0], mval[1]};
+ const float screen_co_a[2] = {x0, y0};
+ const float screen_co_b[2] = {x1, y1};
+
+ if (edge_inside_circle(mval_fl, rad, screen_co_a, screen_co_b)) {
+ return TRUE;
+ }
/* not inside */
- return 0;
+ return FALSE;
}
+static void gp_point_to_xy(ARegion *ar, View2D *v2d, rctf *subrect, bGPDstroke *gps, bGPDspoint *pt,
+ int *r_x, int *r_y)
+{
+ int xyval[2];
+
+ if (gps->flag & GP_STROKE_3DSPACE) {
+ if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ *r_x = xyval[0];
+ *r_y = xyval[1];
+ }
+ else {
+ *r_x = V2D_IS_CLIPPED;
+ *r_y = V2D_IS_CLIPPED;
+ }
+ }
+ else if (gps->flag & GP_STROKE_2DSPACE) {
+ UI_view2d_view_to_region(v2d, pt->x, pt->y, r_x, r_y);
+ }
+ else {
+ if (subrect == NULL) { /* normal 3D view */
+ *r_x = (int)(pt->x / 100 * ar->winx);
+ *r_y = (int)(pt->y / 100 * ar->winy);
+ }
+ else { /* camera view, use subrect */
+ *r_x = (int)((pt->x / 100) * BLI_rctf_size_x(subrect)) + subrect->xmin;
+ *r_y = (int)((pt->y / 100) * BLI_rctf_size_y(subrect)) + subrect->ymin;
+ }
+ }
+}
+
+
/* eraser tool - evaluation per stroke */
// TODO: this could really do with some optimization (KD-Tree/BVH?)
static void gp_stroke_eraser_dostroke(tGPsdata *p,
@@ -802,7 +840,6 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
{
bGPDspoint *pt1, *pt2;
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
- int xyval[2];
int i;
if (gps->totpoints == 0) {
@@ -812,33 +849,11 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
BLI_freelinkN(&gpf->strokes, gps);
}
else if (gps->totpoints == 1) {
- /* get coordinates */
- if (gps->flag & GP_STROKE_3DSPACE) {
- if (ED_view3d_project_int_global(p->ar, &gps->points->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
- x0 = xyval[0];
- y0 = xyval[1];
- }
- else {
- x0 = V2D_IS_CLIPPED;
- y0 = V2D_IS_CLIPPED;
- }
- }
- else if (gps->flag & GP_STROKE_2DSPACE) {
- UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0);
- }
- else {
- if (p->subrect == NULL) { /* normal 3D view */
- x0 = (int)(gps->points->x / 100 * p->ar->winx);
- y0 = (int)(gps->points->y / 100 * p->ar->winy);
- }
- else { /* camera view, use subrect */
- x0 = (int)((gps->points->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin;
- y0 = (int)((gps->points->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin;
- }
- }
+ gp_point_to_xy(p->ar, p->v2d, p->subrect, gps, gps->points, &x0, &y0);
/* do boundbox check first */
- if (BLI_rcti_isect_pt(rect, x0, y0)) {
+
+ if ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) {
/* only check if point is inside */
if (((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) {
/* free stroke */
@@ -847,7 +862,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
}
}
}
- else {
+ else {
/* loop over the points in the stroke, checking for intersections
* - an intersection will require the stroke to be split
*/
@@ -855,48 +870,13 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* get points to work with */
pt1 = gps->points + i;
pt2 = gps->points + i + 1;
-
- /* get coordinates */
- if (gps->flag & GP_STROKE_3DSPACE) {
- if (ED_view3d_project_int_global(p->ar, &pt1->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
- x0 = xyval[0];
- y0 = xyval[1];
- }
- else {
- x0 = V2D_IS_CLIPPED;
- y0 = V2D_IS_CLIPPED;
- }
- if (ED_view3d_project_int_global(p->ar, &pt2->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
- x1 = xyval[0];
- y1 = xyval[1];
- }
- else {
- x1 = V2D_IS_CLIPPED;
- y1 = V2D_IS_CLIPPED;
- }
- }
- else if (gps->flag & GP_STROKE_2DSPACE) {
- UI_view2d_view_to_region(p->v2d, pt1->x, pt1->y, &x0, &y0);
-
- UI_view2d_view_to_region(p->v2d, pt2->x, pt2->y, &x1, &y1);
- }
- else {
- if (p->subrect == NULL) { /* normal 3D view */
- x0 = (int)(pt1->x / 100 * p->ar->winx);
- y0 = (int)(pt1->y / 100 * p->ar->winy);
- x1 = (int)(pt2->x / 100 * p->ar->winx);
- y1 = (int)(pt2->y / 100 * p->ar->winy);
- }
- else { /* camera view, use subrect */
- x0 = (int)((pt1->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin;
- y0 = (int)((pt1->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin;
- x1 = (int)((pt2->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin;
- y1 = (int)((pt2->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin;
- }
- }
-
+
+ gp_point_to_xy(p->ar, p->v2d, p->subrect, gps, pt1, &x0, &y0);
+ gp_point_to_xy(p->ar, p->v2d, p->subrect, gps, pt2, &x1, &y1);
+
/* check that point segment of the boundbox of the eraser stroke */
- if (BLI_rcti_isect_pt(rect, x0, y0) || BLI_rcti_isect_pt(rect, x1, y1)) {
+ if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) ||
+ ((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1))) {
/* check if point segment of stroke had anything to do with
* eraser region (either within stroke painted, or on its lines)
* - this assumes that linewidth is irrelevant
@@ -981,8 +961,8 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
/* supported views first */
case SPACE_VIEW3D:
{
- // View3D *v3d= curarea->spacedata.first;
- // RegionView3D *rv3d= ar->regiondata;
+ // View3D *v3d = curarea->spacedata.first;
+ // RegionView3D *rv3d = ar->regiondata;
/* set current area
* - must verify that region data is 3D-view (and not something else)
@@ -1001,7 +981,7 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
case SPACE_NODE:
{
- //SpaceNode *snode= curarea->spacedata.first;
+ //SpaceNode *snode = curarea->spacedata.first;
/* set current area */
p->sa = curarea;
@@ -1029,7 +1009,7 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
break;
case SPACE_IMAGE:
{
- //SpaceImage *sima= curarea->spacedata.first;
+ //SpaceImage *sima = curarea->spacedata.first;
/* set the current area */
p->sa = curarea;
@@ -1232,7 +1212,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode)
/* make strokes be drawn in screen space */
p->gpd->sbuffer_sflag &= ~GP_STROKE_2DSPACE;
p->gpd->flag &= ~GP_DATA_VIEWALIGN;
- }
+ }
else
p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
}
@@ -1358,7 +1338,7 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
gp_session_cleanup(p);
/* finally, free the temp data */
- MEM_freeN(p);
+ MEM_freeN(p);
}
op->customdata = NULL;
@@ -1419,13 +1399,17 @@ static void gpencil_draw_status_indicators(tGPsdata *p)
/* print status info */
switch (p->paintmode) {
case GP_PAINTMODE_ERASER:
- ED_area_headerprint(p->sa, "Grease Pencil Erase Session: Hold and drag LMB or RMB to erase | ESC/Enter to end");
+ ED_area_headerprint(p->sa,
+ "Grease Pencil Erase Session: Hold and drag LMB or RMB to erase |"
+ " ESC/Enter to end");
break;
case GP_PAINTMODE_DRAW_STRAIGHT:
- ED_area_headerprint(p->sa, "Grease Pencil Line Session: Hold and drag LMB to draw | ESC/Enter to end");
+ ED_area_headerprint(p->sa, "Grease Pencil Line Session: Hold and drag LMB to draw | "
+ "ESC/Enter to end");
break;
case GP_PAINTMODE_DRAW:
- ED_area_headerprint(p->sa, "Grease Pencil Freehand Session: Hold and drag LMB to draw | ESC/Enter to end");
+ ED_area_headerprint(p->sa, "Grease Pencil Freehand Session: Hold and drag LMB to draw | "
+ "ESC/Enter to end");
break;
default: /* unhandled future cases */
@@ -1660,7 +1644,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event)
* painting should start immediately. Otherwise, this was called from a toolbar, in which
* case we should wait for the mouse to be clicked.
*/
- if (event->type) {
+ if (event->val == KM_PRESS) {
/* hotkey invoked - start drawing */
//printf("\tGP - set first spot\n");
p->status = GP_STATUS_PAINTING;
@@ -1701,7 +1685,8 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
//printf("\t\tGP - start stroke\n");
/* we may need to set up paint env again if we're resuming */
- /* XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions */
+ /* XXX: watch it with the paintmode! in future,
+ * it'd be nice to allow changing paint-mode when in sketching-sessions */
/* XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support */
if (gp_session_initdata(C, p))
@@ -1734,7 +1719,7 @@ static void gpencil_stroke_end(wmOperator *op)
static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
{
tGPsdata *p = op->customdata;
- int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */
+ int estate = OPERATOR_RUNNING_MODAL; /* default exit state - we don't pass on events, GP is used with key-modifiers */
/* if (event->type == NDOF_MOTION)
* return OPERATOR_PASS_THROUGH;
@@ -1801,7 +1786,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
if (p->status == GP_STATUS_ERROR) {
estate = OPERATOR_CANCELLED;
}
- }
+ }
else {
p->status = GP_STATUS_IDLING;
}
@@ -1885,7 +1870,10 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH:
/* event doesn't need to be handled */
- //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE);
+#if 0
+ printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n",
+ event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE);
+#endif
break;
}
@@ -1896,10 +1884,10 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event)
/* ------------------------------- */
static EnumPropertyItem prop_gpencil_drawmodes[] = {
- {GP_PAINTMODE_DRAW, "DRAW", 0, "Draw Freehand", ""},
- {GP_PAINTMODE_DRAW_STRAIGHT, "DRAW_STRAIGHT", 0, "Draw Straight Lines", ""},
- {GP_PAINTMODE_DRAW_POLY, "DRAW_POLY", 0, "Draw Poly Line", ""},
- {GP_PAINTMODE_ERASER, "ERASER", 0, "Eraser", ""},
+ {GP_PAINTMODE_DRAW, "DRAW", 0, "Draw Freehand", "Draw freehand stroke(s)"},
+ {GP_PAINTMODE_DRAW_STRAIGHT, "DRAW_STRAIGHT", 0, "Draw Straight Lines", "Draw straight line segment(s)"},
+ {GP_PAINTMODE_DRAW_POLY, "DRAW_POLY", 0, "Draw Poly Line", "Click to place endpoints of straight line segments (connected)"},
+ {GP_PAINTMODE_ERASER, "ERASER", 0, "Eraser", "Erase Grease Pencil strokes"},
{0, NULL, 0, NULL, NULL}
};
@@ -1921,7 +1909,7 @@ void GPENCIL_OT_draw(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* settings for drawing */
- RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements");
+ ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements");
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 8a65699f404..ffee46e30c6 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -157,4 +157,3 @@ short compare_ab_cfraPtr(void *node, void *data);
short actkeyblock_is_valid(ActKeyBlock *ab, struct DLRBT_Tree *keys);
#endif /* __ED_KEYFRAMES_DRAW_H__ */
-
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index dc40b687dfd..46ed9798d32 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -88,8 +88,8 @@ void free_gpcopybuf(void);
void copy_gpdata(void);
void paste_gpdata(void);
- void snap_masklayer_frames(struct MaskLayer *masklay, short mode);
- void mirror_masklayer_frames(struct MaskLayer *masklay, short mode);
+void snap_masklayer_frames(struct MaskLayer *masklay, short mode);
+void mirror_masklayer_frames(struct MaskLayer *masklay, short mode);
#endif
#endif /* __ED_MASK_H__ */
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index 5ce6db97305..1321765588d 100644
--- a/source/blender/editors/include/ED_mball.h
+++ b/source/blender/editors/include/ED_mball.h
@@ -38,7 +38,7 @@ struct wmKeyConfig;
void ED_operatortypes_metaball(void);
void ED_keymap_metaball(struct wmKeyConfig *keyconf);
-struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newname);
+struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], float dia, int type, int newname);
int mouse_mball(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index e1f12360328..05e4d8c4a2f 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -61,6 +61,7 @@ struct BMEditMesh;
struct BMEditSelection;
struct BMesh;
struct BMVert;
+struct BMLoop;
struct MLoopCol;
struct BMEdge;
struct BMFace;
@@ -118,6 +119,7 @@ void EDBM_update_generic(struct bContext *C, struct BMEditMesh *em, const short
struct UvElementMap *EDBM_uv_element_map_create(struct BMEditMesh *em, int selected, int doIslands);
void EDBM_uv_element_map_free(struct UvElementMap *vmap);
+struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l);
int EDBM_mtexpoly_check(struct BMEditMesh *em);
struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, int sloppy, int selected);
@@ -142,9 +144,9 @@ int EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2]
short xmin, short ymin, short xmax, short ymax);
int EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads);
-struct BMVert *EDBM_vert_find_nearest(struct ViewContext *vc, int *dist, short sel, short strict);
-struct BMEdge *EDBM_edge_find_nearest(struct ViewContext *vc, int *dist);
-struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, int *dist);
+struct BMVert *EDBM_vert_find_nearest(struct ViewContext *vc, float *r_dist, const short sel, const short strict);
+struct BMEdge *EDBM_edge_find_nearest(struct ViewContext *vc, float *r_dist);
+struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, float *r_dist);
int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle);
@@ -248,7 +250,7 @@ void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int c
int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me, const char *name, int active_set);
int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me);
-int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum);
+int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum);
int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set);
int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
int ED_mesh_color_remove_named(struct bContext *C, struct Object *ob, struct Mesh *me, const char *name);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 9836d690e53..0d0b8d8e797 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -35,22 +35,31 @@
extern "C" {
#endif
+struct BMEdge;
+struct BMFace;
+struct BMVert;
+struct BPoint;
struct Base;
-struct bConstraint;
-struct bContext;
-struct bPoseChannel;
+struct BezTriple;
struct Curve;
+struct EditBone;
struct EnumPropertyItem;
struct ID;
struct KeyBlock;
struct Lattice;
struct Main;
struct Mesh;
+struct MetaElem;
struct ModifierData;
+struct Nurb;
struct Object;
struct ReportList;
struct Scene;
struct View3D;
+struct ViewContext;
+struct bConstraint;
+struct bContext;
+struct bPoseChannel;
struct wmEvent;
struct wmKeyConfig;
struct wmKeyMap;
@@ -82,8 +91,10 @@ typedef enum eParentType {
PAR_TRIA
} eParentType;
+#ifdef __RNA_TYPES_H__
extern struct EnumPropertyItem prop_clear_parent_types[];
extern struct EnumPropertyItem prop_make_parent_types[];
+#endif
int ED_object_parent_set(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob,
struct Object *par, int partype, int xmirror, int keep_transform);
@@ -123,7 +134,8 @@ void ED_object_location_from_view(struct bContext *C, float loc[3]);
void ED_object_rotation_from_view(struct bContext *C, float rot[3]);
void ED_object_base_init_transform(struct bContext *C, struct Base *base, const float loc[3], const float rot[3]);
float ED_object_new_primitive_matrix(struct bContext *C, struct Object *editob,
- const float loc[3], const float rot[3], float primmat[][4]);
+ const float loc[3], const float rot[3], float primmat[][4],
+ int apply_diameter);
void ED_object_add_generic_props(struct wmOperatorType *ot, int do_editmode);
int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float loc[3], float rot[3],
@@ -183,7 +195,7 @@ int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, int include
int ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v);
-/* ibject_select.c */
+/* object_select.c */
void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);
#ifdef __cplusplus
@@ -191,4 +203,3 @@ void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);
#endif
#endif /* __ED_OBJECT_H__ */
-
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h
index 527ebb6c3ef..9f42fd042c3 100644
--- a/source/blender/editors/include/ED_screen_types.h
+++ b/source/blender/editors/include/ED_screen_types.h
@@ -94,7 +94,7 @@ typedef struct AZone {
/* for draw */
short x1, y1, x2, y2;
/* for clip */
- rcti rect;
+ rcti rect;
} AZone;
/* actionzone type */
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 331a6ce6dc6..b2fadece72d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -37,6 +37,7 @@ struct BMEdge;
struct BMFace;
struct BMVert;
struct BPoint;
+struct Base;
struct BezTriple;
struct BezTriple;
struct BoundBox;
@@ -50,9 +51,12 @@ struct Nurb;
struct Object;
struct RegionView3D;
struct Scene;
+struct ScrArea;
struct View3D;
struct ViewContext;
struct bContext;
+struct bPoseChannel;
+struct bScreen;
struct bglMats;
struct rcti;
struct wmOperator;
@@ -80,24 +84,8 @@ typedef struct ViewDepths {
char damaged;
} ViewDepths;
-/* enum for passing to foreach functions to test RV3D_CLIPPING */
-typedef enum eV3DClipTest {
- V3D_CLIP_TEST_OFF = 0, /* clipping is off */
- V3D_CLIP_TEST_RV3D_CLIPPING = 1, /* clip single points */
- V3D_CLIP_TEST_REGION = 2 /* use for edges to check if both verts are in the view, but not RV3D_CLIPPING */
-} eV3DClipTest;
-
float *give_cursor(struct Scene *scene, struct View3D *v3d);
-int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
-
-void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]);
-void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]);
-void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]);
-void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
-void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
-
-void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist);
void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist);
@@ -119,7 +107,7 @@ void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
/* return values for ED_view3d_project_...() */
typedef enum {
- V3D_PROJ_RET_SUCCESS = 0,
+ V3D_PROJ_RET_OK = 0,
V3D_PROJ_RET_CLIP_NEAR = 1, /* can't avoid this when in perspective mode, (can't avoid) */
V3D_PROJ_RET_CLIP_BB = 2, /* bounding box clip - RV3D_CLIPPING */
V3D_PROJ_RET_CLIP_WIN = 3, /* outside window bounds */
@@ -133,50 +121,96 @@ typedef enum {
V3D_PROJ_TEST_CLIP_WIN = (1 << 1),
} eV3DProjTest;
+#define V3D_PROJ_TEST_CLIP_DEFAULT (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN)
+#define V3D_PROJ_TEST_ALL (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN)
+
+
+/* view3d_iterators.c */
+
+/* foreach iterators */
+void mesh_foreachScreenVert(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct BMVert *eve, const float screen_co[2], int index),
+ void *userData, const eV3DProjTest clip_flag);
+void mesh_foreachScreenEdge(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2],
+ int index),
+ void *userData, const eV3DProjTest clip_flag);
+void mesh_foreachScreenFace(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct BMFace *efa, const float screen_co[2], int index),
+ void *userData, const eV3DProjTest clip_flag);
+void nurbs_foreachScreenVert(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt,
+ int beztindex, const float screen_co[2]),
+ void *userData, const eV3DProjTest clip_flag);
+void mball_foreachScreenElem(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct MetaElem *ml, const float screen_co[2]),
+ void *userData, const eV3DProjTest clip_flag);
+void lattice_foreachScreenVert(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct BPoint *bp,
+ const float screen_co[2]),
+ void *userData, const eV3DProjTest clip_flag);
+void armature_foreachScreenBone(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct EditBone *ebone,
+ const float screen_co_a[2], const float screen_co_b[2]),
+ void *userData, const eV3DProjTest clip_flag);
+void pose_foreachScreenBone(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct bPoseChannel *pchan,
+ const float screen_co_a[2], const float screen_co_b[2]),
+ void *userData, const eV3DProjTest clip_flag);
+/* *** end iterators *** */
+
+
+/* view3d_project.c */
+void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]);
+void ED_view3d_project_float_v3_m4(struct ARegion *a, const float co[3], float r_co[3], float mat[4][4]);
+
+eV3DProjStatus ED_view3d_project_base(struct ARegion *ar, struct Base *base);
/* *** short *** */
eV3DProjStatus ED_view3d_project_short_ex(struct ARegion *ar, float perspmat[4][4], const int is_local,
- const float co[3], short r_co[2], eV3DProjTest flag);
-eV3DProjStatus ED_view3d_project_short_global(struct ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag);
-eV3DProjStatus ED_view3d_project_short_object(struct ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag);
+ const float co[3], short r_co[2], const eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_short_global(struct ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_short_object(struct ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag);
/* *** int *** */
eV3DProjStatus ED_view3d_project_int_ex(struct ARegion *ar, float perspmat[4][4], const int is_local,
- const float co[3], int r_co[2], eV3DProjTest flag);
-eV3DProjStatus ED_view3d_project_int_global(struct ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag);
-eV3DProjStatus ED_view3d_project_int_object(struct ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag);
+ const float co[3], int r_co[2], const eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_int_global(struct ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_int_object(struct ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag);
/* *** float *** */
eV3DProjStatus ED_view3d_project_float_ex(struct ARegion *ar, float perspmat[4][4], const int is_local,
- const float co[3], float r_co[2], eV3DProjTest flag);
-eV3DProjStatus ED_view3d_project_float_global(struct ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag);
-eV3DProjStatus ED_view3d_project_float_object(struct ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag);
+ const float co[3], float r_co[2], const eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_float_global(struct ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_float_object(struct ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag);
-void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]);
-void ED_view3d_project_float_v3_m4(struct ARegion *a, const float co[3], float r_co[3], float mat[4][4]);
+int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
+void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
+void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
+void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]);
+void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]);
+void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]);
+void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
+void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
+void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z);
+
+/* end */
-/* Base's get their own function since its a common operation */
-eV3DProjStatus ED_view3d_project_base(struct ARegion *ar, struct Base *base);
-void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z);
int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend);
int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend);
-void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift);
void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]);
-/* drawobject.c iterators */
-void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BMVert *eve, int x, int y, int index), void *userData, eV3DClipTest clipVerts);
-void mesh_foreachScreenEdge(struct ViewContext *vc, void (*func)(void *userData, struct BMEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, eV3DClipTest clipVerts);
-void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, struct BMFace *efa, int x, int y, int index), void *userData);
-void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData);
-void mball_foreachScreenElem(struct ViewContext *vc, void (*func)(void *userData, struct MetaElem *ml, int x, int y), void *userData);
-void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData);
-void armature_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1), void *userData);
-void pose_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1), void *userData);
-
-
void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect);
void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
int ED_view3d_clipping_test(struct RegionView3D *rv3d, const float vec[3], const int is_local);
@@ -189,7 +223,8 @@ float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]);
/* backbuffer select and draw support */
void view3d_validate_backbuf(struct ViewContext *vc);
struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
-unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict,
+unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2], int size,
+ unsigned int min, unsigned int max, float *dist, short strict,
void *handle, unsigned int (*indextest)(void *handle, unsigned int index));
unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
@@ -213,7 +248,7 @@ int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], cons
void view3d_get_transformation(const struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats);
/* XXX should move to BLI_math */
-int edge_inside_circle(int centx, int centy, int rad, int x1, int y1, int x2, int y2);
+int edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2]);
/* get 3d region from context, also if mouse is in header or toolbar */
struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C);
@@ -226,6 +261,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d);
int ED_view3d_scene_layer_set(int lay, const int *values, int *active);
int ED_view3d_context_activate(struct bContext *C);
+void ED_view3d_draw_offscreen_init(struct Scene *scene, struct View3D *v3d);
void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic, int colormanage_background);
@@ -257,6 +293,7 @@ struct BGpic *ED_view3D_background_image_new(struct View3D *v3d);
void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic);
void ED_view3D_background_image_clear(struct View3D *v3d);
+float ED_view3d_offset_distance(float mat[4][4], float ofs[3]);
float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit);
/* view matrix properties utilities */
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index ef7b8ed3a41..e400e44e944 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -94,7 +94,7 @@ DEF_ICON(LINK)
DEF_ICON(INLINK)
DEF_ICON(PLUGIN)
- /* various ui */
+ /* various ui */
DEF_ICON(HELP)
DEF_ICON(GHOST_ENABLED)
DEF_ICON(COLOR)
@@ -450,8 +450,8 @@ DEF_ICON(FORCE_CURVE)
DEF_ICON(FORCE_BOID)
DEF_ICON(FORCE_TURBULENCE)
DEF_ICON(FORCE_DRAG)
+DEF_ICON(FORCE_SMOKEFLOW)
#ifndef DEF_ICON_BLANK_SKIP
- DEF_ICON(BLANK672)
DEF_ICON(BLANK673)
DEF_ICON(BLANK674)
DEF_ICON(BLANK675)
@@ -799,13 +799,12 @@ DEF_ICON(NDOF_TRANS)
DEF_ICON(LAYER_USED)
DEF_ICON(LAYER_ACTIVE)
#ifndef DEF_ICON_BLANK_SKIP
+ /* available */
DEF_ICON(BLANK254)
DEF_ICON(BLANK255)
DEF_ICON(BLANK256)
DEF_ICON(BLANK257)
DEF_ICON(BLANK257b)
-
- /* available */
DEF_ICON(BLANK258)
DEF_ICON(BLANK259)
DEF_ICON(BLANK260)
@@ -890,8 +889,8 @@ DEF_ICON(FORWARD)
DEF_ICON(BLANK313)
DEF_ICON(BLANK314)
DEF_ICON(BLANK315)
- DEF_ICON(BLANK316)
#endif
+DEF_ICON(FILE_BACKUP)
DEF_ICON(DISK_DRIVE)
/* SHADING / TEXT */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 5d2709f0488..3645f13f27a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -106,9 +106,9 @@ typedef struct uiLayout uiLayout;
/* uiBlock->flag (controls) */
#define UI_BLOCK_LOOP 1
#define UI_BLOCK_REDRAW 2
-#define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
+#define UI_BLOCK_SEARCH_MENU 4
#define UI_BLOCK_NUMSELECT 8
-/*#define UI_BLOCK_ENTER_OK 16*/ /*UNUSED*/
+#define UI_BLOCK_NO_WIN_CLIP 16 /* don't apply window clipping */ /* was UI_BLOCK_ENTER_OK */
#define UI_BLOCK_CLIPBOTTOM 32
#define UI_BLOCK_CLIPTOP 64
#define UI_BLOCK_MOVEMOUSE_QUIT 128
@@ -807,7 +807,7 @@ void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *p
void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush);
-void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
+void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
PointerRNA *used_ptr, const char *used_propname, int active_layer);
void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 5f82dc3ff2d..ffe156da355 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -215,7 +215,11 @@ enum {
TH_NLA_META,
TH_NLA_META_SEL,
TH_NLA_SOUND,
- TH_NLA_SOUND_SEL
+ TH_NLA_SOUND_SEL,
+
+ TH_AXIS_X, /* X/Y/Z Axis */
+ TH_AXIS_Y,
+ TH_AXIS_Z
};
/* XXX WARNING: previous is saved in file, so do not change order! */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 0491e7e6c35..560a5a716c3 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -239,7 +239,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
bt->rect.xmax = bt->rect.xmin + i + block->bounds;
if (col == lastcol) {
- bt->rect.xmax = maxf(bt->rect.xmax, offset + block->minbounds);
+ bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds);
}
ui_check_but(bt); /* clips text again */
@@ -276,7 +276,7 @@ void ui_bounds_block(uiBlock *block)
block->rect.ymax += block->bounds;
}
- block->rect.xmax = block->rect.xmin + maxf(BLI_rctf_size_x(&block->rect), block->minbounds);
+ block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds);
/* hardcoded exception... but that one is annoying with larger safety */
bt = block->buttons.first;
@@ -528,7 +528,7 @@ static void ui_draw_links(uiBlock *block)
foundselectline = TRUE;
}
}
- }
+ }
/* Draw any active lines (lines with either button being hovered over).
* Do this last so they appear on top of inactive lines. */
@@ -540,7 +540,7 @@ static void ui_draw_links(uiBlock *block)
ui_draw_linkline(line, !foundselectline);
}
}
- }
+ }
}
}
@@ -582,7 +582,7 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut
if (line->from == newbut)
line->from = oldbut;
}
- }
+ }
/* check all other button links */
for (but = block->buttons.first; but; but = but->next) {
@@ -611,28 +611,28 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
if (ui_but_equals_old(oldbut, but)) {
if (oldbut->active) {
#if 0
-// but->flag= oldbut->flag;
+// but->flag = oldbut->flag;
#else
/* exception! redalert flag can't be update from old button.
* perhaps it should only copy specific flags rather than all. */
-// but->flag= (oldbut->flag & ~UI_BUT_REDALERT) | (but->flag & UI_BUT_REDALERT);
+// but->flag = (oldbut->flag & ~UI_BUT_REDALERT) | (but->flag & UI_BUT_REDALERT);
#endif
-// but->active= oldbut->active;
-// but->pos= oldbut->pos;
-// but->ofs= oldbut->ofs;
-// but->editstr= oldbut->editstr;
-// but->editval= oldbut->editval;
-// but->editvec= oldbut->editvec;
-// but->editcoba= oldbut->editcoba;
-// but->editcumap= oldbut->editcumap;
-// but->selsta= oldbut->selsta;
-// but->selend= oldbut->selend;
-// but->softmin= oldbut->softmin;
-// but->softmax= oldbut->softmax;
-// but->linkto[0]= oldbut->linkto[0];
-// but->linkto[1]= oldbut->linkto[1];
+// but->active = oldbut->active;
+// but->pos = oldbut->pos;
+// but->ofs = oldbut->ofs;
+// but->editstr = oldbut->editstr;
+// but->editval = oldbut->editval;
+// but->editvec = oldbut->editvec;
+// but->editcoba = oldbut->editcoba;
+// but->editcumap = oldbut->editcumap;
+// but->selsta = oldbut->selsta;
+// but->selend = oldbut->selend;
+// but->softmin = oldbut->softmin;
+// but->softmax = oldbut->softmax;
+// but->linkto[0] = oldbut->linkto[0];
+// but->linkto[1] = oldbut->linkto[1];
found = 1;
-// oldbut->active= NULL;
+// oldbut->active = NULL;
/* move button over from oldblock to new block */
BLI_remlink(&oldblock->buttons, oldbut);
@@ -1150,9 +1150,15 @@ static void ui_is_but_sel(uiBut *but, double *value)
}
}
- if (is_push == 2) ;
- else if (is_push == 1) but->flag |= UI_SELECT;
- else but->flag &= ~UI_SELECT;
+ if (is_push == 2) {
+ /* pass */
+ }
+ else if (is_push == 1) {
+ but->flag |= UI_SELECT;
+ }
+ else {
+ but->flag &= ~UI_SELECT;
+ }
}
static uiBut *ui_find_inlink(uiBlock *block, void *poin)
@@ -1262,7 +1268,7 @@ void ui_delete_linkline(uiLinkLine *line, uiBut *but)
(*(link->ppoin))[b] = (*(link->ppoin))[a];
b++;
}
- }
+ }
(*(link->totlink))--;
}
}
@@ -1295,7 +1301,7 @@ void ui_get_but_vectorf(uiBut *but, float vec[3])
if (RNA_property_type(prop) == PROP_FLOAT) {
tot = RNA_property_array_length(&but->rnapoin, prop);
- tot = MIN2(tot, 3);
+ tot = min_ii(tot, 3);
for (a = 0; a < tot; a++)
vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a);
@@ -1340,7 +1346,7 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3])
int a;
tot = RNA_property_array_length(&but->rnapoin, prop);
- tot = MIN2(tot, 3);
+ tot = min_ii(tot, 3);
for (a = 0; a < tot; a++) {
RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]);
@@ -1383,7 +1389,7 @@ int ui_is_but_unit(uiBut *but)
return 0;
#endif
- /* for now disable time unit conversion */
+ /* for now disable time unit conversion */
if (unit_type == PROP_UNIT_TIME)
return 0;
@@ -1456,16 +1462,16 @@ double ui_get_but_val(uiBut *but)
case 'S': value = hsv[1]; break;
case 'V': value = hsv[2]; break;
}
- }
+ }
else if (but->pointype == UI_BUT_POIN_CHAR) {
value = *(char *)but->poin;
}
else if (but->pointype == UI_BUT_POIN_SHORT) {
value = *(short *)but->poin;
- }
+ }
else if (but->pointype == UI_BUT_POIN_INT) {
value = *(int *)but->poin;
- }
+ }
else if (but->pointype == UI_BUT_POIN_FLOAT) {
value = *(float *)but->poin;
}
@@ -1520,7 +1526,9 @@ void ui_set_but_val(uiBut *but, double value)
* so leave this unset */
value = UI_BUT_VALUE_UNSET;
}
- else if (but->pointype == 0) ;
+ else if (but->pointype == 0) {
+ /* pass */
+ }
else if (but->type == HSVSLI) {
float *fp, hsv[3];
@@ -1687,7 +1695,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
}
else if (buf && buf != str) {
/* string was too long, we have to truncate */
- memcpy(str, buf, MIN2(maxlen, buf_len + 1));
+ memcpy(str, buf, MIN2(maxlen, (size_t)buf_len + 1));
MEM_freeN(buf);
}
}
@@ -1713,8 +1721,9 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
BLI_strncpy(str, but->poin, maxlen);
return;
}
- else if (ui_but_anim_expression_get(but, str, maxlen))
- ; /* driver expression */
+ else if (ui_but_anim_expression_get(but, str, maxlen)) {
+ /* driver expression */
+ }
else {
/* number editing */
double value;
@@ -1891,8 +1900,9 @@ void ui_set_but_default(bContext *C, short all)
static double soft_range_round_up(double value, double max)
{
- /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
- double newmax = pow(10.0, ceil(log(value) / M_LN10));
+ /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
+ * 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)
return newmax * 0.2;
@@ -1904,8 +1914,9 @@ static double soft_range_round_up(double value, double max)
static double soft_range_round_down(double value, double max)
{
- /* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
- double newmax = pow(10.0, floor(log(value) / M_LN10));
+ /* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
+ * 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)
return newmax * 5.0;
@@ -1936,8 +1947,8 @@ void ui_set_but_soft_range(uiBut *but, double value)
RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep);
softmin = (imin == INT_MIN) ? -1e4 : imin;
softmax = (imin == INT_MAX) ? 1e4 : imax;
- /*step= istep;*/ /*UNUSED*/
- /*precision= 1;*/ /*UNUSED*/
+ /*step = istep;*/ /*UNUSED*/
+ /*precision = 1;*/ /*UNUSED*/
if (array_len >= 2) {
int value_range[2];
@@ -1953,8 +1964,8 @@ void ui_set_but_soft_range(uiBut *but, double value)
RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision);
softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin;
softmax = (fmax == FLT_MAX) ? (float)1e4 : fmax;
- /*step= fstep;*/ /*UNUSED*/
- /*precision= fprecision;*/ /*UNUSED*/
+ /*step = fstep;*/ /*UNUSED*/
+ /*precision = fprecision;*/ /*UNUSED*/
if (array_len >= 2) {
float value_range[2];
@@ -1995,7 +2006,7 @@ void ui_set_but_soft_range(uiBut *but, double value)
static void ui_free_link(uiLink *link)
{
- if (link) {
+ if (link) {
BLI_freelistN(&link->lines);
MEM_freeN(link);
}
@@ -2044,7 +2055,7 @@ void uiFreeBlock(const bContext *C, uiBlock *block)
uiBut *but;
while ( (but = block->buttons.first) ) {
- BLI_remlink(&block->buttons, but);
+ BLI_remlink(&block->buttons, but);
ui_free_but(C, but);
}
@@ -2245,7 +2256,7 @@ void ui_check_but(uiBut *but)
/* safety is 4 to enable small number buttons (like 'users') */
- // okwidth= -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
+ // okwidth = -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
/* name: */
switch (but->type) {
@@ -2387,7 +2398,7 @@ void uiBlockBeginAlign(uiBlock *block)
/* if other align was active, end it */
if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
- block->flag |= UI_BUT_ALIGN_DOWN;
+ block->flag |= UI_BUT_ALIGN_DOWN;
block->alignnr++;
/* buttons declared after this call will get this align nr */ // XXX flag?
@@ -2411,7 +2422,7 @@ void uiBlockEndAlign(uiBlock *block)
int ui_but_can_align(uiBut *but)
{
- return !ELEM3(but->type, LABEL, OPTION, OPTIONN);
+ return !ELEM4(but->type, LABEL, OPTION, OPTIONN, SEPR);
}
static void ui_block_do_align_but(uiBut *first, short nr)
@@ -2428,7 +2439,7 @@ static void ui_block_do_align_but(uiBut *first, short nr)
}
}
- /* rows==0: 1 row, cols==0: 1 column */
+ /* rows == 0: 1 row, cols == 0: 1 column */
/* 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) {
@@ -2472,7 +2483,9 @@ static void ui_block_do_align_but(uiBut *first, short nr)
if (rows > 0) {
uiBut *bt = but;
while (bt && bt->alignnr == nr) {
- if (bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next) == 0) break;
+ if (bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next) == 0) {
+ break;
+ }
bt = bt->next;
}
if (bt == NULL || bt->alignnr != nr) flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT;
@@ -2706,9 +2719,8 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
}
/* keep track of UI_interface.h */
- if (ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)) ;
- else if (ELEM(but->type, SCROLL, SEPR /* , FTPREVIEW */ )) ;
- else if (but->type >= SEARCH_MENU) ;
+ if (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR /* , FTPREVIEW */)) {}
+ else if (but->type >= SEARCH_MENU) {}
else but->flag |= UI_BUT_UNDO;
BLI_addtail(&block->buttons, but);
@@ -2742,7 +2754,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str,
- int x, int y, short width, short height,
+ int x, int y, short width, short height,
PointerRNA *ptr, PropertyRNA *prop, int index,
float min, float max, float a1, float a2, const char *tip)
{
@@ -3861,12 +3873,41 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...)
}
}
else if (ELEM3(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) {
+ PointerRNA *ptr = NULL;
+ PropertyRNA *prop = NULL;
+ int value = 0;
+
+ /* get the enum property... */
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
+ /* enum property */
+ ptr = &but->rnapoin;
+ prop = but->rnaprop;
+ value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
+ }
+ else if (but->optype) {
+ PointerRNA *opptr = uiButGetOperatorPtrRNA(but);
+ wmOperatorType *ot = but->optype;
+
+ /* if the default property of the operator is enum and it is set,
+ * fetch the tooltip of the selected value so that "Snap" and "Mirror"
+ * operator menus in the Anim Editors will show tooltips for the different
+ * operations instead of the meaningless generic operator tooltip
+ */
+ if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) {
+ if (RNA_struct_contains_property(opptr, ot->prop)) {
+ ptr = opptr;
+ prop = ot->prop;
+ value = RNA_property_enum_get(opptr, ot->prop);
+ }
+ }
+ }
+
+ /* get strings from matching enum item */
+ if (ptr && prop) {
if (!item) {
int i;
- int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
- RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &items, &totitems, &free_items);
-
+
+ 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)
break;
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 2692bf54900..80003222faa 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -166,13 +166,13 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
/* get current color, needs to be outside of gpuBegin/End */
gpuGetCurrentColor4fv(color);
- /* 'shade' defines strength of shading */
- coltop[0] = minf(1.0f, color[0] + shadetop);
- coltop[1] = minf(1.0f, color[1] + shadetop);
- coltop[2] = minf(1.0f, color[2] + shadetop);
- coldown[0] = maxf(0.0f, color[0] + shadedown);
- coldown[1] = maxf(0.0f, color[1] + shadedown);
- coldown[2] = maxf(0.0f, color[2] + shadedown);
+ /* 'shade' defines strength of shading */
+ coltop[0] = min_ff(1.0f, color[0] + shadetop);
+ coltop[1] = min_ff(1.0f, color[1] + shadetop);
+ coltop[2] = min_ff(1.0f, color[2] + shadetop);
+ coldown[0] = max_ff(0.0f, color[0] + shadedown);
+ coldown[1] = max_ff(0.0f, color[1] + shadedown);
+ coldown[2] = max_ff(0.0f, color[2] + shadedown);
glShadeModel(GL_SMOOTH);
gpuBegin(mode);
@@ -275,13 +275,13 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* get current color, needs to be outside of gpuBegin/End */
gpuGetCurrentColor4fv(color);
- /* 'shade' defines strength of shading */
- colLeft[0] = minf(1.0f, color[0] + shadeLeft);
- colLeft[1] = minf(1.0f, color[1] + shadeLeft);
- colLeft[2] = minf(1.0f, color[2] + shadeLeft);
- colRight[0] = maxf(0.0f, color[0] + shadeRight);
- colRight[1] = maxf(0.0f, color[1] + shadeRight);
- colRight[2] = maxf(0.0f, color[2] + shadeRight);
+ /* 'shade' defines strength of shading */
+ colLeft[0] = min_ff(1.0f, color[0] + shadeLeft);
+ colLeft[1] = min_ff(1.0f, color[1] + shadeLeft);
+ colLeft[2] = min_ff(1.0f, color[2] + shadeLeft);
+ colRight[0] = max_ff(0.0f, color[0] + shadeRight);
+ colRight[1] = max_ff(0.0f, color[1] + shadeRight);
+ colRight[2] = max_ff(0.0f, color[2] + shadeRight);
glShadeModel(GL_SMOOTH);
gpuBegin(mode);
@@ -510,7 +510,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
if (G.selfont && BKE_vfont_is_builtin(G.selfont) == FALSE) {
/* Is the font file packed, if so then use the packed file */
if (G.selfont->packedfile) {
- pf = G.selfont->packedfile;
+ pf = G.selfont->packedfile;
FTF_SetFont(pf->data, pf->size, 14.0);
}
else {
@@ -608,7 +608,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
ey -= buth;
sx = rect->xmin;
ex = rect->xmin + butw;
- }
+ }
glShadeModel(GL_FLAT);
/* Return Font Settings to original */
@@ -641,7 +641,7 @@ static void draw_scope_end(const rctf *rect, GLint *scissor)
/* scale widget */
scaler_x1 = rect->xmin + BLI_rctf_size_x(rect) / 2 - SCOPE_RESIZE_PAD;
- scaler_x2 = rect->xmin + BLI_rctf_size_y(rect) / 2 + SCOPE_RESIZE_PAD;
+ scaler_x2 = rect->xmin + BLI_rctf_size_x(rect) / 2 + SCOPE_RESIZE_PAD;
gpuImmediateFormat_C4_V2(); // DOODLE: fixed number of colored lines
gpuBegin(GL_LINES);
@@ -1656,17 +1656,15 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
&scopes->undist_marker, scopes->use_track_mask,
width, height, scopes->track_pos);
- if (tmpibuf->rect_float)
- IMB_rect_from_float(tmpibuf);
-
- /* XXX: for debug only
- * tmpibuf->ftype = PNG;
- * IMB_saveiff(tmpibuf, "sample.png", IB_rect); */
+ if (tmpibuf) {
+ if (tmpibuf->rect_float)
+ IMB_rect_from_float(tmpibuf);
- if (tmpibuf->rect)
- scopes->track_preview = tmpibuf;
- else
- IMB_freeImBuf(tmpibuf);
+ if (tmpibuf->rect)
+ scopes->track_preview = tmpibuf;
+ else
+ IMB_freeImBuf(tmpibuf);
+ }
}
if (!ok && scopes->track_preview) {
@@ -1772,7 +1770,7 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
gpuEnd();
- /* bottom quad */
+ /* bottom quad */
gpuBegin(GL_TRIANGLE_FAN);
gpuColor4x(CPACK_BLACK, alpha);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 60e4c2aa90f..5f01255b8e0 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -279,12 +279,7 @@ static int ui_is_a_warp_but(uiBut *but)
static float ui_mouse_scale_warp_factor(const short shift)
{
- if (U.uiflag & USER_CONTINUOUS_MOUSE) {
- return shift ? 0.05f : 1.0f;
- }
- else {
- return 1.0f;
- }
+ return shift ? 0.05f : 1.0f;
}
static void ui_mouse_scale_warp(uiHandleButtonData *data,
@@ -292,16 +287,11 @@ static void ui_mouse_scale_warp(uiHandleButtonData *data,
float *r_mx, float *r_my,
const short shift)
{
- if (U.uiflag & USER_CONTINUOUS_MOUSE) {
- 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);
- }
- else {
- *r_mx = mx;
- *r_my = my;
- }
+ 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);
}
/* file selectors are exempt from utf-8 checks */
@@ -704,7 +694,9 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event)
BLI_rcti_rctf_copy(&rect, &but->rect);
- if (but->imb) ; /* use button size itself */
+ if (but->imb) {
+ /* use button size itself */
+ }
else if (but->flag & UI_ICON_LEFT) {
rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
@@ -772,7 +764,7 @@ static void ui_delete_active_linkline(uiBlock *block)
(*(link->ppoin))[b] = (*(link->ppoin))[a];
b++;
}
- }
+ }
(*(link->totlink))--;
}
}
@@ -1061,7 +1053,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
break;
case HSVSLI:
break;
- case TOG3:
+ case TOG3:
ui_apply_but_TOG3(C, but, data);
break;
case MENU:
@@ -1107,10 +1099,10 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
case INLINK:
ui_apply_but_LINK(C, but, data);
break;
- case BUT_IMAGE:
+ case BUT_IMAGE:
ui_apply_but_IMAGE(C, but, data);
break;
- case HISTOGRAM:
+ case HISTOGRAM:
ui_apply_but_HISTOGRAM(C, but, data);
break;
case WAVEFORM:
@@ -1184,7 +1176,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* numeric value */
if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) {
- if (but->poin == NULL && but->rnapoin.data == NULL) ;
+ if (but->poin == NULL && but->rnapoin.data == NULL) {
+ /* pass */
+ }
else if (mode == 'c') {
ui_get_but_string(but, buf, sizeof(buf));
WM_clipboard_text_set(buf, 0);
@@ -1205,7 +1199,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
else if (but->type == COLOR) {
float rgb[3];
- if (but->poin == NULL && but->rnapoin.data == NULL) ;
+ if (but->poin == NULL && but->rnapoin.data == NULL) {
+ /* pass */
+ }
else if (mode == 'c') {
ui_get_but_vectorf(but, rgb);
@@ -1234,7 +1230,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
else if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
uiHandleButtonData *active_data = but->active;
- if (but->poin == NULL && but->rnapoin.data == NULL) ;
+ if (but->poin == NULL && but->rnapoin.data == NULL) {
+ /* pass */
+ }
else if (mode == 'c') {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR);
@@ -1291,6 +1289,71 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
}
+/* ************************ password text ******************************
+ *
+ * Functions to convert password strings that should not be displayed
+ * to asterisk representation (e.g. mysecretpasswd -> *************)
+ *
+ * It converts every UTF-8 character to an asterisk, and also remaps
+ * the cursor position and selection start/end.
+ *
+ * Note: remaping is used, because password could contain UTF-8 characters.
+ *
+ */
+
+static int ui_text_position_from_hidden(uiBut *but, int pos)
+{
+ const char *strpos;
+ int i;
+
+ for (i = 0, strpos = but->drawstr; i < pos; i++)
+ strpos = BLI_str_find_next_char_utf8(strpos, NULL);
+
+ return (strpos - but->drawstr);
+}
+
+static int ui_text_position_to_hidden(uiBut *but, int pos)
+{
+ return BLI_strnlen_utf8(but->drawstr, pos);
+}
+
+void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore)
+{
+ if (!(but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_PASSWORD))
+ return;
+
+ if (restore) {
+ /* restore original string */
+ BLI_strncpy(but->drawstr, password_str, UI_MAX_DRAW_STR);
+
+ /* remap cursor positions */
+ if (but->pos >= 0) {
+ but->pos = ui_text_position_from_hidden(but, but->pos);
+ but->selsta = ui_text_position_from_hidden(but, but->selsta);
+ but->selend = ui_text_position_from_hidden(but, but->selend);
+ }
+ }
+ else {
+ /* convert text to hidden test using asterisks (e.g. pass -> ****) */
+ int i, len = BLI_strlen_utf8(but->drawstr);
+
+ /* remap cursor positions */
+ if (but->pos >= 0) {
+ but->pos = ui_text_position_to_hidden(but, but->pos);
+ but->selsta = ui_text_position_to_hidden(but, but->selsta);
+ but->selend = ui_text_position_to_hidden(but, but->selend);
+ }
+
+ /* save original string */
+ BLI_strncpy(password_str, but->drawstr, UI_MAX_DRAW_STR);
+
+ for (i = 0; i < len; i++)
+ but->drawstr[i] = '*';
+ but->drawstr[i] = '\0';
+ }
+}
+
+
/* ************* in-button text selection/editing ************* */
@@ -1314,13 +1377,15 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
uiStyle *style = UI_GetStyle(); // XXX pass on as arg
uiFontStyle *fstyle = &style->widget;
int startx = but->rect.xmin;
- char *origstr;
+ char *origstr, password_str[UI_MAX_DRAW_STR];
uiStyleFontSet(fstyle);
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ ui_button_text_password_hide(password_str, but, FALSE);
+
origstr = MEM_callocN(sizeof(char) * data->maxlen, "ui_textedit origstr");
BLI_strncpy(origstr, but->drawstr, data->maxlen);
@@ -1335,7 +1400,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
}
/* mouse dragged outside the widget to the left */
- if (x < startx && but->ofs > 0) {
+ if (x < startx && but->ofs > 0) {
int i = but->ofs;
origstr[but->ofs] = 0;
@@ -1399,6 +1464,8 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ ui_button_text_password_hide(password_str, but, TRUE);
+
MEM_freeN(origstr);
}
@@ -1579,7 +1646,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
but->pos -= step;
changed = 1;
}
- }
+ }
}
return changed;
@@ -1668,7 +1735,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
if (cut)
if ((but->selend - but->selsta) > 0)
changed = ui_textedit_delete_selection(but, data);
- }
+ }
return changed;
}
@@ -1707,7 +1774,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
/* optional searchbox */
if (but->type == SEARCH_MENU) {
data->searchbox = ui_searchbox_create(C, data->region, but);
- ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */
+ ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */
}
ui_check_but(but);
@@ -2149,7 +2216,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
}
/* 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_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -2246,7 +2313,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
ED_region_tag_redraw(data->region);
if (event->val == KM_PRESS) {
- if (ISHOTKEY(event->type)) {
+ if (ISHOTKEY(event->type)) {
if (WM_key_event_string(event->type)[0])
ui_set_but_val(but, event->type);
@@ -2297,7 +2364,9 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) {
- if (but->dt == UI_EMBOSSN && !event->ctrl) ;
+ if (but->dt == UI_EMBOSSN && !event->ctrl) {
+ /* pass */
+ }
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
return WM_UI_HANDLER_BREAK;
@@ -2925,7 +2994,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
data->value = temp;
else
data->cancel = TRUE;
- }
+ }
else {
if (f < tempf) tempf -= 0.01f;
else tempf += 0.01f;
@@ -2951,7 +3020,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
- int mx, my /*, click= 0 */;
+ int mx, my /*, click = 0 */;
int retval = WM_UI_HANDLER_CONTINUE;
int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
@@ -3227,7 +3296,7 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && (int)but->a1 != UI_GRAD_SV)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3273,7 +3342,7 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && ((int)but->a1 != UI_GRAD_SV))
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
@@ -3299,7 +3368,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && (int)but->a1 != UI_GRAD_SV)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3326,7 +3395,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
case UI_GRAD_V:
hsv[2] += ndof->ry * sensitivity;
break;
- case UI_GRAD_V_ALT:
+ case UI_GRAD_V_ALT:
/* vertical 'value' strip */
/* exception only for value strip - use the range set in but->min/max */
@@ -3339,7 +3408,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && (int)but->a1 != UI_GRAD_SV)
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
@@ -3450,7 +3519,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
data->ungrab_mval[0] = mx_fl;
data->ungrab_mval[1] = my_fl;
{ /* clamp */
- const float radius = minf(BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)) / 2.0f;
+ const float radius = min_ff(BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)) / 2.0f;
const float cent[2] = {BLI_rctf_cent_x(&but->rect), BLI_rctf_cent_y(&but->rect)};
const float len = len_v2v2(cent, data->ungrab_mval);
if (len > radius) {
@@ -3737,8 +3806,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&cumap->curr);
zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&cumap->curr);
- /* offsx= cumap->curr.xmin; */
- /* offsy= cumap->curr.ymin; */
+ /* offsx = cumap->curr.xmin; */
+ /* offsy = cumap->curr.ymin; */
if (snap) {
float d[2];
@@ -3894,7 +3963,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
changed = 1;
- /* reset cmp back to the curve points again, rather than drawing segments */
+ /* reset cmp back to the curve points again, rather than drawing segments */
cmp = cuma->curve;
/* find newly added point and make it 'sel' */
@@ -3998,7 +4067,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
}
else {
/* scale histogram values (dy / 10 for better control) */
- const float yfac = minf(powf(hist->ymax, 2.0f), 1.0f) * 0.5f;
+ const float yfac = min_ff(powf(hist->ymax, 2.0f), 1.0f) * 0.5f;
hist->ymax += (dy * 0.1f) * yfac;
/* 0.1 allows us to see HDR colors up to 10 */
@@ -4068,7 +4137,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
Scopes *scopes = (Scopes *)but->poin;
/* rcti rect; */
int changed = 1;
- float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */
+ float /* dx, */ dy /* , yfac =1.0f */; /* UNUSED */
/* BLI_rcti_rctf_copy(&rect, &but->rect); */
@@ -4498,11 +4567,11 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
int kmi_id;
/* XXX this guess_opname can potentially return a different keymap than being found on adding later... */
- km = WM_keymap_guess_opname(C, but->optype->idname);
+ km = WM_keymap_guess_opname(C, but->optype->idname);
kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0);
kmi_id = kmi->id;
- /* copy properties, prop can be NULL for reset */
+ /* copy properties, prop can be NULL for reset */
if (prop)
prop = IDP_CopyProperty(prop);
WM_keymap_properties_reset(kmi, prop);
@@ -4510,14 +4579,13 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
/* update and get pointers again */
WM_keyconfig_update(wm);
- km = WM_keymap_guess_opname(C, but->optype->idname);
+ km = WM_keymap_guess_opname(C, but->optype->idname);
kmi = WM_keymap_item_find_id(km, kmi_id);
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
- uiBlockSetFlag(block, UI_BLOCK_RET_1);
uiBlockSetDirection(block, UI_CENTER);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
@@ -4855,14 +4923,10 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
if (but->flag & UI_BUT_DISABLED)
return WM_UI_HANDLER_CONTINUE;
- if ((data->state == BUTTON_STATE_HIGHLIGHT) &&
- /* check prevval because of modal operators [#24016],
- * modifier check is to allow Ctrl+C for copy.
- * if this causes other problems, remove this check and suffer the bug :) - campbell */
- ((event->prevval != KM_PRESS) || (ISKEYMODIFIER(event->prevtype)) || (event->type == EVT_DROP)))
- {
+ if ((data->state == BUTTON_STATE_HIGHLIGHT) || (event->type == EVT_DROP)) {
/* handle copy-paste */
if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && (event->ctrl || event->oskey)) {
+
ui_but_copy_paste(C, but, data, (event->type == CKEY) ? 'c' : 'v');
return WM_UI_HANDLER_BREAK;
}
@@ -4944,7 +5008,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
- }
+ }
else if (but->pointype && but->poin == NULL) {
/* there's a pointer needed */
BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str);
@@ -5976,38 +6040,22 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
switch (event->type) {
case MOUSEMOVE:
{
- /* if the mouse is over the button, do nothing */
- if (ui_mouse_inside_button(data->region, but, event->x, event->y)) {
- break;
- }
+ uiBut *bt;
- /* if the mouse is over the menu, also do nothing */
if (data->menu && data->menu->region) {
if (ui_mouse_inside_region(data->menu->region, event->x, event->y)) {
break;
}
- else {
- /* make a rectangle between the menu and the button that opened it,
- * this avoids any space between them exiting the popup. see [#29072] - campbell */
- rctf rct_all = but->rect;
- rctf rct_win;
-
- ui_block_to_window_fl(ar, block, &rct_all.xmin, &rct_all.ymin);
- ui_block_to_window_fl(ar, block, &rct_all.xmax, &rct_all.ymax);
-
- BLI_rctf_rcti_copy(&rct_win, &data->menu->region->winrct);
- BLI_rctf_union(&rct_all, &rct_win);
-
- if (BLI_rctf_isect_pt(&rct_all, event->x, event->y)) {
- break;
- }
- }
}
- if (but->type != COLOR) { /* exception */
- data->cancel = TRUE;
+ bt = ui_but_find_mouse_over(ar, event->x, event->y);
+
+ if (bt && bt->active != data) {
+ if (but->type != COLOR) { /* exception */
+ data->cancel = TRUE;
+ }
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- button_activate_state(C, but, BUTTON_STATE_EXIT);
break;
}
}
@@ -6017,7 +6065,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
}
else {
retval = ui_do_button(C, block, but, event);
- // retval= WM_UI_HANDLER_BREAK; XXX why ?
+ // retval = WM_UI_HANDLER_BREAK; XXX why ?
}
if (data->state == BUTTON_STATE_EXIT) {
@@ -6233,67 +6281,75 @@ 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 - 14)
+ if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE)
return 't';
if (block->flag & UI_BLOCK_CLIPBOTTOM)
- if (my < block->rect.ymin + 14)
+ if (my < block->rect.ymin + UI_MENU_SCROLL_MOUSE)
return 'b';
}
return 0;
}
-static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my)
+static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt)
{
- char test = ui_menu_scroll_test(block, my);
-
- if (test) {
- uiBut *b1 = block->buttons.first;
- uiBut *b2 = block->buttons.last;
- uiBut *bnext;
- uiBut *bprev;
- int dy = 0;
-
- /* get first and last visible buttons */
- while (b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED))
- b1 = ui_but_next(b1);
- while (b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED))
- b2 = ui_but_prev(b2);
- /* skips separators */
- bnext = ui_but_next(b1);
- bprev = ui_but_prev(b2);
+ 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;
+ }
+ 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;
+ }
+ }
+ 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 */
+ }
+
+ 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;
+
+ for (bt = block->buttons.first; bt; bt = bt->next)
+ ymax = max_ff(ymax, bt->rect.ymax);
+
+ 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;
+
+ for (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;
+ }
+
+ /* apply scroll offset */
+ for (bt = block->buttons.first; bt; bt = bt->next) {
+ bt->rect.ymin += dy;
+ bt->rect.ymax += dy;
+ }
+
+ /* set flags again */
+ ui_popup_block_scrolltest(block);
- if (bnext == NULL || bprev == NULL)
- return 0;
+ ED_region_tag_redraw(ar);
- if (test == 't') {
- /* bottom button is first button */
- if (b1->rect.ymin < b2->rect.ymin)
- dy = bnext->rect.ymin - b1->rect.ymin;
- /* bottom button is last button */
- else
- dy = bprev->rect.ymin - b2->rect.ymin;
- }
- else if (test == 'b') {
- /* bottom button is first button */
- if (b1->rect.ymin < b2->rect.ymin)
- dy = b1->rect.ymin - bnext->rect.ymin;
- /* bottom button is last button */
- else
- dy = b2->rect.ymin - bprev->rect.ymin;
- }
- if (dy) {
-
- for (b1 = block->buttons.first; b1; b1 = b1->next) {
- b1->rect.ymin -= dy;
- b1->rect.ymax -= dy;
- }
- /* set flags again */
- ui_popup_block_scrolltest(block);
-
- ED_region_tag_redraw(ar);
-
- return 1;
- }
+ return 1;
}
return 0;
@@ -6329,7 +6385,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
else if (event->type == TIMER) {
if (event->customdata == menu->scrolltimer)
- ui_menu_scroll(ar, block, my);
+ ui_menu_scroll(ar, block, my, NULL);
}
else {
/* for ui_mouse_motion_towards_block */
@@ -6370,7 +6426,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
break;
/* opening sublevels of pulldowns */
- case RIGHTARROWKEY:
+ case RIGHTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
PASS_EVENT_TO_PARENT_IF_NONACTIVE;
@@ -6424,8 +6480,10 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
but = ui_but_next(but);
}
- if (but)
+ if (but) {
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
+ ui_menu_scroll(ar, block, my, but);
+ }
}
if (!but) {
@@ -6451,6 +6509,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
if (bt) {
ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE);
+ ui_menu_scroll(ar, block, my, bt);
}
}
}
@@ -6557,7 +6616,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
case YKEY:
case ZKEY:
{
- if ((event->val == KM_PRESS) &&
+ if ((event->val == KM_PRESS || event->val == KM_DBL_CLICK) &&
(event->shift == FALSE) &&
(event->ctrl == FALSE) &&
(event->oskey == FALSE))
@@ -6611,7 +6670,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
}
- if (menu->menuretval) ;
+ if (menu->menuretval) {
+ /* pass */
+ }
else if (event->type == ESCKEY && event->val == KM_PRESS) {
/* esc cancels this and all preceding menus */
menu->menuretval = UI_RETURN_CANCEL;
@@ -6763,9 +6824,13 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa
/* now handle events for our own menu */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
if (submenu && submenu->menuretval) {
+ int do_ret_out_parent = (submenu->menuretval & UI_RETURN_OUT_PARENT);
retval = ui_handle_menu_return_submenu(C, event, menu);
- /* we may wan't to quit the submenu and handle the even in this menu */
- if ((retval == WM_UI_HANDLER_BREAK) && (submenu->menuretval & UI_RETURN_OUT_PARENT)) {
+ submenu = NULL; /* hint not to use this, it may be freed by call above */
+ (void)submenu;
+ /* we may wan't to quit the submenu and handle the even in this menu,
+ * if its important to use it, check 'data->menu' first */
+ if ((retval == WM_UI_HANDLER_BREAK) && do_ret_out_parent) {
retval = ui_handle_menu_event(C, event, menu, level);
}
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 99642f08ac5..a0aadedf7a5 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -144,7 +144,7 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int
new_icon = MEM_callocN(sizeof(Icon), "texicon");
new_icon->obj = NULL; /* icon is not for library object */
- new_icon->type = 0;
+ new_icon->type = 0;
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
di->type = type;
@@ -874,7 +874,7 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage *prv_img, enum eIco
if (G.debug & G_DEBUG)
printf("%s: no preview image for this ID: %s\n", __func__, id->name);
return;
- }
+ }
icon_create_rect(prv_img, size);
@@ -1013,8 +1013,8 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
if (!di) {
di = icon_create_drawinfo();
- icon->drawinfo = di;
- icon->drawinfo_free = UI_icons_free_drawinfo;
+ icon->drawinfo = di;
+ icon->drawinfo_free = UI_icons_free_drawinfo;
}
/* scale width and height according to aspect */
@@ -1025,13 +1025,13 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
/* vector icons use the uiBlock transformation, they are not drawn
* with untransformed coordinates like the other icons */
di->data.vector.func((int)x, (int)y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f);
- }
+ }
else if (di->type == ICON_TYPE_TEXTURE) {
icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y,
di->data.texture.w, di->data.texture.h, alpha, rgb);
}
else if (di->type == ICON_TYPE_BUFFER) {
- /* it is a builtin icon */
+ /* it is a builtin icon */
iimg = di->data.buffer.image;
if (!iimg->rect) return; /* something has gone wrong! */
@@ -1041,7 +1041,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
else if (di->type == ICON_TYPE_PREVIEW) {
PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj);
- if (pi) {
+ if (pi) {
/* no create icon on this level in code */
if (!pi->rect[size]) return; /* something has gone wrong! */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index b4b0686d6fc..540a9cc752b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -97,6 +97,11 @@ typedef enum {
UI_WTYPE_PROGRESSBAR
} uiWidgetTypeEnum;
+/* menu scrolling */
+#define UI_MENU_SCROLL_ARROW 12
+#define UI_MENU_SCROLL_MOUSE (UI_MENU_SCROLL_ARROW + 2)
+#define UI_MENU_SCROLL_PAD 4
+
/* panel limits */
#define UI_PANEL_MINX 100
#define UI_PANEL_MINY 70
@@ -160,7 +165,8 @@ struct uiBut {
int flag, drawflag;
eButType type;
eButPointerType pointype;
- short bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr;
+ short bit, bitnr, retval, strwidth, alignnr;
+ short ofs, pos, selsta, selend;
char *str;
char strdata[UI_MAX_NAME_STR];
@@ -170,7 +176,25 @@ struct uiBut {
char *poin;
float hardmin, hardmax, softmin, softmax;
- float a1, a2;
+
+ /* both these values use depends on the button type
+ * (polymorphic struct or union would be nicer for this stuff) */
+
+ /* (type == COLOR), Use UI_GRAD_* values.
+ * (type == NUM), Use to store RNA 'step' value, for dragging and click-step.
+ * (type == LABEL), Use (a1 == 1.0f) to use a2 as a blending factor (wow, this is imaginative!).
+ * (type == SCROLL) Use as scroll size.
+ * (type == SEARCH_MENU) Use as number or rows.
+ */
+ float a1;
+
+ /* (type == HSVCIRCLE ), Use to store the luminosity.
+ * (type == NUM), Use to store RNA 'precision' value, for dragging and click-step.
+ * (type == LABEL), If (a1 == 1.0f) use a2 as a blending factor.
+ * (type == SEARCH_MENU) Use as number or columns.
+ */
+ float a2;
+
float aspect;
unsigned char col[4];
@@ -484,6 +508,7 @@ extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut
extern void ui_button_active_free(const struct bContext *C, uiBut *but);
extern int ui_button_is_active(struct ARegion *ar);
extern int ui_button_open_menu_direction(uiBut *but);
+extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore);
/* interface_widgets.c */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index d692bf8e492..52d909a34c0 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -41,6 +41,7 @@
#include "BLI_string.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "BLF_translation.h"
@@ -1313,7 +1314,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
BLI_addtail(items_list, cis);
}
MEM_freeN(name);
- }
+ }
i++;
}
@@ -1376,7 +1377,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
/* turn button into search button */
if (searchprop) {
but->type = SEARCH_MENU;
- but->hardmax = MAX2(but->hardmax, 256);
+ but->hardmax = MAX2(but->hardmax, 256.0f);
but->rnasearchpoin = *searchptr;
but->rnasearchprop = searchprop;
but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
@@ -1449,6 +1450,11 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
menu.type = mt;
menu.layout = layout;
+
+ if (G.debug & G_DEBUG_WM) {
+ printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
+ }
+
mt->draw(C, &menu);
}
@@ -1708,7 +1714,7 @@ static void ui_litem_layout_row(uiLayout *litem)
int x, y, w, tot, totw, neww, itemw, minw, itemh, offset;
int fixedw, freew, fixedx, freex, flag = 0, lastw = 0;
- /* x= litem->x; */ /* UNUSED */
+ /* x = litem->x; */ /* UNUSED */
y = litem->y;
w = litem->w;
totw = 0;
@@ -1774,7 +1780,7 @@ static void ui_litem_layout_row(uiLayout *litem)
if (item->flag) {
/* fixed minimum size items */
- itemw = ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL);
+ itemw = ui_item_fit(minw, fixedx, fixedw, min_ii(w, fixedw), !item->next, litem->alignment, NULL);
fixedx += itemw;
}
else {
@@ -1932,8 +1938,8 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
return;
}
- flow->totcol = MAX2(litem->root->emw / maxw, 1);
- flow->totcol = MIN2(flow->totcol, totitem);
+ flow->totcol = max_ii(litem->root->emw / maxw, 1);
+ flow->totcol = min_ii(flow->totcol, totitem);
}
else
flow->totcol = flow->number;
@@ -1953,9 +1959,9 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
ui_item_size(item, &itemw, &itemh);
y -= itemh + style->buttonspacey;
- miny = MIN2(miny, y);
+ miny = min_ii(miny, y);
emy -= itemh;
- maxw = MAX2(itemw, maxw);
+ maxw = max_ii(itemw, maxw);
/* decide to go to next one */
if (col < flow->totcol - 1 && emy <= -emh) {
@@ -2007,7 +2013,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
emy -= itemh;
ui_item_position(item, x + offset, y, itemw, itemh);
y -= style->buttonspacey;
- miny = MIN2(miny, y);
+ miny = min_ii(miny, y);
/* decide to go to next one */
if (col < flow->totcol - 1 && emy <= -emh) {
@@ -2038,8 +2044,8 @@ static void ui_litem_estimate_absolute(uiLayout *litem)
ui_item_offset(item, &itemx, &itemy);
ui_item_size(item, &itemw, &itemh);
- minx = MIN2(minx, itemx);
- miny = MIN2(miny, itemy);
+ minx = min_ii(minx, itemx);
+ miny = min_ii(miny, itemy);
litem->w = MAX2(litem->w, itemx + itemw);
litem->h = MAX2(litem->h, itemy + itemh);
@@ -2064,11 +2070,11 @@ static void ui_litem_layout_absolute(uiLayout *litem)
ui_item_offset(item, &itemx, &itemy);
ui_item_size(item, &itemw, &itemh);
- minx = MIN2(minx, itemx);
- miny = MIN2(miny, itemy);
+ minx = min_ii(minx, itemx);
+ miny = min_ii(miny, itemy);
- totw = MAX2(totw, itemx + itemw);
- toth = MAX2(toth, itemy + itemh);
+ totw = max_ii(totw, itemx + itemw);
+ toth = max_ii(toth, itemy + itemh);
}
totw -= minx;
@@ -2516,8 +2522,12 @@ static void ui_item_align(uiLayout *litem, short nr)
if (!bitem->but->alignnr)
bitem->but->alignnr = nr;
}
- else if (item->type == ITEM_LAYOUT_ABSOLUTE) ;
- else if (item->type == ITEM_LAYOUT_OVERLAP) ;
+ else if (item->type == ITEM_LAYOUT_ABSOLUTE) {
+ /* pass */
+ }
+ else if (item->type == ITEM_LAYOUT_OVERLAP) {
+ /* pass */
+ }
else if (item->type == ITEM_LAYOUT_BOX) {
box = (uiLayoutItemBx *)item;
box->roundbox->alignnr = nr;
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index a8202a4f72d..f2c14d005af 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -216,7 +216,7 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3
/* set sample from accumulated values */
static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye)
{
- float col[4];
+ float col[3];
mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot);
eyedropper_color_set(C, eye, col);
}
@@ -807,8 +807,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
}
if (text == NULL) {
- BKE_reportf(op->reports, RPT_WARNING,
- "file: '%s' can't be opened", filepath);
+ BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
return OPERATOR_CANCELLED;
}
else {
@@ -820,8 +819,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
st->text = text;
}
else {
- BKE_reportf(op->reports, RPT_INFO,
- "See '%s' in the text editor", text->id.name + 2);
+ BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
}
txt_move_toline(text, line - 1, FALSE);
@@ -857,8 +855,8 @@ static int editsource_exec(bContext *C, wmOperator *op)
!BLI_ghashIterator_isDone(&ghi);
BLI_ghashIterator_step(&ghi))
{
- uiBut *but = BLI_ghashIterator_getKey(&ghi);
- if (but && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but)) {
+ uiBut *but_key = BLI_ghashIterator_getKey(&ghi);
+ if (but_key && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but_key)) {
but_store = BLI_ghashIterator_getValue(&ghi);
break;
}
@@ -872,14 +870,12 @@ static int editsource_exec(bContext *C, wmOperator *op)
but_store->py_dbg_ln);
}
else {
- BKE_report(op->reports, RPT_ERROR,
- "Active button isn't from a script, cant edit source.");
+ BKE_report(op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source");
ret = OPERATOR_CANCELLED;
}
}
else {
- BKE_report(op->reports, RPT_ERROR,
- "Active button match can't be found.");
+ BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found");
ret = OPERATOR_CANCELLED;
}
@@ -977,20 +973,20 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
uiStringInfo rna_ctxt = {BUT_GET_RNA_LABEL_CONTEXT, NULL};
if (!BLI_is_dir(root)) {
- BKE_report(op->reports, RPT_ERROR, "Please set your User Preferences' \"Translation Branches "
- "Directory\" path to a valid directory.");
+ BKE_report(op->reports, RPT_ERROR, "Please set your User Preferences' 'Translation Branches "
+ "Directory' path to a valid directory");
return OPERATOR_CANCELLED;
}
if (!WM_operatortype_find(EDTSRC_I18N_OP_NAME, 0)) {
- BKE_reportf(op->reports, RPT_ERROR, "Could not find operator \"%s\"! Please enable ui_translate addon "
- "in the User Preferences.", EDTSRC_I18N_OP_NAME);
+ BKE_reportf(op->reports, RPT_ERROR, "Could not find operator '%s'! Please enable ui_translate addon "
+ "in the User Preferences", EDTSRC_I18N_OP_NAME);
return OPERATOR_CANCELLED;
}
/* Try to find a valid po file for current language... */
edittranslation_find_po_file(root, uilng, popath, FILE_MAX);
/* printf("po path: %s\n", popath);*/
if (popath[0] == '\0') {
- BKE_reportf(op->reports, RPT_ERROR, "No valid po found for language '%s' under %s.", uilng, root);
+ BKE_reportf(op->reports, RPT_ERROR, "No valid po found for language '%s' under %s", uilng, root);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 249318c4818..3afdf3361d8 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -242,7 +242,7 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
}
}
}
- }
+ }
}
}
@@ -578,7 +578,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
if (!(panel->flag & PNL_CLOSEDX)) {
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
- /* itemrect smaller */
+ /* itemrect smaller */
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
@@ -627,7 +627,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* draw collapse icon */
UI_ThemeColor(TH_TEXT);
- /* itemrect smaller */
+ /* itemrect smaller */
itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
@@ -847,8 +847,8 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
pa_sizey = pa->ofsy + get_panel_size_y(pa);
}
- sizex = MAX2(sizex, pa_sizex);
- sizey = MIN2(sizey, pa_sizey);
+ sizex = max_ii(sizex, pa_sizex);
+ sizey = min_ii(sizey, pa_sizey);
}
}
@@ -864,7 +864,7 @@ static void ui_do_animate(const bContext *C, Panel *panel)
float fac;
fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME;
- fac = minf(sqrt(fac), 1.0f);
+ fac = min_ff(sqrt(fac), 1.0f);
/* for max 1 second, interpolate positions */
if (uiAlignPanelStep(sa, ar, fac, 0)) {
@@ -928,7 +928,7 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
panew->paneltab = NULL;
ED_region_tag_redraw(ar); /* the buttons panew were not made */
}
- }
+ }
}
/* re-align, possibly with animation */
@@ -1233,7 +1233,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
ED_region_tag_redraw(ar);
retval = WM_UI_HANDLER_BREAK;
- }
+ }
}
}
#endif
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 1d7d1d188ee..9e7e50d69ac 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -46,6 +46,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
+#include "BKE_global.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -215,7 +216,7 @@ static MenuData *decompose_menu_string(const char *str)
else {
menudata_add_item(md, nitem, nretval, nicon, 0);
nretval = md->nitems + 1;
- }
+ }
nitem = NULL;
nicon = 0;
@@ -674,7 +675,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
for (a = 0, fontw = 0, fonth = 0; a < data->totline; a++) {
w = BLF_width(data->fstyle.uifont_id, data->lines[a]);
- fontw = MAX2(fontw, w);
+ fontw = max_ff(fontw, (float)w);
fonth += (a == 0) ? h : h + TIP_MARGIN_Y;
}
@@ -1163,7 +1164,7 @@ ARegion *ui_searchbox_create(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_LOOP)
+ if (but->block->flag & UI_BLOCK_SEARCH_MENU)
data->noback = 1;
if (but->a1 > 0 && but->a2 > 0) {
@@ -1173,7 +1174,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
}
/* compute position */
- if (but->block->flag & UI_BLOCK_LOOP) {
+ if (but->block->flag & UI_BLOCK_SEARCH_MENU) {
/* this case is search menu inside other menu */
/* we copy region size */
@@ -1467,7 +1468,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
if (top == 0 && down == 0) {
if (dir1 == UI_LEFT || dir1 == UI_RIGHT) {
/* align with bottom of screen */
- // yof= ysize; (not with menu scrolls)
+ // yof = ysize; (not with menu scrolls)
}
}
@@ -1552,7 +1553,11 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar)
static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
{
int winx, winy;
-
+
+ if (block->flag & UI_BLOCK_NO_WIN_CLIP) {
+ return;
+ }
+
wm_window_get_size(window, &winx, &winy);
if (block->rect.xmin < MENU_SHADOW_SIDE)
@@ -1569,8 +1574,6 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
void ui_popup_block_scrolltest(uiBlock *block)
{
uiBut *bt;
- /* Knowing direction is necessary for multi-column menus... */
- int is_flip = (block->direction & UI_TOP) && !(block->flag & UI_BLOCK_NO_FLIP);
block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP);
@@ -1580,29 +1583,27 @@ void ui_popup_block_scrolltest(uiBlock *block)
if (block->buttons.first == block->buttons.last)
return;
- /* mark buttons that are outside boundary and the ones next to it for arrow(s) */
+ /* mark buttons that are outside boundary */
for (bt = block->buttons.first; bt; bt = bt->next) {
if (bt->rect.ymin < block->rect.ymin) {
bt->flag |= UI_SCROLLED;
block->flag |= UI_BLOCK_CLIPBOTTOM;
- /* make space for arrow */
- if (bt->rect.ymax < block->rect.ymin + 10) {
- if (is_flip && bt->next && bt->next->rect.ymin > bt->rect.ymin)
- bt->next->flag |= UI_SCROLLED;
- else if (!is_flip && bt->prev && bt->prev->rect.ymin > bt->rect.ymin)
- bt->prev->flag |= UI_SCROLLED;
- }
}
if (bt->rect.ymax > block->rect.ymax) {
bt->flag |= UI_SCROLLED;
block->flag |= UI_BLOCK_CLIPTOP;
- /* make space for arrow */
- if (bt->rect.ymin > block->rect.ymax - 10) {
- if (!is_flip && bt->next && bt->next->rect.ymax < bt->rect.ymax)
- bt->next->flag |= UI_SCROLLED;
- else if (is_flip && bt->prev && bt->prev->rect.ymax < bt->rect.ymax)
- bt->prev->flag |= UI_SCROLLED;
- }
+ }
+ }
+
+ /* 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)
+ bt->flag |= UI_SCROLLED;
+ }
+ if (block->flag & UI_BLOCK_CLIPTOP) {
+ if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW)
+ bt->flag |= UI_SCROLLED;
}
}
}
@@ -1954,7 +1955,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
else if (bt->str[0] == 'V') {
ui_set_but_val(bt, hsv[2]);
}
- }
+ }
ui_check_but(bt);
}
@@ -2257,13 +2258,11 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
show_picker = (but->block->flag & UI_BLOCK_POPUP) == 0;
}
- uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
-
copy_v3_v3(handle->retvec, but->editvec);
uiBlockPicker(block, handle->retvec, &but->rnapoin, but->rnaprop, show_picker);
- block->flag = UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1;
+ block->flag = UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1 | UI_BLOCK_MOVEMOUSE_QUIT;
uiBoundsBlock(block, 10);
block->block_event_func = ui_picker_small_wheel_cb;
@@ -2381,7 +2380,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
if (pup->popup) {
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_NUMSELECT | UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_NUMSELECT);
uiBlockSetDirection(block, direction);
/* offset the mouse position, possibly based on earlier selection */
@@ -2400,7 +2399,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
* on the first item */
offset[0] = 0;
for (bt = block->buttons.first; bt; bt = bt->next)
- offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)));
+ offset[0] = min_ii(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)));
offset[1] = 1.5 * UI_UNIT_Y;
}
@@ -2510,6 +2509,9 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash = ui_popup_menu_hash(title);
pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+
+ /* note, this intentionally differs from the menu & submenu default because many operators
+ * use popups like this to select one of their options - where having invoke doesn't make sense */
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
/* create in advance so we can let buttons point to retval already */
@@ -2678,14 +2680,18 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
ds = BLI_dynstr_new();
for (report = reports->list.first; report; report = report->next) {
- if (report->type < reports->printlevel)
- ; /* pass */
- else if (report->type >= RPT_ERROR)
+ if (report->type < reports->printlevel) {
+ /* pass */
+ }
+ else if (report->type >= RPT_ERROR) {
BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message);
- else if (report->type >= RPT_WARNING)
+ }
+ else if (report->type >= RPT_WARNING) {
BLI_dynstr_appendf(ds, "Warning %%i%d%%t|%s", ICON_ERROR, report->message);
- else if (report->type >= RPT_INFO)
+ }
+ else if (report->type >= RPT_INFO) {
BLI_dynstr_appendf(ds, "Info %%i%d%%t|%s", ICON_INFO, report->message);
+ }
}
str = BLI_dynstr_get_cstring(ds);
@@ -2717,6 +2723,10 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
menu.layout = layout;
menu.type = mt;
+ if (G.debug & G_DEBUG_WM) {
+ printf("%s: opening menu \"%s\"\n", __func__, idname);
+ }
+
mt->draw(C, &menu);
uiPupMenuEnd(C, pup);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index acf7712f97b..7e7db6aeaaa 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -348,7 +348,7 @@ void uiStyleInit(void)
#else
font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
#endif
- }
+ }
else {
font->blf_id = BLF_load(font->filename);
if (font->blf_id == -1)
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 5f9722d0ec0..84ae3a8f57d 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -175,7 +175,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
idptr = RNA_property_pointer_get(&template.ptr, template.prop);
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
/* preview thumbnails */
if (template.prv_rows > 0 && template.prv_cols > 0) {
@@ -199,7 +199,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
uiBoundsBlock(block, 6);
- uiBlockSetDirection(block, UI_DOWN);
+ uiBlockSetDirection(block, UI_DOWN);
uiEndBlock(C, block);
/* give search-field focus */
@@ -400,7 +400,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
//text_idbutton(id, name);
name[0] = '\0';
- but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
+ but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type));
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT);
@@ -580,7 +580,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
- if (!propType || RNA_property_type(propType) != PROP_ENUM) {
+ if (!propType || RNA_property_type(propType) != PROP_ENUM) {
RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename);
return;
}
@@ -1221,7 +1221,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
else ma = (Material *)pparent;
/* Create RNA Pointer */
- RNA_pointer_create(id, &RNA_Material, ma, &material_ptr);
+ RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr);
col = uiLayoutColumn(row, TRUE);
uiLayoutSetScaleX(col, 1.5);
@@ -1281,7 +1281,7 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
if (colorband_element_add(coba, pos)) {
rna_update_cb(C, cb_v, NULL);
- ED_undo_push(C, "Add colorband");
+ ED_undo_push(C, "Add colorband");
}
}
@@ -1405,7 +1405,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
uiItemR(layout, &ptr, "color", 0, "", ICON_NONE);
}
- bt = uiDefButS(block, MENU, 0, TIP_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"),
+ bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"),
xs + 10.0f * unit, butr->ymin + UI_UNIT_Y, unit * 4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0,
TIP_("Set interpolation between color stops"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
@@ -1951,11 +1951,12 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
MEM_freeN(cb);
}
-/********************* ColorWheel Template ************************/
+/********************* ColorPicker Template ************************/
#define WHEEL_SIZE 100
-void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic)
+/* This template now follows User Preference for type - name is not correct anymore... */
+void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
uiBlock *block = uiLayoutGetBlock(layout);
@@ -1970,10 +1971,24 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
- col = uiLayoutColumn(layout, FALSE);
+ col = uiLayoutColumn(layout, TRUE);
row = uiLayoutRow(col, TRUE);
- but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, "");
+ switch (U.color_picker_type) {
+ case USER_CP_CIRCLE:
+ but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, "");
+ break;
+ case USER_CP_SQUARE_SV:
+ but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, UI_GRAD_SV, 0, "");
+ break;
+ case USER_CP_SQUARE_HS:
+ but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, UI_GRAD_HS, 0, "");
+ break;
+ case USER_CP_SQUARE_HV:
+ but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, UI_GRAD_HV, 0, "");
+ break;
+ }
+
if (lock) {
but->flag |= UI_BUT_COLOR_LOCK;
@@ -1989,10 +2004,29 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
if (cubic)
but->flag |= UI_BUT_COLOR_CUBIC;
- uiItemS(row);
- if (value_slider)
- uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, -1, softmin, softmax, UI_GRAD_V_ALT, 0, "");
+ if (value_slider) {
+
+ switch (U.color_picker_type) {
+ case USER_CP_CIRCLE:
+ uiItemS(row);
+ uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, -1, softmin, softmax, UI_GRAD_V_ALT, 0, "");
+ break;
+ case USER_CP_SQUARE_SV:
+ uiItemS(col);
+ uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, -1, softmin, softmax, UI_GRAD_SV + 3, 0, "");
+ break;
+ case USER_CP_SQUARE_HS:
+ uiItemS(col);
+ uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, -1, softmin, softmax, UI_GRAD_HS + 3, 0, "");
+ break;
+ case USER_CP_SQUARE_HV:
+ uiItemS(col);
+ uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, -1, softmin, softmax, UI_GRAD_HV + 3, 0, "");
+ break;
+ }
+
+ }
}
/********************* Layer Buttons Template ************************/
@@ -2744,7 +2778,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
TIP_("Stop screencast"));
if (screen->animtimer)
- uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, TIP_("Anim Player"), 0, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
+ uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
TIP_("Stop animation playback"));
}
@@ -2774,8 +2808,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
block = uiLayoutGetBlock(ui_abs);
width = BLF_width(style->widget.uifont_id, report->message);
- width = MIN2(rti->widthfac * width, width);
- width = MAX2(width, 10);
+ width = min_ii((int)(rti->widthfac * width), width);
+ width = max_ii(width, 10);
/* make a box around the report to make it stand out */
uiBlockBeginAlign(block);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 28599f8386f..bef8fff4ae3 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -344,7 +344,7 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) ||
(roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2;
- minsize = mini(BLI_rcti_size_x(rect) * hnum,
+ minsize = min_ii(BLI_rcti_size_x(rect) * hnum,
BLI_rcti_size_y(rect) * vnum);
if (2.0f * rad > minsize)
@@ -490,7 +490,7 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha
float centx, centy, sizex, sizey, minsize;
int a, i1 = 0, i2 = 1;
- minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
+ minsize = min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -500,16 +500,16 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha
if (where == 'r') {
centx = (float)rect->xmax - 0.5f * minsize;
sizex = -sizex;
- }
+ }
else if (where == 't') {
centy = (float)rect->ymax - 0.5f * minsize;
sizey = -sizey;
i2 = 0; i1 = 1;
- }
+ }
else if (where == 'b') {
sizex = -sizex;
i2 = 0; i1 = 1;
- }
+ }
for (a = 0; a < 3; a++) {
tria->vec[a][0] = sizex * num_tria_vert[a][i1] + centx;
@@ -525,7 +525,7 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize
float centx, centy, sizex, sizey, minsize;
int a, i1 = 0, i2 = 1;
- minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
+ minsize = min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -535,16 +535,16 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize
if (where == 'r') {
centx = (float)rect->xmax - 0.5f * minsize;
sizex = -sizex;
- }
+ }
else if (where == 't') {
centy = (float)rect->ymax - 0.5f * minsize;
sizey = -sizey;
i2 = 0; i1 = 1;
- }
+ }
else if (where == 'b') {
sizex = -sizex;
i2 = 0; i1 = 1;
- }
+ }
for (a = 0; a < 16; a++) {
tria->vec[a][0] = sizex * scroll_circle_vert[a][i1] + centx;
@@ -589,12 +589,12 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
/* center position and size */
centx = rect->xmax - 0.5f * BLI_rcti_size_y(rect);
centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
- size = 0.4f * BLI_rcti_size_y(rect);
+ size = 0.4f * (float)BLI_rcti_size_y(rect);
/* XXX exception */
asp = ((float)BLI_rcti_size_x(rect)) / ((float)BLI_rcti_size_y(rect));
if (asp > 1.2f && asp < 2.6f)
- centx = rect->xmax - 0.3f * BLI_rcti_size_y(rect);
+ centx = rect->xmax - 0.4f * (float)BLI_rcti_size_y(rect);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * menu_tria_vert[a][0] + centx;
@@ -909,7 +909,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
aspect = but->block->aspect;
if (aspect != but->aspect) {
/* prevent scaling up icon in pupmenu */
- if (aspect < 1.0f) {
+ if (aspect < 1.0f) {
height = UI_DPI_ICON_SIZE;
aspect = 1.0f;
@@ -922,8 +922,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
/* calculate blend color */
if (ELEM4(but->type, TOG, ROW, TOGN, LISTROW)) {
- if (but->flag & UI_SELECT) ;
- else if (but->flag & UI_ACTIVE) ;
+ if (but->flag & UI_SELECT) {}
+ else if (but->flag & UI_ACTIVE) {}
else alpha = 0.5f;
}
@@ -1075,6 +1075,8 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, rcti *rect)
ui_text_clip_give_prev_off(but);
len = strlen(but->drawstr);
bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
+ if (bytes < 0)
+ bytes = 1;
but->drawstr[len - bytes] = 0;
}
@@ -1307,9 +1309,12 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* draws text and icons for buttons */
static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
{
- if (but == NULL) {
+ char password_str[UI_MAX_DRAW_STR];
+
+ if (but == NULL)
return;
- }
+
+ ui_button_text_password_hide(password_str, but, FALSE);
/* clip but->drawstr to fit in available space */
if (but->editstr && but->pos >= 0) {
@@ -1368,6 +1373,8 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
widget_draw_text(fstyle, wcol, but, rect);
}
+
+ ui_button_text_password_hide(password_str, but, TRUE);
}
@@ -1888,7 +1895,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
else if (direction == UI_DOWN) {
roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
rect->ymin -= 4.0;
- }
+ }
else if (direction == UI_TOP) {
roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
rect->ymax += 4.0;
@@ -1923,7 +1930,7 @@ void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rec
/* duplication of code... well, simple is better now */
const float centx = BLI_rcti_cent_x_fl(rect);
const float centy = BLI_rcti_cent_y_fl(rect);
- const float radius = (float)mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
+ const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
const float m_delta[2] = {mx - centx, my - centy};
const float dist_squared = len_squared_v2(m_delta);
@@ -1938,7 +1945,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
const float centx = BLI_rcti_cent_x_fl(rect);
const float centy = BLI_rcti_cent_y_fl(rect);
- float radius = (float)mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
+ float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
/* gouraud triangle fan */
const float *hsv_ptr = ui_block_hsv_get(but->block);
@@ -2024,7 +2031,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
/* draws in resolution of 20x4 colors */
void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha)
{
- const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f;
+ const float color_step = (type == UI_GRAD_H) ? 0.02f : 0.05f;
int a;
const float h = hsv[0], s = hsv[1], v = hsv[2];
float dx, dy, sx1, sx2, sy;
@@ -2081,7 +2088,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
/* old below */
- for (dx = 0.0f; dx < 1.0f; dx += color_step) {
+ for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
/* previous color */
copy_v3_v3(col0[0], col1[0]);
copy_v3_v3(col0[1], col1[1]);
@@ -2136,7 +2143,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect);
sy = rect->ymin;
- dy = BLI_rcti_size_y(rect) / 3.0;
+ dy = (float)BLI_rcti_size_y(rect) / 3.0f;
gpuBegin(GL_QUADS);
for (a = 0; a < 3; a++, sy += dy) {
@@ -2389,7 +2396,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
wtb.emboss = 0; /* only emboss once */
/* exception for progress bar */
- if (state & UI_SCROLL_NO_OUTLINE)
+ if (state & UI_SCROLL_NO_OUTLINE)
SWAP(short, outline, wtb.outline);
round_box_edges(&wtb, UI_CNR_ALL, slider, rad);
@@ -2413,7 +2420,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
if (state & UI_SCROLL_NO_OUTLINE)
SWAP(short, outline, wtb.outline);
- }
+ }
}
static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
@@ -2427,7 +2434,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
value = ui_get_but_val(but);
size = (but->softmax + but->a1 - but->softmin);
- size = MAX2(size, 2);
+ size = max_ff(size, 2.0f);
/* position */
rect1 = *rect;
@@ -2448,7 +2455,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
if (rect1.xmax > rect->xmax) {
rect1.xmax = rect->xmax;
- rect1.xmin = maxi(rect1.xmax - min, rect->xmin);
+ rect1.xmin = max_ii(rect1.xmax - min, rect->xmin);
}
}
}
@@ -2465,7 +2472,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
if (rect1.ymax > rect->ymax) {
rect1.ymax = rect->ymax;
- rect1.ymin = MAX2(rect1.ymax - min, rect->ymin);
+ rect1.ymin = max_ii(rect1.ymax - min, rect->ymin);
}
}
}
@@ -2652,7 +2659,7 @@ static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti
/* rounded */
round_box_edges(&wtb, UI_CNR_ALL, rect, 10.0f);
widgetbase_draw(&wtb, wcol);
- }
+ }
}
@@ -2687,8 +2694,8 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
widgetbase_draw(&wtb, wcol);
- /* text space */
- rect->xmax -= BLI_rcti_size_y(rect);
+ /* text space, arrows are about 0.6 height of button */
+ rect->xmax -= (6 * BLI_rcti_size_y(rect)) / 10;
}
static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -3119,14 +3126,10 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
if (but->active) {
int direction = ui_button_open_menu_direction(but);
- if (direction == UI_TOP)
- roundbox &= ~(UI_CNR_TOP_RIGHT|UI_CNR_TOP_LEFT);
- else if (direction == UI_DOWN)
- roundbox &= ~(UI_CNR_BOTTOM_RIGHT|UI_CNR_BOTTOM_LEFT);
- else if (direction == UI_LEFT)
- roundbox &= ~(UI_CNR_TOP_LEFT|UI_CNR_BOTTOM_LEFT);
- else if (direction == UI_RIGHT)
- roundbox &= ~(UI_CNR_TOP_RIGHT|UI_CNR_BOTTOM_RIGHT);
+ if (direction == UI_TOP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT);
+ else if (direction == UI_DOWN) roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
+ else if (direction == UI_LEFT) roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
+ else if (direction == UI_RIGHT) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
}
return roundbox;
@@ -3375,7 +3378,7 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
gpuCurrentColor3ubv((unsigned char *)wt->wcol.text);
UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v');
}
- }
+ }
}
uiWidgetColors *ui_tooltip_get_theme(void)
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 6f72f86818a..a845ed27d0d 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -59,6 +59,9 @@
#include "GPU_compatibility.h"
+/* global for themes */
+typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
+
static bTheme *theme_active = NULL;
static int theme_spacetype = SPACE_VIEW3D;
static int theme_regionid = RGN_TYPE_WINDOW;
@@ -234,7 +237,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = ts->shade2; break;
case TH_HILITE:
cp = ts->hilite; break;
-
+
case TH_GRID:
cp = ts->grid; break;
case TH_WIRE:
@@ -508,6 +511,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_NLA_SOUND_SEL:
cp = ts->nla_sound_sel;
break;
+
+ case TH_AXIS_X:
+ cp = btheme->tui.xaxis; break;
+ case TH_AXIS_Y:
+ cp = btheme->tui.yaxis; break;
+ case TH_AXIS_Z:
+ cp = btheme->tui.zaxis; break;
}
}
}
@@ -649,13 +659,18 @@ void ui_theme_init_default(void)
strcpy(btheme->name, "Default");
}
- UI_SetTheme(0, 0); // make sure the global used in this file is set
+ UI_SetTheme(0, 0); /* make sure the global used in this file is set */
/* UI buttons */
ui_widget_color_init(&btheme->tui);
+
btheme->tui.iconfile[0] = 0;
btheme->tui.panel.show_header = FALSE;
rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
+
+ rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255);
+ rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255);
+ rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255);
/* Bone Color Sets */
ui_theme_init_boneColorSets(btheme);
@@ -806,9 +821,9 @@ void ui_theme_init_default(void)
rgba_char_args_set_fl(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
rgba_char_args_set(btheme->tfile.text, 250, 250, 250, 255);
rgba_char_args_set(btheme->tfile.text_hi, 15, 15, 15, 255);
- rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); // bookmark/ui regions
- rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); // selected files
- rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
+ rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); /* bookmark/ui regions */
+ rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); /* selected files */
+ rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255); /* selected files */
rgba_char_args_set(btheme->tfile.grid, 250, 250, 250, 255);
rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255);
@@ -889,7 +904,7 @@ void ui_theme_init_default(void)
btheme->ttime = btheme->tv3d;
rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
- rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders
+ rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */
/* space node, re-uses syntax color storage */
btheme->tnode = btheme->tv3d;
@@ -930,7 +945,7 @@ void ui_theme_init_default(void)
void UI_SetTheme(int spacetype, int regionid)
{
- if (spacetype == 0) { // called for safety, when delete themes
+ if (spacetype == 0) { /* called for safety, when delete themes */
theme_active = U.themes.first;
theme_spacetype = SPACE_VIEW3D;
theme_regionid = RGN_TYPE_WINDOW;
@@ -948,7 +963,7 @@ bTheme *UI_GetTheme(void)
return U.themes.first;
}
-// for space windows only
+/* for space windows only */
void UI_ThemeColor(int colorid)
{
const unsigned char *cp;
@@ -965,7 +980,7 @@ void UI_ThemeAppendColor(int colorid)
gpuColor3ubv(cp);
}
-// plus alpha
+/* plus alpha */
void UI_ThemeColor4(int colorid)
{
const unsigned char *cp;
@@ -974,7 +989,7 @@ void UI_ThemeColor4(int colorid)
gpuCurrentColor4ubv(cp);
}
-// set the color with offset for shades
+/* set the color with offset for shades */
void UI_ThemeColorShade(int colorid, int offset)
{
int r, g, b;
@@ -1048,7 +1063,7 @@ void UI_ThemeAppendColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
gpuColor4ub(r, g, b, a);
}
-// blend between to theme colors, and set it
+/* blend between to theme colors, and set it */
void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
{
int r, g, b;
@@ -1081,7 +1096,7 @@ void UI_ThemeAppendColorBlend(int colorid1, int colorid2, float fac)
gpuColor3ub(r, g, b);
}
-// blend between to theme colors, shade it, and set it
+/* blend between to theme colors, shade it, and set it */
void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
{
int r, g, b;
@@ -1123,7 +1138,7 @@ void UI_ThemeAppendColorBlendShade(int colorid1, int colorid2, float fac, int of
gpuColor3ub(r, g, b);
}
-// blend between to theme colors, shade it, and set it
+/* blend between to theme colors, shade it, and set it */
void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
{
int r, g, b, a;
@@ -1147,28 +1162,26 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
}
-// get individual values, not scaled
+/* get individual values, not scaled */
float UI_GetThemeValuef(int colorid)
{
const unsigned char *cp;
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((float)cp[0]);
-
}
-// get individual values, not scaled
+/* get individual values, not scaled */
int UI_GetThemeValue(int colorid)
{
const unsigned char *cp;
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((int) cp[0]);
-
}
-// get the color, range 0.0-1.0
+/* get the color, range 0.0-1.0 */
void UI_GetThemeColor3fv(int colorid, float col[3])
{
const unsigned char *cp;
@@ -1190,7 +1203,7 @@ void UI_GetThemeColor4fv(int colorid, float col[4])
col[3] = ((float)cp[3]) / 255.0f;
}
-// get the color, range 0.0-1.0, complete with shading offset
+/* get the color, range 0.0-1.0, complete with shading offset */
void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
{
int r, g, b;
@@ -1229,7 +1242,7 @@ void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
col[2] = b;
}
-// get the color, in char pointer
+/* get the color, in char pointer */
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
{
const unsigned char *cp;
@@ -1240,7 +1253,7 @@ void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
col[2] = cp[2];
}
-// get the color, in char pointer
+/* get the color, in char pointer */
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
{
const unsigned char *cp;
@@ -1263,7 +1276,7 @@ void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
col[3] = cp[3];
}
-// blends and shades between two char color pointers
+/* blends and shades between two char color pointers */
void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
{
int r, g, b;
@@ -1296,7 +1309,7 @@ void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], in
col[2] = b;
}
-// get a 3 byte color, blended and shaded between two other char color pointers
+/* get a 3 byte color, blended and shaded between two other char color pointers */
void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3],
float fac, int offset)
{
@@ -1325,21 +1338,20 @@ void UI_ThemeClearColor(int colorid)
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
{
+ unsigned char col[3];
+
switch (axis) {
case 'X':
- dst_col[0] = src_col[0] > 219 ? 255 : src_col[0] + 36;
- dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
- dst_col[2] = src_col[2] < 26 ? 0 : src_col[2] - 26;
+ UI_GetThemeColor3ubv(TH_AXIS_X, col);
+ UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
break;
case 'Y':
- dst_col[0] = src_col[0] < 46 ? 0 : src_col[0] - 36;
- dst_col[1] = src_col[1] > 189 ? 255 : src_col[1] + 66;
- dst_col[2] = src_col[2] < 46 ? 0 : src_col[2] - 36;
+ UI_GetThemeColor3ubv(TH_AXIS_Y, col);
+ UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
break;
case 'Z':
- dst_col[0] = src_col[0] < 26 ? 0 : src_col[0] - 26;
- dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
- dst_col[2] = src_col[2] > 209 ? 255 : src_col[2] + 46;
+ UI_GetThemeColor3ubv(TH_AXIS_Z, col);
+ UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
break;
default:
BLI_assert(!"invalid axis arg");
@@ -1441,7 +1453,7 @@ void init_userdef_do_versions(void)
btheme->ttime = btheme->tv3d;
rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
- rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders
+ rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */
}
if (btheme->text.syntaxn[3] == 0) {
rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
@@ -2027,6 +2039,16 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
}
}
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 9)) {
+ bTheme *btheme;
+
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+ rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255);
+ rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255);
+ rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255);
+ }
+ }
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 5a0add7d701..b022d4121f4 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -299,7 +299,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* other view types are completely defined using their own settings already */
default:
/* we don't do anything here, as settings should be fine, but just make sure that rect */
- break;
+ break;
}
}
@@ -476,8 +476,14 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
if (winy < v2d->oldwiny) {
float temp = v2d->oldwiny - winy;
- cur->ymin += temp;
- cur->ymax += temp;
+ if (v2d->align & V2D_ALIGN_NO_NEG_Y) {
+ cur->ymin -= temp;
+ cur->ymax -= temp;
+ }
+ else { /* Assume V2D_ALIGN_NO_POS_Y or combination */
+ cur->ymin += temp;
+ cur->ymax += temp;
+ }
}
}
@@ -593,7 +599,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) {
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
temp = BLI_rctf_cent_x(tot);
- diff = curheight * 0.5f;
+ diff = curwidth * 0.5f;
cur->xmin = temp - diff;
cur->xmax = temp + diff;
@@ -1089,7 +1095,7 @@ 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;
@@ -1100,7 +1106,7 @@ static void step_to_grid(float *step, int *power, int unit)
(*power)++;
/* prevents printing 1.0, 2.0, 3.0, etc. */
- if (rem == 10.0f) (*power)++;
+ if (rem == 10.0f) (*power)++;
}
}
@@ -1255,7 +1261,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec2[1] = vec1[1] -= 0.5f * grid->dy;
step++;
- if (flag & V2D_HORIZONTAL_FINELINES) {
+ if (flag & V2D_HORIZONTAL_FINELINES) {
UI_ThemeAppendColorShade(TH_GRID, 16);
for (a = 0; a < step; a++) {
gpuVertex2fv(vec1);
@@ -1491,7 +1497,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d,
/* check whether sliders can disappear due to the full-range being used */
if (v2d->keeptot) {
- if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) {
+ if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) {
v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR;
scrollers->horfull = 1;
}
@@ -1533,7 +1539,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d,
/* check whether sliders can disappear due to the full-range being used */
if (v2d->keeptot) {
- if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) {
+ if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) {
v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR;
scrollers->vertfull = 1;
}
@@ -1686,7 +1692,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
if (fac < hor.xmin + 10)
continue;
- switch (vs->xunits) {
+ switch (vs->xunits) {
case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h');
break;
@@ -1801,7 +1807,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
BLF_disable_default(BLF_ROTATION);
}
- }
+ }
}
}
@@ -2070,7 +2076,7 @@ short UI_view2d_mouse_in_scrollers(const bContext *C, View2D *v2d, int x, int y)
}
if (scroll & V2D_SCROLL_VERTICAL) {
if (IN_2D_VERT_SCROLL(v2d, co)) return 'v';
- }
+ }
/* not found */
return 0;
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 5ac20829480..48a1f8bf0f3 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -642,7 +642,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
- }
+ }
else {
v2d->cur.ymin += dy;
v2d->cur.ymax -= dy;
@@ -827,6 +827,11 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
dx = RNA_float_get(op->ptr, "deltax");
dy = RNA_float_get(op->ptr, "deltay");
+ if (U.uiflag & USER_ZOOM_INVERT) {
+ dx *= -1;
+ dy *= -1;
+ }
+
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
double time = PIL_check_seconds_timer();
@@ -849,12 +854,12 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dx) - (mval_faci * dx);
- v2d->cur.xmin += ofs - dx;
- v2d->cur.xmax += ofs + dx;
+ v2d->cur.xmin += ofs + dx;
+ v2d->cur.xmax += ofs - dx;
}
else {
- v2d->cur.xmin -= dx;
- v2d->cur.xmax += dx;
+ v2d->cur.xmin += dx;
+ v2d->cur.xmax -= dx;
}
}
}
@@ -868,12 +873,12 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dy) - (mval_faci * dy);
- v2d->cur.ymin += ofs - dy;
- v2d->cur.ymax += ofs + dy;
+ v2d->cur.ymin += ofs + dy;
+ v2d->cur.ymax += ofs - dy;
}
else {
- v2d->cur.ymin -= dy;
- v2d->cur.ymax += dy;
+ v2d->cur.ymin += dy;
+ v2d->cur.ymax -= dy;
}
}
}
@@ -951,7 +956,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
view_zoomdrag_apply(C, op);
view_zoomdrag_exit(C, op);
return OPERATOR_FINISHED;
- }
+ }
/* set initial settings */
vzd->lastx = event->x;
@@ -1044,14 +1049,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
}
/* set transform amount, and add current deltas to stored total delta (for redo) */
- if (U.uiflag & USER_ZOOM_INVERT) {
- RNA_float_set(op->ptr, "deltax", -dx);
- RNA_float_set(op->ptr, "deltay", -dy);
- }
- else {
- RNA_float_set(op->ptr, "deltax", dx);
- RNA_float_set(op->ptr, "deltay", dy);
- }
+ RNA_float_set(op->ptr, "deltax", dx);
+ RNA_float_set(op->ptr, "deltay", dy);
+
vzd->dx += dx;
vzd->dy += dy;
@@ -1065,7 +1065,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* apply zooming */
view_zoomdrag_apply(C, op);
- }
+ }
else if (event->type == vzd->invoke_event || event->type == ESCKEY) {
if (event->val == KM_RELEASE) {
@@ -1243,16 +1243,16 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
for (i = 0; i < 2; i++) {
/* axis translation normalized to scale */
- tfac = fabsf(cent_a[i] - cent_b[i]) / minf(size_a[i], size_b[i]);
- fac_max = maxf(fac_max, tfac);
+ 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;
/* axis scale difference, x2 so doubling or half gives 1.0f */
- tfac = (1.0f - (minf(size_a[i], size_b[i]) / maxf(size_a[i], size_b[i]))) * 2.0f;
- fac_max = maxf(fac_max, tfac);
+ 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;
}
- return minf(fac_max, 1.0f);
+ return min_ff(fac_max, 1.0f);
}
/* will start timer if appropriate */
@@ -1469,7 +1469,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
else if (in_min)
return SCROLLHANDLE_MIN;
else if (out_min)
- return SCROLLHANDLE_MIN_OUTSIDE;
+ return SCROLLHANDLE_MIN_OUTSIDE;
else if (out_max)
return SCROLLHANDLE_MAX_OUTSIDE;
@@ -1751,7 +1751,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* can't catch this event for ourselves, so let it go to someone else? */
return OPERATOR_PASS_THROUGH;
- }
+ }
}
/* zone is also inappropriate if scroller is not visible... */
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 0ec99325752..ba93206e63a 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -143,7 +143,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
- BKE_report(op->reports, RPT_WARNING, "Export file not created.");
+ BKE_report(op->reports, RPT_WARNING, "Export file not created");
return OPERATOR_CANCELLED;
}
}
@@ -307,7 +307,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filename);
if (collada_import(C, filename)) return OPERATOR_FINISHED;
- BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log.");
+ BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document (see console for details)");
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index a254a6a9278..e43c8a2b53b 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -46,6 +46,7 @@
#include "WM_types.h"
#include "ED_mask.h" /* own include */
+#include "ED_screen.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -97,7 +98,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
&tot_diff_point);
if (diff_points) {
- int i, tot_point;
+ int j, tot_point;
unsigned int tot_feather_point;
float *feather_points = NULL, *points;
@@ -114,26 +115,26 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
tot_point = tot_diff_point;
}
- for (i = 0; i < tot_point - 1; i++) {
+ for (j = 0; j < tot_point - 1; j++) {
float cur_dist, a[2], b[2];
- a[0] = points[2 * i] * scalex;
- a[1] = points[2 * i + 1] * scaley;
+ a[0] = points[2 * j] * scalex;
+ a[1] = points[2 * j + 1] * scaley;
- b[0] = points[2 * i + 2] * scalex;
- b[1] = points[2 * i + 3] * scaley;
+ b[0] = points[2 * j + 2] * scalex;
+ b[1] = points[2 * j + 3] * scaley;
cur_dist = dist_to_line_segment_v2(co, a, b);
if (cur_dist < dist) {
if (tangent)
- sub_v2_v2v2(tangent, &diff_points[2 * i + 2], &diff_points[2 * i]);
+ sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
point_masklay = masklay;
point_spline = spline;
point = use_deform ? &spline->points[(cur_point - spline->points_deform)] : cur_point;
dist = cur_dist;
- u = (float)i / tot_point;
+ u = (float)j / tot_point;
}
}
@@ -562,6 +563,11 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
float co[2];
+ if (mask == NULL) {
+ /* if there's no active mask, create one */
+ mask = ED_mask_new(C, NULL);
+ }
+
masklay = BKE_mask_layer_active(mask);
if (masklay && masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
@@ -647,7 +653,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
/* api callbacks */
ot->exec = add_vertex_exec;
ot->invoke = add_vertex_invoke;
- ot->poll = ED_maskedit_mask_poll;
+ ot->poll = ED_operator_mask;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index c132bb711d1..0cb19ffbbd2 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -20,6 +20,7 @@
*
*
* Contributor(s): Blender Foundation,
+ * Campbell Barton,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
@@ -41,7 +42,9 @@
#include "DNA_mask_types.h"
#include "DNA_screen_types.h"
#include "DNA_object_types.h" /* SELECT */
+#include "DNA_space_types.h"
+#include "ED_clip.h"
#include "ED_mask.h" /* own include */
#include "ED_space_api.h"
@@ -122,13 +125,22 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline)
}
#endif
+static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], float co[2])
+{
+ BKE_mask_coord_to_movieclip(sc->clip, &sc->user, r_co, co);
+ ED_clip_point_undistorted_pos(sc, r_co, r_co);
+ BKE_mask_coord_from_movieclip(sc->clip, &sc->user, r_co, r_co);
+}
+
/* return non-zero if spline is selected */
-static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline,
+static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline *spline,
const char UNUSED(draw_flag), const char draw_type)
{
const int is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0;
unsigned char rgb_spline[4];
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ int undistort = FALSE;
int i, hsize, tot_feather_point;
float (*feather_points)[2], (*fp)[2];
@@ -136,6 +148,9 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline,
if (!spline->tot_point)
return;
+ if (sc)
+ undistort = sc->clip && sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
+
/* TODO, add this to sequence editor */
hsize = 4; /* UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); */
@@ -158,8 +173,14 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline,
int j;
for (j = 0; j < point->tot_uw + 1; j++) {
+ float feather_point[2];
int sel = FALSE;
+ copy_v2_v2(feather_point, *fp);
+
+ if (undistort)
+ mask_point_undistort_pos(sc, feather_point, feather_point);
+
if (j == 0) {
sel = MASKPOINT_ISSEL_ANY(point);
}
@@ -196,11 +217,17 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline,
BezTriple *bezt = &point_deform->bezt;
float handle[2];
- float *vert = bezt->vec[1];
+ float vert[2];
int has_handle = BKE_mask_point_has_handle(point);
+ copy_v2_v2(vert, bezt->vec[1]);
BKE_mask_point_handle(point_deform, handle);
+ if (undistort) {
+ mask_point_undistort_pos(sc, vert, vert);
+ mask_point_undistort_pos(sc, handle, handle);
+ }
+
/* draw handle segment */
if (has_handle) {
@@ -275,7 +302,7 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r
}
}
-static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot_point,
+static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*orig_points)[2], int tot_point,
const short is_feather, const short is_smooth, const short is_active,
const unsigned char rgb_spline[4], const char draw_type)
{
@@ -284,6 +311,22 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
// const unsigned char rgb_white[4] = {0xff, 0xff, 0xff, 0xff};
unsigned char rgb_tmp[4];
GPUarrays arrays = GPU_ARRAYS_V3F;
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ float (*points)[2] = orig_points;
+
+ if (sc) {
+ int undistort = sc->clip && sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
+
+ if (undistort) {
+ int i;
+
+ points = MEM_callocN(2 * tot_point * sizeof(float), "undistorthed mask curve");
+
+ for (i = 0; i < tot_point; i++) {
+ mask_point_undistort_pos(sc, points[i], orig_points[i]);
+ }
+ }
+ }
arrays.vertexPointer = points;
@@ -352,7 +395,6 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
gpuDrawClientArrays(draw_method, &arrays, 0, tot_point);
gpuRepeat(); // XXX: why twice?
-
if (is_smooth == FALSE && is_feather) {
glDisable(GL_BLEND);
}
@@ -361,14 +403,16 @@ static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot
}
gpuImmediateUnformat();
+ if (points != orig_points)
+ MEM_freeN(points);
}
-static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
+static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline *spline,
const char draw_flag, const char draw_type,
const short is_active,
int width, int height)
{
- const unsigned int resol = maxi(BKE_mask_spline_feather_resolution(spline, width, height),
+ const unsigned int resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height),
BKE_mask_spline_resolution(spline, width, height));
unsigned char rgb_tmp[4];
@@ -397,7 +441,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
/* draw feather */
mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp);
- mask_draw_curve_type(spline, feather_points, tot_feather_point,
+ mask_draw_curve_type(C, spline, feather_points, tot_feather_point,
TRUE, is_smooth, is_active,
rgb_tmp, draw_type);
@@ -416,7 +460,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
}
/* same as above */
- mask_draw_curve_type(spline, feather_points, tot_feather_point,
+ mask_draw_curve_type(C, spline, feather_points, tot_feather_point,
TRUE, is_smooth, is_active,
rgb_tmp, draw_type);
}
@@ -425,7 +469,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
/* draw main curve */
mask_spline_color_get(masklay, spline, is_spline_sel, rgb_tmp);
- mask_draw_curve_type(spline, diff_points, tot_diff_point,
+ mask_draw_curve_type(C, spline, diff_points, tot_diff_point,
FALSE, is_smooth, is_active,
rgb_tmp, draw_type);
MEM_freeN(diff_points);
@@ -438,7 +482,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
(void)draw_type;
}
-static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type,
+static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, const char draw_type,
int width, int height)
{
MaskLayer *masklay;
@@ -455,13 +499,13 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
for (spline = masklay->splines.first; spline; spline = spline->next) {
/* draw curve itself first... */
- draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height);
+ draw_spline_curve(C, masklay, spline, draw_flag, draw_type, is_active, width, height);
// draw_spline_parents(masklay, spline);
if (!(masklay->restrictflag & MASK_RESTRICT_SELECT)) {
/* ...and then handles over the curve so they're nicely visible */
- draw_spline_points(masklay, spline, draw_flag, draw_type);
+ draw_spline_points(C, masklay, spline, draw_flag, draw_type);
}
/* show undeform for testing */
@@ -469,9 +513,9 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
void *back = spline->points_deform;
spline->points_deform = NULL;
- draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height);
+ draw_spline_curve(C, masklay, spline, draw_flag, draw_type, is_active, width, height);
// draw_spline_parents(masklay, spline);
- draw_spline_points(masklay, spline, draw_flag, draw_type);
+ draw_spline_points(C, masklay, spline, draw_flag, draw_type);
spline->points_deform = back;
}
}
@@ -491,7 +535,7 @@ void ED_mask_draw(const bContext *C,
ED_mask_get_size(sa, &width, &height);
- draw_masklays(mask, draw_flag, draw_type, width, height);
+ draw_masklays(C, mask, draw_flag, draw_type, width, height);
}
/* sets up the opengl context.
@@ -502,7 +546,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
const float aspx, const float aspy,
const short do_scale_applied, const short do_post_draw,
float stabmat[4][4], /* optional - only used by clip */
- const bContext *C /* optional - only used when do_post_draw is set */
+ const bContext *C /* optional - only used when do_post_draw is set or called from clip editor */
)
{
struct View2D *v2d = &ar->v2d;
@@ -538,7 +582,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
y += v2d->tot.ymin * zoomy;
/* frame the image */
- maxdim = maxf(width, height);
+ maxdim = max_ff(width, height);
if (width == height) {
xofs = yofs = 0;
}
@@ -561,7 +605,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
}
/* draw! */
- draw_masklays(mask, draw_flag, draw_type, width, height);
+ draw_masklays(C, mask, draw_flag, draw_type, width, height);
if (do_post_draw) {
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index ffd4afca182..fcfcfb237e9 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -33,6 +33,7 @@
#define __MASK_INTERN_H__
struct bContext;
+struct Mask;
struct wmEvent;
struct wmOperatorType;
@@ -43,6 +44,8 @@ void MASK_OT_add_vertex(struct wmOperatorType *ot);
void MASK_OT_add_feather_vertex(struct wmOperatorType *ot);
/* mask_ops.c */
+struct Mask *ED_mask_new(struct bContext *C, const char *name);
+
void MASK_OT_new(struct wmOperatorType *ot);
void MASK_OT_layer_new(struct wmOperatorType *ot);
void MASK_OT_layer_remove(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 88fbb91edfb..35f85f3faee 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -258,13 +258,10 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
/******************** create new mask *********************/
-static int mask_new_exec(bContext *C, wmOperator *op)
+Mask *ED_mask_new(bContext *C, const char *name)
{
ScrArea *sa = CTX_wm_area(C);
Mask *mask;
- char name[MAX_ID_NAME - 2];
-
- RNA_string_get(op->ptr, "name", name);
mask = BKE_mask_new(name);
@@ -290,6 +287,17 @@ static int mask_new_exec(bContext *C, wmOperator *op)
}
}
+ return mask;
+}
+
+static int mask_new_exec(bContext *C, wmOperator *op)
+{
+ char name[MAX_ID_NAME - 2];
+
+ RNA_string_get(op->ptr, "name", name);
+
+ ED_mask_new(C, name);
+
return OPERATOR_FINISHED;
}
@@ -483,15 +491,15 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
customdata->uw = uw;
if (uw) {
- float co[2];
+ float co_uw[2];
float weight_scalar = BKE_mask_point_weight_scalar(spline, point, uw->u);
customdata->weight = uw->w;
customdata->weight_scalar = weight_scalar;
- BKE_mask_point_segment_co(spline, point, uw->u, co);
+ BKE_mask_point_segment_co(spline, point, uw->u, co_uw);
BKE_mask_point_normal(spline, point, uw->u, customdata->no);
- madd_v2_v2v2fl(customdata->feather, co, customdata->no, uw->w * weight_scalar);
+ madd_v2_v2v2fl(customdata->feather, co_uw, customdata->no, uw->w * weight_scalar);
}
else {
BezTriple *bezt = &point->bezt;
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 47a9483d653..86de9cfb8d7 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -34,6 +34,7 @@
#include "BLI_utildefines.h"
#include "BLI_rect.h"
#include "BLI_lasso.h"
+#include "BLI_math.h"
#include "BKE_context.h"
#include "BKE_mask.h"
@@ -557,7 +558,7 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
select = !RNA_boolean_get(op->ptr, "deselect");
do_lasso_select_mask(C, mcords, mcords_tot, select);
- MEM_freeN(mcords);
+ MEM_freeN((void *)mcords);
return OPERATOR_FINISHED;
}
@@ -622,7 +623,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
/* compute ellipse and position in unified coordinates */
ED_mask_get_size(sa, &width, &height);
ED_mask_zoom(sa, ar, &zoomx, &zoomy);
- width = height = MAX2(width, height);
+ width = height = max_ii(width, height);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index bb0d157ad30..d12a2322e20 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -21,6 +21,7 @@
set(INC
../include
../uvedit
+ ../../blenfont
../../blenkernel
../../blenlib
../../blenloader
@@ -69,6 +70,14 @@ if(WITH_GAMEENGINE)
)
endif()
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
+if(WITH_BULLET)
+ add_definitions(-DWITH_BULLET)
+endif()
+
add_definitions(-DGLEW_STATIC)
blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/mesh/SConscript b/source/blender/editors/mesh/SConscript
index b3aba977b21..91ffdc91685 100644
--- a/source/blender/editors/mesh/SConscript
+++ b/source/blender/editors/mesh/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('*.c')
defs = []
-incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
+incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../gpu ../../blenloader'
incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern'
@@ -24,4 +24,10 @@ if env['WITH_BF_GAMEENGINE']:
else:
sources.remove('mesh_navmesh.c')
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
+
+if env['WITH_BF_BULLET']:
+ defs.append('WITH_BULLET')
+
env.BlenderLib ( 'bf_editors_mesh', sources, Split(incs), defs, libtype=['core'], priority=[45] )
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index b2c3f4448f7..2e3480b5964 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -85,7 +85,7 @@ void paintface_flush_flags(Object *ob)
* - Final derived polys => Final derived tessfaces
*/
- if ((index_array = CustomData_get_layer(&me->fdata, CD_POLYINDEX))) {
+ if ((index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX))) {
faces = me->mface;
totface = me->totface;
@@ -109,7 +109,7 @@ void paintface_flush_flags(Object *ob)
}
}
- if ((index_array = CustomData_get_layer(&dm->faceData, CD_POLYINDEX))) {
+ if ((index_array = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))) {
polys = dm->getPolyArray(dm);
faces = dm->getTessFaceArray(dm);
totface = dm->getNumTessFaces(dm);
@@ -214,7 +214,9 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind
/* fill array by selection */
mp = me->mpoly;
for (a = 0; a < me->totpoly; a++, mp++) {
- if (mp->flag & ME_HIDE) ;
+ if (mp->flag & ME_HIDE) {
+ /* pass */
+ }
else if (mp->flag & ME_FACE_SEL) {
hash_add_face(ehash, mp, me->mloop + mp->loopstart);
linkflag[a] = 1;
@@ -572,7 +574,9 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
mpoly = me->mpoly;
for (a = 1; a <= me->totpoly; a++, mpoly++) {
if (selar[a]) {
- if (mpoly->flag & ME_HIDE) ;
+ if (mpoly->flag & ME_HIDE) {
+ /* pass */
+ }
else {
if (select) mpoly->flag |= ME_FACE_SEL;
else mpoly->flag &= ~ME_FACE_SEL;
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 0cf4ac48bf7..70b359d3e28 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -73,7 +73,7 @@ static Object *make_prim_init(bContext *C, const char *idname,
*state = 1;
}
- *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
+ *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, FALSE);
return obedit;
}
@@ -200,7 +200,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
if (!EDBM_op_call_and_selectf(em, op, "vertout",
"create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b mat=%m4",
- RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
+ RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius") * dia,
cap_end, cap_tri, mat))
{
return OPERATOR_CANCELLED;
@@ -256,10 +256,10 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
em, op, "vertout",
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f mat=%m4",
RNA_int_get(op->ptr, "vertices"),
- RNA_float_get(op->ptr, "radius"),
- RNA_float_get(op->ptr, "radius"),
+ RNA_float_get(op->ptr, "radius") * dia,
+ RNA_float_get(op->ptr, "radius") * dia,
cap_end, cap_tri,
- RNA_float_get(op->ptr, "depth"), mat))
+ RNA_float_get(op->ptr, "depth") * dia, mat))
{
return OPERATOR_CANCELLED;
}
@@ -315,8 +315,8 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
if (!EDBM_op_call_and_selectf(
em, op, "vertout",
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f mat=%m4",
- RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
- RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
+ RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1") * dia,
+ RNA_float_get(op->ptr, "radius2") * dia, cap_end, cap_tri, RNA_float_get(op->ptr, "depth") * dia, mat))
{
return OPERATOR_CANCELLED;
}
@@ -421,6 +421,10 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
rot[0] += (float)M_PI / 2.0f;
obedit = make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer);
+ mat[0][0] *= dia;
+ mat[1][1] *= dia;
+ mat[2][2] *= dia;
+
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) {
@@ -465,14 +469,14 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
if (!EDBM_op_call_and_selectf(em, op, "vertout",
"create_uvsphere segments=%i revolutions=%i diameter=%f mat=%m4",
RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"),
- RNA_float_get(op->ptr, "size"), mat))
+ RNA_float_get(op->ptr, "size") * dia, mat))
{
return OPERATOR_CANCELLED;
}
make_prim_finish(C, obedit, &state, enter_editmode);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
@@ -517,7 +521,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
em, op, "vertout",
"create_icosphere subdivisions=%i diameter=%f mat=%m4",
RNA_int_get(op->ptr, "subdivisions"),
- RNA_float_get(op->ptr, "size"), mat))
+ RNA_float_get(op->ptr, "size") * dia, mat))
{
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c
index 5c76cb93f92..3f7100c5417 100644
--- a/source/blender/editors/mesh/editmesh_bvh.c
+++ b/source/blender/editors/mesh/editmesh_bvh.c
@@ -371,9 +371,9 @@ int BMBVH_VertVisible(BMBVHTree *tree, BMEdge *e, RegionView3D *r3d)
}
#endif
-static BMFace *edge_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float *hitout, BMEdge *e)
+static BMFace *edge_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float *r_hitout, BMEdge *e)
{
- BMFace *f = BMBVH_RayCast(tree, co, dir, hitout, NULL);
+ BMFace *f = BMBVH_RayCast(tree, co, dir, r_hitout, NULL);
if (f && BM_edge_in_face(f, e))
return NULL;
@@ -392,7 +392,7 @@ static void scale_point(float c1[3], const float p[3], const float s)
int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Object *obedit)
{
BMFace *f;
- float co1[3], co2[3], co3[3], dir1[4], dir2[4], dir3[4];
+ float co1[3], co2[3], co3[3], dir1[3], dir2[3], dir3[3];
float origin[3], invmat[4][4];
float epsilon = 0.01f;
float end[3];
@@ -405,8 +405,7 @@ int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Obje
mul_m4_v3(invmat, origin);
copy_v3_v3(co1, e->v1->co);
- add_v3_v3v3(co2, e->v1->co, e->v2->co);
- mul_v3_fl(co2, 0.5f);
+ mid_v3_v3v3(co2, e->v1->co, e->v2->co);
copy_v3_v3(co3, e->v2->co);
scale_point(co1, co2, 0.99);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 65bb7879867..f6f226ec614 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -182,6 +182,7 @@ typedef struct KnifeTool_OpData {
char select_result; /* set on initialization */
short is_ortho;
+ float ortho_extent;
float clipsta, clipend;
enum {
@@ -1169,7 +1170,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,
/* for comparing distances, error of intersection depends on triangle scale.
* need to scale down before squaring for accurate comparison */
- const float depsilon = (KNIFE_FLT_EPS / 2.0f) * len_v3_tri_side_max(v1, v2, v3);
+ const float depsilon = (FLT_EPSILON / 2.0f) * len_v3_tri_side_max(v1, v2, v3);
const float depsilon_squared = depsilon * depsilon;
copy_v3_v3(cos + 0, v1);
@@ -1316,6 +1317,22 @@ static void knife_bgl_get_mats(KnifeTool_OpData *UNUSED(kcd), bglMats *mats)
//copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat);
}
+/* Calculate maximum excursion (doubled) from (0,0,0) of mesh */
+static void calc_ortho_extent(KnifeTool_OpData *kcd)
+{
+ BMIter iter;
+ BMVert *v;
+ BMesh* bm = kcd->em->bm;
+ float max_xyz = 0.0f;
+ int i;
+
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ for (i = 0; i < 3; i++)
+ max_xyz = max_ff(max_xyz, fabs(v->co[i]));
+ }
+ kcd->ortho_extent = 2 * max_xyz;
+}
+
/* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */
static void knife_find_line_hits(KnifeTool_OpData *kcd)
{
@@ -1358,8 +1375,10 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
* (which may involve using doubles everywhere!),
* limit the distance between these points */
if (kcd->is_ortho) {
- limit_dist_v3(v1, v3, 200.0f);
- limit_dist_v3(v2, v4, 200.0f);
+ if (kcd->ortho_extent == 0.0f)
+ calc_ortho_extent(kcd);
+ limit_dist_v3(v1, v3, kcd->ortho_extent + 10.0f);
+ limit_dist_v3(v2, v4, kcd->ortho_extent + 10.0f);
}
BLI_smallhash_init(ehash);
@@ -1423,7 +1442,7 @@ static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2],
static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, float co[3], float cageco[3], int *is_space)
{
BMFace *f;
- int dist = KMAXDIST;
+ float dist = KMAXDIST;
float origin[3];
float ray[3];
@@ -1511,7 +1530,7 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize)
if (density < 1.0f)
density = 1.0f;
- return minf(maxsize / (density * 0.5f), maxsize);
+ return min_ff(maxsize / (density * 0.5f), maxsize);
}
/* p is closest point on edge to the mouse cursor */
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 38e5f459a26..851a72f5631 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -265,7 +265,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
lasteed = eed;
}
- if (lasteed != startedge && BM_edge_share_face_count(lasteed, startedge)) {
+ if (lasteed != startedge && BM_edge_share_face_check(lasteed, startedge)) {
v[1][0] = v[0][0];
v[1][1] = v[0][1];
@@ -420,10 +420,10 @@ static int ringcut_invoke(bContext *C, wmOperator *op, wmEvent *evt)
Object *obedit = CTX_data_edit_object(C);
RingSelOpData *lcd;
BMEdge *edge;
- int dist = 75;
+ float dist = 75.0f;
if (modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
- BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display");
+ BKE_report(op->reports, RPT_WARNING, "Loop cut does not work well on deformed edit mesh display");
view3d_operator_needs_opengl(C);
@@ -509,7 +509,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
if (event->val == KM_RELEASE)
break;
- cuts = MAX2(cuts - 1, 0);
+ cuts = max_ii(cuts - 1, 0);
RNA_int_set(op->ptr, "number_cuts", cuts);
ringsel_find_edge(lcd, cuts);
show_cuts = TRUE;
@@ -517,7 +517,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
ED_region_tag_redraw(lcd->ar);
break;
case MOUSEMOVE: { /* mouse moved somewhere to select another loop */
- int dist = 75;
+ float dist = 75.0f;
BMEdge *edge;
lcd->vc.mval[0] = event->mval[0];
@@ -531,7 +531,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
ED_region_tag_redraw(lcd->ar);
break;
- }
+ }
}
/* using the keyboard to input the number of cuts */
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 001d584416f..6379bdbc0ca 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -55,19 +55,59 @@
#include "mesh_intern.h"
-/* helper to find edge for edge_rip */
-static float edbm_rip_rip_edgedist(ARegion *ar, float mat[][4],
- const float co1[3], const float co2[3], const float mvalf[2])
+/**
+ * helper to find edge for edge_rip,
+ *
+ * \param inset is used so we get some useful distance
+ * when comparing multiple edges that meet at the same
+ * point and would result in teh same distance.
+ */
+#define INSET_DEFAULT 0.00001f
+static float edbm_rip_edgedist(ARegion *ar, float mat[][4],
+ const float co1[3], const float co2[3], const float mvalf[2],
+ const float inset)
{
- float vec1[3], vec2[3];
+ float vec1[2], vec2[2];
ED_view3d_project_float_v2_m4(ar, co1, vec1, mat);
ED_view3d_project_float_v2_m4(ar, co2, vec2, mat);
+ if (inset != 0.0f) {
+ const float dist = inset / len_v2v2(vec1, vec2);
+ interp_v2_v2v2(vec1, vec1, vec2, dist);
+ interp_v2_v2v2(vec2, vec2, vec1, dist);
+ }
+
/* TODO: use dist_squared_to_line_segment_v2() looks like we only ever use for comparison */
return dist_to_line_segment_v2(mvalf, vec1, vec2);
}
+#if 0
+static float edbm_rip_linedist(ARegion *ar, float mat[][4],
+ const float co1[3], const float co2[3], const float mvalf[2])
+{
+ float vec1[2], vec2[2];
+
+ ED_view3d_project_float_v2_m4(ar, co1, vec1, mat);
+ ED_view3d_project_float_v2_m4(ar, co2, vec2, mat);
+
+ return dist_to_line_v2(mvalf, vec1, vec2);
+}
+#endif
+
+/* calculaters a point along the loop tangent which can be used to measure against edges */
+static void edbm_calc_loop_co(BMLoop *l, float l_mid_co[3])
+{
+ BM_loop_calc_face_tangent(l, l_mid_co);
+
+ /* scale to average of surrounding edge size, only needs to be approx, but should
+ * be roughly equivalent to the check below which uses the middle of the edge. */
+ mul_v3_fl(l_mid_co, (BM_edge_calc_length(l->e) + BM_edge_calc_length(l->prev->e)) / 2.0f);
+
+ add_v3_v3(l_mid_co, l->v->co);
+}
+
+
static float edbm_rip_edge_side_measure(BMEdge *e, BMLoop *e_l,
ARegion *ar,
float projectMat[4][4], const float fmval[2])
@@ -237,7 +277,6 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm)
uid_start = uid;
while ((e = edbm_ripsel_edge_mark_step(v_step, uid))) {
- BM_elem_flag_disable(e, BM_ELEM_SMOOTH);
v_step = BM_edge_other_vert((e_step = e), v_step);
uid++; /* only different line */
tot++;
@@ -254,7 +293,6 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm)
v_step = e_first->v1;
while ((e = edbm_ripsel_edge_mark_step(v_step, uid))) {
- BM_elem_flag_disable(e, BM_ELEM_SMOOTH);
v_step = BM_edge_other_vert((e_step = e), v_step);
uid--; /* only different line */
tot++;
@@ -344,6 +382,145 @@ static void edbm_ripsel_deselect_helper(BMesh *bm, EdgeLoopPair *eloop_pairs,
}
/* --- end 'ripsel' selection handling code --- */
+
+/* --- face-fill code --- */
+/**
+ * return an un-ordered array of loop pairs
+ * use for rebuilding face-fill
+ *
+ * \note the method currenly used fails for edges with 3+ face users and gives
+ * nasty holes in the mesh, there isnt a good way of knowing ahead of time
+ * which loops will be split apart (its possible to figure out but quite involved).
+ * So for now this is a known limitation of current rip-fill option.
+ */
+
+typedef struct UnorderedLoopPair {
+ BMLoop *l_pair[2];
+ char flag;
+} UnorderedLoopPair;
+enum {
+ ULP_FLIP_0 = (1 << 0),
+ ULP_FLIP_1 = (1 << 1)
+};
+
+static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm)
+{
+ BMIter iter;
+ BMEdge *e;
+
+ unsigned int total_tag = 0;
+ /* count tags, could be pre-calculated */
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ total_tag++;
+ }
+ }
+
+ if (total_tag) {
+ UnorderedLoopPair *uloop_pairs = MEM_mallocN(total_tag * sizeof(UnorderedLoopPair), __func__);
+ UnorderedLoopPair *ulp = uloop_pairs;
+
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BMLoop *l1, *l2;
+ if (BM_edge_loop_pair(e, &l1, &l2)) {
+ BMVert *v_cmp = l1->e->v1;
+ ulp->flag = (((l1->v != v_cmp) ? ULP_FLIP_0 : 0) |
+ ((l2->v == v_cmp) ? ULP_FLIP_1 : 0));
+ }
+ else {
+ ulp->flag = 0;
+ }
+ ulp->l_pair[0] = l1;
+ ulp->l_pair[1] = l2;
+
+ ulp++;
+ }
+ }
+
+ return uloop_pairs;
+ }
+ else {
+ return NULL;
+ }
+}
+
+static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *uloop_pairs)
+{
+ UnorderedLoopPair *ulp;
+ unsigned int total_tag = MEM_allocN_len(uloop_pairs) / sizeof(UnorderedLoopPair);
+ unsigned int i;
+
+ for (i = 0, ulp = uloop_pairs; i < total_tag; i++, ulp++) {
+ if ((ulp->l_pair[0] && ulp->l_pair[1]) &&
+ (ulp->l_pair[0]->e != ulp->l_pair[1]->e))
+ {
+ /* time has come to make a face! */
+ BMVert *v_shared = BM_edge_share_vert(ulp->l_pair[0]->e, ulp->l_pair[1]->e);
+ BMFace *f, *f_example = ulp->l_pair[0]->f;
+ BMLoop *l_iter;
+ BMVert *f_verts[4];
+
+ if (v_shared == NULL) {
+ /* quad */
+ f_verts[0] = ulp->l_pair[0]->e->v1;
+ f_verts[1] = ulp->l_pair[1]->e->v1;
+ f_verts[2] = ulp->l_pair[1]->e->v2;
+ f_verts[3] = ulp->l_pair[0]->e->v2;
+
+ if (ulp->flag & ULP_FLIP_0) {
+ SWAP(BMVert *, f_verts[0], f_verts[3]);
+ }
+ if (ulp->flag & ULP_FLIP_1) {
+ SWAP(BMVert *, f_verts[1], f_verts[2]);
+ }
+ }
+ else {
+ /* tri */
+ f_verts[0] = v_shared;
+ f_verts[1] = BM_edge_other_vert(ulp->l_pair[0]->e, v_shared);
+ f_verts[2] = BM_edge_other_vert(ulp->l_pair[1]->e, v_shared);
+ f_verts[3] = NULL;
+
+ /* don't use the flip flags */
+ if (v_shared == ulp->l_pair[0]->v) {
+ SWAP(BMVert *, f_verts[0], f_verts[1]);
+ }
+ }
+
+ /* face should never exist */
+ BLI_assert(BM_face_exists(bm, f_verts, f_verts[3] ? 4 : 3, &f) == FALSE);
+
+ f = BM_face_create_quad_tri_v(bm, f_verts, f_verts[3] ? 4 : 3, f_example, FALSE);
+
+ l_iter = BM_FACE_FIRST_LOOP(f);
+
+ if (f_verts[3]) {
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter);
+ }
+ else {
+ if (v_shared == f_verts[0]) {
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter);
+ }
+ else {
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next;
+ BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter);
+ }
+ }
+
+ }
+ }
+}
+
+/* --- end 'face-fill' code --- */
+
+
static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op)
{
BMOperator bmop;
@@ -366,6 +543,8 @@ static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op)
*/
static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
{
+ const int do_fill = RNA_boolean_get(op->ptr, "use_fill");
+ UnorderedLoopPair *fill_uloop_pairs = NULL;
Object *obedit = CTX_data_edit_object(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -388,7 +567,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
/* find selected vert - same some time and check history first */
- if (BM_select_history_active_get(em->bm, &ese) && ese.htype == BM_VERT) {
+ if (BM_select_history_active_get(bm, &ese) && ese.htype == BM_VERT) {
v = (BMVert *)ese.ele;
}
else {
@@ -417,7 +596,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
totboundary_edge += (is_boundary != 0 || BM_edge_is_wire(e));
if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
if (is_boundary == FALSE && BM_edge_is_manifold(e)) {
- d = edbm_rip_rip_edgedist(ar, projectMat, e->v1->co, e->v2->co, fmval);
+ d = edbm_rip_edgedist(ar, projectMat, e->v1->co, e->v2->co, fmval, INSET_DEFAULT);
if (d < dist) {
dist = d;
e2 = e;
@@ -426,6 +605,42 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
}
}
+ /* if we are ripping a single vertex from 3 faces,
+ * then measure the distance to the face corner as well as the edge */
+ if (BM_vert_face_count(v) == 3 &&
+ BM_vert_edge_count(v) == 3)
+ {
+ BMEdge *e_all[3];
+ BMLoop *l_all[3];
+ int i1, i2;
+
+ BM_iter_as_array(bm, BM_EDGES_OF_VERT, v, (void **)e_all, 3);
+ BM_iter_as_array(bm, BM_LOOPS_OF_VERT, v, (void **)l_all, 3);
+
+ /* not do a loop similar to the one above, but test against loops */
+ for (i1 = 0; i1 < 3; i1++) {
+ /* consider wire as boundary for this purpose,
+ * otherwise we can't a face away from a wire edge */
+ float l_mid_co[3];
+ l = l_all[i1];
+ edbm_calc_loop_co(l, l_mid_co);
+ d = edbm_rip_edgedist(ar, projectMat, l->v->co, l_mid_co, fmval, INSET_DEFAULT);
+
+ if (d < dist) {
+ dist = d;
+
+ /* find the edge that is not in this loop */
+ e2 = NULL;
+ for (i2 = 0; i2 < 3; i2++) {
+ if (!BM_edge_in_loop(e_all[i2], l)) {
+ e2 = e_all[i2];
+ break;
+ }
+ }
+ BLI_assert(e2 != NULL);
+ }
+ }
+ }
}
/* should we go ahead with edge rip or do we need to do special case, split off vertex?:
@@ -459,7 +674,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
int vi_best = 0;
if (ese.ele) {
- BM_select_history_remove(em->bm, ese.ele);
+ BM_select_history_remove(bm, ese.ele);
}
dist = FLT_MAX;
@@ -473,14 +688,9 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) {
if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
float l_mid_co[3];
- BM_loop_calc_face_tangent(l, l_mid_co);
+ edbm_calc_loop_co(l, l_mid_co);
- /* scale to average of surrounding edge size, only needs to be approx, but should
- * be roughly equivalent to the check below which uses the middle of the edge. */
- mul_v3_fl(l_mid_co, (BM_edge_calc_length(l->e) + BM_edge_calc_length(l->prev->e)) / 2.0f);
- add_v3_v3(l_mid_co, v->co);
-
- d = edbm_rip_rip_edgedist(ar, projectMat, v->co, l_mid_co, fmval);
+ d = edbm_rip_edgedist(ar, projectMat, v->co, l_mid_co, fmval, INSET_DEFAULT);
if (d < dist) {
dist = d;
@@ -496,7 +706,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
float e_mid_co[3];
mid_v3_v3v3(e_mid_co, e->v1->co, e->v2->co);
- d = edbm_rip_rip_edgedist(ar, projectMat, v->co, e_mid_co, fmval);
+ d = edbm_rip_edgedist(ar, projectMat, v->co, e_mid_co, fmval, INSET_DEFAULT);
if (d < dist) {
dist = d;
@@ -512,7 +722,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
BM_vert_select_set(bm, v, TRUE);
if (ese.ele) {
- BM_select_history_store(em->bm, v);
+ BM_select_history_store(bm, v);
}
/* splice all others back together */
@@ -543,39 +753,65 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
}
+ /* *** Execute the split! *** */
+ /* unlike edge split, for single vertex split we only use the operator in one of the cases
+ * but both allocate fill */
+
/* rip two adjacent edges */
if (BM_edge_is_boundary(e2) || BM_vert_face_count(v) == 2) {
+ /* Don't run the edge split operator in this case */
+
+ BM_elem_flag_enable(e2, BM_ELEM_TAG); /* only for face-fill (we don't call the operator) */
+
+ /* keep directly before edgesplit */
+ if (do_fill) {
+ fill_uloop_pairs = edbm_tagged_loop_pairs_to_fill(bm);
+ }
+
l = e2->l;
ripvert = BM_face_vert_separate(bm, l->f, v);
BLI_assert(ripvert);
if (!ripvert) {
+ if (fill_uloop_pairs) MEM_freeN(fill_uloop_pairs);
return OPERATOR_CANCELLED;
}
}
- else if (BM_edge_is_manifold(e2)) {
- l = e2->l;
- e = BM_face_other_edge_loop(l->f, e2, v)->e;
- BM_elem_flag_enable(e, BM_ELEM_TAG);
+ else {
+ if (BM_edge_is_manifold(e2)) {
+ l = e2->l;
+ e = BM_face_other_edge_loop(l->f, e2, v)->e;
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+
+ l = e2->l->radial_next;
+ e = BM_face_other_edge_loop(l->f, e2, v)->e;
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+ }
+ else {
+ /* looks like there are no split edges, we could just return/report-error? - Campbell */
+ }
+
+ /* keep directly before edgesplit */
+ if (do_fill) {
+ fill_uloop_pairs = edbm_tagged_loop_pairs_to_fill(bm);
+ }
- l = e2->l->radial_next;
- e = BM_face_other_edge_loop(l->f, e2, v)->e;
- BM_elem_flag_enable(e, BM_ELEM_TAG);
+ if (!edbm_rip_call_edgesplit(em, op)) {
+ if (fill_uloop_pairs) MEM_freeN(fill_uloop_pairs);
+ return OPERATOR_CANCELLED;
+ }
}
dist = FLT_MAX;
- if (!edbm_rip_call_edgesplit(em, op)) {
- return OPERATOR_CANCELLED;
- }
- else {
+ {
/* --- select which vert --- */
BMVert *v_best = NULL;
float l_prev_co[3], l_next_co[3], l_corner_co[3];
float scale;
dist = FLT_MAX;
- BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
/* disable by default, re-enable winner at end */
BM_vert_select_set(bm, v, FALSE);
@@ -593,7 +829,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
add_v3_v3v3(l_corner_co, l_prev_co, l_next_co);
add_v3_v3(l_corner_co, l->v->co);
- d = edbm_rip_rip_edgedist(ar, projectMat, l->v->co, l_corner_co, fmval);
+ d = edbm_rip_edgedist(ar, projectMat, l->v->co, l_corner_co, fmval, INSET_DEFAULT);
if (d < dist) {
v_best = v;
dist = d;
@@ -605,11 +841,17 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
if (v_best) {
BM_vert_select_set(bm, v_best, TRUE);
if (ese.ele) {
- BM_select_history_store(em->bm, v_best);
+ BM_select_history_store(bm, v_best);
}
}
}
+ if (do_fill && fill_uloop_pairs) {
+ edbm_tagged_loop_pairs_do_fill_faces(bm, fill_uloop_pairs);
+ MEM_freeN(fill_uloop_pairs);
+ }
+
+
if (totvert_orig == bm->totvert) {
BKE_report(op->reports, RPT_ERROR, "No vertices could be ripped");
return OPERATOR_CANCELLED;
@@ -623,6 +865,8 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
*/
static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, wmEvent *event)
{
+ const int do_fill = RNA_boolean_get(op->ptr, "use_fill");
+ UnorderedLoopPair *fill_uloop_pairs = NULL;
Object *obedit = CTX_data_edit_object(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -633,25 +877,25 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, wmEvent *event)
BMEdge *e, *e2;
BMVert *v;
const int totedge_orig = bm->totedge;
- int i;
float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
- int totedge;
- int all_minifold;
-
EdgeLoopPair *eloop_pairs;
ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
- /* important this runs on the original selection, before tempering with tagging */
+ /* important this runs on the original selection, before tampering with tagging */
eloop_pairs = edbm_ripsel_looptag_helper(bm);
/* expand edge selection */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ int all_manifold;
+ int totedge_manifold; /* manifold, visible edges */
+ int i;
+
e2 = NULL;
i = 0;
- totedge = 0;
- all_minifold = TRUE;
+ totedge_manifold = 0;
+ all_manifold = TRUE;
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
if (!BM_edge_is_wire(e) &&
@@ -663,22 +907,25 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, wmEvent *event)
e2 = e;
i++;
}
- totedge++;
+ totedge_manifold++;
}
/** #BM_vert_other_disk_edge has no hidden checks so don't check hidden here */
- if ((all_minifold == TRUE) && (BM_edge_is_manifold(e) == FALSE)) {
- all_minifold = FALSE;
+ if ((all_manifold == TRUE) && (BM_edge_is_manifold(e) == FALSE)) {
+ all_manifold = FALSE;
}
}
/* single edge, extend */
if (i == 1 && e2->l) {
- if ((totedge == 4) || (all_minifold == FALSE)) {
+ /* note: if the case of 3 edges has one change in loop stepping,
+ * if this becomes more involved we may be better off splitting
+ * the 3 edge case into its own else-if branch */
+ if ((totedge_manifold == 4 || totedge_manifold == 3) || (all_manifold == FALSE)) {
BMLoop *l_a = e2->l;
BMLoop *l_b = l_a->radial_next;
- /* find the best face to follow, this what the edge won't point away from
+ /* find the best face to follow, this way the edge won't point away from
* the mouse when there are more then 4 (takes the shortest face fan around) */
l = (edbm_rip_edge_side_measure(e2, l_a, ar, projectMat, fmval) <
edbm_rip_edge_side_measure(e2, l_b, ar, projectMat, fmval)) ? l_a : l_b;
@@ -688,9 +935,12 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, wmEvent *event)
* not crashing but adds duplicate edge. */
if (BM_edge_is_manifold(l->e)) {
l = l->radial_next;
- l = BM_face_other_edge_loop(l->f, l->e, v);
+
+ if (totedge_manifold != 3)
+ l = BM_face_other_edge_loop(l->f, l->e, v);
if (l) {
+ BLI_assert(!BM_elem_flag_test(l->e, BM_ELEM_TAG));
BM_elem_flag_enable(l->e, BM_ELEM_TAG);
}
}
@@ -699,13 +949,20 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, wmEvent *event)
e = BM_vert_other_disk_edge(v, e2);
if (e) {
+ BLI_assert(!BM_elem_flag_test(e, BM_ELEM_TAG));
BM_elem_flag_enable(e, BM_ELEM_TAG);
}
}
}
}
+ /* keep directly before edgesplit */
+ if (do_fill) {
+ fill_uloop_pairs = edbm_tagged_loop_pairs_to_fill(bm);
+ }
+
if (!edbm_rip_call_edgesplit(em, op)) {
+ if (fill_uloop_pairs) MEM_freeN(fill_uloop_pairs);
return OPERATOR_CANCELLED;
}
@@ -718,6 +975,11 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, wmEvent *event)
ar, projectMat, fmval);
MEM_freeN(eloop_pairs);
+ if (do_fill && fill_uloop_pairs) {
+ edbm_tagged_loop_pairs_do_fill_faces(bm, fill_uloop_pairs);
+ MEM_freeN(fill_uloop_pairs);
+ }
+
if (totedge_orig == bm->totedge) {
BKE_report(op->reports, RPT_ERROR, "No edges could be ripped");
return OPERATOR_CANCELLED;
@@ -740,12 +1002,12 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
int ret;
/* running in face mode hardly makes sense, so convert to region loop and rip */
- if (em->bm->totfacesel) {
+ if (bm->totfacesel) {
/* highly nifty but hard to support since the operator can fail and we're left
* with modified selection */
// WM_operator_name_call(C, "MESH_OT_region_to_loop", WM_OP_INVOKE_DEFAULT, NULL);
- BKE_report(op->reports, RPT_ERROR, "Can't rip selected faces");
+ BKE_report(op->reports, RPT_ERROR, "Cannot rip selected faces");
return OPERATOR_CANCELLED;
}
@@ -760,7 +1022,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
*/
/* BM_ELEM_SELECT --> BM_ELEM_TAG */
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
}
@@ -804,5 +1066,6 @@ void MESH_OT_rip(wmOperatorType *ot)
/* to give to transform */
Transform_Properties(ot, P_PROPORTIONAL);
- RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
+ RNA_def_boolean(ot->srna, "mirror", FALSE, "Mirror Editing", "");
+ RNA_def_boolean(ot->srna, "use_fill", FALSE, "Fill", "Fill the ripped region");
}
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 71f1b200dda..0bdb5032a30 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -57,6 +57,7 @@
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_uvedit.h"
+#include "ED_object.h"
#include "ED_view3d.h"
#include "GPU_colors.h"
@@ -331,9 +332,9 @@ int EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
}
-static void findnearestvert__doClosest(void *userData, BMVert *eve, int x, int y, int index)
+static void findnearestvert__doClosest(void *userData, BMVert *eve, const float screen_co[2], int index)
{
- struct { short mval[2], pass, select, strict; int dist, lastIndex, closestIndex; BMVert *closest; } *data = userData;
+ struct { float mval_fl[2], pass, select, strict; float dist, lastIndex, closestIndex; BMVert *closest; } *data = userData;
if (data->pass == 0) {
if (index <= data->lastIndex)
@@ -345,18 +346,18 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, int x, int y
}
if (data->dist > 3) {
- int temp = abs(data->mval[0] - x) + abs(data->mval[1] - y);
+ float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
if (BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->select) {
if (data->strict == 1) {
return;
}
else {
- temp += 5;
+ dist_test += 5;
}
}
- if (temp < data->dist) {
- data->dist = temp;
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
data->closest = eve;
data->closestIndex = index;
}
@@ -383,10 +384,10 @@ static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int
* if 0, unselected vertice are given the bias
* strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
*/
-BMVert *EDBM_vert_find_nearest(ViewContext *vc, int *dist, short sel, short strict)
+BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const short sel, const short strict)
{
if (vc->v3d->drawtype > OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) {
- int distance;
+ float distance;
unsigned int index;
BMVert *eve;
@@ -401,8 +402,8 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, int *dist, short sel, short stri
eve = BM_vert_at_index(vc->em->bm, index - 1);
- if (eve && distance < *dist) {
- *dist = distance;
+ if (eve && distance < *r_dist) {
+ *r_dist = distance;
return eve;
}
else {
@@ -411,7 +412,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, int *dist, short sel, short stri
}
else {
- struct { short mval[2], pass, select, strict; int dist, lastIndex, closestIndex; BMVert *closest; } data;
+ struct { float mval_fl[2], pass, select, strict; float dist, lastIndex, closestIndex; BMVert *closest; } data;
static int lastSelectedIndex = 0;
static BMVert *lastSelected = NULL;
@@ -421,10 +422,10 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, int *dist, short sel, short stri
}
data.lastIndex = lastSelectedIndex;
- data.mval[0] = vc->mval[0];
- data.mval[1] = vc->mval[1];
+ data.mval_fl[0] = vc->mval[0];
+ data.mval_fl[1] = vc->mval[1];
data.select = sel;
- data.dist = *dist;
+ data.dist = *r_dist;
data.strict = strict;
data.closest = NULL;
data.closestIndex = 0;
@@ -433,14 +434,14 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, int *dist, short sel, short stri
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
+ mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.dist > 3) {
data.pass = 1;
- mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
+ mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
- *dist = data.dist;
+ *r_dist = data.dist;
lastSelected = data.closest;
lastSelectedIndex = data.closestIndex;
@@ -463,18 +464,12 @@ float labda_PdistVL2Dfl(const float v1[2], const float v2[2], const float v3[2])
}
/* note; uses v3d, so needs active 3d window */
-static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index))
+static void findnearestedge__doClosest(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int UNUSED(index))
{
- struct { ViewContext vc; float mval[2]; int dist; BMEdge *closest; } *data = userData;
- float v1[2], v2[2];
+ struct { ViewContext vc; float mval_fl[2]; float dist; BMEdge *closest; } *data = userData;
int distance;
-
- v1[0] = x0;
- v1[1] = y0;
- v2[0] = x1;
- v2[1] = y1;
-
- distance = dist_to_line_segment_v2(data->mval, v1, v2);
+
+ distance = dist_to_line_segment_v2(data->mval_fl, screen_co_a, screen_co_b);
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
distance += 5;
@@ -482,7 +477,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int
if (distance < data->dist) {
if (data->vc.rv3d->rflag & RV3D_CLIPPING) {
- float labda = labda_PdistVL2Dfl(data->mval, v1, v2);
+ float labda = labda_PdistVL2Dfl(data->mval_fl, screen_co_a, screen_co_b);
float vec[3];
vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]);
@@ -500,11 +495,11 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int
}
}
}
-BMEdge *EDBM_edge_find_nearest(ViewContext *vc, int *dist)
+BMEdge *EDBM_edge_find_nearest(ViewContext *vc, float *r_dist)
{
if (vc->v3d->drawtype > OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) {
- int distance;
+ float distance;
unsigned int index;
BMEdge *eed;
@@ -513,8 +508,8 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, int *dist)
index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_solidoffs, bm_wireoffs, &distance, 0, NULL, NULL);
eed = BM_edge_at_index(vc->em->bm, index - 1);
- if (eed && distance < *dist) {
- *dist = distance;
+ if (eed && distance < *r_dist) {
+ *r_dist = distance;
return eed;
}
else {
@@ -522,36 +517,37 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, int *dist)
}
}
else {
- struct { ViewContext vc; float mval[2]; int dist; BMEdge *closest; } data;
+ struct { ViewContext vc; float mval_fl[2]; float dist; BMEdge *closest; } data;
data.vc = *vc;
- data.mval[0] = vc->mval[0];
- data.mval[1] = vc->mval[1];
- data.dist = *dist;
+ data.mval_fl[0] = vc->mval[0];
+ data.mval_fl[1] = vc->mval[1];
+ data.dist = *r_dist;
data.closest = NULL;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, V3D_CLIP_TEST_REGION);
+ mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, V3D_PROJ_TEST_CLIP_WIN);
- *dist = data.dist;
+ *r_dist = data.dist;
return data.closest;
}
}
-static void findnearestface__getDistance(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
+static void findnearestface__getDistance(void *userData, BMFace *efa, const float screen_co[2], int UNUSED(index))
{
- struct { short mval[2]; int dist; BMFace *toFace; } *data = userData;
+ struct { float mval_fl[2]; float dist; BMFace *toFace; } *data = userData;
if (efa == data->toFace) {
- int temp = abs(data->mval[0] - x) + abs(data->mval[1] - y);
+ const float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if (temp < data->dist)
- data->dist = temp;
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
+ }
}
}
-static void findnearestface__doClosest(void *userData, BMFace *efa, int x, int y, int index)
+static void findnearestface__doClosest(void *userData, BMFace *efa, const float screen_co[2], int index)
{
- struct { short mval[2], pass; int dist, lastIndex, closestIndex; BMFace *closest; } *data = userData;
+ struct { float mval_fl[2], pass; float dist, lastIndex, closestIndex; BMFace *closest; } *data = userData;
if (data->pass == 0) {
if (index <= data->lastIndex)
@@ -563,17 +559,17 @@ static void findnearestface__doClosest(void *userData, BMFace *efa, int x, int y
}
if (data->dist > 3) {
- int temp = abs(data->mval[0] - x) + abs(data->mval[1] - y);
+ const float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if (temp < data->dist) {
- data->dist = temp;
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
data->closest = efa;
data->closestIndex = index;
}
}
}
-BMFace *EDBM_face_find_nearest(ViewContext *vc, int *dist)
+BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
{
if (vc->v3d->drawtype > OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) {
@@ -586,17 +582,17 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, int *dist)
efa = BM_face_at_index(vc->em->bm, index - 1);
if (efa) {
- struct { short mval[2]; int dist; BMFace *toFace; } data;
+ struct { float mval_fl[2]; float dist; BMFace *toFace; } data;
- data.mval[0] = vc->mval[0];
- data.mval[1] = vc->mval[1];
+ data.mval_fl[0] = vc->mval[0];
+ data.mval_fl[1] = vc->mval[1];
data.dist = 0x7FFF; /* largest short */
data.toFace = efa;
- mesh_foreachScreenFace(vc, findnearestface__getDistance, &data);
+ mesh_foreachScreenFace(vc, findnearestface__getDistance, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- if (vc->em->selectmode == SCE_SELECT_FACE || data.dist < *dist) { /* only faces, no dist check */
- *dist = data.dist;
+ if ((vc->em->selectmode == SCE_SELECT_FACE) || (data.dist < *r_dist)) { /* only faces, no dist check */
+ *r_dist = data.dist;
return efa;
}
}
@@ -604,7 +600,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, int *dist)
return NULL;
}
else {
- struct { short mval[2], pass; int dist, lastIndex, closestIndex; BMFace *closest; } data;
+ struct { float mval_fl[2], pass; float dist, lastIndex, closestIndex; BMFace *closest; } data;
static int lastSelectedIndex = 0;
static BMFace *lastSelected = NULL;
@@ -614,23 +610,23 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, int *dist)
}
data.lastIndex = lastSelectedIndex;
- data.mval[0] = vc->mval[0];
- data.mval[1] = vc->mval[1];
- data.dist = *dist;
+ data.mval_fl[0] = vc->mval[0];
+ data.mval_fl[1] = vc->mval[1];
+ data.dist = *r_dist;
data.closest = NULL;
data.closestIndex = 0;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
data.pass = 0;
- mesh_foreachScreenFace(vc, findnearestface__doClosest, &data);
+ mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- if (data.dist > 3) {
+ if (data.dist > 3.0f) {
data.pass = 1;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenFace(vc, findnearestface__doClosest, &data);
+ mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
- *dist = data.dist;
+ *r_dist = data.dist;
lastSelected = data.closest;
lastSelectedIndex = data.closestIndex;
@@ -646,7 +642,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, int *dist)
static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
{
BMEditMesh *em = vc->em;
- int dist = 75;
+ float dist = 75.0f;
*r_eve = NULL;
*r_eed = NULL;
@@ -676,6 +672,13 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
}
/* **************** SIMILAR "group" SELECTS. FACE, EDGE AND VERTEX ************** */
+static EnumPropertyItem prop_similar_compare_types[] = {
+ {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""},
+ {SIM_CMP_GT, "GREATER", 0, "Greater", ""},
+ {SIM_CMP_LT, "LESS", 0, "Less", ""},
+
+ {0, NULL, 0, NULL, NULL}
+};
static EnumPropertyItem prop_similar_types[] = {
{SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""},
@@ -695,6 +698,7 @@ static EnumPropertyItem prop_similar_types[] = {
{SIMFACE_MATERIAL, "MATERIAL", 0, "Material", ""},
{SIMFACE_IMAGE, "IMAGE", 0, "Image", ""},
{SIMFACE_AREA, "AREA", 0, "Area", ""},
+ {SIMFACE_SIDES, "SIDES", 0, "Polygon Sides", ""},
{SIMFACE_PERIMETER, "PERIMETER", 0, "Perimeter", ""},
{SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""},
{SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""},
@@ -711,11 +715,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
BMOperator bmop;
/* get the type from RNA */
- int type = RNA_enum_get(op->ptr, "type");
- float thresh = RNA_float_get(op->ptr, "threshold");
+ const int type = RNA_enum_get(op->ptr, "type");
+ const float thresh = RNA_float_get(op->ptr, "threshold");
+ const int compare = RNA_enum_get(op->ptr, "compare");
/* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
- EDBM_op_init(em, &bmop, op, "similar_faces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
+ EDBM_op_init(em, &bmop, op,
+ "similar_faces faces=%hf type=%i thresh=%f compare=%i",
+ BM_ELEM_SELECT, type, thresh, compare);
/* execute the operator */
BMO_op_exec(em->bm, &bmop);
@@ -749,11 +756,14 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
BMOperator bmop;
/* get the type from RNA */
- int type = RNA_enum_get(op->ptr, "type");
- float thresh = RNA_float_get(op->ptr, "threshold");
+ const int type = RNA_enum_get(op->ptr, "type");
+ const float thresh = RNA_float_get(op->ptr, "threshold");
+ const int compare = RNA_enum_get(op->ptr, "compare");
/* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
- EDBM_op_init(em, &bmop, op, "similar_edges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
+ EDBM_op_init(em, &bmop, op,
+ "similar_edges edges=%he type=%i thresh=%f compare=%i",
+ BM_ELEM_SELECT, type, thresh, compare);
/* execute the operator */
BMO_op_exec(em->bm, &bmop);
@@ -790,11 +800,14 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
BMEditMesh *em = BMEdit_FromObject(ob);
BMOperator bmop;
/* get the type from RNA */
- int type = RNA_enum_get(op->ptr, "type");
+ const int type = RNA_enum_get(op->ptr, "type");
float thresh = RNA_float_get(op->ptr, "threshold");
+ const int compare = RNA_enum_get(op->ptr, "compare");
/* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
- EDBM_op_init(em, &bmop, op, "similar_verts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
+ EDBM_op_init(em, &bmop, op,
+ "similar_verts verts=%hv type=%i thresh=%f compare=%i",
+ BM_ELEM_SELECT, type, thresh, compare);
/* execute the operator */
BMO_op_exec(em->bm, &bmop);
@@ -823,7 +836,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
ToolSettings *ts = CTX_data_tool_settings(C);
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "threshold");
- int type = RNA_enum_get(op->ptr, "type");
+ const int type = RNA_enum_get(op->ptr, "type");
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_float_set(op->ptr, prop, ts->select_thresh);
@@ -834,7 +847,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
if (type < 100) return similar_vert_select_exec(C, op);
else if (type < 200) return similar_edge_select_exec(C, op);
- else return similar_face_select_exec(C, op);
+ else return similar_face_select_exec(C, op);
}
static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop),
@@ -898,7 +911,9 @@ void MESH_OT_select_similar(wmOperatorType *ot)
prop = ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", "");
RNA_def_enum_funcs(prop, select_similar_type_itemf);
- RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.01, 1.0);
+ RNA_def_enum(ot->srna, "compare", prop_similar_compare_types, SIM_CMP_EQ, "Compare", "");
+
+ RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.0, 1.0);
}
/* ***************************************************** */
@@ -1005,7 +1020,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
BMEditMesh *em;
BMEdge *eed;
int select = TRUE;
- int dist = 50;
+ float dist = 50.0f;
float mvalf[2];
em_setup_viewcontext(C, &vc);
@@ -1060,11 +1075,11 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
/* We can't be sure this has already been set... */
ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
- if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
length_1 = len_squared_v2v2(mvalf, v1_co);
}
- if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
length_2 = len_squared_v2v2(mvalf, v2_co);
}
#if 0
@@ -1091,7 +1106,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
float co[2], tdist;
BM_face_calc_center_mean(f, cent);
- if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
tdist = len_squared_v2v2(mvalf, co);
if (tdist < best_dist) {
/* printf("Best face: %p (%f)\n", f, tdist);*/
@@ -1161,19 +1176,17 @@ void MESH_OT_edgering_select(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring");
}
-/* ******************* edgetag_shortest_path and helpers ****************** */
+/* ******************* generic tag_shortest_path and helpers ****************** */
-static float edgetag_cut_cost(BMEditMesh *UNUSED(em), BMEdge *e1, BMEdge *e2, BMVert *v)
+static float step_cost_3_v3(const float v1[3], const float v2[3], const float v3[3])
{
- BMVert *v1 = (e1->v1 == v) ? e1->v2 : e1->v1;
- BMVert *v2 = (e2->v1 == v) ? e2->v2 : e2->v1;
float cost, d1[3], d2[3];
+
/* The cost is based on the simple sum of the length of the two edgees... */
- sub_v3_v3v3(d1, v->co, v1->co);
- sub_v3_v3v3(d2, v2->co, v->co);
- cost = len_v3(d1);
- cost += len_v3(d2);
+ sub_v3_v3v3(d1, v2, v1);
+ sub_v3_v3v3(d2, v3, v2);
+ cost = len_v3(d1) + len_v3(d2);
/* but is biased to give higher values to sharp turns, so that it will take
* paths with fewer "turns" when selecting between equal-weighted paths between
@@ -1183,39 +1196,49 @@ static float edgetag_cut_cost(BMEditMesh *UNUSED(em), BMEdge *e1, BMEdge *e2, BM
return cost;
}
-static void edgetag_add_adjacent(BMEditMesh *em, SmallHash *visithash, Heap *heap, int mednum, int vertnum,
- int *nedges, int *edges, int *prevedge, float *cost)
-{
- BMEdge *e1 = EDBM_edge_at_index(em, mednum);
- BMVert *v = EDBM_vert_at_index(em, vertnum);
- int startadj, endadj = nedges[vertnum + 1];
-
- for (startadj = nedges[vertnum]; startadj < endadj; startadj++) {
- int adjnum = edges[startadj];
- BMEdge *e2 = EDBM_edge_at_index(em, adjnum);
- float newcost;
- float cutcost;
+/* ******************* edgetag_shortest_path and helpers ****************** */
- if (BLI_smallhash_haskey(visithash, (uintptr_t)e2))
- continue;
+static float edgetag_cut_cost(BMEdge *e1, BMEdge *e2, BMVert *v)
+{
+ BMVert *v1 = BM_edge_other_vert(e1, v);
+ BMVert *v2 = BM_edge_other_vert(e2, v);
+ return step_cost_3_v3(v1->co, v->co, v2->co);
+}
- cutcost = edgetag_cut_cost(em, e1, e2, v);
- newcost = cost[mednum] + cutcost;
+static void edgetag_add_adjacent(Heap *heap, BMEdge *e1, BMEdge **edges_prev, float *cost)
+{
+ BMIter viter;
+ BMVert *v;
- if (cost[adjnum] > newcost) {
- cost[adjnum] = newcost;
- prevedge[adjnum] = mednum;
- BLI_heap_insert(heap, newcost, SET_INT_IN_POINTER(adjnum));
+ BMIter eiter;
+ BMEdge *e2;
+
+ const int e1_index = BM_elem_index_get(e1);
+
+ BM_ITER_ELEM (v, &viter, e1, BM_VERTS_OF_EDGE) {
+ BM_ITER_ELEM (e2, &eiter, v, BM_EDGES_OF_VERT) {
+ if (!BM_elem_flag_test(e2, BM_ELEM_TAG)) {
+ /* we know 'e2' is not visited, check it out! */
+ const int e2_index = BM_elem_index_get(e2);
+ const float cost_cut = edgetag_cut_cost(e1, e2, v);
+ const float cost_new = cost[e1_index] + cost_cut;
+
+ if (cost[e2_index] > cost_new) {
+ cost[e2_index] = cost_new;
+ edges_prev[e2_index] = e1;
+ BLI_heap_insert(heap, cost_new, e2);
+ }
+ }
}
}
}
-static void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *e, int val)
+static void edgetag_context_set(BMesh *bm, Scene *scene, BMEdge *e, int val)
{
switch (scene->toolsettings->edge_mode) {
case EDGE_MODE_SELECT:
- BM_edge_select_set(em->bm, e, val);
+ BM_edge_select_set(bm, e, val);
break;
case EDGE_MODE_TAG_SEAM:
BM_elem_flag_set(e, BM_ELEM_SEAM, val);
@@ -1224,98 +1247,66 @@ static void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *e, int val
BM_elem_flag_set(e, BM_ELEM_SMOOTH, !val);
break;
case EDGE_MODE_TAG_CREASE:
- {
- float *crease = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_CREASE);
- *crease = (val) ? 1.0f : 0.0f;
+ BM_elem_float_data_set(&bm->edata, e, CD_CREASE, (val) ? 1.0f : 0.0f);
break;
- }
case EDGE_MODE_TAG_BEVEL:
- {
- float *bweight = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_BWEIGHT);
- *bweight = (val) ? 1.0f : 0.0f;
+ BM_elem_float_data_set(&bm->edata, e, CD_BWEIGHT, (val) ? 1.0f : 0.0f);
break;
- }
}
}
-static int edgetag_context_check(Scene *scene, BMEditMesh *em, BMEdge *e)
+static int edgetag_context_check(Scene *scene, BMesh *bm, BMEdge *e)
{
switch (scene->toolsettings->edge_mode) {
case EDGE_MODE_SELECT:
- return BM_elem_flag_test(e, BM_ELEM_SELECT) ? 1 : 0;
+ return BM_elem_flag_test(e, BM_ELEM_SELECT) ? TRUE : FALSE;
case EDGE_MODE_TAG_SEAM:
return BM_elem_flag_test(e, BM_ELEM_SEAM);
case EDGE_MODE_TAG_SHARP:
return !BM_elem_flag_test(e, BM_ELEM_SMOOTH);
case EDGE_MODE_TAG_CREASE:
- return BM_elem_float_data_get(&em->bm->edata, e, CD_CREASE) ? 1 : 0;
+ return BM_elem_float_data_get(&bm->edata, e, CD_CREASE) ? TRUE : FALSE;
case EDGE_MODE_TAG_BEVEL:
- return BM_elem_float_data_get(&em->bm->edata, e, CD_BWEIGHT) ? 1 : 0;
+ return BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT) ? TRUE : FALSE;
}
return 0;
}
-static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge *target)
+static int edgetag_shortest_path(Scene *scene, BMesh *bm, BMEdge *e_src, BMEdge *e_dst)
{
+ /* BM_ELEM_TAG flag is used to store visited edges */
BMEdge *e;
- BMIter iter;
+ BMIter eiter;
Heap *heap;
- SmallHash visithash;
float *cost;
- int i, totvert = 0, totedge = 0, *nedges, *edges, *prevedge, mednum = -1, nedgeswap = 0;
- int targetnum;
-
- BLI_smallhash_init(&visithash);
+ BMEdge **edges_prev;
+ int i, totedge;
/* note, would pass BM_EDGE except we are looping over all edges anyway */
- BM_mesh_elem_index_ensure(em->bm, BM_VERT /* | BM_EDGE */);
+ BM_mesh_elem_index_ensure(bm, BM_VERT /* | BM_EDGE */);
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
- BLI_smallhash_insert(&visithash, (uintptr_t)e, NULL);
+ BM_ITER_MESH_INDEX (e, &eiter, bm, BM_EDGES_OF_MESH, i) {
+ if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == FALSE) {
+ BM_elem_flag_disable(e, BM_ELEM_TAG);
+ }
+ else {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
}
- BM_elem_index_set(e, totedge); /* set_inline */
- totedge++;
+ BM_elem_index_set(e, i); /* set_inline */
}
- em->bm->elem_index_dirty &= ~BM_EDGE;
+ bm->elem_index_dirty &= ~BM_EDGE;
/* alloc */
- totvert = em->bm->totvert;
- nedges = MEM_callocN(sizeof(*nedges) * totvert + 1, "SeamPathNEdges");
- edges = MEM_mallocN(sizeof(*edges) * totedge * 2, "SeamPathEdges");
- prevedge = MEM_mallocN(sizeof(*prevedge) * totedge, "SeamPathPrevious");
+ totedge = bm->totedge;
+ edges_prev = MEM_callocN(sizeof(*edges_prev) * totedge, "SeamPathPrevious");
cost = MEM_mallocN(sizeof(*cost) * totedge, "SeamPathCost");
- /* count edges, compute adjacent edges offsets and fill adjacent */
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- nedges[BM_elem_index_get(e->v1) + 1]++;
- nedges[BM_elem_index_get(e->v2) + 1]++;
- }
-
- for (i = 1; i < totvert; i++) {
- int newswap = nedges[i + 1];
- nedges[i + 1] = nedgeswap + nedges[i];
- nedgeswap = newswap;
- }
- nedges[0] = nedges[1] = 0;
-
- i = 0;
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- edges[nedges[BM_elem_index_get(e->v1) + 1]++] = i;
- edges[nedges[BM_elem_index_get(e->v2) + 1]++] = i;
-
- cost[i] = 1e20f;
- prevedge[i] = -1;
- i++;
- }
+ fill_vn_fl(cost, totedge, 1e20f);
/*
* Arrays are now filled as follows:
*
- * nedges[n] = sum of the # of edges incident to all vertices numbered 0 through n - 1
- * edges[edges[n]..edges[n - 1]] = the indices of of the edges incident to vertex n
- *
* As the search continues, prevedge[n] will be the previous edge on the shortest
* path found so far to edge n. The visitedhash will of course contain entries
* for edges that have been visited, cost[n] will contain the length of the shortest
@@ -1326,61 +1317,46 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
/* regular dijkstra shortest path, but over edges instead of vertices */
heap = BLI_heap_new();
- BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(BM_elem_index_get(source)));
- cost[BM_elem_index_get(source)] = 0.0f;
- EDBM_index_arrays_init(em, 1, 1, 0);
- targetnum = BM_elem_index_get(target);
+ BLI_heap_insert(heap, 0.0f, e_src);
+ cost[BM_elem_index_get(e_src)] = 0.0f;
- while (!BLI_heap_empty(heap)) {
- mednum = GET_INT_FROM_POINTER(BLI_heap_popmin(heap));
- e = EDBM_edge_at_index(em, mednum);
+ e = NULL;
- if (mednum == targetnum)
- break;
-
- if (BLI_smallhash_haskey(&visithash, (uintptr_t)e))
- continue;
+ while (!BLI_heap_is_empty(heap)) {
+ e = BLI_heap_popmin(heap);
- BLI_smallhash_insert(&visithash, (uintptr_t)e, NULL);
+ if (e == e_dst)
+ break;
- edgetag_add_adjacent(em, &visithash, heap, mednum, BM_elem_index_get(e->v1), nedges, edges, prevedge, cost);
- edgetag_add_adjacent(em, &visithash, heap, mednum, BM_elem_index_get(e->v2), nedges, edges, prevedge, cost);
+ if (!BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+ edgetag_add_adjacent(heap, e, edges_prev, cost);
+ }
}
- if (mednum == targetnum) {
- short allseams = 1;
+ if (e == e_dst) {
+ short all_set = TRUE;
/* Check whether the path is already completely tagged.
* if it is, the tags will be cleared instead of set. */
- mednum = targetnum;
+ e = e_dst;
do {
- e = EDBM_edge_at_index(em, mednum);
- if (!edgetag_context_check(scene, em, e)) {
- allseams = 0;
+ if (!edgetag_context_check(scene, bm, e)) {
+ all_set = FALSE;
break;
}
- mednum = prevedge[mednum];
- } while (mednum != BM_elem_index_get(source));
+ } while ((e = edges_prev[BM_elem_index_get(e)]));
/* Follow path back and source and add or remove tags */
- mednum = targetnum;
+ e = e_dst;
do {
- e = EDBM_edge_at_index(em, mednum);
- if (allseams)
- edgetag_context_set(em, scene, e, 0);
- else
- edgetag_context_set(em, scene, e, 1);
- mednum = prevedge[mednum];
- } while (mednum != -1);
+ edgetag_context_set(bm, scene, e, !all_set);
+ } while ((e = edges_prev[BM_elem_index_get(e)]));
}
- EDBM_index_arrays_free(em);
- MEM_freeN(nedges);
- MEM_freeN(edges);
- MEM_freeN(prevedge);
+ MEM_freeN(edges_prev);
MEM_freeN(cost);
BLI_heap_free(heap, NULL);
- BLI_smallhash_release(&visithash);
return 1;
}
@@ -1388,21 +1364,15 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
/* ******************* mesh shortest path select, uses prev-selected edge ****************** */
/* since you want to create paths with multiple selects, it doesn't have extend option */
-static int mouse_mesh_shortest_path(bContext *C, int mval[2])
+static int mouse_mesh_shortest_path_edge(bContext *C, ViewContext *vc)
{
- ViewContext vc;
- BMEditMesh *em;
- BMEdge *e;
- int dist = 50;
-
- em_setup_viewcontext(C, &vc);
- vc.mval[0] = mval[0];
- vc.mval[1] = mval[1];
- em = vc.em;
+ BMEditMesh *em = vc->em;
+ BMEdge *e_dst;
+ float dist = 75.0f;
- e = EDBM_edge_find_nearest(&vc, &dist);
- if (e) {
- Mesh *me = vc.obedit->data;
+ e_dst = EDBM_edge_find_nearest(vc, &dist);
+ if (e_dst) {
+ Mesh *me = vc->obedit->data;
int path = 0;
if (em->bm->selected.last) {
@@ -1411,8 +1381,8 @@ static int mouse_mesh_shortest_path(bContext *C, int mval[2])
if (ese && ese->htype == BM_EDGE) {
BMEdge *e_act;
e_act = (BMEdge *)ese->ele;
- if (e_act != e) {
- if (edgetag_shortest_path(vc.scene, em, e_act, e)) {
+ if (e_act != e_dst) {
+ if (edgetag_shortest_path(vc->scene, em->bm, e_act, e_dst)) {
BM_select_history_remove(em->bm, e_act);
path = 1;
}
@@ -1420,29 +1390,29 @@ static int mouse_mesh_shortest_path(bContext *C, int mval[2])
}
}
if (path == 0) {
- int act = (edgetag_context_check(vc.scene, em, e) == 0);
- edgetag_context_set(em, vc.scene, e, act); /* switch the edge option */
+ int act = (edgetag_context_check(vc->scene, em->bm, e_dst) == 0);
+ edgetag_context_set(em->bm, vc->scene, e_dst, act); /* switch the edge option */
}
EDBM_selectmode_flush(em);
/* even if this is selected it may not be in the selection list */
- if (edgetag_context_check(vc.scene, em, e) == 0)
- BM_select_history_remove(em->bm, e);
+ if (edgetag_context_check(vc->scene, em->bm, e_dst) == 0)
+ BM_select_history_remove(em->bm, e_dst);
else
- BM_select_history_store(em->bm, e);
+ BM_select_history_store(em->bm, e_dst);
/* force drawmode for mesh */
switch (CTX_data_tool_settings(C)->edge_mode) {
case EDGE_MODE_TAG_SEAM:
me->drawflag |= ME_DRAWSEAMS;
- ED_uvedit_live_unwrap(vc.scene, vc.obedit);
+ ED_uvedit_live_unwrap(vc->scene, vc->obedit);
break;
case EDGE_MODE_TAG_SHARP:
me->drawflag |= ME_DRAWSHARP;
break;
- case EDGE_MODE_TAG_CREASE:
+ case EDGE_MODE_TAG_CREASE:
me->drawflag |= ME_DRAWCREASES;
break;
case EDGE_MODE_TAG_BEVEL:
@@ -1460,17 +1430,229 @@ static int mouse_mesh_shortest_path(bContext *C, int mval[2])
}
+/* ******************* facetag_shortest_path and helpers ****************** */
+
+
+static float facetag_cut_cost(BMFace *f1, BMFace *f2, BMEdge *e)
+{
+ float f1_cent[3];
+ float f2_cent[3];
+ float e_cent[3];
+
+ BM_face_calc_center_mean(f1, f1_cent);
+ BM_face_calc_center_mean(f2, f2_cent);
+ mid_v3_v3v3(e_cent, e->v1->co, e->v2->co);
+
+ return step_cost_3_v3(f1_cent, e_cent, f2_cent);
+}
+
+static void facetag_add_adjacent(Heap *heap, BMFace *f1, BMFace **faces_prev, float *cost)
+{
+ BMIter liter;
+ BMLoop *l2;
+ BMFace *f2;
+
+ const int f1_index = BM_elem_index_get(f1);
+
+ /* loop over faces of face, but do so by first looping over loops */
+ BM_ITER_ELEM (l2, &liter, f1, BM_LOOPS_OF_FACE) {
+ BMLoop *l_first;
+ BMLoop *l_iter;
+
+ l_iter = l_first = l2;
+ do {
+ f2 = l_iter->f;
+ if (!BM_elem_flag_test(f2, BM_ELEM_TAG)) {
+ /* we know 'f2' is not visited, check it out! */
+ const int f2_index = BM_elem_index_get(f2);
+ const float cost_cut = facetag_cut_cost(f1, f2, l_iter->e);
+ const float cost_new = cost[f1_index] + cost_cut;
+
+ if (cost[f2_index] > cost_new) {
+ cost[f2_index] = cost_new;
+ faces_prev[f2_index] = f1;
+ BLI_heap_insert(heap, cost_new, f2);
+ }
+ }
+ } while ((l_iter = l_iter->radial_next) != l_first);
+ }
+}
+
+static void facetag_context_set(BMesh *bm, Scene *UNUSED(scene), BMFace *f, int val)
+{
+ BM_face_select_set(bm, f, val);
+}
+
+static int facetag_context_check(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
+{
+ return BM_elem_flag_test(f, BM_ELEM_SELECT) ? 1 : 0;
+}
+
+static int facetag_shortest_path(Scene *scene, BMesh *bm, BMFace *f_src, BMFace *f_dst)
+{
+ /* BM_ELEM_TAG flag is used to store visited edges */
+ BMFace *f;
+ BMIter fiter;
+ Heap *heap;
+ float *cost;
+ BMFace **faces_prev;
+ int i, totface;
+
+ /* note, would pass BM_EDGE except we are looping over all faces anyway */
+ // BM_mesh_elem_index_ensure(bm, BM_VERT /* | BM_EDGE */); // NOT NEEDED FOR FACETAG
+
+ BM_ITER_MESH_INDEX (f, &fiter, bm, BM_FACES_OF_MESH, i) {
+ if (BM_elem_flag_test(f, BM_ELEM_HIDDEN) == FALSE) {
+ BM_elem_flag_disable(f, BM_ELEM_TAG);
+ }
+ else {
+ BM_elem_flag_enable(f, BM_ELEM_TAG);
+ }
+
+ BM_elem_index_set(f, i); /* set_inline */
+ }
+ bm->elem_index_dirty &= ~BM_FACE;
+
+ /* alloc */
+ totface = bm->totface;
+ faces_prev = MEM_callocN(sizeof(*faces_prev) * totface, "SeamPathPrevious");
+ cost = MEM_mallocN(sizeof(*cost) * totface, "SeamPathCost");
+
+ fill_vn_fl(cost, totface, 1e20f);
+
+ /*
+ * Arrays are now filled as follows:
+ *
+ * As the search continues, faces_prev[n] will be the previous face on the shortest
+ * path found so far to face n. The visitedhash will of course contain entries
+ * for faces that have been visited, cost[n] will contain the length of the shortest
+ * path to face n found so far, Finally, heap is a priority heap which is built on the
+ * the same data as the cost array, but inverted: it is a worklist of faces prioritized
+ * by the shortest path found so far to the face.
+ */
+
+ /* regular dijkstra shortest path, but over faces instead of vertices */
+ heap = BLI_heap_new();
+ BLI_heap_insert(heap, 0.0f, f_src);
+ cost[BM_elem_index_get(f_src)] = 0.0f;
+
+ f = NULL;
+
+ while (!BLI_heap_is_empty(heap)) {
+ f = BLI_heap_popmin(heap);
+
+ if (f == f_dst)
+ break;
+
+ if (!BM_elem_flag_test(f, BM_ELEM_TAG)) {
+ BM_elem_flag_enable(f, BM_ELEM_TAG);
+ facetag_add_adjacent(heap, f, faces_prev, cost);
+ }
+ }
+
+ if (f == f_dst) {
+ short all_set = TRUE;
+
+ /* Check whether the path is already completely tagged.
+ * if it is, the tags will be cleared instead of set. */
+ f = f_dst;
+ do {
+ if (!facetag_context_check(scene, bm, f)) {
+ all_set = FALSE;
+ break;
+ }
+ } while ((f = faces_prev[BM_elem_index_get(f)]));
+
+ /* Follow path back and source and add or remove tags */
+ f = f_dst;
+ do {
+ facetag_context_set(bm, scene, f, !all_set);
+ } while ((f = faces_prev[BM_elem_index_get(f)]));
+ }
+
+ MEM_freeN(faces_prev);
+ MEM_freeN(cost);
+ BLI_heap_free(heap, NULL);
+
+ return 1;
+}
+
+static int mouse_mesh_shortest_path_face(bContext *C, ViewContext *vc)
+{
+ BMEditMesh *em = vc->em;
+ BMFace *f_dst;
+ float dist = 75.0f;
+
+ f_dst = EDBM_face_find_nearest(vc, &dist);
+ if (f_dst) {
+ int path = 0;
+ BMFace *f_act = BM_active_face_get(em->bm, FALSE, TRUE);
+
+ if (f_act) {
+ if (f_act != f_dst) {
+ if (facetag_shortest_path(vc->scene, em->bm, f_act, f_dst)) {
+ BM_select_history_remove(em->bm, f_act);
+ path = 1;
+ }
+ }
+ }
+ if (path == 0) {
+ int act = (facetag_context_check(vc->scene, em->bm, f_dst) == 0);
+ facetag_context_set(em->bm, vc->scene, f_dst, act); /* switch the face option */
+ }
+
+ EDBM_selectmode_flush(em);
+
+ /* even if this is selected it may not be in the selection list */
+ if (facetag_context_check(vc->scene, em->bm, f_dst) == 0)
+ BM_select_history_remove(em->bm, f_dst);
+ else
+ BM_select_history_store(em->bm, f_dst);
+
+ BM_active_face_set(em->bm, f_dst);
+
+ EDBM_update_generic(C, em, FALSE);
+
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+
+/* ******************* operator for edge and face tag ****************** */
+
static int edbm_shortest_path_select_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
-
+ ViewContext vc;
+ BMEditMesh *em;
+
view3d_operator_needs_opengl(C);
- if (mouse_mesh_shortest_path(C, event->mval)) {
- return OPERATOR_FINISHED;
+ em_setup_viewcontext(C, &vc);
+ vc.mval[0] = event->mval[0];
+ vc.mval[1] = event->mval[1];
+ em = vc.em;
+
+ if (em->selectmode & SCE_SELECT_EDGE) {
+ if (mouse_mesh_shortest_path_edge(C, &vc)) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_PASS_THROUGH;
+ }
}
- else {
- return OPERATOR_PASS_THROUGH;
+ else if (em->selectmode & SCE_SELECT_FACE) {
+ if (mouse_mesh_shortest_path_face(C, &vc)) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_PASS_THROUGH;
+ }
}
+
+ return OPERATOR_PASS_THROUGH;
}
static int edbm_shortest_path_select_poll(bContext *C)
@@ -1478,7 +1660,7 @@ static int edbm_shortest_path_select_poll(bContext *C)
if (ED_operator_editmesh_region_view3d(C)) {
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
- return (em->selectmode & SCE_SELECT_EDGE) != 0;
+ return (em->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_FACE)) != 0;
}
return 0;
}
@@ -1712,7 +1894,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, short selectmode_old, short selectm
BM_edge_select_set(em->bm, eed, TRUE);
}
}
- }
+ }
else if (selectmode_new == SCE_SELECT_FACE) {
BMIter liter;
BMLoop *l;
@@ -2170,11 +2352,19 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h
BMW_FLAG_NOP, /* don't use BMW_FLAG_TEST_HIDDEN here since we want to desel all */
BMW_NIL_LAY);
+ /* use tag to avoid touching the same verts twice */
+ BM_ITER_MESH (ele, &iter, bm, itertype) {
+ BM_elem_flag_disable(ele, BM_ELEM_TAG);
+ }
+
BLI_assert(walker.order == BMW_BREADTH_FIRST);
for (ele = BMW_begin(&walker, h_act); ele != NULL; ele = BMW_step(&walker)) {
- /* Deselect elements that aren't at "nth" depth from active */
- if ((offset + BMW_current_depth(&walker)) % nth) {
- BM_elem_select_set(bm, ele, FALSE);
+ if (!BM_elem_flag_test(ele, BM_ELEM_TAG)) {
+ /* Deselect elements that aren't at "nth" depth from active */
+ if ((offset + BMW_current_depth(&walker)) % nth) {
+ BM_elem_select_set(bm, ele, FALSE);
+ }
+ BM_elem_flag_enable(ele, BM_ELEM_TAG);
}
}
BMW_end(&walker);
@@ -2286,9 +2476,9 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
void MESH_OT_select_nth(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Select Nth";
+ ot->name = "Checker Deselect";
ot->idname = "MESH_OT_select_nth";
- ot->description = "Select every Nth element starting from a selected vertex, edge or face";
+ ot->description = "Deselect every Nth element starting from a selected vertex, edge or face";
/* api callbacks */
ot->exec = edbm_select_nth_exec;
@@ -2297,8 +2487,8 @@ void MESH_OT_select_nth(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "nth", 2, 2, 100, "Nth Selection", "", 1, INT_MAX);
- RNA_def_int(ot->srna, "offset", 0, 0, 100, "Offset", "", 0, INT_MAX);
+ RNA_def_int(ot->srna, "nth", 2, 2, INT_MAX, "Nth Selection", "", 2, 100);
+ RNA_def_int(ot->srna, "offset", 0, 0, INT_MAX, "Offset", "", 0, 100);
}
void em_setup_viewcontext(bContext *C, ViewContext *vc)
@@ -2469,7 +2659,7 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op)
*/
if (em->selectmode == SCE_SELECT_FACE) {
- BKE_report(op->reports, RPT_ERROR, "Doesn't work in face selection mode");
+ BKE_report(op->reports, RPT_ERROR, "Does not work in face selection mode");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c
index 85fc8011e9b..5d77dd88c91 100644
--- a/source/blender/editors/mesh/editmesh_slide.c
+++ b/source/blender/editors/mesh/editmesh_slide.c
@@ -34,6 +34,8 @@
#include "BLI_array.h"
#include "BLI_math.h"
+#include "BLF_translation.h"
+
#include "BKE_context.h"
#include "BKE_report.h"
#include "BKE_tessmesh.h"
@@ -114,11 +116,11 @@ static int vtx_slide_init(bContext *C, wmOperator *op)
/* Custom data */
VertexSlideOp *vso;
- const char *header_str = "Vertex Slide: Hover over an edge and left-click to select slide edge. "
- "Left-Shift: Midpoint Snap, Left-Alt: Snap, Left-Ctrl: Snap&Merge";
+ const char *header_str = TIP_("Vertex Slide: Hover over an edge and left-click to select slide edge. "
+ "Left-Shift: Midpoint Snap, Left-Alt: Snap, Left-Ctrl: Snap & Merge");
if (!obedit) {
- BKE_report(op->reports, RPT_ERROR, "Vertex Slide Error: Not object in context");
+ BKE_report(op->reports, RPT_ERROR, "Vertex slide error: no object in context");
return FALSE;
}
@@ -127,7 +129,7 @@ static int vtx_slide_init(bContext *C, wmOperator *op)
/* Is there a starting vertex ? */
if (ese == NULL || (ese->htype != BM_VERT && ese->htype != BM_EDGE)) {
- BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex Slide Error: Select a (single) vertex");
+ BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex slide error: select a (single) vertex");
return FALSE;
}
@@ -178,7 +180,7 @@ static int vtx_slide_init(bContext *C, wmOperator *op)
/* Init frame */
if (!vtx_slide_set_frame(vso)) {
- BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex Slide: Can't find starting vertex!");
+ BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex slide error: cannot find starting vertex!");
vtx_slide_exit(C, op);
return FALSE;
}
@@ -393,8 +395,8 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2])
mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co);
/* we could use ED_view3d_project_float_object here, but for now dont since we dont have the context */
- if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
- (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
{
const float dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
if (dist < min_dist) {
@@ -412,7 +414,8 @@ static void vtx_slide_find_edge(VertexSlideOp *vso, wmEvent *event)
/* Nearest edge */
BMEdge *nst_edge = NULL;
- const float mval_float[] = { (float)event->mval[0], (float)event->mval[1]};
+ const float mval_float[2] = {(float)event->mval[0],
+ (float)event->mval[1]};
/* Set mouse coords */
copy_v2_v2_int(vso->view_context->mval, event->mval);
@@ -461,8 +464,8 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event)
mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co);
mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co);
- if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) ||
- (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS))
+ if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) ||
+ (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK))
{
/* not much we can do here */
return;
@@ -721,7 +724,7 @@ static int edbm_vertex_slide_exec_ex(bContext *C, wmOperator *op, const int do_u
/* Is there a starting vertex ? */
if ((ese == NULL) || (ese->htype != BM_VERT && ese->htype != BM_EDGE)) {
- BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex Slide Error: Select a (single) vertex");
+ BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex slide error: select a (single) vertex");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 879e20fcf8b..0c5c756a0fc 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -41,7 +41,9 @@
#include "RNA_define.h"
#include "RNA_access.h"
+#include "BLI_array.h"
#include "BLI_blenlib.h"
+#include "BLI_noise.h"
#include "BLI_math.h"
#include "BLI_rand.h"
@@ -49,6 +51,7 @@
#include "BKE_context.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_depsgraph.h"
+#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_texture.h"
@@ -72,6 +75,8 @@
#include "mesh_intern.h"
+#define MVAL_PIXEL_MARGIN 5.0f
+
/* allow accumulated normals to form a new direction but don't
* accept direct opposite directions else they will cancel each other out */
static void add_normal_aligned(float nor[3], const float add[3])
@@ -153,6 +158,51 @@ void MESH_OT_subdivide(wmOperatorType *ot)
}
+static int edbm_unsubdivide_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMOperator bmop;
+
+ int iterations = RNA_int_get(op->ptr, "iterations");
+
+ EDBM_op_init(em, &bmop, op,
+ "unsubdivide verts=%hv iterations=%i", BM_ELEM_SELECT, iterations);
+
+ BMO_op_exec(em->bm, &bmop);
+
+ if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
+ return 0;
+ }
+
+ if ((em->selectmode & SCE_SELECT_VERTEX) == 0) {
+ EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); /* need to flush vert->face first */
+ }
+ EDBM_selectmode_flush(em);
+
+ EDBM_update_generic(C, em, TRUE);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_unsubdivide(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Un-Subdivide";
+ ot->description = "UnSubdivide selected edges & faces";
+ ot->idname = "MESH_OT_unsubdivide";
+
+ /* api callbacks */
+ ot->exec = edbm_unsubdivide_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_int(ot->srna, "iterations", 2, 1, INT_MAX, "Iterations", "Number of times to unsubdivide", 1, 100);
+}
+
void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
{
Object *obedit = em->ob;
@@ -165,7 +215,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
float mval[2], co_proj[3], no_dummy[3];
int dist_dummy;
- if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
if (snapObjectsContext(C, mval, &dist_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) {
mul_v3_m4v3(eve->co, obedit->imat, co_proj);
}
@@ -205,7 +255,7 @@ static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const c
return 0;
}
- return 's'; // s is shrink/fatten
+ return 's'; /* s is shrink/fatten */
}
/* extrudes individual edges */
@@ -225,7 +275,7 @@ static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char
return 0;
}
- return 'n'; // n is normal grab
+ return 'n'; /* n is normal grab */
}
/* extrudes individual vertices */
@@ -245,7 +295,7 @@ static short edbm_extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char
return 0;
}
- return 'g'; // g is grab
+ return 'g'; /* g is grab */
}
static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, float nor[3])
@@ -429,8 +479,8 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, FLT_MAX);
- RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, INT_MAX);
+ RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, FLT_MAX, "Offset", "", 0.0f, 100.0f);
+ RNA_def_int(ot->srna, "steps", 10, 0, INT_MAX, "Steps", "", 0, 180);
}
/* generic extern called extruder */
@@ -765,10 +815,10 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
done = FALSE;
BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- float co1[3], co2[3];
+ float co1[2], co2[2];
- if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
- (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
{
/* 2D rotate by 90d while adding.
* (x, y) = (y, -x)
@@ -1215,10 +1265,13 @@ static int edbm_vert_connect(bContext *C, wmOperator *op)
if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
return OPERATOR_CANCELLED;
}
-
- EDBM_update_generic(C, em, TRUE);
+ else {
+ EDBM_selectmode_flush(em); /* so newly created edges get the selection state from the vertex */
- return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+ EDBM_update_generic(C, em, TRUE);
+
+ return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+ }
}
void MESH_OT_vert_connect(wmOperatorType *ot)
@@ -1607,12 +1660,94 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "repeat", 1, 1, 100, "Number of times to smooth the mesh", "", 1, INT_MAX);
+ RNA_def_int(ot->srna, "repeat", 1, 1, 1000, "Number of times to smooth the mesh", "", 1, 100);
RNA_def_boolean(ot->srna, "xaxis", 1, "X-Axis", "Smooth along the X axis");
RNA_def_boolean(ot->srna, "yaxis", 1, "Y-Axis", "Smooth along the Y axis");
RNA_def_boolean(ot->srna, "zaxis", 1, "Z-Axis", "Smooth along the Z axis");
}
+static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ int usex = TRUE, usey = TRUE, usez = TRUE, volume_preservation = TRUE;
+ int i, repeat;
+ float lambda;
+ float lambda_border;
+ BMIter fiter;
+ BMFace *f;
+
+ /* Check if select faces are triangles */
+ BM_ITER_MESH (f, &fiter, em->bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ if (f->len > 4) {
+ BKE_report(op->reports, RPT_WARNING, "Selected faces must be triangles or quads");
+ return OPERATOR_CANCELLED;
+ }
+ }
+ }
+
+ /* mirror before smooth */
+ if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) {
+ EDBM_verts_mirror_cache_begin(em, TRUE);
+ }
+
+ repeat = RNA_int_get(op->ptr, "repeat");
+ lambda = RNA_float_get(op->ptr, "lambda");
+ lambda_border = RNA_float_get(op->ptr, "lambda_border");
+ usex = RNA_boolean_get(op->ptr, "use_x");
+ usey = RNA_boolean_get(op->ptr, "use_y");
+ usez = RNA_boolean_get(op->ptr, "use_z");
+ volume_preservation = RNA_boolean_get(op->ptr, "volume_preservation");
+ if (!repeat)
+ repeat = 1;
+
+ for (i = 0; i < repeat; i++) {
+ if (!EDBM_op_callf(em, op,
+ "smooth_laplacian_vert verts=%hv lambda=%f lambda_border=%f use_x=%b use_y=%b use_z=%b volume_preservation=%b",
+ BM_ELEM_SELECT, lambda, lambda_border, usex, usey, usez, volume_preservation))
+ {
+ return OPERATOR_CANCELLED;
+ }
+ }
+
+ /* apply mirror */
+ if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) {
+ EDBM_verts_mirror_apply(em, BM_ELEM_SELECT, 0);
+ EDBM_verts_mirror_cache_end(em);
+ }
+
+ EDBM_update_generic(C, em, TRUE);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Laplacian Smooth Vertex";
+ ot->description = "Laplacian smooth of selected vertices";
+ ot->idname = "MESH_OT_vertices_smooth_laplacian";
+
+ /* api callbacks */
+ ot->exec = edbm_do_smooth_laplacian_vertex_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_int(ot->srna, "repeat", 1, 1, 200,
+ "Number of iterations to smooth the mesh", "", 1, 200);
+ RNA_def_float(ot->srna, "lambda", 0.00005f, 0.0000001f, 1000.0f,
+ "Lambda factor", "", 0.0000001f, 1000.0f);
+ RNA_def_float(ot->srna, "lambda_border", 0.00005f, 0.0000001f, 1000.0f,
+ "Lambda factor in border", "", 0.0000001f, 1000.0f);
+ RNA_def_boolean(ot->srna, "use_x", 1, "Smooth X Axis", "Smooth object along X axis");
+ RNA_def_boolean(ot->srna, "use_y", 1, "Smooth Y Axis", "Smooth object along Y axis");
+ RNA_def_boolean(ot->srna, "use_z", 1, "Smooth Z Axis", "Smooth object along Z axis");
+ RNA_def_boolean(ot->srna, "volume_preservation", 1, "Preserve Volume", "Apply volume preservation after smooth");
+}
+
/********************** Smooth/Solid Operators *************************/
static void mesh_set_smooth_faces(BMEditMesh *em, short smooth)
@@ -2080,7 +2215,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
}
count = totvert_orig - em->bm->totvert;
- BKE_reportf(op->reports, RPT_INFO, "Removed %d vert%s", count, (count == 1) ? "ex" : "ices");
+ BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", count);
EDBM_update_generic(C, em, TRUE);
@@ -2165,7 +2300,7 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op)
}
if (svert == NULL || evert == NULL) {
- BKE_report(op->reports, RPT_WARNING, "Path Selection requires that two vertices be selected");
+ BKE_report(op->reports, RPT_WARNING, "Path selection requires two vertices to be selected");
return OPERATOR_CANCELLED;
}
@@ -2659,21 +2794,21 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2],
m1 = MAXSLOPE;
b1 = x12;
}
- x2max = maxf(x21, x22) + 0.001f; /* prevent missed edges */
- x2min = minf(x21, x22) - 0.001f; /* due to round off error */
- y2max = maxf(y21, y22) + 0.001f;
- y2min = minf(y21, y22) - 0.001f;
+ x2max = max_ff(x21, x22) + 0.001f; /* prevent missed edges */
+ x2min = min_ff(x21, x22) - 0.001f; /* due to round off error */
+ y2max = max_ff(y21, y22) + 0.001f;
+ y2min = min_ff(y21, y22) - 0.001f;
/* Found an intersect, calc intersect point */
if (m1 == m2) { /* co-incident lines */
/* cut at 50% of overlap area */
- x1max = maxf(x11, x12);
- x1min = minf(x11, x12);
- xi = (minf(x2max, x1max) + maxf(x2min, x1min)) / 2.0f;
+ x1max = max_ff(x11, x12);
+ x1min = min_ff(x11, x12);
+ xi = (min_ff(x2max, x1max) + max_ff(x2min, x1min)) / 2.0f;
- y1max = maxf(y11, y12);
- y1min = minf(y11, y12);
- yi = (minf(y2max, y1max) + maxf(y2min, y1min)) / 2.0f;
+ y1max = max_ff(y11, y12);
+ y1min = min_ff(y11, y12);
+ yi = (min_ff(y2max, y1max) + max_ff(y2min, y1min)) / 2.0f;
}
else if (m2 == MAXSLOPE) {
xi = x22;
@@ -2713,7 +2848,7 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2],
break;
}
- }
+ }
lastdist = dist;
}
return perc;
@@ -2772,7 +2907,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
screen_vert_coords = sco = MEM_mallocN(bm->totvert * sizeof(float) * 2, __func__);
BM_ITER_MESH_INDEX (bv, &iter, bm, BM_VERTS_OF_MESH, i) {
- if (ED_view3d_project_float_object(ar, bv->co, *sco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_object(ar, bv->co, *sco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
copy_v2_fl(*sco, FLT_MAX); /* set error value */
}
BM_elem_index_set(bv, i); /* set_ok */
@@ -3078,7 +3213,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
}
else {
if (type == 0) {
- BKE_report(op->reports, RPT_ERROR, "Selecton not supported in object mode");
+ BKE_report(op->reports, RPT_ERROR, "Selection not supported in object mode");
return OPERATOR_CANCELLED;
}
@@ -3359,7 +3494,8 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
BMesh *bm = em->bm;
- float angle_limit = RNA_float_get(op->ptr, "angle_limit");
+ const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
+ const int use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries");
char dissolve_flag;
@@ -3395,8 +3531,8 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
}
if (!EDBM_op_callf(em, op,
- "dissolve_limit edges=%he verts=%hv angle_limit=%f",
- dissolve_flag, dissolve_flag, angle_limit))
+ "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b",
+ dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries))
{
return OPERATOR_CANCELLED;
}
@@ -3423,8 +3559,10 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_float_rotation(ot->srna, "angle_limit", 0, NULL, 0.0f, DEG2RADF(180.0f),
- "Max Angle", "Angle Limit in Degrees", 0.0f, DEG2RADF(180.0f));
+ "Max Angle", "Angle limit", 0.0f, DEG2RADF(180.0f));
RNA_def_property_float_default(prop, DEG2RADF(15.0f));
+ RNA_def_boolean(ot->srna, "use_dissolve_boundaries", 0, "All Boundaries",
+ "Dissolve all vertices inbetween face boundaries");
}
static int edbm_split_exec(bContext *C, wmOperator *op)
@@ -3542,7 +3680,7 @@ void MESH_OT_spin(wmOperatorType *ot)
RNA_def_float(ot->srna, "degrees", 90.0f, -FLT_MAX, FLT_MAX, "Degrees", "Degrees", -360.0f, 360.0f);
RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
- RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX);
+ RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX, "Axis", "Axis in global view space", -1.0f, 1.0f);
}
@@ -3666,34 +3804,40 @@ void MESH_OT_screw(wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX,
"Center", "Center in global view space", -FLT_MAX, FLT_MAX);
- RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f,
- "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX);
+ RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX,
+ "Axis", "Axis in global view space", -1.0f, 1.0f);
}
-static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op)
+static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
BMFace *efa;
BMIter iter;
- int numverts = RNA_int_get(op->ptr, "number");
- int type = RNA_enum_get(op->ptr, "type");
+ const int numverts = RNA_int_get(op->ptr, "number");
+ const int type = RNA_enum_get(op->ptr, "type");
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- int select = 0;
+ int select;
- if (type == 0 && efa->len < numverts) {
- select = 1;
- }
- else if (type == 1 && efa->len == numverts) {
- select = 1;
- }
- else if (type == 2 && efa->len > numverts) {
- select = 1;
- }
- else if (type == 3 && efa->len != numverts) {
- select = 1;
+ switch (type) {
+ case 0:
+ select = (efa->len < numverts);
+ break;
+ case 1:
+ select = (efa->len == numverts);
+ break;
+ case 2:
+ select = (efa->len > numverts);
+ break;
+ case 3:
+ select = (efa->len != numverts);
+ break;
+ default:
+ BLI_assert(0);
+ select = FALSE;
+ break;
}
if (select) {
@@ -3707,7 +3851,7 @@ static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void MESH_OT_select_by_number_vertices(wmOperatorType *ot)
+void MESH_OT_select_face_by_sides(wmOperatorType *ot)
{
static const EnumPropertyItem type_items[] = {
{0, "LESS", 0, "Less Than", ""},
@@ -3718,12 +3862,12 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot)
};
/* identifiers */
- ot->name = "Select by Number of Vertices";
- ot->description = "Select vertices or faces by vertex count";
- ot->idname = "MESH_OT_select_by_number_vertices";
+ ot->name = "Select Faces by Sides";
+ ot->description = "Select vertices or faces by the number of polygon sides";
+ ot->idname = "MESH_OT_select_face_by_sides";
/* api callbacks */
- ot->exec = edbm_select_by_number_vertices_exec;
+ ot->exec = edbm_select_face_by_sides_exec;
ot->poll = ED_operator_editmesh;
/* flags */
@@ -3851,8 +3995,8 @@ static void sort_bmelem_flag(Scene *scene, Object *ob,
char *pblock[3] = {NULL, NULL, NULL}, *pb;
BMElemSort *sblock[3] = {NULL, NULL, NULL}, *sb;
int *map[3] = {NULL, NULL, NULL}, *mp;
- int totelem[3] = {0, 0, 0}, tot;
- int affected[3] = {0, 0, 0}, aff;
+ int totelem[3] = {0, 0, 0};
+ int affected[3] = {0, 0, 0};
int i, j;
if (!(types && flag && action))
@@ -4227,8 +4371,8 @@ static void sort_bmelem_flag(Scene *scene, Object *ob,
if (pb && sb && !map[j]) {
char *p_blk;
BMElemSort *s_blk;
- tot = totelem[j];
- aff = affected[j];
+ int tot = totelem[j];
+ int aff = affected[j];
qsort(sb, aff, sizeof(BMElemSort), bmelemsort_comp);
@@ -4277,7 +4421,7 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) {
if (rv3d == NULL) {
- BKE_report(op->reports, RPT_ERROR, "View not found, can't sort by view axis");
+ BKE_report(op->reports, RPT_ERROR, "View not found, cannot sort by view axis");
return OPERATOR_CANCELLED;
}
}
@@ -4458,13 +4602,18 @@ void MESH_OT_noise(wmOperatorType *ot)
RNA_def_float(ot->srna, "factor", 0.1f, -FLT_MAX, FLT_MAX, "Factor", "", 0.0f, 1.0f);
}
+#define NEW_BEVEL 1
+
typedef struct {
BMEditMesh *em;
BMBackup mesh_backup;
+#ifndef NEW_BEVEL
float *weights;
int li;
+#endif
int mcenter[2];
float initial_length;
+ float pixel_size; /* use when mouse input is interpreted as spatial distance */
int is_modal;
NumInput num_input;
float shift_factor; /* The current factor when shift is pressed. Negative when shift not active. */
@@ -4474,13 +4623,25 @@ typedef struct {
static void edbm_bevel_update_header(wmOperator *op, bContext *C)
{
+#ifdef NEW_BEVEL
+ static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RMB), offset: %s, segments: %d";
+#else
static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RMB), factor: %s, Use Dist (D): %s: Use Even (E): %s";
+ BevelData *opdata = op->customdata;
+#endif
char msg[HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
- BevelData *opdata = op->customdata;
if (sa) {
+#ifdef NEW_BEVEL
+ char offset_str[NUM_STR_REP_LEN];
+ BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
+ BLI_snprintf(msg, HEADER_LENGTH, str,
+ offset_str,
+ RNA_int_get(op->ptr, "segments")
+ );
+#else
char factor_str[NUM_STR_REP_LEN];
if (hasNumInput(&opdata->num_input))
outputNumInput(&opdata->num_input, factor_str);
@@ -4491,11 +4652,13 @@ static void edbm_bevel_update_header(wmOperator *op, bContext *C)
RNA_boolean_get(op->ptr, "use_dist") ? "On" : "Off",
RNA_boolean_get(op->ptr, "use_even") ? "On" : "Off"
);
+#endif
ED_area_headerprint(sa, msg);
}
}
+#ifndef NEW_BEVEL
static void edbm_bevel_recalc_weights(wmOperator *op)
{
float df, s, ftot;
@@ -4523,15 +4686,20 @@ static void edbm_bevel_recalc_weights(wmOperator *op)
mul_vn_fl(opdata->weights, recursion, 1.0f / (float)ftot);
}
+#endif
static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
+#ifdef NEW_BEVEL
+ BevelData *opdata;
+#else
BMIter iter;
BMEdge *eed;
BevelData *opdata;
int li;
+#endif
if (em == NULL) {
return 0;
@@ -4539,6 +4707,7 @@ static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
+#ifndef NEW_BEVEL
BM_data_layer_add(em->bm, &em->bm->edata, CD_PROP_FLT);
li = CustomData_number_of_layers(&em->bm->edata, CD_PROP_FLT) - 1;
@@ -4548,10 +4717,12 @@ static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
*dv = d;
}
-
- opdata->em = em;
+
opdata->li = li;
opdata->weights = NULL;
+#endif
+
+ opdata->em = em;
opdata->is_modal = is_modal;
opdata->shift_factor = -1.0f;
@@ -4561,7 +4732,9 @@ static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
/* avoid the cost of allocating a bm copy */
if (is_modal)
opdata->mesh_backup = EDBM_redo_state_store(em);
+#ifndef NEW_BEVEL
edbm_bevel_recalc_weights(op);
+#endif
return 1;
}
@@ -4571,6 +4744,26 @@ static int edbm_bevel_calc(bContext *C, wmOperator *op)
BevelData *opdata = op->customdata;
BMEditMesh *em = opdata->em;
BMOperator bmop;
+#ifdef NEW_BEVEL
+ float offset = RNA_float_get(op->ptr, "offset");
+ int segments = RNA_int_get(op->ptr, "segments");
+
+ /* revert to original mesh */
+ if (opdata->is_modal) {
+ EDBM_redo_state_restore(opdata->mesh_backup, em, FALSE);
+ }
+
+ if (!EDBM_op_init(em, &bmop, op,
+ "bevel geom=%hev offset=%f segments=%i",
+ BM_ELEM_SELECT, offset, segments))
+ {
+ return 0;
+ }
+
+ BMO_op_exec(em->bm, &bmop);
+ if (!EDBM_op_finish(em, &bmop, op, TRUE))
+ return 0;
+#else
int i;
float factor = RNA_float_get(op->ptr, "percent") /*, dfac */ /* UNUSED */;
@@ -4598,6 +4791,7 @@ static int edbm_bevel_calc(bContext *C, wmOperator *op)
if (!EDBM_op_finish(em, &bmop, op, TRUE))
return 0;
}
+#endif
EDBM_mesh_normals_update(opdata->em);
@@ -4615,10 +4809,12 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op)
if (sa) {
ED_area_headerprint(sa, NULL);
}
+#ifndef NEW_BEVEL
BM_data_layer_free_n(opdata->em->bm, &opdata->em->bm->edata, CD_PROP_FLT, opdata->li);
if (opdata->weights)
MEM_freeN(opdata->weights);
+#endif
if (opdata->is_modal) {
EDBM_redo_state_free(&opdata->mesh_backup, NULL, FALSE);
}
@@ -4662,8 +4858,10 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op)
static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
/* TODO make modal keymap (see fly mode) */
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
BevelData *opdata;
float mlen[2];
+ float center_3d[3];
if (!edbm_bevel_init(C, op, TRUE)) {
return OPERATOR_CANCELLED;
@@ -4672,7 +4870,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event)
opdata = op->customdata;
/* initialize mouse values */
- if (!calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter)) {
+ if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
/* in this case the tool will likely do nothing,
* ideally this will never happen and should be checked for above */
opdata->mcenter[0] = opdata->mcenter[1] = 0;
@@ -4680,6 +4878,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event)
mlen[0] = opdata->mcenter[0] - event->mval[0];
mlen[1] = opdata->mcenter[1] - event->mval[1];
opdata->initial_length = len_v2(mlen);
+ opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
edbm_bevel_update_header(op, C);
@@ -4693,12 +4892,66 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
+static float edbm_bevel_mval_factor(wmOperator *op, wmEvent *event)
+{
+ BevelData *opdata = op->customdata;
+#ifdef NEW_BEVEL
+ int use_dist = TRUE;
+#else
+ int use_dist = RNA_boolean_get(op->ptr, "use_dist");
+#endif
+ float mdiff[2];
+ float factor;
+
+ mdiff[0] = opdata->mcenter[0] - event->mval[0];
+ mdiff[1] = opdata->mcenter[1] - event->mval[1];
+
+ if (use_dist) {
+ factor = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length) * opdata->pixel_size;
+ }
+ else {
+ factor = (len_v2(mdiff) - MVAL_PIXEL_MARGIN) / opdata->initial_length;
+ factor = factor - 1.0f; /* a different kind of buffer where nothing happens */
+ }
+
+ /* Fake shift-transform... */
+ if (event->shift) {
+ if (opdata->shift_factor < 0.0f)
+ opdata->shift_factor = RNA_float_get(op->ptr, "percent");
+ factor = (factor - opdata->shift_factor) * 0.1f + opdata->shift_factor;
+ }
+ else if (opdata->shift_factor >= 0.0f)
+ opdata->shift_factor = -1.0f;
+
+ /* clamp differently based on distance/factor */
+ if (use_dist) {
+ if (factor < 0.0f) factor = 0.0f;
+ }
+ else {
+ CLAMP(factor, 0.0f, 1.0f);
+ }
+
+ return factor;
+}
+
static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
{
BevelData *opdata = op->customdata;
+ int segments = RNA_int_get(op->ptr, "segments");
if (event->val == KM_PRESS) {
/* Try to handle numeric inputs... */
+#ifdef NEW_BEVEL
+ float value;
+
+ if (handleNumInput(&opdata->num_input, event)) {
+ applyNumInput(&opdata->num_input, &value);
+ RNA_float_set(op->ptr, "offset", value);
+ edbm_bevel_calc(C, op);
+ edbm_bevel_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
+ }
+#else
float factor;
if (handleNumInput(&opdata->num_input, event)) {
@@ -4710,6 +4963,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
edbm_bevel_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
+#endif
}
switch (event->type) {
@@ -4720,26 +4974,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
case MOUSEMOVE:
if (!hasNumInput(&opdata->num_input)) {
- float factor;
- float mdiff[2];
-
- mdiff[0] = opdata->mcenter[0] - event->mval[0];
- mdiff[1] = opdata->mcenter[1] - event->mval[1];
-
- factor = opdata->initial_length / -len_v2(mdiff) + 1.0f;
-
- /* Fake shift-transform... */
- if (event->shift) {
- if (opdata->shift_factor < 0.0f)
- opdata->shift_factor = RNA_float_get(op->ptr, "percent");
- factor = (factor - opdata->shift_factor) * 0.1f + opdata->shift_factor;
- }
- else if (opdata->shift_factor >= 0.0f)
- opdata->shift_factor = -1.0f;
-
- CLAMP(factor, 0.0f, 1.0f);
-
+ const float factor = edbm_bevel_mval_factor(op, event);
+#ifdef NEW_BEVEL
+ RNA_float_set(op->ptr, "offset", factor);
+#else
RNA_float_set(op->ptr, "percent", factor);
+#endif
edbm_bevel_calc(C, op);
edbm_bevel_update_header(op, C);
@@ -4753,6 +4993,28 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
edbm_bevel_exit(C, op);
return OPERATOR_FINISHED;
+#ifdef NEW_BEVEL
+ case WHEELUPMOUSE: /* change number of segments */
+ if (event->val == KM_RELEASE)
+ break;
+
+ segments++;
+ RNA_int_set(op->ptr, "segments", segments);
+ edbm_bevel_calc(C, op);
+ edbm_bevel_update_header(op, C);
+ break;
+
+ case WHEELDOWNMOUSE: /* change number of segments */
+ if (event->val == KM_RELEASE)
+ break;
+
+ segments = max_ii(segments - 1, 1);
+ RNA_int_set(op->ptr, "segments", segments);
+ edbm_bevel_calc(C, op);
+ edbm_bevel_update_header(op, C);
+ break;
+
+#else
case EKEY:
if (event->val == KM_PRESS) {
int use_even = RNA_boolean_get(op->ptr, "use_even");
@@ -4768,10 +5030,16 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
int use_dist = RNA_boolean_get(op->ptr, "use_dist");
RNA_boolean_set(op->ptr, "use_dist", !use_dist);
+ {
+ const float factor = edbm_bevel_mval_factor(op, event);
+ RNA_float_set(op->ptr, "percent", factor);
+ }
+
edbm_bevel_calc(C, op);
edbm_bevel_update_header(op, C);
}
break;
+#endif
}
return OPERATOR_RUNNING_MODAL;
@@ -4794,12 +5062,18 @@ void MESH_OT_bevel(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING;
+#ifdef NEW_BEVEL
+ RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f);
+ RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8);
+#else
+ /* take note, used as a factor _and_ a distance depending on 'use_dist' */
RNA_def_float(ot->srna, "percent", 0.0f, -FLT_MAX, FLT_MAX, "Percentage", "", 0.0f, 1.0f);
/* XXX, disabled for 2.63 release, needs to work much better without overlap before we can give to users. */
/* RNA_def_int(ot->srna, "recursion", 1, 1, 50, "Recursion Level", "Recursion Level", 1, 8); */
RNA_def_boolean(ot->srna, "use_even", FALSE, "Even", "Calculate evenly spaced bevel");
RNA_def_boolean(ot->srna, "use_dist", FALSE, "Distance", "Interpret the percent in blender units");
+#endif
}
@@ -4858,8 +5132,9 @@ typedef struct {
float old_depth;
int mcenter[2];
int modify_depth;
- int is_modal;
float initial_length;
+ float pixel_size; /* use when mouse input is interpreted as spatial distance */
+ int is_modal;
int shift;
float shift_amount;
BMBackup backup;
@@ -5025,15 +5300,17 @@ static int edbm_inset_exec(bContext *C, wmOperator *op)
static int edbm_inset_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
InsetData *opdata;
float mlen[2];
+ float center_3d[3];
edbm_inset_init(C, op, TRUE);
opdata = op->customdata;
/* initialize mouse values */
- if (!calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter)) {
+ if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
/* in this case the tool will likely do nothing,
* ideally this will never happen and should be checked for above */
opdata->mcenter[0] = opdata->mcenter[1] = 0;
@@ -5041,6 +5318,7 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, wmEvent *event)
mlen[0] = opdata->mcenter[0] - event->mval[0];
mlen[1] = opdata->mcenter[1] - event->mval[1];
opdata->initial_length = len_v2(mlen);
+ opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
edbm_inset_calc(C, op);
@@ -5060,7 +5338,7 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
if (handleNumInput(&opdata->num_input, event)) {
applyNumInput(&opdata->num_input, amounts);
- amounts[0] = maxf(amounts[0], 0.0f);
+ amounts[0] = max_ff(amounts[0], 0.0f);
RNA_float_set(op->ptr, "thickness", amounts[0]);
RNA_float_set(op->ptr, "depth", amounts[1]);
@@ -5090,9 +5368,9 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
mdiff[1] = opdata->mcenter[1] - event->mval[1];
if (opdata->modify_depth)
- amount = opdata->old_depth + opdata->initial_length / len_v2(mdiff) - 1.0f;
+ amount = opdata->old_depth + ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
else
- amount = opdata->old_thickness - opdata->initial_length / len_v2(mdiff) + 1.0f;
+ amount = opdata->old_thickness - ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
/* Fake shift-transform... */
if (opdata->shift)
@@ -5101,7 +5379,7 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
if (opdata->modify_depth)
RNA_float_set(op->ptr, "depth", amount);
else {
- amount = maxf(amount, 0.0f);
+ amount = max_ff(amount, 0.0f);
RNA_float_set(op->ptr, "thickness", amount);
}
@@ -5299,6 +5577,7 @@ void MESH_OT_wireframe(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "use_replace", TRUE, "Replace", "Remove original faces");
}
+#ifdef WITH_BULLET
static int edbm_convex_hull_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
@@ -5392,3 +5671,55 @@ void MESH_OT_convex_hull(wmOperatorType *ot)
join_triangle_props(ot);
}
+#endif
+
+static int mesh_symmetrize_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMOperator bmop;
+
+ EDBM_op_init(em, &bmop, op, "symmetrize input=%hvef direction=%i",
+ BM_ELEM_SELECT, RNA_enum_get(op->ptr, "direction"));
+ BMO_op_exec(em->bm, &bmop);
+
+ if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ EDBM_update_generic(C, em, TRUE);
+ EDBM_selectmode_flush(em);
+ return OPERATOR_FINISHED;
+ }
+}
+
+void MESH_OT_symmetrize(struct wmOperatorType *ot)
+{
+ static EnumPropertyItem axis_direction_items[] = {
+ {BMO_SYMMETRIZE_NEGATIVE_X, "NEGATIVE_X", 0, "-X to +X", ""},
+ {BMO_SYMMETRIZE_POSITIVE_X, "POSITIVE_X", 0, "+X to -X", ""},
+
+ {BMO_SYMMETRIZE_NEGATIVE_Y, "NEGATIVE_Y", 0, "-Y to +Y", ""},
+ {BMO_SYMMETRIZE_POSITIVE_Y, "POSITIVE_Y", 0, "+Y to -Y", ""},
+
+ {BMO_SYMMETRIZE_NEGATIVE_Z, "NEGATIVE_Z", 0, "-Z to +Z", ""},
+ {BMO_SYMMETRIZE_POSITIVE_Z, "POSITIVE_Z", 0, "+Z to -Z", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ /* identifiers */
+ ot->name = "Symmetrize";
+ ot->description = "Enforce symmetry (both form and topological) across an axis";
+ ot->idname = "MESH_OT_symmetrize";
+
+ /* api callbacks */
+ ot->exec = mesh_symmetrize_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ ot->prop = RNA_def_enum(ot->srna, "direction", axis_direction_items,
+ BMO_SYMMETRIZE_NEGATIVE_X,
+ "Direction", "Which sides to copy from and to");
+}
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 537d463dfbc..ef3d8db4156 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -1012,6 +1012,19 @@ void EDBM_uv_element_map_free(UvElementMap *element_map)
}
}
+UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l)
+{
+ UvElement *element;
+
+ element = map->vert[BM_elem_index_get(l->v)];
+
+ for (; element; element = element->next)
+ if (element->face == efa)
+ return element;
+
+ return NULL;
+}
+
/* last_sel, use em->act_face otherwise get the last selected face in the editselections
* at the moment, last_sel is mainly useful for making sure the space image dosnt flicker */
MTexPoly *EDBM_mtexpoly_active_get(BMEditMesh *em, BMFace **r_act_efa, int sloppy, int selected)
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 735492cb553..e9906f852de 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -235,7 +235,8 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
}
}
-int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum)
+/* without bContext, called in uvedit */
+int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
{
BMEditMesh *em = me->edit_btmesh;
MLoopUV *luv;
@@ -338,7 +339,6 @@ int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int laye
BLI_array_free(polylengths);
DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return 1;
}
@@ -348,7 +348,11 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
/* could be ldata or pdata */
CustomData *pdata = GET_CD_DATA(me, pdata);
const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
- return ED_mesh_uv_loop_reset_ex(C, me, layernum);
+ int retval = ED_mesh_uv_loop_reset_ex(me, layernum);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+
+ return retval;
}
/* note: keep in sync with ED_mesh_color_add */
@@ -419,7 +423,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
/* don't overwrite our copied coords */
if (is_init == FALSE) {
- ED_mesh_uv_loop_reset_ex(C, me, layernum_dst);
+ ED_mesh_uv_loop_reset_ex(me, layernum_dst);
}
DAG_id_tag_update(&me->id, 0);
@@ -593,7 +597,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* Check context */
if (base == NULL || base->object->type != OB_MESH) {
- BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh");
+ BKE_report(op->reports, RPT_ERROR, "Not an object or mesh");
return OPERATOR_CANCELLED;
}
@@ -610,7 +614,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
if (!ima) {
- BKE_report(op->reports, RPT_ERROR, "Not an Image");
+ BKE_report(op->reports, RPT_ERROR, "Not an image");
return OPERATOR_CANCELLED;
}
@@ -902,7 +906,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
* so rather then add poly-index layer and calculate normals for it
* calculate normals only for the mvert's. - campbell */
#ifdef USE_BMESH_MPOLY_NORMALS
- polyindex = CustomData_get_layer(&mesh->fdata, CD_POLYINDEX);
+ polyindex = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX);
/* add a normals layer for tessellated faces, a tessface normal will
* contain the normal of the poly the face was tessellated from. */
face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface);
@@ -947,6 +951,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
/* scan the input list and insert the new vertices */
+ /* set default flags */
mvert = &mesh->mvert[mesh->totvert];
for (i = 0; i < len; i++, mvert++)
mvert->flag |= SELECT;
@@ -1124,7 +1129,7 @@ static void mesh_remove_faces(Mesh *mesh, int len)
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add geometry in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot add geometry in edit mode");
return;
}
@@ -1140,12 +1145,12 @@ void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges,
void ED_mesh_tessfaces_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add tessfaces in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot add tessfaces in edit mode");
return;
}
if (mesh->mpoly) {
- BKE_report(reports, RPT_ERROR, "Can't add tessfaces to a mesh that already has polygons");
+ BKE_report(reports, RPT_ERROR, "Cannot add tessfaces to a mesh that already has polygons");
return;
}
@@ -1155,7 +1160,7 @@ void ED_mesh_tessfaces_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode");
return;
}
@@ -1165,7 +1170,7 @@ void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add vertices in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode");
return;
}
@@ -1175,11 +1180,11 @@ void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't remove faces in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot remove faces in edit mode");
return;
}
else if (count > mesh->totface) {
- BKE_report(reports, RPT_ERROR, "Can't remove more faces than the mesh contains");
+ BKE_report(reports, RPT_ERROR, "Cannot remove more faces than the mesh contains");
return;
}
@@ -1189,11 +1194,11 @@ void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't remove edges in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode");
return;
}
else if (count > mesh->totedge) {
- BKE_report(reports, RPT_ERROR, "Can't remove more edges than the mesh contains");
+ BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains");
return;
}
@@ -1203,11 +1208,11 @@ void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't remove vertices in edit mode");
+ BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode");
return;
}
else if (count > mesh->totvert) {
- BKE_report(reports, RPT_ERROR, "Can't remove more vertices than the mesh contains");
+ BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains");
return;
}
@@ -1217,7 +1222,7 @@ void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add loops in edit mode.");
+ BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode");
return;
}
@@ -1227,7 +1232,7 @@ void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add polys in edit mode.");
+ BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode");
return;
}
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index de594b87e2c..82b785e5785 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -121,7 +121,7 @@ void MESH_OT_select_linked(struct wmOperatorType *ot);
void MESH_OT_select_linked_pick(struct wmOperatorType *ot);
void MESH_OT_hide(struct wmOperatorType *ot);
void MESH_OT_reveal(struct wmOperatorType *ot);
-void MESH_OT_select_by_number_vertices(struct wmOperatorType *ot);
+void MESH_OT_select_face_by_sides(struct wmOperatorType *ot);
void MESH_OT_select_loose_verts(struct wmOperatorType *ot);
void MESH_OT_select_mirror(struct wmOperatorType *ot);
void MESH_OT_normals_make_consistent(struct wmOperatorType *ot);
@@ -134,6 +134,7 @@ void MESH_OT_loop_multi_select(struct wmOperatorType *ot);
void MESH_OT_mark_seam(struct wmOperatorType *ot);
void MESH_OT_mark_sharp(struct wmOperatorType *ot);
void MESH_OT_vertices_smooth(struct wmOperatorType *ot);
+void MESH_OT_vertices_smooth_laplacian(struct wmOperatorType *ot);
void MESH_OT_noise(struct wmOperatorType *ot);
void MESH_OT_flip_normals(struct wmOperatorType *ot);
void MESH_OT_solidify(struct wmOperatorType *ot);
@@ -144,6 +145,7 @@ extern struct EnumPropertyItem *corner_type_items;
void MESH_OT_merge(struct wmOperatorType *ot);
void MESH_OT_subdivide(struct wmOperatorType *ot);
+void MESH_OT_unsubdivide(struct wmOperatorType *ot);
void MESH_OT_remove_doubles(struct wmOperatorType *ot);
void MESH_OT_spin(struct wmOperatorType *ot);
void MESH_OT_screw(struct wmOperatorType *ot);
@@ -214,6 +216,8 @@ void MESH_OT_vert_slide(struct wmOperatorType *ot);
void MESH_OT_convex_hull(struct wmOperatorType *ot);
+void MESH_OT_symmetrize(struct wmOperatorType *ot);
+
/* ******************* mesh_navmesh.c */
void MESH_OT_navmesh_make(struct wmOperatorType *ot);
void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot);
@@ -221,5 +225,4 @@ void MESH_OT_navmesh_face_add(struct wmOperatorType *ot);
void MESH_OT_navmesh_reset(struct wmOperatorType *ot);
void MESH_OT_navmesh_clear(struct wmOperatorType *ot);
-#endif // __MESH_INTERN_H__
-
+#endif /* __MESH_INTERN_H__ */
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index 88b1f191e3a..f6f8eee0a69 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -209,7 +209,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags");
/* Find triangles which are walkable based on their slope and rasterize them */
- recast_markWalkableTriangles(RAD2DEG(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
+ recast_markWalkableTriangles(RAD2DEGF(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid);
MEM_freeN(triflags);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 3ac8719f304..d319fdcca26 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -68,12 +68,13 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_select_random);
WM_operatortype_append(MESH_OT_hide);
WM_operatortype_append(MESH_OT_reveal);
- WM_operatortype_append(MESH_OT_select_by_number_vertices);
+ WM_operatortype_append(MESH_OT_select_face_by_sides);
WM_operatortype_append(MESH_OT_select_loose_verts);
WM_operatortype_append(MESH_OT_select_mirror);
WM_operatortype_append(MESH_OT_normals_make_consistent);
WM_operatortype_append(MESH_OT_merge);
WM_operatortype_append(MESH_OT_subdivide);
+ WM_operatortype_append(MESH_OT_unsubdivide);
WM_operatortype_append(MESH_OT_faces_select_linked_flat);
WM_operatortype_append(MESH_OT_edges_select_sharp);
WM_operatortype_append(MESH_OT_primitive_plane_add);
@@ -132,6 +133,7 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_mark_seam);
WM_operatortype_append(MESH_OT_mark_sharp);
WM_operatortype_append(MESH_OT_vertices_smooth);
+ WM_operatortype_append(MESH_OT_vertices_smooth_laplacian);
WM_operatortype_append(MESH_OT_noise);
WM_operatortype_append(MESH_OT_flip_normals);
WM_operatortype_append(MESH_OT_rip);
@@ -164,7 +166,11 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_wireframe);
WM_operatortype_append(MESH_OT_edge_split);
+#ifdef WITH_BULLET
WM_operatortype_append(MESH_OT_convex_hull);
+#endif
+
+ WM_operatortype_append(MESH_OT_symmetrize);
#ifdef WITH_GAMEENGINE
WM_operatortype_append(MESH_OT_navmesh_make);
@@ -209,7 +215,17 @@ void ED_operatormacros_mesh(void)
ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result",
OPTYPE_UNDO | OPTYPE_REGISTER);
- WM_operatortype_macro_define(ot, "MESH_OT_rip");
+ otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
+ RNA_boolean_set(otmacro->ptr, "use_fill", FALSE);
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
+
+ /* annoying we can't pass 'use_fill' through the macro */
+ ot = WM_operatortype_append_macro("MESH_OT_rip_move_fill", "Rip Fill", "Rip-fill polygons and move the result",
+ OPTYPE_UNDO | OPTYPE_REGISTER);
+ otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
+ RNA_boolean_set(otmacro->ptr, "use_fill", TRUE);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
@@ -324,6 +340,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_rip_move", VKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "MESH_OT_rip_move_fill", VKEY, KM_PRESS, KM_ALT, 0);
+
WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "TRANSFORM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 42d82fff38e..c0b6327d740 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -113,7 +113,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
CustomData vdata, edata, fdata, ldata, pdata;
if (scene->obedit) {
- BKE_report(op->reports, RPT_WARNING, "Cant join while in editmode");
+ BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode");
return OPERATOR_CANCELLED;
}
@@ -161,10 +161,13 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
if (totvert > MESH_MAX_VERTS) {
- BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is " STRINGIFY(MESH_MAX_VERTS), totvert);
- return OPERATOR_CANCELLED;
+ BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is %ld", totvert, MESH_MAX_VERTS);
+ return OPERATOR_CANCELLED;
}
+ /* remove tessface to ensure we don't old references to invalid faces */
+ BKE_mesh_tessface_clear(me);
+
/* new material indices and material array */
matar = MEM_callocN(sizeof(void *) * totmat, "join_mesh matar");
if (totmat) matmap = MEM_callocN(sizeof(int) * totmat, "join_mesh matmap");
@@ -264,7 +267,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* adjust settings to fit (allocate a new data-array) */
kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
- kbn->totelem = totvert;
+ kbn->totelem = totvert;
/* XXX 2.5 Animato */
#if 0
@@ -296,12 +299,12 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* setup new data for destination mesh */
- memset(&vdata, 0, sizeof(vdata));
- memset(&edata, 0, sizeof(edata));
- memset(&fdata, 0, sizeof(fdata));
- memset(&ldata, 0, sizeof(ldata));
- memset(&pdata, 0, sizeof(pdata));
-
+ CustomData_reset(&vdata);
+ CustomData_reset(&edata);
+ CustomData_reset(&fdata);
+ CustomData_reset(&ldata);
+ CustomData_reset(&pdata);
+
mvert = CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
medge = CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
mloop = CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
@@ -513,7 +516,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
me->ldata = ldata;
me->pdata = pdata;
- mesh_update_customdata_pointers(me, TRUE); /* BMESH_TODO, check if this arg can be failse, non urgent - campbell */
+ /* tessface data removed above, no need to update */
+ mesh_update_customdata_pointers(me, FALSE);
/* old material array */
for (a = 1; a <= ob->totcol; a++) {
@@ -843,7 +847,7 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, const float co[3], char m
minmax_v3v3_v3(min, max, eve->co);
}
}
- else {
+ else {
MVert *mvert;
int a;
@@ -878,7 +882,7 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, const float co[3], char m
mesh_octree_add_nodes(MeshOctree.table, eve->co, MeshOctree.offs, MeshOctree.div, (intptr_t)(eve));
}
}
- else {
+ else {
MVert *mvert;
int a;
@@ -1192,7 +1196,7 @@ int ED_mesh_pick_face(bContext *C, Mesh *me, const int mval[2], unsigned int *in
/* sample rect to increase chances of selecting, so that when clicking
* on an edge in the backbuf, we can still select a face */
- int dummy_dist;
+ float dummy_dist;
*index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totpoly + 1, &dummy_dist, 0, NULL, NULL);
}
else {
@@ -1237,7 +1241,7 @@ int ED_mesh_pick_face_vert(bContext *C, Mesh *me, Object *ob, const int mval[2],
const int v_idx = me->mloop[mp->loopstart + fidx].v;
dm->getVertCo(dm, v_idx, co);
mul_m4_v3(ob->obmat, co);
- if (ED_view3d_project_float_global(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_global(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
len = len_squared_v2v2(mval_f, sco);
if (len < len_best) {
len_best = len;
@@ -1277,7 +1281,7 @@ int ED_mesh_pick_vert(bContext *C, Mesh *me, const int mval[2], unsigned int *in
/* sample rect to increase chances of selecting, so that when clicking
* on an face in the backbuf, we can still select a vert */
- int dummy_dist;
+ float dummy_dist;
*index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert + 1, &dummy_dist, 0, NULL, NULL);
}
else {
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index e9063687506..8633a7a9b38 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -98,7 +98,7 @@ void load_editMball(Object *UNUSED(obedit))
}
/* Add metaelem primitive to metaball object (which is in edit mode) */
-MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[4][4], int type, int UNUSED(newname))
+MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[4][4], float dia, int type, int UNUSED(newname))
{
MetaBall *mball = (MetaBall *)obedit->data;
MetaElem *ml;
@@ -111,6 +111,7 @@ MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[
}
ml = BKE_mball_element_add(mball, type);
+ ml->rad *= dia;
copy_v3_v3(&ml->x, mat[3]);
ml->flag |= SELECT;
@@ -123,7 +124,6 @@ MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[
/* Select or deselect all MetaElements */
static int mball_select_all_exec(bContext *C, wmOperator *op)
{
- //Scene *scene= CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 43a32cd662e..4d1f2bbc4e9 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -136,6 +136,7 @@ static EnumPropertyItem field_type_items[] = {
{PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
{PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
{PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
+ {PFIELD_SMOKEFLOW, "SMOKE", ICON_FORCE_SMOKEFLOW, "Smoke Flow", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -185,7 +186,8 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
/* Uses context to figure out transform for primitive.
* Returns standard diameter. */
float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
- const float loc[3], const float rot[3], float primmat[][4])
+ const float loc[3], const float rot[3], float primmat[][4],
+ int apply_diameter)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -208,8 +210,17 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
invert_m3_m3(imat, mat);
mul_m3_v3(imat, primmat[3]);
- if (v3d)
- return ED_view3d_grid_scale(scene, v3d, NULL);
+ if (v3d) {
+ float dia = ED_view3d_grid_scale(scene, v3d, NULL);
+
+ if (apply_diameter) {
+ primmat[0][0] *= dia;
+ primmat[1][1] *= dia;
+ primmat[2][2] *= dia;
+ }
+
+ return dia;
+ }
return 1.0f;
}
@@ -356,7 +367,7 @@ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const floa
Scene *scene = CTX_data_scene(C);
Object *ob;
- /* For as long scene has editmode... */
+ /* for as long scene has editmode... */
if (CTX_data_edit_object(C))
ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */
@@ -441,7 +452,7 @@ static int effector_add_exec(bContext *C, wmOperator *op)
rename_id(&ob->id, "CurveGuide");
((Curve *)ob->data)->flag |= CU_PATH | CU_3D;
ED_object_enter_editmode(C, 0);
- ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
+ ED_object_new_primitive_matrix(C, ob, loc, rot, mat, FALSE);
BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, 1));
if (!enter_editmode)
ED_object_exit_editmode(C, EM_FREEDATA);
@@ -546,6 +557,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
unsigned int layer;
float loc[3], rot[3];
float mat[4][4];
+ float dia;
if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
@@ -557,9 +569,9 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
else
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
- ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
+ dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, FALSE);
- add_metaball_primitive(C, obedit, mat, RNA_enum_get(op->ptr, "type"), newob);
+ add_metaball_primitive(C, obedit, mat, dia, RNA_enum_get(op->ptr, "type"), newob);
/* userdef */
if (newob && !enter_editmode) {
@@ -821,8 +833,6 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
/* only used as menu */
void OBJECT_OT_group_instance_add(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
/* identifiers */
ot->name = "Add Group Instance";
ot->description = "Add a dupligroup instance";
@@ -837,9 +847,8 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
- RNA_def_enum_funcs(prop, RNA_group_itemf);
- ot->prop = prop;
+ ot->prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
+ RNA_def_enum_funcs(ot->prop, RNA_group_itemf);
ED_object_add_generic_props(ot, FALSE);
}
@@ -1112,13 +1121,13 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
basen->object = ob;
/* make sure apply works */
- BKE_free_animdata(&ob->id);
+ BKE_free_animdata(&ob->id);
ob->adt = NULL;
ob->parent = NULL;
ob->constraints.first = ob->constraints.last = NULL;
ob->disp.first = ob->disp.last = NULL;
- ob->transflag &= ~OB_DUPLI;
+ ob->transflag &= ~OB_DUPLI;
ob->lay = base->lay;
copy_m4_m4(ob->obmat, dob->mat);
@@ -1127,7 +1136,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
if (dupli_gh)
BLI_ghash_insert(dupli_gh, dob, ob);
if (parent_gh)
- BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, SET_INT_IN_POINTER(dob->index)), ob);
+ BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, SET_INT_IN_POINTER(dob->persistent_id[0])), ob);
}
if (use_hierarchy) {
@@ -1141,7 +1150,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
/* find parent that was also made real */
if (ob_src_par) {
- GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, SET_INT_IN_POINTER(dob->index));
+ GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, SET_INT_IN_POINTER(dob->persistent_id[0]));
ob_dst_par = BLI_ghash_lookup(parent_gh, pair);
BLI_ghashutil_pairfree(pair);
}
@@ -1398,7 +1407,7 @@ static int convert_exec(bContext *C, wmOperator *op)
* cases this doesnt give correct results (when MDEF is used for eg)
*/
dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH);
- /* dm= mesh_create_derived_no_deform(ob1, NULL); this was called original (instead of get_derived). man o man why! (ton) */
+ // dm = mesh_create_derived_no_deform(ob1, NULL); /* this was called original (instead of get_derived). man o man why! (ton) */
DM_to_mesh(dm, newob->data, newob);
@@ -1564,7 +1573,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* delete original if needed */
if (basedel) {
if (!keep_original)
- ED_base_object_free_and_unlink(bmain, scene, basedel);
+ ED_base_object_free_and_unlink(bmain, scene, basedel);
basedel = NULL;
}
@@ -2048,11 +2057,11 @@ static int join_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (scene->obedit) {
- BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode");
+ BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode");
return OPERATOR_CANCELLED;
}
else if (BKE_object_obdata_is_libdata(ob)) {
- BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
+ BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
return OPERATOR_CANCELLED;
}
@@ -2102,11 +2111,11 @@ static int join_shapes_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (scene->obedit) {
- BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode");
+ BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode");
return OPERATOR_CANCELLED;
}
else if (BKE_object_obdata_is_libdata(ob)) {
- BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
+ BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 6d124377821..ee3c66b6eac 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -150,11 +150,13 @@ typedef struct {
float height_min, height_max;
Image *ima;
DerivedMesh *ssdm;
- const int *origindex;
+ const int *orig_index_mf_to_mpoly;
+ const int *orig_index_mp_to_orig;
} MHeightBakeData;
typedef struct {
- const int *origindex;
+ const int *orig_index_mf_to_mpoly;
+ const int *orig_index_mp_to_orig;
} MNormalBakeData;
static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int face_num, const int vert_index)
@@ -508,7 +510,9 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float
interp_bilinear_quad_data(data, u, v, res);
}
-static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *origindex, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3])
+static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm,
+ const int *index_mf_to_mpoly, const int *index_mp_to_orig,
+ const int lvl, const int face_index, const float u, const float v, float co[3], float n[3])
{
MFace mface;
CCGElem **grid_data;
@@ -532,7 +536,7 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig
}
else {
int side = (1 << (lvl - 1)) + 1;
- int grid_index = origindex[face_index];
+ int grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index);
int loc_offs = face_index % (1 << (2 * lvl));
int cell_index = loc_offs % ((side - 1) * (side - 1));
int cell_side = (grid_size - 1) / (side - 1);
@@ -628,7 +632,8 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
}
}
- height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ height_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ height_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX);
return (void *)height_data;
}
@@ -640,7 +645,8 @@ static void *init_normal_data(MultiresBakeRender *bkr, Image *UNUSED(ima))
normal_data = MEM_callocN(sizeof(MNormalBakeData), "MultiresBake normalData");
- normal_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ normal_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ normal_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX);
return (void *)normal_data;
}
@@ -735,10 +741,14 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
CLAMP(uv[0], 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
- get_ccgdm_data(lores_dm, hires_dm, height_data->origindex, lvl, face_index, uv[0], uv[1], p1, 0);
+ get_ccgdm_data(lores_dm, hires_dm,
+ height_data->orig_index_mf_to_mpoly, height_data->orig_index_mf_to_mpoly,
+ lvl, face_index, uv[0], uv[1], p1, 0);
if (height_data->ssdm) {
- get_ccgdm_data(lores_dm, height_data->ssdm, height_data->origindex, 0, face_index, uv[0], uv[1], p0, n);
+ get_ccgdm_data(lores_dm, height_data->ssdm,
+ height_data->orig_index_mf_to_mpoly, height_data->orig_index_mf_to_mpoly,
+ 0, face_index, uv[0], uv[1], p0, n);
}
else {
lores_dm->getTessFace(lores_dm, face_index, &mface);
@@ -808,7 +818,9 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
CLAMP(uv[0], 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
- get_ccgdm_data(lores_dm, hires_dm, normal_data->origindex, lvl, face_index, uv[0], uv[1], NULL, n);
+ get_ccgdm_data(lores_dm, hires_dm,
+ normal_data->orig_index_mf_to_mpoly, normal_data->orig_index_mp_to_orig,
+ lvl, face_index, uv[0], uv[1], NULL, n);
mul_v3_m3v3(vec, tangmat, n);
normalize_v3(vec);
@@ -900,7 +912,7 @@ static void finish_images(MultiresBakeRender *bkr)
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
- ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;;
+ ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
if (ibuf->rect_float)
ibuf->userflags |= IB_RECT_INVALID;
@@ -937,7 +949,7 @@ static int multiresbake_check(bContext *C, wmOperator *op)
ob = base->object;
if (ob->type != OB_MESH) {
- BKE_report(op->reports, RPT_ERROR, "Basking of multires data only works with active object which is a mesh");
+ BKE_report(op->reports, RPT_ERROR, "Baking of multires data only works with an active mesh object");
ok = 0;
break;
@@ -966,6 +978,12 @@ static int multiresbake_check(bContext *C, wmOperator *op)
break;
}
+ if (mmd->lvl == 0) {
+ BKE_report(op->reports, RPT_ERROR, "Multires data baking is not supported for preview subdivision level 0");
+
+ break;
+ }
+
if (!me->mtpoly) {
BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking");
@@ -985,7 +1003,7 @@ static int multiresbake_check(bContext *C, wmOperator *op)
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
if (!ibuf) {
- BKE_report(op->reports, RPT_ERROR, "Baking should happend to image with image buffer");
+ BKE_report(op->reports, RPT_ERROR, "Baking should happen to image with image buffer");
ok = 0;
}
@@ -1030,8 +1048,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
tmp_mmd.lvl = *lvl;
tmp_mmd.sculptlvl = *lvl;
- dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob,
- 0);
+ dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0);
cddm->release(cddm);
}
@@ -1051,8 +1068,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
tmp_mmd.lvl = mmd->totlvl;
tmp_mmd.sculptlvl = mmd->totlvl;
- dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob,
- 0);
+ dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0);
cddm->release(cddm);
return dm;
@@ -1366,20 +1382,23 @@ static void finish_bake_internal(BakeRender *bkr)
if (bkr->prev_r_raytrace == 0)
bkr->scene->r.mode &= ~R_RAYTRACE;
-
/* force OpenGL reload and mipmap recalc */
for (ima = G.main->image.first; ima; ima = ima->id.next) {
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
- if (bkr->result == BAKE_RESULT_OK) {
- if (ima->ok == IMA_OK_LOADED) {
- if (ibuf) {
- if (ibuf->userflags & IB_BITMAPDIRTY) {
- ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
- GPU_free_image(ima);
- imb_freemipmapImBuf(ibuf);
- }
+ /* some of the images could have been changed during bake,
+ * so recreate mipmaps regardless bake result status
+ */
+ if (ima->ok == IMA_OK_LOADED) {
+ if (ibuf) {
+ if (ibuf->userflags & IB_BITMAPDIRTY) {
+ GPU_free_image(ima);
+ imb_freemipmapImBuf(ibuf);
}
+
+ /* invalidate display buffers for changed images */
+ if (ibuf->userflags & IB_BITMAPDIRTY)
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
}
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 56f2426b1b0..f78e1203bc4 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -494,9 +494,9 @@ static void test_constraints(Object *owner, bPoseChannel *pchan)
/* auto-set 'Path' setting on curve so this works */
cu->flag |= CU_PATH;
}
- }
+ }
}
- }
+ }
/* free any temporary targets */
if (cti->flush_constraint_targets)
@@ -593,7 +593,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) {
list = &ob->constraints;
- }
+ }
else if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan)
@@ -807,7 +807,7 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL) {
printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>");
- BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse");
+ BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse");
return OPERATOR_CANCELLED;
}
@@ -853,7 +853,7 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
if (data == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Childof constraint not found");
+ BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found");
return OPERATOR_CANCELLED;
}
@@ -1028,7 +1028,7 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL) {
printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>");
- BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse");
+ BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse");
return OPERATOR_CANCELLED;
}
@@ -1073,7 +1073,7 @@ static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op)
bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL;
if (data == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Childof constraint not found");
+ BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found");
return OPERATOR_CANCELLED;
}
@@ -1628,15 +1628,15 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
return OPERATOR_CANCELLED;
}
if ((type == CONSTRAINT_TYPE_RIGIDBODYJOINT) && (list != &ob->constraints)) {
- BKE_report(op->reports, RPT_ERROR, "Rigid Body Joint Constraint can only be added to Objects");
+ BKE_report(op->reports, RPT_ERROR, "Rigid Body Joint constraint can only be added to objects");
return OPERATOR_CANCELLED;
}
if ((type == CONSTRAINT_TYPE_KINEMATIC) && ((!pchan) || (list != &pchan->constraints))) {
- BKE_report(op->reports, RPT_ERROR, "IK Constraint can only be added to Bones");
+ BKE_report(op->reports, RPT_ERROR, "IK constraint can only be added to bones");
return OPERATOR_CANCELLED;
}
if ((type == CONSTRAINT_TYPE_SPLINEIK) && ((!pchan) || (list != &pchan->constraints))) {
- BKE_report(op->reports, RPT_ERROR, "Spline IK Constraint can only be added to Bones");
+ BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones");
return OPERATOR_CANCELLED;
}
@@ -1856,7 +1856,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
/* must have active bone */
if (ELEM(NULL, ob, pchan)) {
- BKE_report(op->reports, RPT_ERROR, "Must have active bone to add IK Constraint to");
+ BKE_report(op->reports, RPT_ERROR, "Must have an active bone to add IK constraint to");
return OPERATOR_CANCELLED;
}
@@ -1865,7 +1865,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
if (con->type == CONSTRAINT_TYPE_KINEMATIC) break;
}
if (con) {
- BKE_report(op->reports, RPT_ERROR, "Bone already has IK Constraint");
+ BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 43c6c332791..c0c2195592b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -201,7 +201,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
ED_base_object_activate(C, NULL);
}
}
- }
+ }
}
CTX_DATA_END;
@@ -684,7 +684,7 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob)
if (TESTBASELIB(v3d, base)) {
/* first: free all logic */
- free_sensors(&base->object->sensors);
+ free_sensors(&base->object->sensors);
unlink_controllers(&base->object->controllers);
free_controllers(&base->object->controllers);
unlink_actuators(&base->object->actuators);
@@ -885,7 +885,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
id_us_plus((ID *)cu1->vfonti);
if (cu1->vfontbi) cu1->vfontbi->id.us--;
cu1->vfontbi = cu->vfontbi;
- id_us_plus((ID *)cu1->vfontbi);
+ id_us_plus((ID *)cu1->vfontbi);
BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */
@@ -988,7 +988,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
cu1->flag |= CU_UV_ORCO;
else
cu1->flag &= ~CU_UV_ORCO;
- }
+ }
}
else if (event == 29) { /* protected bits */
base->object->protectflag = ob->protectflag;
@@ -1401,7 +1401,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d)
else ob->size[1] = ob->size[0] * y / x;
done = TRUE;
- DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
}
if (done) break;
@@ -1795,7 +1795,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
if (ob != ob_iter) {
/* first: free all logic */
- free_sensors(&ob_iter->sensors);
+ free_sensors(&ob_iter->sensors);
unlink_controllers(&ob_iter->controllers);
free_controllers(&ob_iter->controllers);
unlink_actuators(&ob_iter->actuators);
@@ -1864,7 +1864,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
ob_iter->anisotropicFriction[0] = ob->anisotropicFriction[0];
ob_iter->anisotropicFriction[1] = ob->anisotropicFriction[1];
ob_iter->anisotropicFriction[2] = ob->anisotropicFriction[2];
- ob_iter->collision_boundtype = ob->collision_boundtype;
+ ob_iter->collision_boundtype = ob->collision_boundtype;
ob_iter->margin = ob->margin;
ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft);
if (ob->restrictflag & OB_RESTRICT_RENDER)
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index cca37cf3a44..a3bf27a19d6 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -195,7 +195,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
}
}
- if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
+ if (!ok) BKE_report(op->reports, RPT_ERROR, "Active object contains no groups");
DAG_scene_sort(bmain, scene);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -211,7 +211,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot)
ot->idname = "GROUP_OT_objects_remove_active";
/* api callbacks */
- ot->exec = objects_remove_active_exec;
+ ot->exec = objects_remove_active_exec;
ot->poll = ED_operator_objectmode;
/* flags */
@@ -333,7 +333,7 @@ void GROUP_OT_create(wmOperatorType *ot)
ot->idname = "GROUP_OT_create";
/* api callbacks */
- ot->exec = group_create_exec;
+ ot->exec = group_create_exec;
ot->poll = ED_operator_objectmode;
/* flags */
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index a6afe6b2d04..caeff1e82a7 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -442,7 +442,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob
ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent);
if (!ok) {
- BKE_report(reports, RPT_ERROR, "Requires selected vertices or active Vertex Group");
+ BKE_report(reports, RPT_ERROR, "Requires selected vertices or active vertex group");
return FALSE;
}
@@ -515,12 +515,12 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
if (!obsel) {
- BKE_report(op->reports, RPT_ERROR, "Can't add hook with no other selected objects");
+ BKE_report(op->reports, RPT_ERROR, "Cannot add hook with no other selected objects");
return OPERATOR_CANCELLED;
}
if (use_bone && obsel->type != OB_ARMATURE) {
- BKE_report(op->reports, RPT_ERROR, "Can't add hook bone for a non armature object");
+ BKE_report(op->reports, RPT_ERROR, "Cannot add hook bone for a non armature object");
return OPERATOR_CANCELLED;
}
@@ -590,7 +590,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op)
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
if (!hmd) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
+ BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
@@ -667,13 +667,13 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
if (ptr.data) { /* if modifier context is available, use that */
ob = ptr.id.data;
hmd = ptr.data;
- }
+ }
else { /* use the provided property */
ob = CTX_data_edit_object(C);
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
}
if (!ob || !hmd) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
+ BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
@@ -735,13 +735,13 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op)
if (ptr.data) { /* if modifier context is available, use that */
ob = ptr.id.data;
hmd = ptr.data;
- }
+ }
else { /* use the provided property */
ob = CTX_data_edit_object(C);
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
}
if (!ob || !hmd) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
+ BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
@@ -793,13 +793,13 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
if (ptr.data) { /* if modifier context is available, use that */
ob = ptr.id.data;
hmd = ptr.data;
- }
+ }
else { /* use the provided property */
ob = CTX_data_edit_object(C);
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
}
if (!ob || !hmd) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
+ BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
@@ -855,13 +855,13 @@ static int object_hook_select_exec(bContext *C, wmOperator *op)
if (ptr.data) { /* if modifier context is available, use that */
ob = ptr.id.data;
hmd = ptr.data;
- }
+ }
else { /* use the provided property */
ob = CTX_data_edit_object(C);
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
}
if (!ob || !hmd) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
+ BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 4c83f6ef2ce..0be9c92897e 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -138,6 +138,7 @@ void OBJECT_OT_hook_recenter(struct wmOperatorType *ot);
/* object_lattice.c */
void LATTICE_OT_select_all(struct wmOperatorType *ot);
void LATTICE_OT_make_regular(struct wmOperatorType *ot);
+void LATTICE_OT_flip(struct wmOperatorType *ot);
/* object_group.c */
void GROUP_OT_create(struct wmOperatorType *ot);
@@ -204,6 +205,7 @@ void OBJECT_OT_vertex_group_remove_from(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_select(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_deselect(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy_to_linked(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_transfer_weight(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy_to_selected(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize(struct wmOperatorType *ot);
@@ -214,6 +216,7 @@ void OBJECT_OT_vertex_group_fix(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_limit_total(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_mirror(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_set_active(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_sort(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 1f7be0bf9a6..4aa2e825954 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -46,6 +46,7 @@
#include "DNA_scene_types.h"
#include "RNA_access.h"
+#include "RNA_define.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
@@ -167,7 +168,7 @@ void load_editLatt(Object *obedit)
}
}
-/************************** Operators *************************/
+/************************** Select All Operator *************************/
void ED_setflagsLatt(Object *obedit, int flag)
{
@@ -254,6 +255,8 @@ void LATTICE_OT_select_all(wmOperatorType *ot)
WM_operator_properties_select_all(ot);
}
+/************************** Make Regular Operator *************************/
+
static int make_regular_poll(bContext *C)
{
Object *ob;
@@ -300,18 +303,265 @@ void LATTICE_OT_make_regular(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/************************** Flip Verts Operator *************************/
+
+/* flipping options */
+typedef enum eLattice_FlipAxes {
+ LATTICE_FLIP_U = 0,
+ LATTICE_FLIP_V = 1,
+ LATTICE_FLIP_W = 2
+} eLattice_FlipAxes;
+
+/* Helper macro for accessing item at index (u, v, w)
+ * < lt: (Lattice)
+ * < U: (int) u-axis coordinate of point
+ * < V: (int) v-axis coordinate of point
+ * < W: (int) w-axis coordinate of point
+ * < dimU: (int) number of points per row or number of columns (U-Axis)
+ * < dimV: (int) number of rows (V-Axis)
+ * > returns: (BPoint *) pointer to BPoint at this index
+ */
+#define LATTICE_PT(lt, U, V, W, dimU, dimV) \
+ ( (lt)->def + \
+ ((dimU) * (dimV)) * (W) + \
+ (dimU) * (V) + \
+ (U) \
+ )
+
+/* Flip midpoint value so that relative distances between midpoint and neighbour-pair is maintained
+ * ! Assumes that uvw <=> xyz (i.e. axis-aligned index-axes with coordinate-axes)
+ * - Helper for lattice_flip_exec()
+ */
+static void lattice_flip_point_value(Lattice *lt, int u, int v, int w, float mid, eLattice_FlipAxes axis)
+{
+ BPoint *bp;
+ float diff;
+
+ /* just the point in the middle (unpaired) */
+ bp = LATTICE_PT(lt, u, v, w, lt->pntsu, lt->pntsv);
+
+ /* flip over axis */
+ diff = mid - bp->vec[axis];
+ bp->vec[axis] = mid + diff;
+}
+
+/* Swap pairs of lattice points along a specified axis
+ * - Helper for lattice_flip_exec()
+ */
+static void lattice_swap_point_pairs(Lattice *lt, int u, int v, int w, float mid, eLattice_FlipAxes axis)
+{
+ BPoint *bpA, *bpB;
+
+ int numU = lt->pntsu;
+ int numV = lt->pntsv;
+ int numW = lt->pntsw;
+
+ int u0 = u, u1 = u;
+ int v0 = v, v1 = v;
+ int w0 = w, w1 = w;
+
+ /* get pair index by just overriding the relevant pair-value
+ * - "-1" else buffer overflow
+ */
+ switch (axis) {
+ case LATTICE_FLIP_U:
+ u1 = numU - u - 1;
+ break;
+ case LATTICE_FLIP_V:
+ v1 = numV - v - 1;
+ break;
+ case LATTICE_FLIP_W:
+ w1 = numW - w - 1;
+ break;
+ }
+
+ /* get points to operate on */
+ bpA = LATTICE_PT(lt, u0, v0, w0, numU, numV);
+ bpB = LATTICE_PT(lt, u1, v1, w1, numU, numV);
+
+ /* Swap all coordinates, so that flipped coordinates belong to
+ * the indices on the correct side of the lattice.
+ *
+ * Coords: (-2 4) |0| (3 4) --> (3 4) |0| (-2 4)
+ * Indices: (0,L) (1,R) --> (0,L) (1,R)
+ */
+ swap_v3_v3(bpA->vec, bpB->vec);
+
+ /* However, we need to mirror the coordinate values on the axis we're dealing with,
+ * otherwise we'd have effectively only rotated the points around. If we don't do this,
+ * we'd just be reimplementing the naive mirroring algorithm, which causes unwanted deforms
+ * such as flipped normals, etc.
+ *
+ * Coords: (3 4) |0| (-2 4) --\
+ * \-> (-3 4) |0| (2 4)
+ * Indices: (0,L) (1,R) --> (0,L) (1,R)
+ */
+ lattice_flip_point_value(lt, u0, v0, w0, mid, axis);
+ lattice_flip_point_value(lt, u1, v1, w1, mid, axis);
+}
+
+static int lattice_flip_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ Lattice *lt;
+
+ eLattice_FlipAxes axis = RNA_enum_get(op->ptr, "axis");
+ int numU, numV, numW;
+ int totP;
+
+ float mid = 0.0f;
+ short isOdd = 0;
+
+ /* get lattice - we need the "edit lattice" from the lattice... confusing... */
+ lt = (Lattice *)obedit->data;
+ lt = lt->editlatt->latt;
+
+ numU = lt->pntsu;
+ numV = lt->pntsv;
+ numW = lt->pntsw;
+ totP = numU * numV * numW;
+
+ /* First Pass: determine midpoint - used for flipping center verts if there are odd number of points on axis */
+ switch (axis) {
+ case LATTICE_FLIP_U:
+ isOdd = numU & 1;
+ break;
+ case LATTICE_FLIP_V:
+ isOdd = numV & 1;
+ break;
+ case LATTICE_FLIP_W:
+ isOdd = numW & 1;
+ break;
+
+ default:
+ printf("lattice_flip(): Unknown flipping axis (%d)\n", axis);
+ return OPERATOR_CANCELLED;
+ }
+
+ if (isOdd) {
+ BPoint *bp;
+ float avgInv = 1.0f / (float)totP;
+ int i;
+
+ /* midpoint calculation - assuming that u/v/w are axis-aligned */
+ for (i = 0, bp = lt->def; i < totP; i++, bp++) {
+ mid += bp->vec[axis] * avgInv;
+ }
+ }
+
+ /* Second Pass: swap pairs of vertices per axis, assuming they are all sorted */
+ switch (axis) {
+ case LATTICE_FLIP_U:
+ {
+ int u, v, w;
+
+ /* v/w strips - front to back, top to bottom */
+ for (w = 0; w < numW; w++) {
+ for (v = 0; v < numV; v++) {
+ /* swap coordinates of pairs of vertices on u */
+ for (u = 0; u < (numU / 2); u++) {
+ lattice_swap_point_pairs(lt, u, v, w, mid, axis);
+ }
+
+ /* flip u-coordinate of midpoint (i.e. unpaired point on u) */
+ if (isOdd) {
+ u = (numU / 2);
+ lattice_flip_point_value(lt, u, v, w, mid, axis);
+ }
+ }
+ }
+ }
+ break;
+ case LATTICE_FLIP_V:
+ {
+ int u, v, w;
+
+ /* u/w strips - front to back, left to right */
+ for (w = 0; w < numW; w++) {
+ for (u = 0; u < numU; u++) {
+ /* swap coordinates of pairs of vertices on v */
+ for (v = 0; v < (numV / 2); v++) {
+ lattice_swap_point_pairs(lt, u, v, w, mid, axis);
+ }
+
+ /* flip v-coordinate of midpoint (i.e. unpaired point on v) */
+ if (isOdd) {
+ v = (numV / 2);
+ lattice_flip_point_value(lt, u, v, w, mid, axis);
+ }
+ }
+ }
+ }
+ break;
+ case LATTICE_FLIP_W:
+ {
+ int u, v, w;
+
+ for (v = 0; v < numV; v++) {
+ for (u = 0; u < numU; u++) {
+ /* swap coordinates of pairs of vertices on w */
+ for (w = 0; w < (numW / 2); w++) {
+ lattice_swap_point_pairs(lt, u, v, w, mid, axis);
+ }
+
+ /* flip w-coordinate of midpoint (i.e. unpaired point on w) */
+ if (isOdd) {
+ w = (numW / 2);
+ lattice_flip_point_value(lt, u, v, w, mid, axis);
+ }
+ }
+ }
+ }
+ break;
+
+ default: /* shouldn't happen, but just in case */
+ break;
+ }
+
+ /* updates */
+ DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+
+ return OPERATOR_FINISHED;
+}
+
+void LATTICE_OT_flip(wmOperatorType *ot)
+{
+ static EnumPropertyItem flip_items[] = {
+ {LATTICE_FLIP_U, "U", 0, "U (X) Axis", ""},
+ {LATTICE_FLIP_V, "V", 0, "V (Y) Axis", ""},
+ {LATTICE_FLIP_W, "W", 0, "W (Z) Axis", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+ /* identifiers */
+ ot->name = "Flip (Distortion Free)";
+ ot->description = "Mirror all control points without inverting the lattice deform";
+ ot->idname = "LATTICE_OT_flip";
+
+ /* api callbacks */
+ ot->poll = ED_operator_editlattice;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = lattice_flip_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "axis", flip_items, LATTICE_FLIP_U, "Flip Axis", "Coordinates along this axis get flipped");
+}
+
/****************************** Mouse Selection *************************/
-static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y)
+static void findnearestLattvert__doClosest(void *userData, BPoint *bp, const float screen_co[2])
{
- struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData;
- float temp = abs(data->mval[0] - x) + abs(data->mval[1] - y);
+ struct { BPoint *bp; float dist; int select; float mval_fl[2]; } *data = userData;
+ float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if ((bp->f1 & SELECT) == data->select)
- temp += 5;
+ if ((bp->f1 & SELECT) && data->select)
+ dist_test += 5.0f;
- if (temp < data->dist) {
- data->dist = temp;
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
data->bp = bp;
}
@@ -319,18 +569,18 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in
static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel)
{
- /* sel==1: selected gets a disadvantage */
+ /* (sel == 1): selected gets a disadvantage */
/* in nurb and bezt or bp the nearest is written */
/* return 0 1 2: handlepunt */
- struct { BPoint *bp; short dist, select; int mval[2]; } data = {NULL};
+ struct { BPoint *bp; float dist; int select; float mval_fl[2]; } data = {NULL};
data.dist = 100;
data.select = sel;
- data.mval[0] = mval[0];
- data.mval[1] = mval[1];
+ data.mval_fl[0] = mval[0];
+ data.mval_fl[1] = mval[1];
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- lattice_foreachScreenVert(vc, findnearestLattvert__doClosest, &data);
+ lattice_foreachScreenVert(vc, findnearestLattvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
return data.bp;
}
@@ -341,7 +591,7 @@ int mouse_lattice(bContext *C, const int mval[2], int extend, int deselect, int
BPoint *bp = NULL;
view3d_set_viewcontext(C, &vc);
- bp = findnearestLattvert(&vc, mval, 1);
+ bp = findnearestLattvert(&vc, mval, TRUE);
if (bp) {
if (extend) {
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index d75ef78fc4c..3d2c4f95624 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -99,13 +99,13 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
/* only geometry objects should be able to get modifiers [#25291] */
if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
- BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name + 2);
+ BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2);
return NULL;
}
if (mti->flags & eModifierTypeFlag_Single) {
if (modifiers_findByType(ob, type)) {
- BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed");
+ BKE_report(reports, RPT_WARNING, "Only one modifier of this type is allowed");
return NULL;
}
}
@@ -556,7 +556,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
KeyBlock *kb;
if (!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
- BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to Shapes");
+ BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
return 0;
}
@@ -604,7 +604,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
MultiresModifierData *mmd = find_multires_modifier_before(scene, md);
if (me->key && mti->type != eModifierTypeType_NonGeometrical) {
- BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys");
+ BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys");
return 0;
}
@@ -681,7 +681,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi
int prev_mode;
if (scene->obedit) {
- BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in editmode");
+ BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode");
return 0;
}
else if (((ID *) ob->data)->us > 1) {
@@ -1242,7 +1242,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
if (!secondob) {
- BKE_report(op->reports, RPT_ERROR, "Second selected mesh object require to copy shape from");
+ BKE_report(op->reports, RPT_ERROR, "Second selected mesh object required to copy shape from");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index fa40d579e2b..d19277d20a2 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -178,6 +178,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_vertex_group_select);
WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
+ WM_operatortype_append(OBJECT_OT_vertex_group_transfer_weight);
WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
WM_operatortype_append(OBJECT_OT_vertex_group_copy);
WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
@@ -188,6 +189,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_vertex_group_levels);
WM_operatortype_append(OBJECT_OT_vertex_group_blend);
WM_operatortype_append(OBJECT_OT_vertex_group_clean);
+ WM_operatortype_append(OBJECT_OT_vertex_group_limit_total);
WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
WM_operatortype_append(OBJECT_OT_vertex_group_sort);
@@ -209,6 +211,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(LATTICE_OT_select_all);
WM_operatortype_append(LATTICE_OT_make_regular);
+ WM_operatortype_append(LATTICE_OT_flip);
WM_operatortype_append(OBJECT_OT_group_add);
WM_operatortype_append(OBJECT_OT_group_link);
@@ -390,7 +393,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0);
- // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
+ /* XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith */
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
@@ -422,6 +425,8 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "LATTICE_OT_flip", FKEY, KM_PRESS, KM_CTRL, 0);
+
/* menus */
WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 446c0a51ed5..58c6959d6f0 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -423,29 +423,92 @@ void OBJECT_OT_proxy_make(wmOperatorType *ot)
/********************** Clear Parent Operator ******************* */
+typedef enum eObClearParentTypes {
+ CLEAR_PARENT_ALL = 0,
+ CLEAR_PARENT_KEEP_TRANSFORM,
+ CLEAR_PARENT_INVERSE
+} eObClearParentTypes;
+
EnumPropertyItem prop_clear_parent_types[] = {
- {0, "CLEAR", 0, "Clear Parent", ""},
- {1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", ""},
- {2, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""},
+ {CLEAR_PARENT_ALL, "CLEAR", 0, "Clear Parent", ""},
+ {CLEAR_PARENT_KEEP_TRANSFORM, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", ""},
+ {CLEAR_PARENT_INVERSE, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""},
{0, NULL, 0, NULL, NULL}
};
-void ED_object_parent_clear(Object *ob, int type)
+/* Helper for ED_object_parent_clear() - Remove deform-modifiers associated with parent */
+static void object_remove_parent_deform_modifiers(Object *ob, const Object *par)
{
+ if (ELEM3(par->type, OB_ARMATURE, OB_LATTICE, OB_CURVE)) {
+ ModifierData *md, *mdn;
+
+ /* assume that we only need to remove the first instance of matching deform modifier here */
+ for (md = ob->modifiers.first; md; md = mdn) {
+ short free = FALSE;
+
+ mdn = md->next;
+
+ /* need to match types (modifier + parent) and references */
+ if ((md->type == eModifierType_Armature) && (par->type == OB_ARMATURE)) {
+ ArmatureModifierData *amd = (ArmatureModifierData *)md;
+ if (amd->object == par) {
+ free = TRUE;
+ }
+ }
+ else if ((md->type == eModifierType_Lattice) && (par->type == OB_LATTICE)) {
+ LatticeModifierData *lmd = (LatticeModifierData *)md;
+ if (lmd->object == par) {
+ free = TRUE;
+ }
+ }
+ else if ((md->type == eModifierType_Curve) && (par->type == OB_CURVE)) {
+ CurveModifierData *cmd = (CurveModifierData *)md;
+ if (cmd->object == par) {
+ free = TRUE;
+ }
+ }
+
+ /* free modifier if match */
+ if (free) {
+ BLI_remlink(&ob->modifiers, md);
+ modifier_free(md);
+ }
+ }
+ }
+}
+void ED_object_parent_clear(Object *ob, int type)
+{
if (ob->parent == NULL)
return;
+
+ switch (type) {
+ case CLEAR_PARENT_ALL:
+ {
+ /* for deformers, remove corresponding modifiers to prevent a large number of modifiers building up */
+ object_remove_parent_deform_modifiers(ob, ob->parent);
+
+ /* clear parenting relationship completely */
+ ob->parent = NULL;
+ }
+ break;
- if (type == 0) {
- ob->parent = NULL;
- }
- else if (type == 1) {
- ob->parent = NULL;
- BKE_object_apply_mat4(ob, ob->obmat, TRUE, FALSE);
- }
- else if (type == 2)
- unit_m4(ob->parentinv);
+ case CLEAR_PARENT_KEEP_TRANSFORM:
+ {
+ /* remove parent, and apply the parented transform result as object's local transforms */
+ ob->parent = NULL;
+ BKE_object_apply_mat4(ob, ob->obmat, TRUE, FALSE);
+ }
+ break;
+ case CLEAR_PARENT_INVERSE:
+ {
+ /* object stays parented, but the parent inverse (i.e. offset from parent to retain binding state) is cleared */
+ unit_m4(ob->parentinv);
+ }
+ break;
+ }
+
ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
}
@@ -559,13 +622,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
/* fall back on regular parenting now (for follow only) */
if (partype == PAR_FOLLOW)
partype = PAR_OBJECT;
- }
+ }
}
else if (partype == PAR_BONE) {
pchan = BKE_pose_channel_active(par);
if (pchan == NULL) {
- BKE_report(reports, RPT_ERROR, "No active Bone");
+ BKE_report(reports, RPT_ERROR, "No active bone");
return 0;
}
}
@@ -604,25 +667,40 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
* NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers
*/
ob->partype = PAROBJECT; /* note, dna define, not operator property */
- //ob->partype= PARSKEL; /* note, dna define, not operator property */
+ //ob->partype = PARSKEL; /* note, dna define, not operator property */
- /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */
+ /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses
+ * - We need to ensure that the modifier we're adding doesn't already exist, so we check this by
+ * assuming that the parent is selected too...
+ */
// XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet
if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
ModifierData *md;
switch (partype) {
case PAR_CURVE: /* curve deform */
- md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve);
- ((CurveModifierData *)md)->object = par;
+ if ( modifiers_isDeformedByCurve(ob) != par) {
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve);
+ if (md) {
+ ((CurveModifierData *)md)->object = par;
+ }
+ }
break;
case PAR_LATTICE: /* lattice deform */
- md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice);
- ((LatticeModifierData *)md)->object = par;
+ if (modifiers_isDeformedByLattice(ob) != par) {
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice);
+ if (md) {
+ ((LatticeModifierData *)md)->object = par;
+ }
+ }
break;
default: /* armature deform */
- md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature);
- ((ArmatureModifierData *)md)->object = par;
+ if (modifiers_isDeformedByArmature(ob) != par) {
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature);
+ if (md) {
+ ((ArmatureModifierData *)md)->object = par;
+ }
+ }
break;
}
}
@@ -958,7 +1036,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
int type = RNA_enum_get(op->ptr, "type");
if (CTX_data_edit_object(C)) {
- BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
+ BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode");
return OPERATOR_CANCELLED;
}
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -1182,7 +1260,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
base->object->lay = lay;
base->object->flag &= ~SELECT;
base->flag &= ~SELECT;
- /* if (base->object->type==OB_LAMP) is_lamp = TRUE; */
+ /* if (base->object->type == OB_LAMP) is_lamp = TRUE; */
}
CTX_DATA_END;
}
@@ -1195,7 +1273,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
local = base->lay & 0xFF000000;
base->lay = lay + local;
base->object->lay = lay;
- /* if (base->object->type==OB_LAMP) is_lamp = TRUE; */
+ /* if (base->object->type == OB_LAMP) is_lamp = TRUE; */
}
CTX_DATA_END;
}
@@ -1272,17 +1350,17 @@ static int make_links_scene_exec(bContext *C, wmOperator *op)
Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
if (scene_to == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't find scene");
+ BKE_report(op->reports, RPT_ERROR, "Could not find scene");
return OPERATOR_CANCELLED;
}
if (scene_to == CTX_data_scene(C)) {
- BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene");
+ BKE_report(op->reports, RPT_ERROR, "Cannot link objects into the same scene");
return OPERATOR_CANCELLED;
}
if (scene_to->id.lib) {
- BKE_report(op->reports, RPT_ERROR, "Can't link objects into a linked scene");
+ BKE_report(op->reports, RPT_ERROR, "Cannot link objects into a linked scene");
return OPERATOR_CANCELLED;
}
@@ -1632,7 +1710,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
break;
case OB_MESH:
ob->data = BKE_mesh_copy(ob->data);
- //me= ob->data;
+ //me = ob->data;
//if (me && me->key)
// ipo_idnew(me->key->ipo); /* drivers */
break;
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 4ed14c3cdce..2aa737d204d 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -425,7 +425,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
ob = OBACT;
if (ob == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No Active Object");
+ BKE_report(op->reports, RPT_ERROR, "No active object");
return OPERATOR_CANCELLED;
}
@@ -608,11 +608,11 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in
for (i = 0; i < group_count; i++) {
group = ob_groups[i];
- uiItemStringO(layout, group->id.name + 2, 0, "OBJECT_OT_select_same_group", "group", group->id.name);
+ uiItemStringO(layout, group->id.name + 2, 0, "OBJECT_OT_select_same_group", "group", group->id.name + 2);
}
uiPupMenuEnd(C, pup);
- return changed; // The operator already handle this!
+ return changed; /* The operator already handle this! */
}
static short select_grouped_object_hooks(bContext *C, Object *ob)
@@ -754,8 +754,8 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob))
return 0;
/* select each object that Keying Set refers to */
- // TODO: perhaps to be more in line with the rest of these, we should only take objects
- // if the passed in object is included in this too
+ /* TODO: perhaps to be more in line with the rest of these, we should only take objects
+ * if the passed in object is included in this too */
CTX_DATA_BEGIN (C, Base *, base, selectable_bases)
{
/* only check for this object if it isn't selected already, to limit time wasted */
@@ -800,7 +800,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
ob = OBACT;
if (ob == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No Active Object");
+ BKE_report(op->reports, RPT_ERROR, "No active object");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index cfd4945688b..2b6d69ca694 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -162,15 +162,15 @@ static int object_shape_key_mirror(bContext *C, Object *ob)
kb = BLI_findlink(&key->block, ob->shapenr - 1);
if (kb) {
- int i1, i2;
- float *fp1, *fp2;
- float tvec[3];
char *tag_elem = MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror");
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
MVert *mv;
+ int i1, i2;
+ float *fp1, *fp2;
+ float tvec[3];
mesh_octree_table(ob, NULL, NULL, 's');
@@ -211,7 +211,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob)
/* currently editmode isn't supported by mesh so
* ignore here for now too */
- /* if (lt->editlatt) lt= lt->editlatt->latt; */
+ /* if (lt->editlatt) lt = lt->editlatt->latt; */
for (w = 0; w < lt->pntsw; w++) {
for (v = 0; v < lt->pntsv; v++) {
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 9129d651d4d..900bf57b509 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -171,7 +171,7 @@ static void object_clear_rot(Object *ob)
}
}
} // Duplicated in source/blender/editors/armature/editarmature.c
- else {
+ else {
if (ob->rotmode == ROT_MODE_QUAT) {
unit_qt(ob->quat);
unit_qt(ob->dquat);
@@ -217,7 +217,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* sanity checks */
if (ELEM(NULL, clear_func, default_ksName)) {
- BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform func or Keying Set Name");
+ BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name");
return OPERATOR_CANCELLED;
}
@@ -381,8 +381,8 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- float rsmat[3][3], tmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
- int a, change = 1;
+ float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
+ int change = 1;
/* first check if we can execute */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -390,19 +390,19 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
if (ob->type == OB_MESH) {
if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Can't apply to a multi user mesh, doing nothing");
+ BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user mesh, doing nothing");
change = 0;
}
}
else if (ob->type == OB_ARMATURE) {
if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Can't apply to a multi user armature, doing nothing");
+ BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user armature, doing nothing");
change = 0;
}
}
else if (ob->type == OB_LATTICE) {
if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Can't apply to a multi user lattice, doing nothing");
+ BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user lattice, doing nothing");
change = 0;
}
}
@@ -410,18 +410,19 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
Curve *cu;
if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Can't apply to a multi user curve, doing nothing");
+ BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user curve, doing nothing");
change = 0;
}
cu = ob->data;
if (!(cu->flag & CU_3D) && (apply_rot || apply_loc)) {
- BKE_report(reports, RPT_ERROR, "Neither rotation nor location could be applied to a 2d curve, doing nothing");
+ BKE_report(reports, RPT_ERROR,
+ "Neither rotation nor location could be applied to a 2D curve, doing nothing");
change = 0;
}
if (cu->key) {
- BKE_report(reports, RPT_ERROR, "Can't apply to a curve with vertex keys, doing nothing");
+ BKE_report(reports, RPT_ERROR, "Cannot apply to a curve with vertex keys, doing nothing");
change = 0;
}
}
@@ -464,6 +465,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
copy_v3_v3(mat[3], ob->loc);
if (!(apply_scale && apply_rot)) {
+ float tmat[3][3];
/* correct for scale and rotation that is still applied */
BKE_object_to_mat3(ob, obmat);
invert_m3_m3(iobmat, obmat);
@@ -476,6 +478,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
MVert *mvert;
+ int a;
if (apply_scale)
multiresModifier_scale_disp(scene, ob);
@@ -518,6 +521,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
Nurb *nu;
BPoint *bp;
BezTriple *bezt;
+ int a;
scale = mat3_to_scale(rsmat);
@@ -650,7 +654,8 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot)
enum {
GEOMETRY_TO_ORIGIN = 0,
ORIGIN_TO_GEOMETRY,
- ORIGIN_TO_CURSOR
+ ORIGIN_TO_CURSOR,
+ ORIGIN_TO_CENTER_OF_MASS
};
static int object_origin_set_exec(bContext *C, wmOperator *op)
@@ -667,7 +672,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0;
if (obedit && centermode != GEOMETRY_TO_ORIGIN) {
- BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
+ BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode");
return OPERATOR_CANCELLED;
}
else {
@@ -781,6 +786,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Mesh *me = ob->data;
if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if (centermode == ORIGIN_TO_CENTER_OF_MASS) { BKE_mesh_center_centroid(me, cent); }
else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); }
else { BKE_mesh_center_bounds(me, cent); }
@@ -848,7 +854,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (ID_REAL_USERS(arm) > 1) {
#if 0
- BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature");
+ BKE_report(op->reports, RPT_ERROR, "Cannot apply to a multi user armature");
return;
#endif
tot_multiuser_arm_error++;
@@ -861,7 +867,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
tot_change++;
arm->id.flag |= LIB_DOIT;
- /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */
+ /* do_inverse_offset = TRUE; */ /* docenter_armature() handles this */
BKE_object_where_is_calc(scene, ob);
BKE_pose_where_is(scene, ob); /* needed for bone parents */
@@ -896,10 +902,17 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* offset other selected objects */
if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
+ CollectionPointerLink *ctx_link_other;
+ float obmat[4][4];
+
/* was the object data modified
* note: the functions above must set 'cent' */
+
+ /* convert the offset to parent space */
+ BKE_object_to_mat4(ob, obmat);
copy_v3_v3(centn, cent);
- mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
+ mul_mat3_m4_v3(obmat, centn); /* omit translation part */
+
add_v3_v3(ob->loc, centn);
BKE_object_where_is_calc(scene, ob);
@@ -910,8 +923,16 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(bmain, scene, ob);
/* other users? */
- CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
+ //CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
+ //{
+
+ /* use existing context looper */
+ for (ctx_link_other = ctx_data_list.first;
+ ctx_link_other;
+ ctx_link_other = ctx_link_other->next)
{
+ Object *ob_other = ctx_link_other->ptr.data;
+
if ((ob_other->flag & OB_DONE) == 0 &&
((ob->data && (ob->data == ob_other->data)) ||
(ob->dup_group == ob_other->dup_group &&
@@ -931,7 +952,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(bmain, scene, ob_other);
}
}
- CTX_DATA_END;
+ //CTX_DATA_END;
}
}
}
@@ -948,9 +969,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* Warn if any errors occurred */
if (tot_lib_error + tot_multiuser_arm_error) {
- BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:", tot_lib_error + tot_multiuser_arm_error, tot_change);
+ BKE_reportf(op->reports, RPT_WARNING, "%i object(s) not centered, %i changed:", tot_lib_error + tot_multiuser_arm_error, tot_change);
if (tot_lib_error)
- BKE_reportf(op->reports, RPT_WARNING, "|%i linked library objects", tot_lib_error);
+ BKE_reportf(op->reports, RPT_WARNING, "|%i linked library object(s)", tot_lib_error);
if (tot_multiuser_arm_error)
BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)", tot_multiuser_arm_error);
}
@@ -962,8 +983,12 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
{
static EnumPropertyItem prop_set_center_types[] = {
{GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
- {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"},
- {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"},
+ {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry",
+ "Move object origin to center of object geometry"},
+ {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor",
+ "Move object origin to position of the 3D cursor"},
+ {ORIGIN_TO_CENTER_OF_MASS, "ORIGIN_CENTER_OF_MASS", 0, "Origin to Center of Mass",
+ "Move object origin to the object center of mass (assuming uniform density)"},
{0, NULL, 0, NULL, NULL}
};
@@ -975,7 +1000,7 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
/* identifiers */
ot->name = "Set Origin";
- ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3d cursor";
+ ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3D cursor";
ot->idname = "OBJECT_OT_origin_set";
/* api callbacks */
@@ -990,4 +1015,3 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", "");
}
-
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index b31d2b8b076..05524af34f0 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -20,7 +20,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Ove M Henriksen.
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -29,7 +29,6 @@
* \ingroup edobj
*/
-
#include <string.h>
#include <stddef.h>
#include <math.h>
@@ -83,6 +82,19 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup);
static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg);
static void vgroup_delete_all(Object *ob);
+static int vertex_group_use_vert_sel(Object *ob)
+{
+ if (ob->mode == OB_MODE_EDIT) {
+ return TRUE;
+ }
+ else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
static Lattice *vgroup_edit_lattice(Object *ob)
{
Lattice *lt = ob->data;
@@ -126,21 +138,12 @@ bDeformGroup *ED_vgroup_add(Object *ob)
void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup)
{
- bDeformGroup *dg = (bDeformGroup *)ob->defbase.first;
-
- while (dg) {
- if (dg == defgroup)
- break;
- dg = dg->next;
- }
-
- if (dg == NULL)
- return;
+ BLI_assert(BLI_findindex(&ob->defbase, defgroup) != -1);
if (ED_vgroup_object_is_edit_mode(ob))
- vgroup_delete_edit_mode(ob, dg);
+ vgroup_delete_edit_mode(ob, defgroup);
else
- vgroup_delete_object_mode(ob, dg);
+ vgroup_delete_object_mode(ob, defgroup);
}
void ED_vgroup_clear(Object *ob)
@@ -377,6 +380,332 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from)
return 1;
}
+/***********************Start weight transfer (WT)*********************************/
+
+typedef enum WT_VertexGroupMode {
+ WT_REPLACE_ACTIVE_VERTEX_GROUP = 1,
+ WT_REPLACE_ALL_VERTEX_GROUPS = 2
+} WT_VertexGroupMode;
+
+typedef enum WT_Method {
+ WT_BY_INDEX = 1,
+ WT_BY_NEAREST_VERTEX = 2,
+ WT_BY_NEAREST_FACE = 3,
+ WT_BY_NEAREST_VERTEX_IN_FACE = 4
+} WT_Method;
+
+typedef enum WT_ReplaceMode {
+ WT_REPLACE_ALL_WEIGHTS = 1,
+ WT_REPLACE_EMPTY_WEIGHTS = 2
+} WT_ReplaceMode;
+
+static EnumPropertyItem WT_vertex_group_mode_item[] = {
+ {WT_REPLACE_ACTIVE_VERTEX_GROUP, "WT_REPLACE_ACTIVE_VERTEX_GROUP", 1, "Active", "Transfer active vertex group from selected to active mesh"},
+ {WT_REPLACE_ALL_VERTEX_GROUPS, "WT_REPLACE_ALL_VERTEX_GROUPS", 1, "All", "Transfer all vertex groups from selected to active mesh"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static EnumPropertyItem WT_method_item[] = {
+ {WT_BY_INDEX, "WT_BY_INDEX", 1, "Vertex index", "Copy for identical meshes"},
+ {WT_BY_NEAREST_VERTEX, "WT_BY_NEAREST_VERTEX", 1, "Nearest vertex", "Copy weight from closest vertex"},
+ {WT_BY_NEAREST_FACE, "WT_BY_NEAREST_FACE", 1, "Nearest face", "Barycentric interpolation from nearest face"},
+ {WT_BY_NEAREST_VERTEX_IN_FACE, "WT_BY_NEAREST_VERTEX_IN_FACE", 1, "Nearest vertex in face", "Copy weight from closest vertex in nearest face"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static EnumPropertyItem WT_replace_mode_item[] = {
+ {WT_REPLACE_ALL_WEIGHTS, "WT_REPLACE_ALL_WEIGHTS", 1, "All", "Overwrite all weights"},
+ {WT_REPLACE_EMPTY_WEIGHTS, "WT_REPLACE_EMPTY_WEIGHTS", 1, "Empty", "Add weights to vertices with no weight"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+/*copy weight*/
+static void vgroup_transfer_weight(float *r_weight_dst, const float weight_src, const WT_ReplaceMode replace_mode)
+{
+ switch (replace_mode) {
+ case WT_REPLACE_ALL_WEIGHTS:
+ *r_weight_dst = weight_src;
+ break;
+
+ case WT_REPLACE_EMPTY_WEIGHTS:
+ if (*r_weight_dst == 0.0f) {
+ *r_weight_dst = weight_src;
+ }
+ break;
+
+ default:
+ BLI_assert(0);
+ break;
+ }
+}
+
+/* could be exposed externally */
+static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGroup *dg_src, Scene *scene,
+ WT_Method method, WT_ReplaceMode replace_mode, wmOperator *op)
+{
+ bDeformGroup *dg_dst;
+ Mesh *me_dst, *me_src;
+ DerivedMesh *dmesh_src;
+ BVHTreeFromMesh tree_mesh_vertices_src, tree_mesh_faces_src = {NULL};
+ MDeformVert **dv_array_src, **dv_array_dst, **dv_src, **dv_dst;
+ MVert *mv_dst, *mv_src;
+ MFace *mface_src, *mf;
+ BVHTreeNearest nearest;
+ MDeformWeight *dw_dst, *dw_src;
+ int dv_tot_src, dv_tot_dst, i, v_index, index_dst, index_src, index_nearest, index_nearest_vertex;
+ unsigned int f_index;
+ float weight, tmp_weight[4], tmp_co[3], normal[3], tmp_mat[4][4], dist_v1, dist_v2, dist_v3, dist_v4;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob_dst);
+
+ /* create new and overwrite vertex group on destination without data */
+ if (!defgroup_find_name(ob_dst, dg_src->name)) {
+ ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_src->name));
+ ED_vgroup_add_name(ob_dst, dg_src->name);
+ }
+
+ /* get destination deformgroup */
+ dg_dst = defgroup_find_name(ob_dst, dg_src->name);
+
+ /* get meshes */
+ dmesh_src = mesh_get_derived_deform(scene, ob_src, CD_MASK_BAREMESH);
+ me_dst = ob_dst->data;
+ me_src = ob_src->data;
+
+ /* sanity check */
+ if (!me_src->dvert) {
+ BKE_report(op->reports, RPT_ERROR, "Transfer failed (source mesh does not have any vertex groups)");
+ return 0;
+ }
+
+ /* create data in memory when nothing there */
+ if (!me_dst->dvert) ED_vgroup_data_create(ob_dst->data);
+
+ /* get vertex group arrays */
+ ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, FALSE);
+ ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, use_vert_sel);
+
+ /* get indexes of vertex groups */
+ index_src = BLI_findindex(&ob_src->defbase, dg_src);
+ index_dst = BLI_findindex(&ob_dst->defbase, dg_dst);
+
+ /* get vertices */
+ mv_dst = me_dst->mvert;
+ mv_src = dmesh_src->getVertArray(dmesh_src);
+
+ /* prepare transformation matrix */
+ invert_m4_m4(ob_src->imat, ob_src->obmat);
+ mult_m4_m4m4(tmp_mat, ob_src->imat, ob_dst->obmat);
+
+ /* clear weights */
+ if (replace_mode == WT_REPLACE_ALL_WEIGHTS) {
+ for (i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++) {
+
+ if (*dv_dst == NULL) continue;
+
+ dw_dst = defvert_find_index(*dv_dst, index_dst);
+ /* remove vertex from group */
+ if (dw_dst) defvert_remove_group(*dv_dst, dw_dst);
+ }
+ }
+
+ switch (method) {
+
+ case WT_BY_INDEX:
+ /* check if indices are matching, delete and return if not */
+ if (ob_dst == ob_src || dv_tot_dst == 0 || dv_tot_dst != dv_tot_src ||
+ dv_array_src == NULL || dv_array_dst == NULL)
+ {
+ ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_dst->name));
+ if (dv_array_src) MEM_freeN(dv_array_src);
+ if (dv_array_dst) MEM_freeN(dv_array_dst);
+ dmesh_src->release(dmesh_src);
+ BKE_report(op->reports, RPT_ERROR, "Transfer failed (indices are not matching)");
+ return 0;
+ }
+
+ /* loop through the vertices*/
+ for (i = 0, dv_src = dv_array_src, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, dv_src++, mv_src++, mv_dst++) {
+
+ if (*dv_dst == NULL) {
+ continue;
+ }
+
+ /* copy weight */
+ dw_src = defvert_find_index(*dv_src, index_src);
+ if (dw_src && dw_src->weight) {
+ dw_dst = defvert_verify_index(*dv_dst, index_dst);
+ vgroup_transfer_weight(&dw_dst->weight, dw_src->weight, replace_mode);
+ }
+ }
+ break;
+
+ case WT_BY_NEAREST_VERTEX:
+ /* make node tree */
+ bvhtree_from_mesh_verts(&tree_mesh_vertices_src, dmesh_src, FLT_EPSILON, 2, 6);
+
+ /* loop trough vertices */
+ for (i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++) {
+
+ if (*dv_dst == NULL) {
+ continue;
+ }
+
+ /* reset nearest */
+ nearest.dist = FLT_MAX;
+ /* with current binary tree its marginally faster to start searching at the top, as opposed to previous search. */
+ nearest.index = -1;
+
+ /* transform into target space */
+ mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);
+
+ /* node tree accelerated search for closest vetex */
+ BLI_bvhtree_find_nearest(tree_mesh_vertices_src.tree, tmp_co,
+ &nearest, tree_mesh_vertices_src.nearest_callback, &tree_mesh_vertices_src);
+
+ /* copy weight that are not NULL including weight value 0. Existing target weights are overwritten prior to this in relevant cases. */
+ dw_src = defvert_find_index(dv_array_src[nearest.index], index_src);
+ if (dw_src && dw_src->weight) {
+ dw_dst = defvert_verify_index(*dv_dst, index_dst);
+ vgroup_transfer_weight(&dw_dst->weight, dw_src->weight, replace_mode);
+ }
+ }
+
+ /* free memory */
+ free_bvhtree_from_mesh(&tree_mesh_vertices_src);
+ break;
+
+ case WT_BY_NEAREST_FACE:
+ /* get faces */
+ DM_ensure_tessface(dmesh_src);
+ mface_src = dmesh_src->getTessFaceArray(dmesh_src);
+
+ /* make node tree */
+ bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, FLT_EPSILON, 2, 6);
+
+ /* loop through the vertices */
+ for (i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++) {
+
+ if (*dv_dst == NULL) {
+ continue;
+ }
+
+ /* reset nearest */
+ nearest.dist = FLT_MAX;
+ /* with current binary tree its marginally faster to start searching at the top, as opposed to previous search. */
+ nearest.index = -1;
+
+ /* transform into target space */
+ mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);
+
+ /* node tree accelerated search for closest face */
+ BLI_bvhtree_find_nearest(tree_mesh_faces_src.tree, tmp_co,
+ &nearest, tree_mesh_faces_src.nearest_callback, &tree_mesh_faces_src);
+ index_nearest = nearest.index;
+
+ /* project onto face */
+ mf = &mface_src[index_nearest];
+ normal_tri_v3(normal, mv_src[mf->v1].co, mv_src[mf->v2].co, mv_src[mf->v3].co);
+ project_v3_plane(tmp_co, normal, mv_src[mf->v1].co);
+
+ /* interpolate weights over face*/
+ f_index = mf->v4 ? 3 : 2;
+ if (f_index == 3) {
+ interp_weights_face_v3(tmp_weight, mv_src[mf->v1].co, mv_src[mf->v2].co, mv_src[mf->v3].co, mv_src[mf->v4].co, tmp_co);
+ }
+ else {
+ interp_weights_face_v3(tmp_weight, mv_src[mf->v1].co, mv_src[mf->v2].co, mv_src[mf->v3].co, NULL, tmp_co);
+ }
+
+ /* get weights from face*/
+ weight = 0;
+ do {
+ v_index = (&mf->v1)[f_index];
+ weight += tmp_weight[f_index] * defvert_find_weight(dv_array_src[v_index], index_src);
+ } while (f_index--);
+
+ /* copy weight that are not NULL including weight value 0. Existing target weights are overwritten prior to this in relevant cases. */
+ if (weight > 0) {
+ dw_dst = defvert_verify_index(*dv_dst, index_dst);
+ vgroup_transfer_weight(&dw_dst->weight, weight, replace_mode);
+ }
+ }
+
+ /* free memory */
+ free_bvhtree_from_mesh(&tree_mesh_faces_src);
+ break;
+
+ case WT_BY_NEAREST_VERTEX_IN_FACE:
+ /* get faces */
+ DM_ensure_tessface(dmesh_src);
+ mface_src = dmesh_src->getTessFaceArray(dmesh_src);
+
+ /* make node tree */
+ bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, FLT_EPSILON, 2, 6);
+
+ /* loop through the vertices */
+ for (i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++) {
+
+ if (*dv_dst == NULL) {
+ continue;
+ }
+
+ /* reset nearest */
+ nearest.dist = FLT_MAX;
+ /* With current binary tree its marginally faster to start searching at the top, as opposed to previous search. */
+ nearest.index = -1;
+
+ /* transform into target space */
+ mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);
+
+ /* node tree accelerated search for closest face */
+ BLI_bvhtree_find_nearest(tree_mesh_faces_src.tree, tmp_co,
+ &nearest, tree_mesh_faces_src.nearest_callback, &tree_mesh_faces_src);
+ index_nearest = nearest.index;
+
+ /* get distances */
+ mf = &mface_src[index_nearest];
+ dist_v1 = len_squared_v3v3(tmp_co, mv_src[mf->v1].co);
+ dist_v2 = len_squared_v3v3(tmp_co, mv_src[mf->v2].co);
+ dist_v3 = len_squared_v3v3(tmp_co, mv_src[mf->v3].co);
+
+ /* get closest vertex */
+ f_index = mf->v4 ? 3 : 2;
+ if (dist_v1 < dist_v2 && dist_v1 < dist_v3) index_nearest_vertex = mf->v1;
+ else if (dist_v2 < dist_v3) index_nearest_vertex = mf->v2;
+ else index_nearest_vertex = mf->v3;
+ if (f_index == 3) {
+ dist_v4 = len_squared_v3v3(tmp_co, mv_src[mf->v4].co);
+ if (dist_v4 < dist_v1 && dist_v4 < dist_v2 && dist_v4 < dist_v3) {
+ index_nearest_vertex = mf->v4;
+ }
+ }
+
+ /* copy weight that are not NULL including weight value 0. Existing target weights are overwritten prior to this in relevant cases. */
+ dw_src = defvert_find_index(dv_array_src[index_nearest_vertex], index_src);
+ if (dw_src && dw_src->weight) {
+ dw_dst = defvert_verify_index(*dv_dst, index_dst);
+ vgroup_transfer_weight(&dw_dst->weight, dw_src->weight, replace_mode);
+ }
+ }
+
+ /* free memory */
+ free_bvhtree_from_mesh(&tree_mesh_faces_src);
+ break;
+
+ default:
+ BLI_assert(0);
+ break;
+ }
+
+ /*free memory*/
+ if (dv_array_src) MEM_freeN(dv_array_src);
+ if (dv_array_dst) MEM_freeN(dv_array_dst);
+ dmesh_src->release(dmesh_src);
+
+ return 1;
+}
+
+/***********************End weight transfer (WT)***********************************/
/* for Mesh in Object mode */
/* allows editmode for Lattice */
@@ -580,7 +909,6 @@ void ED_vgroup_select_by_name(Object *ob, const char *name)
static void vgroup_select_verts(Object *ob, int select)
{
const int def_nr = ob->actdef - 1;
- MDeformVert *dv;
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -596,7 +924,7 @@ static void vgroup_select_verts(Object *ob, int select)
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
+ MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
if (defvert_find_index(dv, def_nr)) {
BM_vert_select_set(em->bm, eve, select);
}
@@ -604,7 +932,7 @@ static void vgroup_select_verts(Object *ob, int select)
}
/* this has to be called, because this function operates on vertices only */
- if (select) EDBM_select_flush(em); // vertices to edges/faces
+ if (select) EDBM_select_flush(em); /* vertices to edges/faces */
else EDBM_deselect_flush(em);
}
else {
@@ -633,6 +961,7 @@ static void vgroup_select_verts(Object *ob, int select)
Lattice *lt = vgroup_edit_lattice(ob);
if (lt->dvert) {
+ MDeformVert *dv;
BPoint *bp;
int a, tot;
@@ -704,7 +1033,7 @@ static void vgroup_normalize(Object *ob)
int i, dvert_tot = 0;
const int def_nr = ob->actdef - 1;
- const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -724,7 +1053,7 @@ static void vgroup_normalize(Object *ob)
dw = defvert_find_index(dv, def_nr);
if (dw) {
- weight_max = MAX2(dw->weight, weight_max);
+ weight_max = max_ff(dw->weight, weight_max);
}
}
@@ -836,23 +1165,24 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f
const float start[3], float distToStart,
float *end, float (*changes)[2], float *dists, int index)
{
- // A=Q-((Q-P).N)N
- // D = (a*x0 + b*y0 +c*z0 +d)
+ /* A = Q - ((Q - P).N)N
+ * D = (a * x0 + b * y0 +c * z0 + d) */
float projA[3], projB[3];
closest_to_plane_v3(projA, coord, norm, start);
closest_to_plane_v3(projB, coord, norm, end);
- // (vertical and horizontal refer to the plane's y and xz respectively)
- // vertical distance
+ /* (vertical and horizontal refer to the plane's y and xz respectively)
+ * vertical distance */
dists[index] = dot_v3v3(norm, end) + d;
- // vertical change
+ /* vertical change */
changes[index][0] = dists[index] - distToStart;
//printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]);
- // horizontal change
+ /* horizontal change */
changes[index][1] = len_v3v3(projA, projB);
}
-// I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc)
+/* I need the derived mesh to be forgotten so the positions are recalculated
+ * with weight changes (see dm_deform_recalc) */
static void dm_deform_clear(DerivedMesh *dm, Object *ob)
{
if (ob->derivedDeform && (ob->derivedDeform) == dm) {
@@ -973,7 +1303,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
}
}
}
- // sort the changes by the vertical change
+ /* sort the changes by the vertical change */
for (k = 0; k < totweight; k++) {
float tf;
int ti;
@@ -985,7 +1315,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
bestIndex = i;
}
}
- // switch with k
+ /* switch with k */
if (bestIndex != k) {
ti = upDown[k];
upDown[k] = upDown[bestIndex];
@@ -1109,7 +1439,7 @@ static void vgroup_levels(Object *ob, float offset, float gain)
int i, dvert_tot = 0;
const int def_nr = ob->actdef - 1;
- const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1143,7 +1473,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
int i, dvert_tot = 0;
const int def_nr = ob->actdef - 1;
- const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
if (lock_active && !BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1221,7 +1551,7 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_
MDeformVert *dv, **dvert_array = NULL;
int i, dvert_tot = 0;
const int def_nr = ob->actdef - 1;
- const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1312,11 +1642,11 @@ static void vgroup_blend(Object *ob, const float fac)
/* i1 is always the selected one */
if (sel1) {
i1 = BM_elem_index_get(eed->v1);
- /* i2= BM_elem_index_get(eed->v2); */ /* UNUSED */
+ /* i2 = BM_elem_index_get(eed->v2); */ /* UNUSED */
eve = eed->v2;
}
else {
- /* i2= BM_elem_index_get(eed->v1); */ /* UNUSED */
+ /* i2 = BM_elem_index_get(eed->v1); */ /* UNUSED */
i1 = BM_elem_index_get(eed->v2);
eve = eed->v1;
}
@@ -1389,13 +1719,119 @@ static void vgroup_blend(Object *ob, const float fac)
}
}
+static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2)
+{
+ /* qsort sorts in ascending order. We want descending order to save a memcopy
+ * so this compare function is inverted from the standard greater than comparison qsort needs.
+ * A normal compare function is called with two pointer arguments and should return an integer less than, equal to,
+ * or greater than zero corresponding to whether its first argument is considered less than, equal to,
+ * or greater than its second argument. This does the opposite. */
+ const struct MDeformWeight *dw1 = a1, *dw2 = a2;
+
+ if (dw1->weight < dw2->weight) return 1;
+ else if (dw1->weight > dw2->weight) return -1;
+ else if (&dw1 < &dw2) return 1; /* compare addresses so we have a stable sort algorithm */
+ else return -1;
+}
+
+/* Used for limiting the number of influencing bones per vertex when exporting
+ * skinned meshes. if all_deform_weights is True, limit all deform modifiers
+ * to max_weights regardless of type, otherwise, only limit the number of influencing bones per vertex*/
+static int vertex_group_limit_total(Object *ob,
+ const int max_weights,
+ const int all_deform_weights)
+{
+ MDeformVert *dv, **dvert_array = NULL;
+ int i, dvert_tot = 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
+ int is_change = FALSE;
+
+ ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
+
+ if (dvert_array) {
+ int defbase_tot = BLI_countlist(&ob->defbase);
+ const char *vgroup_validmap = (all_deform_weights == FALSE) ?
+ BKE_objdef_validmap_get(ob, defbase_tot) :
+ NULL;
+ int num_to_drop = 0;
+
+ /* only the active group */
+ for (i = 0; i < dvert_tot; i++) {
+
+ /* in case its not selected */
+ if (!(dv = dvert_array[i])) {
+ continue;
+ }
+
+ if (all_deform_weights) {
+ /* keep only the largest weights, discarding the rest
+ * qsort will put array in descending order because of invCompare function */
+ num_to_drop = dv->totweight - max_weights;
+ if (num_to_drop > 0) {
+ qsort(dv->dw, dv->totweight, sizeof(MDeformWeight), inv_cmp_mdef_vert_weights);
+ dv->dw = MEM_reallocN(dv->dw, sizeof(MDeformWeight) * max_weights);
+ dv->totweight = max_weights;
+ is_change = TRUE;
+ }
+ }
+ else {
+ MDeformWeight *dw_temp;
+ int bone_count = 0, non_bone_count = 0;
+ int j;
+ /* only consider vgroups with bone modifiers attached (in vgroup_validmap) */
+
+ num_to_drop = dv->totweight - max_weights;
+
+ /* first check if we even need to test further */
+ if (num_to_drop > 0) {
+ /* re-pack dw array so that non-bone weights are first, bone-weighted verts at end
+ * sort the tail, then copy only the truncated array back to dv->dw */
+ dw_temp = MEM_mallocN(sizeof(MDeformWeight) * (dv->totweight), __func__);
+ bone_count = 0; non_bone_count = 0;
+ for (j = 0; j < dv->totweight; j++) {
+ BLI_assert(dv->dw[j].def_nr < defbase_tot);
+ if (!vgroup_validmap[(dv->dw[j]).def_nr]) {
+ dw_temp[non_bone_count] = dv->dw[j];
+ non_bone_count += 1;
+ }
+ else {
+ dw_temp[dv->totweight - 1 - bone_count] = dv->dw[j];
+ bone_count += 1;
+ }
+ }
+ BLI_assert(bone_count + non_bone_count == dv->totweight);
+ num_to_drop = bone_count - max_weights;
+ if (num_to_drop > 0) {
+ qsort(&dw_temp[non_bone_count], bone_count, sizeof(MDeformWeight), inv_cmp_mdef_vert_weights);
+ dv->totweight -= num_to_drop;
+ /* Do we want to clean/normalize here? */
+ MEM_freeN(dv->dw);
+ dv->dw = MEM_reallocN(dw_temp, sizeof(MDeformWeight) * dv->totweight);
+ is_change = TRUE;
+ }
+ else {
+ MEM_freeN(dw_temp);
+ }
+ }
+ }
+ }
+ MEM_freeN(dvert_array);
+
+ if (vgroup_validmap) {
+ MEM_freeN((void *)vgroup_validmap);
+ }
+ }
+
+ return is_change;
+}
+
static void vgroup_clean(Object *ob, const float epsilon, int keep_single)
{
MDeformWeight *dw;
MDeformVert *dv, **dvert_array = NULL;
int i, dvert_tot = 0;
const int def_nr = ob->actdef - 1;
- const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1431,7 +1867,7 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin
{
MDeformVert **dvert_array = NULL;
int i, dvert_tot = 0;
- const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = vertex_group_use_vert_sel(ob);
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
@@ -2007,7 +2443,6 @@ static void vgroup_delete_all(Object *ob)
/* only in editmode */
static void vgroup_assign_verts(Object *ob, const float weight)
{
- MDeformVert *dv;
const int def_nr = ob->actdef - 1;
if (!BLI_findlink(&ob->defbase, def_nr))
@@ -2027,6 +2462,7 @@ static void vgroup_assign_verts(Object *ob, const float weight)
/* Go through the list of editverts and assign them */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ MDeformVert *dv;
MDeformWeight *dw;
dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); /* can be NULL */
dw = defvert_verify_index(dv, def_nr);
@@ -2061,6 +2497,7 @@ static void vgroup_assign_verts(Object *ob, const float weight)
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = vgroup_edit_lattice(ob);
+ MDeformVert *dv;
BPoint *bp;
int a, tot;
@@ -2665,6 +3102,47 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot)
"Keep verts assigned to at least one group when cleaning");
}
+static int vertex_group_limit_total_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = ED_object_context(C);
+
+ const int limit = RNA_int_get(op->ptr, "limit");
+ const int all_deform_weights = RNA_boolean_get(op->ptr, "all_deform_weights");
+
+ if (vertex_group_limit_total(ob, limit, all_deform_weights)) {
+
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_WARNING, "No vertex groups limited");
+
+ /* note, would normally return cancelled, except we want the redo
+ * UI to show up for users to change */
+ return OPERATOR_FINISHED;
+ }
+}
+
+void OBJECT_OT_vertex_group_limit_total(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Limit Number of Weights per Vertex";
+ ot->idname = "OBJECT_OT_vertex_group_limit_total";
+ ot->description = "Limit deform weights associated with a vertex to a specified number by removing lowest weights";
+
+ /* api callbacks */
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_limit_total_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_int(ot->srna, "limit", 4, 1, 32, "Limit", "Maximum number of deform weights", 1, 32);
+ RNA_def_boolean(ot->srna, "all_deform_weights", FALSE, "All Deform Weights", "Cull all deform weights, not just bones");
+}
static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
{
@@ -2762,14 +3240,13 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
if ((change == 0 && fail == 0) || fail) {
BKE_reportf(op->reports, RPT_ERROR,
- "Copy to VGroups to Selected warning done %d, failed %d, object data must have matching indices",
+ "Copy VGroups to Selected warning, %d done, %d failed (object data must have matching indices)",
change, fail);
}
return OPERATOR_FINISHED;
}
-
void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
{
/* identifiers */
@@ -2785,6 +3262,86 @@ void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob_act = CTX_data_active_object(C);
+ bDeformGroup *dg_src;
+ int fail = 0;
+
+ WT_VertexGroupMode vertex_group_mode = RNA_enum_get(op->ptr, "WT_vertex_group_mode");
+ WT_Method method = RNA_enum_get(op->ptr, "WT_method");
+ WT_ReplaceMode replace_mode = RNA_enum_get(op->ptr, "WT_replace_mode");
+
+ /* Macro to loop through selected objects and perform operation depending on function, option and method */
+ CTX_DATA_BEGIN (C, Object *, ob_slc, selected_editable_objects)
+ {
+
+ if (ob_act != ob_slc && ob_slc->defbase.first) {
+ switch (vertex_group_mode) {
+
+ case WT_REPLACE_ACTIVE_VERTEX_GROUP:
+ if (!ed_vgroup_transfer_weight(ob_act, ob_slc,
+ BLI_findlink(&ob_slc->defbase, ob_slc->actdef - 1),
+ scene, method, replace_mode, op))
+ {
+ fail++;
+ }
+ break;
+
+ case WT_REPLACE_ALL_VERTEX_GROUPS:
+ for (dg_src = ob_slc->defbase.first; dg_src; dg_src = dg_src->next) {
+ if (!ed_vgroup_transfer_weight(ob_act, ob_slc,
+ dg_src, scene, method, replace_mode, op))
+ {
+ fail++;
+ }
+ }
+ break;
+
+ default:
+ BLI_assert(0);
+ break;
+ }
+ }
+ }
+
+ /* Event notifiers for correct display of data */
+ DAG_id_tag_update(&ob_slc->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_slc);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob_slc->data);
+
+ CTX_DATA_END;
+
+ if (fail != 0) {
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ return OPERATOR_FINISHED;
+ }
+}
+
+/* transfers weight from active to selected */
+void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Transfer Weights";
+ ot->idname = "OBJECT_OT_vertex_group_transfer_weight";
+ ot->description = "Transfer weight paint to active from selected mesh";
+
+ /* api callbacks */
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_transfer_weight_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "WT_vertex_group_mode", WT_vertex_group_mode_item, 1, "Group", "");
+ ot->prop = RNA_def_enum(ot->srna, "WT_method", WT_method_item, 3, "Method", "");
+ ot->prop = RNA_def_enum(ot->srna, "WT_replace_mode", WT_replace_mode_item, 1, "Replace", "");
+}
+
static EnumPropertyItem vgroup_items[] = {
{0, NULL, 0, NULL, NULL}
};
@@ -2904,7 +3461,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
}
}
else {
- BKE_report(op->reports, RPT_ERROR, "Editmode lattice isn't supported yet");
+ BKE_report(op->reports, RPT_ERROR, "Editmode lattice is not supported yet");
MEM_freeN(sort_map_update);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt
index f5f70b18f48..75c97e76b1d 100644
--- a/source/blender/editors/physics/CMakeLists.txt
+++ b/source/blender/editors/physics/CMakeLists.txt
@@ -20,6 +20,7 @@
set(INC
../include
+ ../../blenfont
../../blenkernel
../../blenlib
../../blenloader
@@ -55,6 +56,10 @@ if(WITH_OPENMP)
add_definitions(-DPARALLEL=1)
endif()
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
add_definitions(-DGLEW_STATIC)
blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/physics/SConscript b/source/blender/editors/physics/SConscript
index 9fe6cff4349..fffe05d6a0d 100644
--- a/source/blender/editors/physics/SConscript
+++ b/source/blender/editors/physics/SConscript
@@ -3,12 +3,12 @@ Import ('env')
sources = env.Glob('*.c')
-incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
+incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../gpu ../../blenloader ../../bmesh'
incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern'
-defs = ''
+defs = []
if env['OURPLATFORM'] == 'linux':
cflags='-pthread'
@@ -17,9 +17,11 @@ if env['OURPLATFORM'] == 'linux':
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']
-
if env['OURPLATFORM'] == 'darwin':
if env['WITH_BF_OPENMP']:
- defs += ' PARALLEL=1'
+ defs.append('PARALLEL=1')
+
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
-env.BlenderLib ( 'bf_editors_physics', sources, Split(incs), Split(defs), libtype=['core'], priority=[45] )
+env.BlenderLib ( 'bf_editors_physics', sources, Split(incs), defs, libtype=['core'], priority=[45] )
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 70fe87e5c01..c51b3ca4c43 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -26,6 +26,8 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "DNA_dynamicpaint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@@ -73,9 +75,9 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
/* set preview for this surface only and set active */
canvas->active_sur = 0;
- for (surface=surface->prev; surface; surface=surface->prev) {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- canvas->active_sur++;
+ for (surface = surface->prev; surface; surface = surface->prev) {
+ surface->flags &= ~MOD_DPAINT_PREVIEW;
+ canvas->active_sur++;
}
return OPERATOR_FINISHED;
@@ -94,26 +96,26 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
DynamicPaintModifierData *pmd = NULL;
- Object *cObject = ED_object_context(C);
+ Object *obj_ctx = ED_object_context(C);
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
- int id=0;
+ int id = 0;
/* Make sure we're dealing with a canvas */
- pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
+ pmd = (DynamicPaintModifierData *)modifiers_findByType(obj_ctx, eModifierType_DynamicPaint);
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
canvas = pmd->canvas;
surface = canvas->surfaces.first;
/* find active surface and remove it */
- for (; surface; surface=surface->next) {
+ for (; surface; surface = surface->next) {
if (id == canvas->active_sur) {
canvas->active_sur -= 1;
dynamicPaint_freeSurface(surface);
@@ -123,8 +125,8 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
}
dynamicPaint_resetPreview(canvas);
- DAG_id_tag_update(&cObject->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, cObject);
+ DAG_id_tag_update(&obj_ctx->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
return OPERATOR_FINISHED;
}
@@ -142,7 +144,7 @@ void DPAINT_OT_surface_slot_remove(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int type_toggle_exec(bContext *C, wmOperator *op)
@@ -151,7 +153,7 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
Object *cObject = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
- int type= RNA_enum_get(op->ptr, "type");
+ int type = RNA_enum_get(op->ptr, "type");
if (!pmd) return OPERATOR_CANCELLED;
@@ -170,7 +172,7 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
/* update dependency */
DAG_id_tag_update(&cObject->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, cObject);
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, cObject);
DAG_scene_sort(CTX_data_main(C), scene);
return OPERATOR_FINISHED;
@@ -190,10 +192,10 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop= RNA_def_enum(ot->srna, "type", prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", "");
+ prop = RNA_def_enum(ot->srna, "type", prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", "");
ot->prop = prop;
}
@@ -203,7 +205,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
DynamicPaintSurface *surface;
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
- int output= RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */
+ int output = RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
surface = get_activeSurface(pmd->canvas);
@@ -258,7 +260,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", "");
@@ -274,13 +276,16 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surface, Object *cObject)
{
DynamicPaintCanvasSettings *canvas = surface->canvas;
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
wmWindow *win = CTX_wm_window(C);
int frame = 1;
int frames;
frames = surface->end_frame - surface->start_frame + 1;
- if (frames <= 0) {BLI_strncpy(canvas->error, "No frames to bake.", sizeof(canvas->error)); return 0;}
+ if (frames <= 0) {
+ BLI_strncpy(canvas->error, N_("No frames to bake"), sizeof(canvas->error));
+ return 0;
+ }
/* Set frame to start point (also inits modifier data) */
frame = surface->start_frame;
@@ -291,7 +296,7 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf
if (!dynamicPaint_createUVSurface(surface)) return 0;
/* Loop through selected frames */
- for (frame=surface->start_frame; frame<=surface->end_frame; frame++) {
+ for (frame = surface->start_frame; frame <= surface->end_frame; frame++) {
float progress = (frame - surface->start_frame) / (float)frames * 100;
surface->current_frame = frame;
@@ -346,7 +351,6 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
Object *ob = ED_object_context(C);
int status = 0;
double timer = PIL_check_seconds_timer();
- char result_str[80];
DynamicPaintSurface *surface;
/*
@@ -354,14 +358,14 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
*/
pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
if (!pmd) {
- BKE_report(op->reports, RPT_ERROR, "Bake Failed: No Dynamic Paint modifier found.");
+ BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found");
return 0;
}
/* Make sure we're dealing with a canvas */
canvas = pmd->canvas;
if (!canvas) {
- BKE_report(op->reports, RPT_ERROR, "Bake Failed: Invalid Canvas.");
+ BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas");
return 0;
}
surface = get_activeSurface(canvas);
@@ -381,23 +385,20 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
/* Bake was successful:
* Report for ended bake and how long it took */
if (status) {
- /* Format time string */
+ /* Format time string */
char time_str[30];
double time = PIL_check_seconds_timer() - timer;
BLI_timestr(time, time_str);
/* Show bake info */
- BLI_snprintf(result_str, sizeof(result_str), "Bake Complete! (%s)", time_str);
- BKE_report(op->reports, RPT_INFO, result_str);
+ BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%s)", time_str);
}
else {
- if (strlen(canvas->error)) { /* If an error occured */
- BLI_snprintf(result_str, sizeof(result_str), "Bake Failed: %s", canvas->error);
- BKE_report(op->reports, RPT_ERROR, result_str);
+ if (strlen(canvas->error)) { /* If an error occurred */
+ BKE_reportf(op->reports, RPT_ERROR, "Bake failed: %s", canvas->error);
}
- else { /* User canceled the bake */
- BLI_strncpy(result_str, "Baking Cancelled!", sizeof(result_str));
- BKE_report(op->reports, RPT_WARNING, result_str);
+ else { /* User canceled the bake */
+ BKE_report(op->reports, RPT_WARNING, "Baking canceled!");
}
}
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index aff66b272fe..dc309ec3c31 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -273,7 +273,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
/* there must be at least one state */
if (!part->boids->states.first) {
state = boid_new_state(part->boids);
- BLI_addtail(&part->boids->states, state);
+ BLI_addtail(&part->boids->states, state);
}
else
state = part->boids->states.first;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index ebcb397b094..82e47312222 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -413,7 +413,7 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2
/* used to calculate here but all callers have the screen_co already, so pass as arg */
#if 0
if (ED_view3d_project_int_global(data->vc.ar, co, screen_co,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS)
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK)
{
return 0;
}
@@ -450,7 +450,7 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float *
int screen_co[2];
/* TODO, should this check V3D_PROJ_TEST_CLIP_BB too? */
- if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK) {
return 0;
}
@@ -475,7 +475,7 @@ static int key_inside_rect(PEData *data, const float co[3])
{
int screen_co[2];
- if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK) {
return 0;
}
@@ -605,7 +605,7 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
ParticleSystemModifierData *psmd = NULL;
ParticleEditSettings *pset= PE_settings(data->scene);
POINT_P; KEY_K;
- float mat[4][4]= MAT4_UNITY, imat[4][4]= MAT4_UNITY;
+ float mat[4][4] = MAT4_UNITY, imat[4][4] = MAT4_UNITY;
if (edit->psys)
psmd= psys_get_modifier(data->ob, edit->psys);
@@ -675,7 +675,7 @@ static void foreach_point(PEData *data, ForPointFunc func)
PTCacheEdit *edit = data->edit;
POINT_P;
- LOOP_POINTS {
+ LOOP_POINTS {
func(data, p);
}
}
@@ -746,15 +746,15 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
psys_mat_hair_to_orco(ob, psmd->dm, psys->part->from, pa, mat);
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- co[0]= -co[0];
+ co[0] = -co[0];
index= BLI_kdtree_find_nearest(tree, co, NULL, &nearest);
/* this needs a custom threshold still, duplicated for editmode mirror */
if (index != -1 && index != p && (nearest.dist <= 0.0002f))
- edit->mirror_cache[p]= index;
+ edit->mirror_cache[p] = index;
else
- edit->mirror_cache[p]= -1;
+ edit->mirror_cache[p] = -1;
}
/* make sure mirrors are in two directions */
@@ -762,7 +762,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
if (edit->mirror_cache[p]) {
index= edit->mirror_cache[p];
if (edit->mirror_cache[index] != p)
- edit->mirror_cache[p]= -1;
+ edit->mirror_cache[p] = -1;
}
}
@@ -831,7 +831,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys
for (k=0; k<pa->totkey; k++, hkey++, mhkey++, key++, mkey++) {
copy_v3_v3(mhkey->co, hkey->co);
mul_m4_v3(mat, mhkey->co);
- mhkey->co[0]= -mhkey->co[0];
+ mhkey->co[0] = -mhkey->co[0];
mul_m4_v3(immat, mhkey->co);
if (key->flag & PEK_TAG)
@@ -988,9 +988,9 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit)
PTCacheEditKey *key;
int j, k;
float tlen;
- float dv0[3]= {0.0f, 0.0f, 0.0f};
- float dv1[3]= {0.0f, 0.0f, 0.0f};
- float dv2[3]= {0.0f, 0.0f, 0.0f};
+ float dv0[3] = {0.0f, 0.0f, 0.0f};
+ float dv1[3] = {0.0f, 0.0f, 0.0f};
+ float dv2[3] = {0.0f, 0.0f, 0.0f};
if (edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0)
return;
@@ -1005,12 +1005,12 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit)
if (pset->flag & PE_LOCK_FIRST) {
key= point->keys + 1;
k= 1;
- dv1[0]= dv1[1]= dv1[2]= 0.0;
+ dv1[0] = dv1[1] = dv1[2] = 0.0;
}
else {
key= point->keys;
k= 0;
- dv0[0]= dv0[1]= dv0[2]= 0.0;
+ dv0[0] = dv0[1] = dv0[2] = 0.0;
}
for (; k<point->totkey; k++, key++) {
@@ -1529,8 +1529,8 @@ static int select_linked_exec(bContext *C, wmOperator *op)
int location[2];
RNA_int_get_array(op->ptr, "location", location);
- mval[0]= location[0];
- mval[1]= location[1];
+ mval[0] = location[0];
+ mval[1] = location[1];
PE_set_view3d_data(C, &data);
data.mval= mval;
@@ -1645,7 +1645,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
POINT_P; KEY_K;
- float co[3], mat[4][4]= MAT4_UNITY;
+ float co[3], mat[4][4] = MAT4_UNITY;
int screen_co[2];
PEData data;
@@ -1667,7 +1667,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short
LOOP_KEYS {
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) &&
+ if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co))
{
@@ -1687,7 +1687,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) &&
+ if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co))
{
@@ -2416,7 +2416,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
if (totremoved == 0)
return OPERATOR_CANCELLED;
- BKE_reportf(op->reports, RPT_INFO, "Remove %d double particles", totremoved);
+ BKE_reportf(op->reports, RPT_INFO, "Removed %d double particles", totremoved);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
@@ -2531,7 +2531,7 @@ static void toggle_particle_cursor(bContext *C, int enable)
enum { DEL_PARTICLE, DEL_KEY };
-static EnumPropertyItem delete_type_items[]= {
+static EnumPropertyItem delete_type_items[] = {
{DEL_PARTICLE, "PARTICLE", 0, "Particle", ""},
{DEL_KEY, "KEY", 0, "Key", ""},
{0, NULL, 0, NULL, NULL}};
@@ -2687,10 +2687,10 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
/* rotate weights according to vertex index rotation */
rotation= mirrorfaces[pa->num*2+1];
- newpa->fuv[0]= pa->fuv[2];
- newpa->fuv[1]= pa->fuv[1];
- newpa->fuv[2]= pa->fuv[0];
- newpa->fuv[3]= pa->fuv[3];
+ newpa->fuv[0] = pa->fuv[2];
+ newpa->fuv[1] = pa->fuv[1];
+ newpa->fuv[2] = pa->fuv[0];
+ newpa->fuv[3] = pa->fuv[3];
while (rotation-- > 0)
if (me->mface[pa->num].v4) {
SHIFT4(float, newpa->fuv[0], newpa->fuv[1], newpa->fuv[2], newpa->fuv[3]);
@@ -2793,7 +2793,7 @@ static void brush_cut(PEData *data, int pa_index)
if (edit->points[pa_index].flag & PEP_HIDE)
return;
- if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS)
+ if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK)
return;
rad2= data->rad * data->rad;
@@ -2818,7 +2818,7 @@ static void brush_cut(PEData *data, int pa_index)
/* calculate path time closest to root that was inside the circle */
for (k=1, key++; k<=keys; k++, key++) {
- if ((ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) ||
+ if ((ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) ||
key_test_depth(data, key->co, screen_co) == 0)
{
x0 = (float)screen_co[0];
@@ -3084,9 +3084,9 @@ static void intersect_dm_quad_weights(const float v1[3], const float v2[3], cons
copy_v3_v3(vert[2], v3);
copy_v3_v3(vert[3], v4);
- co[0]= v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2] + v4[0]*w[3];
- co[1]= v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3];
- co[2]= v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3];
+ co[0] = v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2] + v4[0]*w[3];
+ co[1] = v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3];
+ co[2] = v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3];
interp_weights_poly_v3(w, vert, 4, co);
}
@@ -3194,10 +3194,10 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
if (isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)) {
if (cur_d<*min_d) {
*min_d=cur_d;
- min_w[0]= 1.0f - cur_uv[0] - cur_uv[1];
- min_w[1]= cur_uv[0];
- min_w[2]= cur_uv[1];
- min_w[3]= 0.0f;
+ min_w[0] = 1.0f - cur_uv[0] - cur_uv[1];
+ min_w[1] = cur_uv[0];
+ min_w[2] = cur_uv[1];
+ min_w[3] = 0.0f;
if (mface->v4)
intersect_dm_quad_weights(v1, v2, v3, v4, min_w);
*min_face=i;
@@ -3208,10 +3208,10 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
if (isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)) {
if (cur_d<*min_d) {
*min_d=cur_d;
- min_w[0]= 1.0f - cur_uv[0] - cur_uv[1];
- min_w[1]= 0.0f;
- min_w[2]= cur_uv[0];
- min_w[3]= cur_uv[1];
+ min_w[0] = 1.0f - cur_uv[0] - cur_uv[1];
+ min_w[1] = 0.0f;
+ min_w[2] = cur_uv[0];
+ min_w[3] = cur_uv[1];
intersect_dm_quad_weights(v1, v2, v3, v4, min_w);
*min_face=i;
intersect=1;
@@ -3270,8 +3270,8 @@ static int brush_add(PEData *data, short number)
}
}
- mco[0]= data->mval[0] + dmx;
- mco[1]= data->mval[1] + dmy;
+ mco[0] = data->mval[0] + dmx;
+ mco[1] = data->mval[1] + dmy;
ED_view3d_win_to_segment_clip(data->vc.ar, data->vc.v3d, mco, co1, co2);
mul_m4_v3(imat, co1);
@@ -3364,11 +3364,11 @@ static int brush_add(PEData *data, short number)
maxd= ptn[maxw-1].dist;
for (w=0; w<maxw; w++) {
- weight[w]= (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
+ weight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
totw += weight[w];
}
for (;w<3; w++) {
- weight[w]= 0.0f;
+ weight[w] = 0.0f;
}
for (w=0; w<maxw; w++)
@@ -3502,15 +3502,15 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
flip= RNA_boolean_get(itemptr, "pen_flip");
if (bedit->first) {
- bedit->lastmouse[0]= mouse[0];
- bedit->lastmouse[1]= mouse[1];
+ bedit->lastmouse[0] = mouse[0];
+ bedit->lastmouse[1] = mouse[1];
}
dx= mouse[0] - bedit->lastmouse[0];
dy= mouse[1] - bedit->lastmouse[1];
- mval[0]= mouse[0];
- mval[1]= mouse[1];
+ mval[0] = mouse[0];
+ mval[1] = mouse[1];
/* disable locking temporatily for disconnected hair */
@@ -3525,7 +3525,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
view3d_operator_needs_opengl(C);
selected= (short)count_selected_keys(scene, edit);
- dmax = maxf(fabsf(dx), fabsf(dy));
+ dmax = max_ff(fabsf(dx), fabsf(dy));
tot_steps = dmax/(0.2f * brush->size) + 1;
dx /= (float)tot_steps;
@@ -3635,7 +3635,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.mval= mval;
data.rad= (float)brush->size;
- data.vec[0]= data.vec[1]= data.vec[2]= 0.0f;
+ data.vec[0] = data.vec[1] = data.vec[2] = 0.0f;
data.tot= 0;
data.smoothfac= brush->strength;
@@ -3689,8 +3689,8 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
}
- bedit->lastmouse[0]= mouse[0];
- bedit->lastmouse[1]= mouse[1];
+ bedit->lastmouse[0] = mouse[0];
+ bedit->lastmouse[1] = mouse[1];
bedit->first= 0;
}
@@ -3985,7 +3985,9 @@ void PE_undo_step(Scene *scene, int step)
}
else if (step==1) {
- if (edit->curundo==NULL || edit->curundo->prev==NULL);
+ if (edit->curundo==NULL || edit->curundo->prev==NULL) {
+ /* pass */
+ }
else {
if (G.debug & G_DEBUG) printf("undo %s\n", edit->curundo->name);
edit->curundo= edit->curundo->prev;
@@ -3995,7 +3997,9 @@ void PE_undo_step(Scene *scene, int step)
else {
/* curundo has to remain current situation! */
- if (edit->curundo==NULL || edit->curundo->next==NULL);
+ if (edit->curundo==NULL || edit->curundo->next==NULL) {
+ /* pass */
+ }
else {
get_PTCacheUndo(edit, edit->curundo->next);
edit->curundo= edit->curundo->next;
@@ -4101,7 +4105,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3])
LOOP_SELECTED_KEYS {
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- DO_MINMAX(co, min, max);
+ DO_MINMAX(co, min, max);
ok= 1;
}
}
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index a17d84af128..221aad2161c 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -110,11 +110,14 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
/* possible this isn't the active object
* object_remove_particle_system() clears the mode on the last psys
- * */
- if (mode_orig & OB_MODE_PARTICLE_EDIT)
- if ((ob->mode & OB_MODE_PARTICLE_EDIT)==0)
- if (scene->basact && scene->basact->object==ob)
+ */
+ if (mode_orig & OB_MODE_PARTICLE_EDIT) {
+ if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
+ if (scene->basact && scene->basact->object == ob) {
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
+ }
+ }
+ }
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 315386a947e..7cd153d9564 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -196,10 +196,10 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char
int i, j;
int channelSize = paramsize;
- if (entries==3) {
+ if (entries == 3) {
elbeemSimplifyChannelVec3(channel, &channelSize);
}
- else if (entries==1) {
+ else if (entries == 1) {
elbeemSimplifyChannelFloat(channel, &channelSize);
}
else {
@@ -211,10 +211,10 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char
fprintf(file, " ");
for (j=0;j <= entries;j++) { // also print time value
fprintf(file, " %f ", channel[i*(entries + 1) + j]);
- if (j==entries-1) { fprintf(file, " "); }
- }
+ if (j == entries-1) { fprintf(file, " "); }
+ }
fprintf(file, "\n");
- }
+ }
fprintf(file, " ;\n");
}
@@ -242,7 +242,7 @@ static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *chann
channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1
for (i=2; i <= channels->length; i++) {
- channels->timeAtFrame[i] = channels->timeAtFrame[i-1] + channels->aniFrameTime;
+ channels->timeAtFrame[i] = channels->timeAtFrame[i - 1] + (float)channels->aniFrameTime;
}
}
@@ -402,7 +402,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
}
/* now we loop over the frames and fill the allocated channels with data */
- for (i=0; i<channels->length; i++) {
+ for (i=0; i < channels->length; i++) {
FluidObject *fobj;
float viscosity, gravity[3];
float timeAtFrame, time;
@@ -426,7 +426,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* Domain time */
// TODO: have option for not running sim, time mangling, in which case second case comes in handy
if (channels->DomainTime) {
- time = get_fluid_rate(domainSettings) * channels->aniFrameTime;
+ time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime;
timeAtFrame = channels->timeAtFrame[i] + time;
channels->timeAtFrame[i+1] = timeAtFrame;
@@ -456,11 +456,11 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
if (i) {
copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1));
- mul_v3_fl(old_rot, -M_PI/180.f);
+ mul_v3_fl(old_rot, (float)-M_PI / 180.f);
}
mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat);
- mul_v3_fl(rot_d, -180.f/M_PI);
+ mul_v3_fl(rot_d, -180.0f / (float)M_PI);
set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC);
set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC);
@@ -527,7 +527,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
fsmesh.channelInitialVel = fobj->InitialVelocity;
fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD)?1:0);
- }
+ }
if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
@@ -574,7 +574,8 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
fsmesh.channelScale = NULL;
/* Override user settings, only noslip is supported here! */
- fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
+ if (fsmesh.type != OB_FLUIDSIM_CONTROL)
+ fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
}
elbeemAddMesh(&fsmesh);
@@ -593,7 +594,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom
for (base=scene->base.first; base; base= base->next) {
Object *ob = base->object;
- FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+ FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
/* only find objects with fluid modifiers */
if (!fluidmdtmp || ob->type != OB_MESH) continue;
@@ -627,7 +628,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom
return 0;
}
- if (channelObjCount>=255) {
+ if (channelObjCount >= 255) {
BKE_report(reports, RPT_ERROR, "Cannot bake with more then 256 objects");
return 0;
}
@@ -648,7 +649,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom
static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetFile, char *debugStrBuffer)
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim);
- FluidsimSettings *domainSettings= fluidmd->fss;
+ FluidsimSettings *domainSettings= fluidmd->fss;
FILE *fileCfg;
int dirExist = 0;
char newSurfdataPath[FILE_MAX]; /* modified output settings */
@@ -673,7 +674,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF
// check selected directory
// simply try to open cfg file for writing to test validity of settings
fileCfg = BLI_fopen(targetFile, "w");
- if (fileCfg) {
+ if (fileCfg) {
dirExist = 1; fclose(fileCfg);
// remove cfg dummy from directory test
BLI_delete(targetFile, 0, 0);
@@ -902,7 +903,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
/* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */;
noFrames = scene->r.efra - 0;
if (noFrames<=0) {
- BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings");
+ BKE_report(reports, RPT_ERROR, "No frames to export (check your animation range settings)");
fluidbake_free_data(channels, fobjects, fsset, fb);
return 0;
}
@@ -944,8 +945,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
if (domainSettings->resolutionxyz>128) {
gridlevels = 2;
}
- else
- if (domainSettings->resolutionxyz>64) {
+ else if (domainSettings->resolutionxyz > 64) {
gridlevels = 1;
}
else {
@@ -963,7 +963,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
/* ******** prepare output file paths ******** */
outStringsChanged = fluid_init_filepaths(fsDomain, targetDir, targetFile, debugStrBuffer);
channels->length = scene->r.efra;
- channels->aniFrameTime = (domainSettings->animEnd - domainSettings->animStart)/(double)noFrames;
+ channels->aniFrameTime = (double)(domainSettings->animEnd - domainSettings->animStart) / (double)noFrames;
/* ******** initialize and allocate animation channels ******** */
fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects);
@@ -1050,7 +1050,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
fsset->generateVertexVectors = (domainSettings->domainNovecgen==0);
// init blender domain transform matrix
- { int j;
+ { int j;
for (i=0; i<4; i++) {
for (j=0; j<4; j++) {
fsset->surfaceTrafo[i*4+j] = invDomMat[j][i];
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 89ddfe02208..fb99d296a54 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -61,7 +61,7 @@ static void operatortypes_particle(void)
WM_operatortype_append(PARTICLE_OT_rekey);
WM_operatortype_append(PARTICLE_OT_subdivide);
WM_operatortype_append(PARTICLE_OT_remove_doubles);
- WM_operatortype_append(PARTICLE_OT_weight_set);
+ WM_operatortype_append(PARTICLE_OT_weight_set);
WM_operatortype_append(PARTICLE_OT_delete);
WM_operatortype_append(PARTICLE_OT_mirror);
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 218ae628d3f..bbce94b6215 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -325,9 +325,9 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op))
for (pid=pidlist.first; pid; pid=pid->next) {
if (pid->cache == cache) {
- PointCache *cache = BKE_ptcache_add(pid->ptcaches);
- cache->step = pid->default_step;
- *(pid->cache_ptr) = cache;
+ PointCache *cache_new = BKE_ptcache_add(pid->ptcaches);
+ cache_new->step = pid->default_step;
+ *(pid->cache_ptr) = cache_new;
break;
}
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index c08ea2b6429..4b177629f72 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -80,11 +80,10 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
float *rectf = NULL;
int ymin, ymax, xmin, xmax;
int rymin, rxmin;
- /* unsigned char *rectc; */ /* UNUSED */
/* if renrect argument, we only refresh scanlines */
if (renrect) {
- /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
+ /* if (ymax == recty), rendering of layer is ready, we should not draw, other things happen... */
if (rr->renlay == NULL || renrect->ymax >= rr->recty)
return;
@@ -143,11 +142,10 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
imb_addrectImBuf(ibuf);
rectf += 4 * (rr->rectx * ymin + xmin);
- /* rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin); */ /* UNUSED */
IMB_partial_display_buffer_update(ibuf, rectf, NULL, rr->rectx, rxmin, rymin,
&scene->view_settings, &scene->display_settings,
- rxmin, rymin, rxmin + xmax, rymin + ymax);
+ rxmin, rymin, rxmin + xmax, rymin + ymax, TRUE);
}
/* ****************************** render invoking ***************** */
@@ -204,7 +202,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
screen_render_scene_layer_set(op, mainp, &scene, &srl);
if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
- BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected");
+ BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");
return OPERATOR_CANCELLED;
}
@@ -297,7 +295,11 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
if (rs->tothalo) spos += sprintf(spos, "Ha:%d ", rs->tothalo);
if (rs->totstrand) spos += sprintf(spos, "St:%d ", rs->totstrand);
if (rs->totlamp) spos += sprintf(spos, "La:%d ", rs->totlamp);
- spos += sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
+
+ if (rs->mem_peak == 0.0f)
+ spos += sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
+ else
+ spos += sprintf(spos, "Mem:%.2fM, Peak: %.2fM ", rs->mem_used, rs->mem_peak);
if (rs->curfield)
spos += sprintf(spos, "Field %d ", rs->curfield);
@@ -495,12 +497,12 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
- BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected");
+ BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");
return OPERATOR_CANCELLED;
- }
+ }
- /* stop all running jobs, currently previews frustrate Render */
- WM_jobs_stop_all(CTX_wm_manager(C));
+ /* stop all running jobs, except screen one. currently previews frustrate Render */
+ WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
/* get main */
if (G.debug_value == 101) {
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 5e12d5d0f31..4dc08d2687a 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -170,11 +170,13 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
}
else if (view_context) {
+ ED_view3d_draw_offscreen_init(scene, v3d);
+
GPU_offscreen_bind(oglrender->ofs); /* bind */
/* render 3d view */
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
- /*int is_ortho= scene->r.mode & R_ORTHO;*/
+ /*int is_ortho = scene->r.mode & R_ORTHO;*/
camera = v3d->camera;
RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat);
@@ -188,7 +190,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
- if ((scene->r.mode & R_OSA) == 0) {
+ if ((scene->r.mode & R_OSA) == 0) {
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf);
}
@@ -305,7 +307,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
char err_out[256] = "unknown";
if (G.background) {
- BKE_report(op->reports, RPT_ERROR, "Can't use OpenGL render in background mode (no opengl context)");
+ BKE_report(op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)");
return 0;
}
@@ -326,12 +328,12 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
}
if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
- BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected");
+ BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");
return 0;
}
- /* stop all running jobs, currently previews frustrate Render */
- WM_jobs_stop_all(CTX_wm_manager(C));
+ /* stop all running jobs, except screen one. currently previews frustrate Render */
+ WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
/* create offscreen buffer */
sizex = (scene->r.size * scene->r.xsch) / 100;
@@ -341,7 +343,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
ofs = GPU_offscreen_create(sizex, sizey, err_out);
if (!ofs) {
- BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer, %s", err_out);
+ BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer, %s", err_out);
return 0;
}
@@ -715,7 +717,7 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
}
}
- // no redraw needed, we leave state as we entered it
+ /* no redraw needed, we leave state as we entered it */
// ED_update_for_newframe(C, 1);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, CTX_data_scene(C));
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index f24bc109b5e..2f9b6231858 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -237,6 +237,14 @@ static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
return 0;
}
+static Scene *preview_get_scene(void)
+{
+ if (pr_main == NULL) return NULL;
+
+ return pr_main->scene.first;
+}
+
+
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -244,9 +252,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
Scene *sce;
Base *base;
- if (pr_main == NULL) return NULL;
-
- sce = pr_main->scene.first;
+ sce = preview_get_scene();
if (sce) {
/* this flag tells render to not execute depsgraph or ipos etc */
@@ -266,23 +272,17 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings);
/* prevent overhead for small renders and icons (32) */
- if (id && sp->sizex < 40)
- sce->r.xparts = sce->r.yparts = 1;
- else
- sce->r.xparts = sce->r.yparts = 4;
+ if (id && sp->sizex < 40) {
+ sce->r.tilex = sce->r.tiley = 64;
+ }
+ else {
+ sce->r.tilex = sce->r.xsch / 4;
+ sce->r.tiley = sce->r.ysch / 4;
+ }
/* exception: don't apply render part of display transform for texture previews or icons */
if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE) {
- ColorManagedDisplaySettings *display_settings = &sce->display_settings;
- ColorManagedViewSettings *view_settings = &sce->view_settings;
-
- const char *default_view_name = IMB_colormanagement_view_get_default_name(display_settings->display_device);
-
- view_settings->exposure = 0.0f;
- view_settings->gamma = 1.0f;
- view_settings->flag &= ~COLORMANAGE_VIEW_USE_CURVES;
-
- BLI_strncpy(view_settings->view_transform, default_view_name, sizeof(view_settings->view_transform));
+ BKE_scene_disable_color_management(sce);
}
if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
@@ -350,7 +350,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
if (sp->pr_method == PR_ICON_RENDER) {
if (mat->material_type == MA_TYPE_HALO) {
sce->lay = 1 << MA_FLAT;
- }
+ }
else {
sce->lay = 1 << MA_SPHERE_A;
}
@@ -377,7 +377,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) {
/* don't use assign_material, it changed mat->id.us, which shows in the UI */
Material ***matar = give_matarar(base->object);
- int actcol = MAX2(base->object->actcol - 1, 0);
+ int actcol = max_ii(base->object->actcol - 1, 0);
if (matar && actcol < base->object->totcol)
(*matar)[actcol] = mat;
@@ -395,7 +395,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
tex = localize_texture(origtex);
sp->texcopy = tex;
BLI_addtail(&pr_main->tex, tex);
- }
+ }
sce->lay = 1 << MA_TEXTURE;
for (base = sce->base.first; base; base = base->next) {
@@ -527,8 +527,8 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) {
- newrect->xmax = MAX2(newrect->xmax, rect->xmin + rres.rectx + offx);
- newrect->ymax = MAX2(newrect->ymax, rect->ymin + rres.recty);
+ newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx);
+ newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty);
if (rres.rectx && rres.recty) {
/* temporary conversion to byte for drawing */
@@ -550,7 +550,7 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
* color managed as well?
*/
IMB_buffer_byte_from_float(rect_byte, rres.rectf,
- 4, dither, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, do_predivide,
+ 4, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, do_predivide,
rres.rectx, rres.recty, rres.rectx, rres.rectx);
}
@@ -606,7 +606,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
if (ok == 0) {
ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
}
- }
+ }
}
/* **************************** new shader preview system ****************** */
@@ -658,7 +658,7 @@ static void shader_preview_updatejob(void *spv)
if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree)
ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree);
}
- }
+ }
}
}
@@ -671,8 +671,23 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
char name[32];
int sizex;
+ /* in case of split preview, use border render */
+ if (split) {
+ if (first) sizex = sp->sizex / 2;
+ else sizex = sp->sizex - sp->sizex / 2;
+ }
+ else sizex = sp->sizex;
+
+ /* we have to set preview variables first */
+ sce = preview_get_scene();
+ if (sce) {
+ sce->r.xsch = sizex;
+ sce->r.ysch = sp->sizey;
+ sce->r.size = 100;
+ }
+
/* get the stuff from the builtin preview dbase */
- sce = preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex
+ sce = preview_prepare_scene(sp->scene, id, idtype, sp);
if (sce == NULL) return;
if (!split || first) sprintf(name, "Preview %p", sp->owner);
@@ -700,17 +715,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->r.mode |= R_OSA;
}
- /* in case of split preview, use border render */
- if (split) {
- if (first) sizex = sp->sizex / 2;
- else sizex = sp->sizex - sp->sizex / 2;
- }
- else sizex = sp->sizex;
-
- /* allocates or re-uses render result */
- sce->r.xsch = sizex;
- sce->r.ysch = sp->sizey;
- sce->r.size = 100;
/* callbacs are cleared on GetRender() */
if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) {
@@ -818,7 +822,7 @@ static void shader_preview_free(void *customdata)
/* get rid of copied world */
BLI_remlink(&pr_main->world, sp->worldcopy);
- BKE_world_free_ex(sp->worldcopy, FALSE);
+ BKE_world_free_ex(sp->worldcopy, TRUE); /* [#32865] - we need to unlink the texture copies, unlike for materials */
properties = IDP_GetProperties((ID *)sp->worldcopy, FALSE);
if (properties) {
@@ -870,7 +874,7 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
scaledx = (float)w;
scaledy = ( (float)ima->y / (float)ima->x) * (float)w;
}
- else {
+ else {
scaledx = ( (float)ima->x / (float)ima->y) * (float)h;
scaledy = (float)h;
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 8bdd4e544e8..25a01d38dd5 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -747,7 +747,11 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */
/* properties */
- prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f);
+ prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f,
+ "File layout",
+ "Flat array describing the X,Y position of each cube face in the output image, "
+ "where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] "
+ "(use -1 to skip a face)", 0.0f, 0.0f);
RNA_def_property_flag(prop, PROP_HIDDEN);
WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE,
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 08ccf37265b..5155f1001ab 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -58,6 +58,7 @@
#include "GPU_material.h"
#include "RE_engine.h"
+#include "RE_pipeline.h"
#include "ED_node.h"
#include "ED_render.h"
@@ -74,12 +75,19 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
bScreen *sc;
ScrArea *sa;
ARegion *ar;
+ static int recursive_check = FALSE;
/* don't do this render engine update if we're updating the scene from
* other threads doing e.g. rendering or baking jobs */
if (!BLI_thread_is_main())
return;
+ /* don't call this recursively for frame updates */
+ if (recursive_check)
+ return;
+
+ recursive_check = TRUE;
+
C = CTX_create();
CTX_data_main_set(C, bmain);
CTX_data_scene_set(C, scene);
@@ -114,6 +122,8 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
}
CTX_free(C);
+
+ recursive_check = FALSE;
}
void ED_render_engine_area_exit(ScrArea *sa)
@@ -148,6 +158,8 @@ void ED_render_engine_changed(Main *bmain)
for (sc = bmain->screen.first; sc; sc = sc->id.next)
for (sa = sc->areabase.first; sa; sa = sa->next)
ED_render_engine_area_exit(sa);
+
+ RE_FreePersistentData();
}
/***************************** Updates ***********************************
@@ -224,8 +236,12 @@ static void material_changed(Main *bmain, Material *ma)
/* find node materials using this */
for (parent = bmain->mat.first; parent; parent = parent->id.next) {
- if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) ;
- else continue;
+ if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) {
+ /* pass */
+ }
+ else {
+ continue;
+ }
BKE_icon_changed(BKE_icon_getid(&parent->id));
@@ -247,9 +263,15 @@ static void texture_changed(Main *bmain, Tex *tex)
/* find materials */
for (ma = bmain->mat.first; ma; ma = ma->id.next) {
- if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) ;
- else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) ;
- else continue;
+ if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) {
+ /* pass */
+ }
+ else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) {
+ /* pass */
+ }
+ else {
+ continue;
+ }
BKE_icon_changed(BKE_icon_getid(&ma->id));
@@ -259,18 +281,30 @@ static void texture_changed(Main *bmain, Tex *tex)
/* find lamps */
for (la = bmain->lamp.first; la; la = la->id.next) {
- if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) ;
- else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) ;
- else continue;
+ if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) {
+ /* pass */
+ }
+ else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) {
+ /* pass */
+ }
+ else {
+ continue;
+ }
BKE_icon_changed(BKE_icon_getid(&la->id));
}
/* find worlds */
for (wo = bmain->world.first; wo; wo = wo->id.next) {
- if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) ;
- else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) ;
- else continue;
+ if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) {
+ /* pass */
+ }
+ else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) {
+ /* pass */
+ }
+ else {
+ continue;
+ }
BKE_icon_changed(BKE_icon_getid(&wo->id));
}
@@ -347,6 +381,12 @@ static void scene_changed(Main *bmain, Scene *UNUSED(scene))
void ED_render_id_flush_update(Main *bmain, ID *id)
{
+ /* this can be called from render or baking thread when a python script makes
+ * changes, in that case we don't want to do any editor updates, and making
+ * GPU changes is not possible because OpenGL only works in the main thread */
+ if (!BLI_thread_is_main())
+ return;
+
switch (GS(id->name)) {
case ID_MA:
material_changed(bmain, (Material *)id);
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index 01c0169eb50..5ec7f4d05b6 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -220,7 +220,6 @@ void render_view_open(bContext *C, int mx, int my)
else {
/* Leave it alone so the image editor will just go back from
* full screen to the original tiled setup */
- ;
}
}
}
@@ -282,7 +281,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
if (wincur->screen->temp) {
wm_window_lower(wincur);
}
- else {
+ else {
wmWindow *win, *winshow;
ScrArea *sa = find_area_showing_r_result(C, &winshow);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 7f95e2b732c..ce6033f5f49 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -404,7 +404,7 @@ void ED_area_overdraw(bContext *C)
az->do_draw = FALSE;
}
}
- }
+ }
glDisable(GL_BLEND);
}
@@ -421,8 +421,12 @@ void region_scissor_winrct(ARegion *ar, rcti *winrct)
ar = ar->prev;
if (BLI_rcti_isect(winrct, &ar->winrct, NULL)) {
- if (ar->flag & RGN_FLAG_HIDDEN) ;
- else if (ar->alignment & RGN_SPLIT_PREV) ;
+ if (ar->flag & RGN_FLAG_HIDDEN) {
+ /* pass */
+ }
+ else if (ar->alignment & RGN_SPLIT_PREV) {
+ /* pass */
+ }
else if (ar->alignment == RGN_OVERLAP_LEFT) {
winrct->xmin = ar->winrct.xmax + 1;
}
@@ -475,11 +479,11 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
if (ar->drawrct.xmin == ar->drawrct.xmax)
ar->drawrct = winrct;
else {
- /* extra clip for safety */
- ar->drawrct.xmin = MAX2(winrct.xmin, ar->drawrct.xmin);
- ar->drawrct.ymin = MAX2(winrct.ymin, ar->drawrct.ymin);
- ar->drawrct.xmax = MIN2(winrct.xmax, ar->drawrct.xmax);
- ar->drawrct.ymax = MIN2(winrct.ymax, ar->drawrct.ymax);
+ /* extra clip for safety (intersect the rects, could use API func) */
+ ar->drawrct.xmin = max_ii(winrct.xmin, ar->drawrct.xmin);
+ ar->drawrct.ymin = max_ii(winrct.ymin, ar->drawrct.ymin);
+ ar->drawrct.xmax = min_ii(winrct.xmax, ar->drawrct.xmax);
+ ar->drawrct.ymax = min_ii(winrct.ymax, ar->drawrct.ymax);
}
/* note; this sets state, so we can use wmOrtho and friends */
@@ -543,10 +547,7 @@ void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct)
}
else if (ar->drawrct.xmin != ar->drawrct.xmax) {
/* partial redraw already set, expand region */
- ar->drawrct.xmin = MIN2(ar->drawrct.xmin, rct->xmin);
- ar->drawrct.ymin = MIN2(ar->drawrct.ymin, rct->ymin);
- ar->drawrct.xmax = MAX2(ar->drawrct.xmax, rct->xmax);
- ar->drawrct.ymax = MAX2(ar->drawrct.ymax, rct->ymax);
+ BLI_rcti_union(&ar->drawrct, rct);
}
}
}
@@ -949,20 +950,25 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
/* prefsize, for header we stick to exception */
prefsizex = ar->sizex ? ar->sizex : ar->type->prefsizex;
- if (ar->regiontype == RGN_TYPE_HEADER)
+ if (ar->regiontype == RGN_TYPE_HEADER) {
prefsizey = ar->type->prefsizey;
+ }
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
}
- else
+ else {
prefsizey = ar->sizey ? ar->sizey : ar->type->prefsizey;
-
- /* hidden is user flag */
- if (ar->flag & RGN_FLAG_HIDDEN) ;
- /* XXX floating area region, not handled yet here */
- else if (alignment == RGN_ALIGN_FLOAT) ;
- /* remainder is too small for any usage */
+ }
+
+
+ if (ar->flag & RGN_FLAG_HIDDEN) {
+ /* hidden is user flag */
+ }
+ else if (alignment == RGN_ALIGN_FLOAT) {
+ /* XXX floating area region, not handled yet here */
+ }
else if (rct_fits(remainder, 'v', 1) < 0 || rct_fits(remainder, 'h', 1) < 0) {
+ /* remainder is too small for any usage */
ar->flag |= RGN_FLAG_TOO_SMALL;
}
else if (alignment == RGN_ALIGN_NONE) {
@@ -1265,19 +1271,15 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
}
else {
/* prevent uiblocks to run */
- uiFreeBlocks(NULL, &ar->uiblocks);
+ uiFreeBlocks(NULL, &ar->uiblocks);
}
-
- /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */
- if (ar->regiontype == RGN_TYPE_HEADER)
- ar->v2d.flag &= ~V2D_IS_INITIALISED;
}
}
/* externally called for floating regions like menus */
void ED_region_init(bContext *C, ARegion *ar)
{
-// ARegionType *at= ar->type;
+// ARegionType *at = ar->type;
/* refresh can be called before window opened */
region_subwindow(CTX_wm_window(C), ar);
@@ -1419,7 +1421,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
/* put in front of list */
BLI_remlink(&sa->spacedata, sl);
BLI_addhead(&sa->spacedata, sl);
- }
+ }
else {
/* new space */
if (st) {
@@ -1462,7 +1464,8 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
ED_area_newspace(C, sa, sl->next->spacetype);
}
else {
- ED_area_newspace(C, sa, SPACE_INFO);
+ /* no change */
+ return;
}
ED_area_tag_redraw(sa);
@@ -1531,7 +1534,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
but = uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D,
editortype_pup(), xco, yco, UI_UNIT_X + 10, UI_UNIT_Y,
&(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0,
- TIP_("Display current editor type (click for menu of available types)"));
+ TIP_("Display current editor type (click for a menu of available types)"));
uiButSetFunc(but, spacefunc, NULL, NULL);
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
@@ -1675,11 +1678,9 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE;
- /* don't jump back when panels close or hide */
- if (!newcontext)
- y = MAX2(-y, -v2d->cur.ymin);
- else
- y = -y;
+ /* ensure tot is set correctly, to keep views on bottons, with sliders */
+ y = min_ii(y, v2d->cur.ymin);
+ y = -y;
}
else {
/* for now, allow scrolling in both directions (since layouts are optimized for vertical,
@@ -1693,7 +1694,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
/* don't jump back when panels close or hide */
if (!newcontext)
- x = MAX2(x, v2d->cur.xmax);
+ x = max_ii(x, v2d->cur.xmax);
y = -y;
}
@@ -1746,7 +1747,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
int maxco, xco, yco;
int headery = ED_area_headersize();
- /* clear */
+ /* clear */
UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL);
gpuClear(GL_COLOR_BUFFER_BIT);
@@ -1783,7 +1784,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
}
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_rctf_size_y(&ar->v2d.tot));
+ UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery);
/* restore view matrix? */
UI_view2d_view_restore(C);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index e9de3275a07..3bd4001250d 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -506,8 +506,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
/* The maximum pixel amounts the image can be cropped
* at the lower left without exceeding the origin.
*/
- int off_x = floor(MAX2(ix, 0));
- int off_y = floor(MAX2(iy, 0));
+ int off_x = floor(max_ff(ix, 0.0f));
+ int off_y = floor(max_ff(iy, 0.0f));
/* The zoomed space coordinate of the raster position
* (starting at the lower left most unclipped pixel).
@@ -531,8 +531,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
* covers the entire screen).
*/
gpuGetSizeBox(GL_SCISSOR_BOX, scissor);
- draw_w = mini(img_w - off_x, ceil(((float)scissor[2] - rast_x) / xzoom));
- draw_h = mini(img_h - off_y, ceil(((float)scissor[3] - rast_y) / yzoom));
+ draw_w = min_ii(img_w - off_x, ceil((float)(scissor[2] - rast_x) / xzoom));
+ draw_h = min_ii(img_h - off_y, ceil((float)(scissor[3] - rast_y) / yzoom));
if (draw_w > 0 && draw_h > 0) {
/* Don't use safe RasterPos (slower) if we can avoid it. */
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 352039c5a61..a516603cfd4 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -194,7 +194,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
}
}
- }
+ }
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
}
@@ -236,7 +236,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
}
}
- }
+ }
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
}
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index b1c6dfc2ebf..52d026c2a89 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -36,6 +36,7 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
+#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -273,7 +274,7 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
if (abs(my - se->v1->vec.y) <= 2 && mx >= min && mx <= max)
return se;
- }
+ }
else {
short min, max;
min = MIN2(se->v1->vec.y, se->v2->vec.y);
@@ -633,10 +634,8 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
max[0] = max[1] = 0.0f;
for (sv = sc->vertbase.first; sv; sv = sv->next) {
- min[0] = MIN2(min[0], sv->vec.x);
- min[1] = MIN2(min[1], sv->vec.y);
- max[0] = MAX2(max[0], sv->vec.x);
- max[1] = MAX2(max[1], sv->vec.y);
+ const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y};
+ minmax_v2v2_v2(min, max, fv);
}
/* always make 0.0 left under */
@@ -1084,7 +1083,7 @@ static void screen_refresh_headersizes(void)
for (st = lb->first; st; st = st->next) {
ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
if (art) art->prefsizey = ED_area_headersize();
- }
+ }
}
/* make this screen usable */
@@ -1338,7 +1337,7 @@ int ED_screen_area_active(const bContext *C)
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->swinid == sc->subwinactive)
return 1;
- }
+ }
return 0;
}
@@ -1471,10 +1470,10 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene)
if (scene != sc->scene) {
/* all areas endlocalview */
- // XXX ScrArea *sa= sc->areabase.first;
+ // XXX ScrArea *sa = sc->areabase.first;
// while (sa) {
// endlocalview(sa);
- // sa= sa->next;
+ // sa = sa->next;
// }
sc->scene = scene;
}
@@ -1751,7 +1750,7 @@ void ED_refresh_viewport_fps(bContext *C)
fpsi->redrawtime = fpsi->lredrawtime;
fpsi->lredrawtime = animtimer->ltime;
}
- else {
+ else {
/* playback stopped or shouldn't be running */
if (scene->fps_info)
MEM_freeN(scene->fps_info);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index c64a4a37f3a..6a9c24d2913 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -192,7 +192,7 @@ int ED_operator_region_view3d_active(bContext *C)
return TRUE;
CTX_wm_operator_poll_msg_set(C, "expected a view3d region");
- return FALSE;
+ return FALSE;
}
/* generic for any view2d which uses anim_ops */
@@ -256,7 +256,7 @@ int ED_operator_node_active(bContext *C)
return 0;
}
-// XXX rename
+/* XXX rename */
int ED_operator_graphedit_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_IPO);
@@ -580,7 +580,7 @@ static int actionzone_area_poll(bContext *C)
for (az = sa->actionzones.first; az; az = az->next)
if (BLI_rcti_isect_pt(&az->rect, x, y))
return 1;
- }
+ }
return 0;
}
@@ -628,6 +628,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
event.type = EVT_ACTIONZONE_AREA;
else
event.type = EVT_ACTIONZONE_REGION;
+ event.val = 0;
event.customdata = op->customdata;
event.customdatafree = TRUE;
op->customdata = NULL;
@@ -701,7 +702,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
case ESCKEY:
actionzone_exit(op);
return OPERATOR_CANCELLED;
- case LEFTMOUSE:
+ case LEFTMOUSE:
actionzone_exit(op);
return OPERATOR_CANCELLED;
@@ -969,18 +970,18 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller
/* if top or down edge selected, test height */
if (sa->v1->flag && sa->v4->flag)
- *bigger = MIN2(*bigger, y1);
+ *bigger = min_ii(*bigger, y1);
else if (sa->v2->flag && sa->v3->flag)
- *smaller = MIN2(*smaller, y1);
+ *smaller = min_ii(*smaller, y1);
}
else {
int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX;
/* if left or right edge selected, test width */
if (sa->v1->flag && sa->v2->flag)
- *bigger = MIN2(*bigger, x1);
+ *bigger = min_ii(*bigger, x1);
else if (sa->v3->flag && sa->v4->flag)
- *smaller = MIN2(*smaller, x1);
+ *smaller = min_ii(*smaller, x1);
}
}
}
@@ -1341,7 +1342,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
return 1;
- }
+ }
return 0;
}
@@ -1691,7 +1692,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
AZone *az;
if (event->type != EVT_ACTIONZONE_REGION) {
- BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
+ BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
return OPERATOR_CANCELLED;
}
@@ -1855,7 +1856,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
break;
case ESCKEY:
- ;
+ break;
}
return OPERATOR_RUNNING_MODAL;
@@ -2071,15 +2072,23 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
/* ************** switch screen operator ***************************** */
+static int screen_set_is_ok(bScreen *screen, bScreen *screen_prev)
+{
+ return ((screen->winid == 0) &&
+ (screen->full == 0) &&
+ (screen != screen_prev) &&
+ (screen->id.name[2] != '.' || !(U.uiflag & USER_HIDE_DOT)));
+}
/* function to be called outside UI context, or for redo */
static int screen_set_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
bScreen *screen = CTX_wm_screen(C);
bScreen *screen_prev = screen;
ScrArea *sa = CTX_wm_area(C);
- int tot = BLI_countlist(&CTX_data_main(C)->screen);
+ int tot = BLI_countlist(&bmain->screen);
int delta = RNA_int_get(op->ptr, "delta");
/* temp screens are for userpref or render display */
@@ -2089,17 +2098,19 @@ static int screen_set_exec(bContext *C, wmOperator *op)
if (delta == 1) {
while (tot--) {
screen = screen->id.next;
- if (screen == NULL) screen = CTX_data_main(C)->screen.first;
- if (screen->winid == 0 && screen->full == 0 && screen != screen_prev)
+ if (screen == NULL) screen = bmain->screen.first;
+ if (screen_set_is_ok(screen, screen_prev)) {
break;
+ }
}
}
else if (delta == -1) {
while (tot--) {
screen = screen->id.prev;
- if (screen == NULL) screen = CTX_data_main(C)->screen.last;
- if (screen->winid == 0 && screen->full == 0 && screen != screen_prev)
+ if (screen == NULL) screen = bmain->screen.last;
+ if (screen_set_is_ok(screen, screen_prev)) {
break;
+ }
}
}
else {
@@ -2359,14 +2370,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
ScrArea *sa = screen_areahascursor(sc, event->x, event->y);
int dir;
- if (sa) {
+ if (sa) {
if (jd->sa1 != sa) {
dir = area_getorientation(jd->sa1, sa);
if (dir >= 0) {
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = sa;
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
- }
+ }
else {
/* we are not bordering on the previously selected area
* we check if area has common border with the one marked for removal
@@ -2380,14 +2391,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
jd->sa2 = sa;
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
- }
+ }
else {
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = NULL;
}
}
WM_event_add_notifier(C, NC_WINDOW, NULL);
- }
+ }
else {
/* we are back in the area previously selected for keeping
* we swap the areas if possible to allow user to choose */
@@ -2402,7 +2413,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
if (dir < 0) {
printf("oops, didn't expect that!\n");
}
- }
+ }
else {
dir = area_getorientation(jd->sa1, sa);
if (dir >= 0) {
@@ -2716,6 +2727,8 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* lock views and set them */
if (sa->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = sa->spacedata.first;
+
/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
* otherwise when restoring rv3d->localvd the 'viewquat' won't
* match the 'view', set on entering localview See: [#26315],
@@ -2743,7 +2756,15 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ar = ar->next;
rv3d = ar->regiondata;
- rv3d->view = RV3D_VIEW_CAMERA; rv3d->persp = RV3D_CAMOB;
+
+ /* check if we have a camera */
+ if (v3d->camera) {
+ rv3d->view = RV3D_VIEW_CAMERA; rv3d->persp = RV3D_CAMOB;
+ }
+ else {
+ rv3d->view = RV3D_VIEW_PERSPORTHO; rv3d->persp = RV3D_PERSP;
+ }
+
ED_view3d_lock(rv3d);
view3d_localview_update_rv3d(rv3d);
}
@@ -2827,7 +2848,7 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op))
/* don't do anything if no region */
if (ar == NULL)
return OPERATOR_CANCELLED;
- }
+ }
/* copied from SCREEN_OT_region_flip */
if (ar->alignment == RGN_ALIGN_TOP)
@@ -2861,6 +2882,38 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot)
ot->flag = 0;
}
+
+
+/* ************** show menus operator ***************************** */
+
+/* show/hide header text menus */
+static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ ScrArea *sa = CTX_wm_area(C);
+
+ sa->flag = sa->flag ^ HEADER_NO_PULLDOWN;
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+
+static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Show/Hide Header Menus";
+ ot->idname = "SCREEN_OT_header_toggle_menus";
+ ot->description = "Show or hide the header pulldown menus";
+
+ /* api callbacks */
+ ot->exec = header_toggle_menus_exec;
+ ot->poll = ED_operator_areaactive;
+ ot->flag = 0;
+}
+
+
/* ************** header tools operator ***************************** */
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
@@ -2873,6 +2926,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
else
uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip");
+ if (sa->flag & HEADER_NO_PULLDOWN)
+ uiItemO(layout, IFACE_("Show Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus");
+ else
+ uiItemO(layout, IFACE_("Hide Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus");
+
uiItemS(layout);
/* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
@@ -3025,7 +3083,11 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
}
else {
if (sync) {
- int step = floor((wt->duration - sad->last_duration) * FPS);
+ /* note: this is very simplistic,
+ * its has problem that it may skip too many frames.
+ * however at least this gives a less jittery playback */
+ const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
+
/* skip frames */
if (sad->flag & ANIMPLAY_FLAG_REVERSE)
scene->r.cfra -= step;
@@ -3094,11 +3156,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
for (sa = window->screen->areabase.first; sa; sa = sa->next) {
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar == sad->ar)
+ if (ar == sad->ar) {
ED_region_tag_redraw(ar);
- else
- if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws))
+ }
+ else if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) {
ED_region_tag_redraw(ar);
+ }
}
if (match_area_with_refresh(sa->spacetype, sad->refresh))
@@ -3115,7 +3178,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
/* recalculate the timestep for the timer now that we've finished calculating this,
* since the frames-per-second value may have been changed
*/
- // TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this?
+ /* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */
wt->timestep = (1.0 / FPS);
return OPERATOR_FINISHED;
@@ -3165,7 +3228,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
else {
int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */
- if (mode == 1) // XXX only play audio forwards!?
+ if (mode == 1) /* XXX only play audio forwards!? */
sound_play_scene(scene);
ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
@@ -3417,7 +3480,7 @@ static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op))
static void SCREEN_OT_delete(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Delete Screen"; //was scene
+ ot->name = "Delete Screen"; /* was scene */
ot->description = "Delete active screen";
ot->idname = "SCREEN_OT_delete";
@@ -3537,6 +3600,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_region_scale);
WM_operatortype_append(SCREEN_OT_region_flip);
WM_operatortype_append(SCREEN_OT_header_flip);
+ WM_operatortype_append(SCREEN_OT_header_toggle_menus);
WM_operatortype_append(SCREEN_OT_header_toolbox);
WM_operatortype_append(SCREEN_OT_screen_set);
WM_operatortype_append(SCREEN_OT_screen_full_area);
@@ -3564,7 +3628,7 @@ void ED_operatortypes_screen(void)
/* tools shared by more space types */
WM_operatortype_append(ED_OT_undo);
WM_operatortype_append(ED_OT_undo_push);
- WM_operatortype_append(ED_OT_redo);
+ WM_operatortype_append(ED_OT_redo);
WM_operatortype_append(ED_OT_undo_history);
}
@@ -3734,7 +3798,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", MEDIASTOP, KM_PRESS, 0, 0);
/* Alternative keys for animation and sequencer playing */
-#if 0 // XXX: disabled for restoring later... bad implementation
+#if 0 /* XXX: disabled for restoring later... bad implementation */
keymap = WM_keymap_find(keyconf, "Frames", 0, 0);
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE);
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 13146d9000f..d980703dce5 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -214,7 +214,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
- }
+ }
return OPERATOR_CANCELLED;
}
@@ -365,7 +365,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
if (ok == 0) {
printf("Write error: cannot save %s\n", name);
- BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name);
+ BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s", name);
break;
}
else {
@@ -374,7 +374,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
}
/* imbuf knows which rects are not part of ibuf */
- IMB_freeImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
}
MEM_freeN(sj->dumprect);
@@ -408,7 +408,7 @@ static int screencast_exec(bContext *C, wmOperator *op)
sj->y = 0;
sj->dumpsx = win->sizex;
sj->dumpsy = win->sizey;
- }
+ }
else {
ScrArea *curarea = CTX_wm_area(C);
sj->x = curarea->totrct.xmin;
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 2d139782ca2..b386d5ff628 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -323,8 +323,8 @@ static int project_brush_radius(ViewContext *vc,
add_v3_v3v3(offset, location, ortho);
/* project the center of the brush, and the tangent point to the view onto the screen */
- if ((ED_view3d_project_float_global(vc->ar, location, p1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
- (ED_view3d_project_float_global(vc->ar, offset, p2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ if ((ED_view3d_project_float_global(vc->ar, location, p1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_global(vc->ar, offset, p2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
{
/* the distance between these points is the size of the projected brush in pixels */
return len_v2v2(p1, p2);
@@ -341,7 +341,6 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
{
Scene *scene = CTX_data_scene(C);
Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
float window[2];
int hit;
@@ -351,6 +350,7 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
if (vc->obact->sculpt && vc->obact->sculpt->pbvh &&
sculpt_stroke_get_location(C, location, window))
{
+ Brush *brush = paint_brush(paint);
*pixel_radius =
project_brush_radius(vc,
BKE_brush_unprojected_radius_get(scene, brush),
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 945e6c6c893..3cf4c947c26 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -110,30 +110,36 @@
#include "paint_intern.h"
/* Defines and Structs */
+/* FTOCHAR as inline function */
+BLI_INLINE unsigned char f_to_char(const float val)
+{
+ return FTOCHAR(val);
+}
+
#define IMAPAINT_CHAR_TO_FLOAT(c) ((c) / 255.0f)
#define IMAPAINT_FLOAT_RGB_TO_CHAR(c, f) { \
- (c)[0]= FTOCHAR((f)[0]); \
- (c)[1]= FTOCHAR((f)[1]); \
- (c)[2]= FTOCHAR((f)[2]); \
+ (c)[0] = f_to_char((f)[0]); \
+ (c)[1] = f_to_char((f)[1]); \
+ (c)[2] = f_to_char((f)[2]); \
} (void)0
#define IMAPAINT_FLOAT_RGBA_TO_CHAR(c, f) { \
- (c)[0]= FTOCHAR((f)[0]); \
- (c)[1]= FTOCHAR((f)[1]); \
- (c)[2]= FTOCHAR((f)[2]); \
- (c)[3]= FTOCHAR((f)[3]); \
+ (c)[0] = f_to_char((f)[0]); \
+ (c)[1] = f_to_char((f)[1]); \
+ (c)[2] = f_to_char((f)[2]); \
+ (c)[3] = f_to_char((f)[3]); \
} (void)0
#define IMAPAINT_CHAR_RGB_TO_FLOAT(f, c) { \
- (f)[0]= IMAPAINT_CHAR_TO_FLOAT((c)[0]); \
- (f)[1]= IMAPAINT_CHAR_TO_FLOAT((c)[1]); \
- (f)[2]= IMAPAINT_CHAR_TO_FLOAT((c)[2]); \
+ (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \
+ (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \
+ (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \
} (void)0
#define IMAPAINT_CHAR_RGBA_TO_FLOAT(f, c) { \
- (f)[0]= IMAPAINT_CHAR_TO_FLOAT((c)[0]); \
- (f)[1]= IMAPAINT_CHAR_TO_FLOAT((c)[1]); \
- (f)[2]= IMAPAINT_CHAR_TO_FLOAT((c)[2]); \
- (f)[3]= IMAPAINT_CHAR_TO_FLOAT((c)[3]); \
+ (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \
+ (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \
+ (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \
+ (f)[3] = IMAPAINT_CHAR_TO_FLOAT((c)[3]); \
} (void)0
#define IMAPAINT_FLOAT_RGB_COPY(a, b) copy_v3_v3(a, b)
@@ -174,7 +180,7 @@ typedef struct ImagePaintState {
} ImagePaintState;
typedef struct ImagePaintPartialRedraw {
- int x1, y1, x2, y2;
+ int x1, y1, x2, y2; /* XXX, could use 'rcti' */
int enabled;
} ImagePaintPartialRedraw;
@@ -289,9 +295,11 @@ typedef struct ProjPaintState {
char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */
int buckets_x; /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */
int buckets_y;
-
+
ProjPaintImage *projImages;
+ int pixel_sizeof; /* result of project_paint_pixel_sizeof(), constant per stroke */
+
int image_tot; /* size of projectImages array */
float (*screenCoords)[4]; /* verts projected into floating point screen space */
@@ -380,6 +388,18 @@ typedef struct ProjPixelClone {
PixelStore clonepx;
} ProjPixelClone;
+/* blur, store surrounding colors */
+#define PROJ_PIXEL_SOFTEN_TOT 4
+/* blur picking offset (in screenspace) */
+#define PROJ_PIXEL_SOFTEN_OFS_PX 1.0f
+
+static const float proj_pixel_soften_v2[PROJ_PIXEL_SOFTEN_TOT][2] = {
+ {-PROJ_PIXEL_SOFTEN_OFS_PX, 0.0f},
+ { 0.0f, -PROJ_PIXEL_SOFTEN_OFS_PX},
+ { 0.0f, PROJ_PIXEL_SOFTEN_OFS_PX},
+ { PROJ_PIXEL_SOFTEN_OFS_PX, 0.0f},
+};
+
/* Finish projection painting structs */
typedef struct UndoImageTile {
@@ -784,7 +804,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
else {
//xi = (int)((uv[0]*ibuf->x) + 0.5f);
//yi = (int)((uv[1]*ibuf->y) + 0.5f);
- //if (xi<0 || xi>=ibuf->x || yi<0 || yi>=ibuf->y) return 0;
+ //if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0;
/* wrap */
xi = ((int)(uv[0] * ibuf->x)) % ibuf->x;
@@ -904,7 +924,7 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc
else
isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], w, ps->is_ortho);
- /* Note, if isect_ret==-1 then we don't want to test the other side of the quad */
+ /* Note, if (isect_ret == -1) then we don't want to test the other side of the quad */
if (isect_ret == 0 && mf->v4) {
if (do_clip)
isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], 1);
@@ -943,7 +963,7 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve
if (y_diff < 0.000001f) {
*x_isect = (p1[0] + p2[0]) * 0.5f;
- return ISECT_TRUE;
+ return ISECT_TRUE;
}
if (p1[1] > y_level && p2[1] < y_level) {
@@ -976,7 +996,7 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve
if (x_diff < 0.000001f) { /* yuck, vertical line, we cant do much here */
*y_isect = (p1[0] + p2[0]) * 0.5f;
- return ISECT_TRUE;
+ return ISECT_TRUE;
}
if (p1[0] > x_level && p2[0] < x_level) {
@@ -1004,7 +1024,7 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2])
float ya = (float)fmodf(vec2a[1], 1.0f);
float xb = (float)fmodf(vec2b[0], 1.0f);
- float yb = (float)fmodf(vec2b[1], 1.0f);
+ float yb = (float)fmodf(vec2b[1], 1.0f);
if (xa < 0.0f) xa += 1.0f;
if (ya < 0.0f) ya += 1.0f;
@@ -1492,6 +1512,16 @@ static float project_paint_uvpixel_mask(
return mask;
}
+static int project_paint_pixel_sizeof(const short tool)
+{
+ if ((tool == PAINT_TOOL_CLONE) || (tool == PAINT_TOOL_SMEAR)) {
+ return sizeof(ProjPixelClone);
+ }
+ else {
+ return sizeof(ProjPixel);
+ }
+}
+
/* run this function when we know a bucket's, face's pixel can be initialized,
* return the ProjPixel which is added to 'ps->bucketRect[bucket_index]' */
static ProjPixel *project_paint_uvpixel_init(
@@ -1507,33 +1537,23 @@ static ProjPixel *project_paint_uvpixel_init(
const float w[3])
{
ProjPixel *projPixel;
- short size;
-
+
/* wrap pixel location */
x_px = x_px % ibuf->x;
if (x_px < 0) x_px += ibuf->x;
y_px = y_px % ibuf->y;
if (y_px < 0) y_px += ibuf->y;
-
- if (ps->tool == PAINT_TOOL_CLONE) {
- size = sizeof(ProjPixelClone);
- }
- else if (ps->tool == PAINT_TOOL_SMEAR) {
- size = sizeof(ProjPixelClone);
- }
- else {
- size = sizeof(ProjPixel);
- }
-
- projPixel = (ProjPixel *)BLI_memarena_alloc(arena, size);
+
+ BLI_assert(ps->pixel_sizeof == project_paint_pixel_sizeof(ps->tool));
+ projPixel = (ProjPixel *)BLI_memarena_alloc(arena, ps->pixel_sizeof);
//memset(projPixel, 0, size);
if (ibuf->rect_float) {
projPixel->pixel.f_pt = ibuf->rect_float + ((x_px + y_px * ibuf->x) * 4);
- projPixel->origColor.f[0] = projPixel->newColor.f[0] = projPixel->pixel.f_pt[0];
- projPixel->origColor.f[1] = projPixel->newColor.f[1] = projPixel->pixel.f_pt[1];
- projPixel->origColor.f[2] = projPixel->newColor.f[2] = projPixel->pixel.f_pt[2];
- projPixel->origColor.f[3] = projPixel->newColor.f[3] = projPixel->pixel.f_pt[3];
+ projPixel->origColor.f[0] = projPixel->newColor.f[0] = projPixel->pixel.f_pt[0];
+ projPixel->origColor.f[1] = projPixel->newColor.f[1] = projPixel->pixel.f_pt[1];
+ projPixel->origColor.f[2] = projPixel->newColor.f[2] = projPixel->pixel.f_pt[2];
+ projPixel->origColor.f[3] = projPixel->newColor.f[3] = projPixel->pixel.f_pt[3];
}
else {
projPixel->pixel.ch_pt = ((unsigned char *)ibuf->rect + ((x_px + y_px * ibuf->x) * 4));
@@ -1861,7 +1881,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s
/* lower left out of radius test */
if (cent[1] < bucket_bounds->ymin) {
return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymin) < radius_squared) ? 1 : 0;
- }
+ }
/* top left test */
else if (cent[1] > bucket_bounds->ymax) {
return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymax) < radius_squared) ? 1 : 0;
@@ -1871,7 +1891,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s
/* lower right out of radius test */
if (cent[1] < bucket_bounds->ymin) {
return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymin) < radius_squared) ? 1 : 0;
- }
+ }
/* top right test */
else if (cent[1] > bucket_bounds->ymax) {
return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymax) < radius_squared) ? 1 : 0;
@@ -2112,7 +2132,7 @@ static void project_bucket_clip_face(
if ((inside_bucket_flag & ISECT_2) == 0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
if ((inside_bucket_flag & ISECT_3) == 0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
}
- }
+ }
if ((inside_bucket_flag & (ISECT_3 | ISECT_1)) != (ISECT_3 | ISECT_1)) {
if (line_clip_rect2f(bucket_bounds, v3coSS, v1coSS, v1_clipSS, v2_clipSS)) {
@@ -2395,7 +2415,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
tf_uv_pxoffset[1][1] = tf->uv[1][1] - yhalfpx;
tf_uv_pxoffset[2][0] = tf->uv[2][0] - xhalfpx;
- tf_uv_pxoffset[2][1] = tf->uv[2][1] - yhalfpx;
+ tf_uv_pxoffset[2][1] = tf->uv[2][1] - yhalfpx;
if (mf->v4) {
vCo[3] = ps->dm_mvert[mf->v4].co;
@@ -2555,7 +2575,6 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
float (*outset_uv)[2] = ps->faceSeamUVs[face_index];
float insetCos[4][3]; /* inset face coords. NOTE!!! ScreenSace for ortho, Worldspace in prespective view */
- float fac;
float *vCoSS[4]; /* vertex screenspace coords */
float bucket_clip_edges[2][2]; /* store the screenspace coords of the face, clipped by the bucket's screen aligned rectangle */
@@ -2637,6 +2656,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* test we're inside uvspace bucket and triangle bounds */
if (isect_point_quad_v2(uv, seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3])) {
+ float fac;
/* We need to find the closest point along the face edge,
* getting the screen_px_from_*** wont work because our actual location
@@ -2671,9 +2691,9 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
#if 1
/* get the UV on the line since we want to copy the pixels from there for bleeding */
float uv_close[2];
- float fac = closest_to_line_v2(uv_close, uv, tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2]);
- if (fac < 0.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx1]);
- else if (fac > 1.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx2]);
+ float uv_fac = closest_to_line_v2(uv_close, uv, tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2]);
+ if (uv_fac < 0.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx1]);
+ else if (uv_fac > 1.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx2]);
if (side) {
barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], uv_close, w);
@@ -2684,16 +2704,16 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
#else /* this is buggy with quads, don't use for now */
/* Cheat, we know where we are along the edge so work out the weights from that */
- fac = fac1 + (fac * (fac2 - fac1));
+ uv_fac = fac1 + (uv_fac * (fac2 - fac1));
w[0] = w[1] = w[2] = 0.0;
if (side) {
- w[fidx1 ? fidx1 - 1 : 0] = 1.0f - fac;
- w[fidx2 ? fidx2 - 1 : 0] = fac;
+ w[fidx1 ? fidx1 - 1 : 0] = 1.0f - uv_fac;
+ w[fidx2 ? fidx2 - 1 : 0] = uv_fac;
}
else {
- w[fidx1] = 1.0f - fac;
- w[fidx2] = fac;
+ w[fidx1] = 1.0f - uv_fac;
+ w[fidx2] = uv_fac;
}
#endif
}
@@ -3433,7 +3453,7 @@ static void project_paint_begin_clone(ProjPaintState *ps, int mouse[2])
mul_m4_v4(ps->projectMat, projCo);
ps->cloneOffset[0] = mouse[0] - ((float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projCo[0] / projCo[3]);
ps->cloneOffset[1] = mouse[1] - ((float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projCo[1] / projCo[3]);
- }
+ }
}
static void project_paint_end(ProjPaintState *ps)
@@ -3562,7 +3582,7 @@ static void project_paint_end(ProjPaintState *ps)
ps->dm->release(ps->dm);
}
-/* 1= an undo, -1 is a redo. */
+/* 1 = an undo, -1 is a redo. */
static void partial_redraw_array_init(ImagePaintPartialRedraw *pr)
{
int tot = PROJ_BOUNDBOX_SQUARED;
@@ -3584,11 +3604,11 @@ static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPar
{
int touch = 0;
while (tot--) {
- pr->x1 = MIN2(pr->x1, pr_other->x1);
- pr->y1 = MIN2(pr->y1, pr_other->y1);
+ pr->x1 = min_ii(pr->x1, pr_other->x1);
+ pr->y1 = min_ii(pr->y1, pr_other->y1);
- pr->x2 = MAX2(pr->x2, pr_other->x2);
- pr->y2 = MAX2(pr->y2, pr_other->y2);
+ pr->x2 = max_ii(pr->x2, pr_other->x2);
+ pr->y2 = max_ii(pr->y2, pr_other->y2);
if (pr->x2 != -1)
touch = 1;
@@ -3815,15 +3835,97 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
}
+/* do_projectpaint_soften for float & byte
+ */
+static float inv_pow2(float f)
+{
+ f = 1.0f - f;
+ f = f * f;
+ return 1.0f - f;
+}
+
+static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *softenArena, LinkNode **softenPixels)
+{
+ unsigned int accum_tot = 0;
+ unsigned int i;
+
+ float *rgba = projPixel->newColor.f;
+
+ /* sigh, alpha values tend to need to be a _lot_ stronger with blur */
+ mask = inv_pow2(mask);
+ alpha = inv_pow2(alpha);
+
+ /* rather then painting, accumulate surrounding colors */
+ zero_v4(rgba);
+
+ for (i = 0; i < PROJ_PIXEL_SOFTEN_TOT; i++) {
+ float co_ofs[2];
+ float rgba_tmp[4];
+ sub_v2_v2v2(co_ofs, projPixel->projCoSS, proj_pixel_soften_v2[i]);
+ if (project_paint_PickColor(ps, co_ofs, rgba_tmp, NULL, TRUE)) {
+ add_v4_v4(rgba, rgba_tmp);
+ accum_tot++;
+ }
+ }
+
+ if (LIKELY(accum_tot != 0)) {
+ mul_v4_fl(rgba, 1.0f / (float)accum_tot);
+ blend_color_mix_float(rgba, projPixel->pixel.f_pt, rgba, alpha);
+ if (mask < 1.0f) blend_color_mix_float(rgba, projPixel->origColor.f, rgba, mask);
+ BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
+ }
+}
+
+static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *softenArena, LinkNode **softenPixels)
+{
+ unsigned int accum_tot = 0;
+ unsigned int i;
+
+ float rgba[4]; /* convert to byte after */
+
+ /* sigh, alpha values tend to need to be a _lot_ stronger with blur */
+ mask = inv_pow2(mask);
+ alpha = inv_pow2(alpha);
+
+ /* rather then painting, accumulate surrounding colors */
+ zero_v4(rgba);
+
+ for (i = 0; i < PROJ_PIXEL_SOFTEN_TOT; i++) {
+ float co_ofs[2];
+ float rgba_tmp[4];
+ sub_v2_v2v2(co_ofs, projPixel->projCoSS, proj_pixel_soften_v2[i]);
+ if (project_paint_PickColor(ps, co_ofs, rgba_tmp, NULL, TRUE)) {
+ add_v4_v4(rgba, rgba_tmp);
+ accum_tot++;
+ }
+ }
+
+ if (LIKELY(accum_tot != 0)) {
+ unsigned char *rgba_ub = projPixel->newColor.ch;
+
+ mul_v4_fl(rgba, 1.0f / (float)accum_tot);
+ IMAPAINT_FLOAT_RGBA_TO_CHAR(rgba_ub, rgba);
+
+ blend_color_mix(rgba_ub, projPixel->pixel.ch_pt, rgba_ub, (int)(alpha * 255));
+ if (mask != 1.0f) blend_color_mix(rgba_ub, projPixel->origColor.ch, rgba_ub, (int)(mask * 255));
+ BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
+ }
+}
+
+BLI_INLINE void rgba_float_to_uchar__mul_v3(unsigned char rgba_ub[4], const float rgba[4], const float rgb[3])
+{
+ rgba_ub[0] = f_to_char(rgba[0] * rgb[0]);
+ rgba_ub[1] = f_to_char(rgba[1] * rgb[1]);
+ rgba_ub[2] = f_to_char(rgba[2] * rgb[3]);
+ rgba_ub[3] = f_to_char(rgba[3]);
+}
+
static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, const float rgba[4], float alpha, float mask)
{
unsigned char rgba_ub[4];
if (ps->is_texbrush) {
- rgba_ub[0] = FTOCHAR(rgba[0] * ps->brush->rgb[0]);
- rgba_ub[1] = FTOCHAR(rgba[1] * ps->brush->rgb[1]);
- rgba_ub[2] = FTOCHAR(rgba[2] * ps->brush->rgb[2]);
- rgba_ub[3] = FTOCHAR(rgba[3]);
+ rgba_float_to_uchar__mul_v3(rgba_ub, rgba, ps->brush->rgb);
}
else {
IMAPAINT_FLOAT_RGB_TO_CHAR(rgba_ub, ps->brush->rgb);
@@ -3913,6 +4015,10 @@ static void *do_projectpaint_thread(void *ph_v)
LinkNode *smearPixels = NULL;
LinkNode *smearPixels_f = NULL;
MemArena *smearArena = NULL; /* mem arena for this brush projection only */
+
+ LinkNode *softenPixels = NULL;
+ LinkNode *softenPixels_f = NULL;
+ MemArena *softenArena = NULL; /* mem arena for this brush projection only */
if (tool == PAINT_TOOL_SMEAR) {
pos_ofs[0] = pos[0] - lastpos[0];
@@ -3920,6 +4026,9 @@ static void *do_projectpaint_thread(void *ph_v)
smearArena = BLI_memarena_new(1 << 16, "paint smear arena");
}
+ else if (tool == PAINT_TOOL_SOFTEN) {
+ softenArena = BLI_memarena_new(1 << 16, "paint soften arena");
+ }
/* printf("brush bounds %d %d %d %d\n", bucketMin[0], bucketMin[1], bucketMax[0], bucketMax[1]); */
@@ -4033,11 +4142,11 @@ static void *do_projectpaint_thread(void *ph_v)
/* end copy */
last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index;
- last_partial_redraw_cell->x1 = MIN2(last_partial_redraw_cell->x1, projPixel->x_px);
- last_partial_redraw_cell->y1 = MIN2(last_partial_redraw_cell->y1, projPixel->y_px);
+ last_partial_redraw_cell->x1 = min_ii(last_partial_redraw_cell->x1, (int)projPixel->x_px);
+ last_partial_redraw_cell->y1 = min_ii(last_partial_redraw_cell->y1, (int)projPixel->y_px);
- last_partial_redraw_cell->x2 = MAX2(last_partial_redraw_cell->x2, projPixel->x_px + 1);
- last_partial_redraw_cell->y2 = MAX2(last_partial_redraw_cell->y2, projPixel->y_px + 1);
+ last_partial_redraw_cell->x2 = max_ii(last_partial_redraw_cell->x2, (int)projPixel->x_px + 1);
+ last_partial_redraw_cell->y2 = max_ii(last_partial_redraw_cell->y2, (int)projPixel->y_px + 1);
switch (tool) {
@@ -4059,6 +4168,10 @@ static void *do_projectpaint_thread(void *ph_v)
if (is_floatbuf) do_projectpaint_smear_f(ps, projPixel, alpha, mask, smearArena, &smearPixels_f, co);
else do_projectpaint_smear(ps, projPixel, alpha, mask, smearArena, &smearPixels, co);
break;
+ case PAINT_TOOL_SOFTEN:
+ if (is_floatbuf) do_projectpaint_soften_f(ps, projPixel, alpha, mask, softenArena, &softenPixels_f);
+ else do_projectpaint_soften(ps, projPixel, alpha, mask, softenArena, &softenPixels);
+ break;
default:
if (is_floatbuf) do_projectpaint_draw_f(ps, projPixel, rgba, alpha, mask, use_color_correction);
else do_projectpaint_draw(ps, projPixel, rgba, alpha, mask);
@@ -4093,7 +4206,21 @@ static void *do_projectpaint_thread(void *ph_v)
BLI_memarena_free(smearArena);
}
-
+ else if (tool == PAINT_TOOL_SOFTEN) {
+
+ for (node = softenPixels; node; node = node->next) { /* this wont run for a float image */
+ projPixel = node->link;
+ *projPixel->pixel.uint_pt = projPixel->newColor.uint;
+ }
+
+ for (node = softenPixels_f; node; node = node->next) {
+ projPixel = node->link;
+ copy_v4_v4(projPixel->pixel.f_pt, projPixel->newColor.f);
+ }
+
+ BLI_memarena_free(softenArena);
+ }
+
return NULL;
}
@@ -4101,7 +4228,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp
{
/* First unpack args from the struct */
ProjPaintState *ps = (ProjPaintState *)state;
- int touch_any = 0;
+ int touch_any = 0;
ProjectHandle handles[BLENDER_MAX_THREADS];
ListBase threads;
@@ -4134,7 +4261,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp
/* image bounds */
for (i = 0; i < ps->image_tot; i++) {
handles[a].projImages[i].partRedrawRect = (ImagePaintPartialRedraw *)BLI_memarena_alloc(ps->arena_mt[a], sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
- memcpy(handles[a].projImages[i].partRedrawRect, ps->projImages[i].partRedrawRect, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
+ memcpy(handles[a].projImages[i].partRedrawRect, ps->projImages[i].partRedrawRect, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
}
if (ps->thread_tot > 1)
@@ -4223,10 +4350,10 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
imapaintpartial.enabled = 1;
}
else {
- imapaintpartial.x1 = MIN2(imapaintpartial.x1, x);
- imapaintpartial.y1 = MIN2(imapaintpartial.y1, y);
- imapaintpartial.x2 = MAX2(imapaintpartial.x2, x + w);
- imapaintpartial.y2 = MAX2(imapaintpartial.y2, y + h);
+ imapaintpartial.x1 = min_ii(imapaintpartial.x1, x);
+ imapaintpartial.y1 = min_ii(imapaintpartial.y1, y);
+ imapaintpartial.x2 = max_ii(imapaintpartial.x2, x + w);
+ imapaintpartial.y2 = max_ii(imapaintpartial.y2, y + h);
}
w = ((x + w - 1) >> IMAPAINT_TILE_BITS);
@@ -4250,7 +4377,7 @@ static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image,
IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, ibuf->x, 0, 0,
&scene->view_settings, &scene->display_settings,
imapaintpartial.x1, imapaintpartial.y1,
- imapaintpartial.x2, imapaintpartial.y2);
+ imapaintpartial.x2, imapaintpartial.y2, FALSE);
}
else {
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
@@ -4555,7 +4682,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
else if (ima->packedfile && ima->rr) {
s->warnpackedfile = ima->id.name + 2;
return 0;
- }
+ }
else if (ibuf && ibuf->channels != 4) {
s->warnmultifile = ima->id.name + 2;
return 0;
@@ -4843,6 +4970,10 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps)
ps->tool = brush->imagepaint_tool;
ps->blend = brush->blend;
+ /* sizeof ProjPixel, since we alloc this a _lot_ */
+ ps->pixel_sizeof = project_paint_pixel_sizeof(ps->tool);
+ BLI_assert(ps->pixel_sizeof >= sizeof(ProjPixel));
+
ps->is_airbrush = (brush->flag & BRUSH_AIRBRUSH) ? 1 : 0;
ps->is_texbrush = (brush->mtex.tex) ? 1 : 0;
@@ -4908,13 +5039,6 @@ static int texture_paint_init(bContext *C, wmOperator *op)
pop->first = 1;
op->customdata = pop;
-
- /* XXX: Soften tool does not support projection painting atm, so just disable
- * projection for this brush */
- if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) {
- settings->imapaint.flag |= IMAGEPAINT_PROJECT_DISABLE;
- pop->restore_projection = 1;
- }
/* initialize from context */
if (CTX_wm_region_view3d(C)) {
@@ -5049,7 +5173,7 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
pop->prevmouse[1] = mouse[1];
}
- else {
+ else {
redraw = imapaint_paint_stroke(&pop->vc, &pop->s, pop->painter, pop->mode == PAINT_MODE_3D, pop->prevmouse, mouse, time, pressure);
pop->prevmouse[0] = mouse[0];
pop->prevmouse[1] = mouse[1];
@@ -5067,7 +5191,7 @@ static void paint_brush_exit_tex(Brush *brush)
MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1);
- }
+ }
}
static void paint_exit(bContext *C, wmOperator *op)
@@ -5267,10 +5391,12 @@ static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
if (!rv3d) {
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
-
- ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
- return 1;
+ if (sima->mode == SI_MODE_PAINT) {
+ ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
+
+ return 1;
+ }
}
*zoomx = *zoomy = 1;
@@ -5286,24 +5412,21 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
#define PX_SIZE_FADE_MIN 4.0f
Scene *scene = CTX_data_scene(C);
- //Brush *brush= image_paint_brush(C);
+ //Brush *brush = image_paint_brush(C);
Paint *paint = paint_get_active_from_context(C);
Brush *brush = paint_brush(paint);
if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
- ToolSettings *ts;
float zoomx, zoomy;
const float size = (float)BKE_brush_size_get(scene, brush);
short use_zoom;
float pixel_size;
float alpha = 0.5f;
- ts = scene->toolsettings;
- use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy) &&
- !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT));
+ use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy);
if (use_zoom) {
- pixel_size = size * maxf(zoomx, zoomy);
+ pixel_size = size * max_ff(zoomx, zoomy);
}
else {
pixel_size = size;
@@ -5655,7 +5778,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if (BKE_object_obdata_is_libdata(ob)) {
- BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
+ BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
return OPERATOR_CANCELLED;
}
@@ -5891,7 +6014,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (!ibuf) {
/* Mostly happens when OpenGL offscreen buffer was failed to create, */
/* but could be other reasons. Should be handled in the future. nazgul */
- BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer: %s", err_out);
+ BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer: %s", err_out);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 794e7755636..162e2fa15d6 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -51,7 +51,7 @@ struct wmOperator;
struct wmOperatorType;
/* paint_stroke.c */
-typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], float mouse[2]);
+typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2]);
typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2]);
typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr);
typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 39a95300d5d..40dcb92f087 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -93,7 +93,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Paint *paint = paint_get_active_from_context(C);
struct Brush *brush = paint_brush(paint);
- // Object *ob= CTX_data_active_object(C);
+ // Object *ob = CTX_data_active_object(C);
float scalar = RNA_float_get(op->ptr, "scalar");
if (brush) {
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 699f1230475..0e72aedeb7a 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -148,13 +148,13 @@ static float event_tablet_data(wmEvent *event, int *pen_flip)
}
/* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */
-static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2])
+static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, const float mouse_in[2])
{
Scene *scene = CTX_data_scene(C);
Paint *paint = paint_get_active_from_context(C);
Brush *brush = paint_brush(paint);
PaintStroke *stroke = op->customdata;
- float mouse[3];
+ float mouse_out[2];
PointerRNA itemptr;
float location[3];
float pressure;
@@ -168,24 +168,24 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
if (stroke->vc.obact->sculpt) {
float delta[2];
- BKE_brush_jitter_pos(scene, brush, mouse_in, mouse);
+ BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out);
/* XXX: meh, this is round about because
* BKE_brush_jitter_pos isn't written in the best way to
* be reused here */
if (brush->flag & BRUSH_JITTER_PRESSURE) {
- sub_v2_v2v2(delta, mouse, mouse_in);
+ sub_v2_v2v2(delta, mouse_out, mouse_in);
mul_v2_fl(delta, pressure);
- add_v2_v2v2(mouse, mouse_in, delta);
+ add_v2_v2v2(mouse_out, mouse_in, delta);
}
}
else {
- copy_v2_v2(mouse, mouse_in);
+ copy_v2_v2(mouse_out, mouse_in);
}
/* TODO: can remove the if statement once all modes have this */
if (stroke->get_location)
- stroke->get_location(C, location, mouse);
+ stroke->get_location(C, location, mouse_out);
else
zero_v3(location);
@@ -193,19 +193,18 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
RNA_collection_add(op->ptr, "stroke", &itemptr);
RNA_float_set_array(&itemptr, "location", location);
- RNA_float_set_array(&itemptr, "mouse", mouse);
+ RNA_float_set_array(&itemptr, "mouse", mouse_out);
RNA_boolean_set(&itemptr, "pen_flip", pen_flip);
RNA_float_set(&itemptr, "pressure", pressure);
- stroke->last_mouse_position[0] = mouse[0];
- stroke->last_mouse_position[1] = mouse[1];
+ copy_v2_v2(stroke->last_mouse_position, mouse_out);
stroke->update_step(C, stroke, &itemptr);
}
/* Returns zero if no sculpt changes should be made, non-zero otherwise */
static int paint_smooth_stroke(PaintStroke *stroke, float output[2],
- const PaintSample *sample)
+ const PaintSample *sample)
{
output[0] = sample->mouse[0];
output[1] = sample->mouse[1];
@@ -265,7 +264,7 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
if (pressure > FLT_EPSILON) {
/* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel
* causing very high step sizes, hanging blender [#32381] */
- const float size_clamp = maxf(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure);
+ const float size_clamp = max_ff(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure);
scale = (size_clamp * stroke->brush->spacing / 50.0f) / length;
if (scale > FLT_EPSILON) {
mul_v2_fl(vec, scale);
@@ -416,10 +415,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
paint_stroke_add_sample(p, stroke, event->x, event->y);
paint_stroke_sample_average(stroke, &sample_average);
- // let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!
- // this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
- // since the 2D deltas are zero -- code in this file needs to be updated to use the
- // post-NDOF_MOTION MOUSEMOVE
+ /* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!
+ * this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
+ * since the 2D deltas are zero -- code in this file needs to be updated to use the
+ * post-NDOF_MOTION MOUSEMOVE */
if (event->type == NDOF_MOTION)
return OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index f5b9aa742c6..e406d4f5c3b 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -152,7 +152,9 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char *
UndoElem *undo;
if (step == 1) {
- if (stack->current == NULL) ;
+ if (stack->current == NULL) {
+ /* pass */
+ }
else {
if (!name || strcmp(stack->current->name, name) == 0) {
if (G.debug & G_DEBUG_WM) {
@@ -165,7 +167,9 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char *
}
}
else if (step == -1) {
- if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) ;
+ if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) {
+ /* pass */
+ }
else {
if (!name || strcmp(stack->current->name, name) == 0) {
undo = (stack->current && stack->current->next) ? stack->current->next : stack->elems.first;
@@ -254,7 +258,9 @@ int ED_undo_paint_valid(int type, const char *name)
else
return 0;
- if (stack->current == NULL) ;
+ if (stack->current == NULL) {
+ /* pass */
+ }
else {
if (name && strcmp(stack->current->name, name) == 0)
return 1;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index a59b07b7c05..ffa5822100a 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -251,19 +251,25 @@ static void imapaint_tri_weights(Object *ob,
void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- const int *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
MTFace *tface = dm->getTessFaceDataArray(dm, CD_MTFACE), *tf;
int numfaces = dm->getNumTessFaces(dm), a, findex;
float p[2], w[3], absw, minabsw;
MFace mf;
MVert mv[4];
+ /* double lookup */
+ const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
+
minabsw = 1e10;
uv[0] = uv[1] = 0.0;
/* test all faces in the derivedmesh with the original index of the picked face */
for (a = 0; a < numfaces; a++) {
- findex = index ? index[a] : a;
+ findex = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
if (findex == faceindex) {
dm->getTessFace(dm, a, &mf);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 5a79368ac49..94b00101dc2 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -79,6 +79,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "GPU_buffers.h"
#include "ED_armature.h"
#include "ED_mesh.h"
@@ -106,18 +107,42 @@ static int vertex_paint_use_fast_update_check(Object *ob)
/* if the polygons from the mesh and the 'derivedFinal' match
* we can assume that no modifiers are applied and that its worth adding tessellated faces
* so 'vertex_paint_use_fast_update_check()' returns TRUE */
-static int vertex_paint_use_tessface_check(Object *ob)
+static int vertex_paint_use_tessface_check(Object *ob, Mesh *me)
{
DerivedMesh *dm = ob->derivedFinal;
- if (dm) {
- Mesh *me = BKE_mesh_from_object(ob);
- return (me->mpoly == CustomData_get_layer(&dm->faceData, CD_MPOLY));
+ if (me && dm) {
+ return (me->mpoly == CustomData_get_layer(&dm->polyData, CD_MPOLY));
}
return FALSE;
}
+static void update_tessface_data(Object *ob, Mesh *me)
+{
+ if (vertex_paint_use_tessface_check(ob, me)) {
+ /* assume if these exist, that they are up to date & valid */
+ if (!me->mcol || !me->mface) {
+ /* should always be true */
+ /* XXX Why this clearing? tessface_calc will reset it anyway! */
+#if 0
+ if (me->mcol) {
+ memset(me->mcol, 255, 4 * sizeof(MCol) * me->totface);
+ }
+#endif
+
+ /* create tessfaces because they will be used for drawing & fast updates */
+ BKE_mesh_tessface_calc(me); /* does own call to update pointers */
+ }
+ }
+ else {
+ if (me->totface) {
+ /* this wont be used, theres no need to keep it */
+ BKE_mesh_tessface_clear(me);
+ }
+ }
+
+}
/* polling - retrieve whether cursor should be set or operator should be done */
/* Returns true if vertex paint mode is active */
@@ -326,29 +351,12 @@ static void make_vertexcol(Object *ob) /* single ob */
CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface);
}
if (!me->mloopcol) {
- CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop);
+ CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop);
}
mesh_update_customdata_pointers(me, TRUE);
}
- if (vertex_paint_use_tessface_check(ob)) {
- /* assume if these exist, that they are up to date & valid */
- if (!me->mcol || !me->mface) {
- /* should always be true */
- if (me->mcol) {
- memset(me->mcol, 255, 4 * sizeof(MCol) * me->totface);
- }
-
- /* create tessfaces because they will be used for drawing & fast updates */
- BKE_mesh_tessface_calc(me); /* does own call to update pointers */
- }
- }
- else {
- if (me->totface) {
- /* this wont be used, theres no need to keep it */
- BKE_mesh_tessface_clear(me);
- }
- }
+ update_tessface_data(ob, me);
//if (shade)
// shadeMeshMCol(scene, ob, me);
@@ -848,7 +856,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_n
{
float vertco[2];
- if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
float delta[2];
float dist_squared;
@@ -1526,7 +1534,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv,
if (total_changed > 1 && do_multipaint) {
float undo_change = get_mp_change(ndv, defbase_tot, defbase_sel, left_over);
multipaint_selection(ndv, defbase_tot, undo_change, defbase_sel);
- }
+ }
/* or designatedw is still -1 put weight back as evenly as possible */
else {
redistribute_change(ndv, defbase_tot, change_status, 2, -2, left_over, total_changed, do_auto_normalize);
@@ -1535,7 +1543,6 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv,
}
else {
/* reset the weights */
- unsigned int i;
MDeformWeight *dw_old = odv->dw;
MDeformWeight *dw_new = ndv->dw;
@@ -2049,7 +2056,6 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNU
Object *ob = CTX_data_active_object(C);
struct WPaintData *wpd;
Mesh *me;
- bDeformGroup *dg;
float mat[4][4], imat[4][4];
@@ -2098,12 +2104,14 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNU
return FALSE;
}
- /* check if we are attempting to paint onto a locked vertex group,
- * and other options disallow it from doing anything useful */
- dg = BLI_findlink(&ob->defbase, (ob->actdef - 1));
- if (dg->flag & DG_LOCK_WEIGHT) {
- BKE_report(op->reports, RPT_WARNING, "Active group is locked, aborting");
- return FALSE;
+ {
+ /* check if we are attempting to paint onto a locked vertex group,
+ * and other options disallow it from doing anything useful */
+ bDeformGroup *dg = BLI_findlink(&ob->defbase, (ob->actdef - 1));
+ if (dg->flag & DG_LOCK_WEIGHT) {
+ BKE_report(op->reports, RPT_WARNING, "Active group is locked, aborting");
+ return FALSE;
+ }
}
/* ALLOCATIONS! no return after this line */
@@ -2564,7 +2572,7 @@ static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me)
vd->polyfacemap = BLI_memarena_alloc(vd->polyfacemap_arena, sizeof(ListBase) * me->totpoly);
- origIndex = CustomData_get_layer(&me->fdata, CD_POLYINDEX);
+ origIndex = CustomData_get_layer(&me->fdata, CD_ORIGINDEX);
mf = me->mface;
if (!origIndex)
@@ -2600,7 +2608,12 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
make_vertexcol(ob);
if (me->mloopcol == NULL)
return OPERATOR_CANCELLED;
-
+
+ /* Update tessface data if needed
+ * Added here too because e.g. switching to/from edit mode would remove tessface data,
+ * yet "fast_update" could still be used! */
+ update_tessface_data(ob, me);
+
/* make mode data storage */
vpd = MEM_callocN(sizeof(struct VPaintData), "VPaintData");
paint_stroke_set_mode_data(stroke, vpd);
@@ -2616,9 +2629,11 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
if (vertex_paint_use_fast_update_check(ob)) {
vpaint_build_poly_facemap(vpd, me);
vpd->use_fast_update = TRUE;
+/* printf("Fast update!\n");*/
}
else {
vpd->use_fast_update = FALSE;
+/* printf("No fast update!\n");*/
}
/* for filtering */
@@ -2632,14 +2647,6 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
return 1;
}
-static void copy_lcol_to_mcol(MCol *mcol, const MLoopCol *lcol)
-{
- mcol->a = lcol->a;
- mcol->r = lcol->r;
- mcol->g = lcol->g;
- mcol->b = lcol->b;
-}
-
static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob,
const unsigned int index, const float mval[2],
const float brush_size_pressure, const float brush_alpha_pressure)
@@ -2707,11 +2714,18 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob,
ml = me->mloop + mpoly->loopstart;
mlc = me->mloopcol + mpoly->loopstart;
for (j = 0; j < mpoly->totloop; j++, ml++, mlc++) {
- if (ml->v == mf->v1) copy_lcol_to_mcol(mc + 0, mlc);
- else if (ml->v == mf->v2) copy_lcol_to_mcol(mc + 1, mlc);
- else if (ml->v == mf->v3) copy_lcol_to_mcol(mc + 2, mlc);
- else if (mf->v4 && ml->v == mf->v4) copy_lcol_to_mcol(mc + 3, mlc);
-
+ if (ml->v == mf->v1) {
+ MESH_MLOOPCOL_TO_MCOL(mlc, mc + 0);
+ }
+ else if (ml->v == mf->v2) {
+ MESH_MLOOPCOL_TO_MCOL(mlc, mc + 1);
+ }
+ else if (ml->v == mf->v3) {
+ MESH_MLOOPCOL_TO_MCOL(mlc, mc + 2);
+ }
+ else if (mf->v4 && ml->v == mf->v4) {
+ MESH_MLOOPCOL_TO_MCOL(mlc, mc + 3);
+ }
}
}
}
@@ -2792,6 +2806,10 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
* avoid this if we can! */
DAG_id_tag_update(ob->data, 0);
}
+ else if (!GPU_buffer_legacy(ob->derivedFinal)) {
+ /* If using new VBO drawing, mark mcol as dirty to force colors gpu buffer refresh! */
+ ob->derivedFinal->dirty |= DM_DIRTY_MCOL_UPDATE_DRAW;
+ }
}
static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 3d3e86d2acb..38dbdcd8337 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3076,6 +3076,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob);
+ ss->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE;
if (need_mask) {
if (mmd == NULL) {
@@ -3130,6 +3131,8 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
ss->pbvh = dm->getPBVH(ob, dm);
ss->pmap = (need_pmap && dm->getPolyMap) ? dm->getPolyMap(ob, dm) : NULL;
+ pbvh_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color);
+
if (ss->modifiers_active) {
if (!ss->orig_cos) {
int a;
@@ -3513,7 +3516,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
if (tool == SCULPT_TOOL_GRAB)
copy_v3_v3(sd->anchored_location, cache->true_location);
else if (tool == SCULPT_TOOL_THUMB)
- copy_v3_v3(sd->anchored_location, cache->orig_grab_location);
+ copy_v3_v3(sd->anchored_location, cache->orig_grab_location);
if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) {
/* location stays the same for finding vertices in brush radius */
@@ -3536,8 +3539,6 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
StrokeCache *cache = ss->cache;
Brush *brush = paint_brush(&sd->paint);
- int dx, dy;
-
/* RNA_float_get_array(ptr, "location", cache->traced_location); */
if (cache->first_time ||
@@ -3606,8 +3607,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
if (brush->flag & BRUSH_ANCHORED) {
int hit = 0;
- dx = cache->mouse[0] - cache->initial_mouse[0];
- dy = cache->mouse[1] - cache->initial_mouse[1];
+ const float dx = cache->mouse[0] - cache->initial_mouse[0];
+ const float dy = cache->mouse[1] - cache->initial_mouse[1];
sd->anchored_size = cache->pixel_radius = sqrt(dx * dx + dy * dy);
@@ -3617,8 +3618,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
float halfway[2];
float out[3];
- halfway[0] = (float)dx * 0.5f + cache->initial_mouse[0];
- halfway[1] = (float)dy * 0.5f + cache->initial_mouse[1];
+ halfway[0] = dx * 0.5f + cache->initial_mouse[0];
+ halfway[1] = dy * 0.5f + cache->initial_mouse[1];
if (sculpt_stroke_get_location(C, out, halfway)) {
copy_v3_v3(sd->anchored_location, out);
@@ -3665,8 +3666,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
sculpt_update_brush_delta(sd, ob, brush);
if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
- dx = cache->mouse[0] - cache->initial_mouse[0];
- dy = cache->mouse[1] - cache->initial_mouse[1];
+ const float dx = cache->mouse[0] - cache->initial_mouse[0];
+ const float dy = cache->mouse[1] - cache->initial_mouse[1];
cache->vertex_rotation = -atan2f(dx, dy) * cache->bstrength;
@@ -3738,7 +3739,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
* (This allows us to ignore the GL depth buffer)
* Returns 0 if the ray doesn't hit the mesh, non-zero otherwise
*/
-int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2])
+int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
{
ViewContext vc;
Object *ob;
@@ -4153,7 +4154,7 @@ int ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
* isn't one already */
if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
GridPaintMask *gmask;
- int level = MAX2(1, mmd->sculptlvl);
+ int level = max_ii(1, mmd->sculptlvl);
int gridsize = ccg_gridsize(level);
int gridarea = gridsize * gridsize;
int i, j;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 0852378974e..acb906e4a91 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -65,7 +65,7 @@ void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct
void free_sculptsession_deformMats(struct SculptSession *ss);
/* Stroke */
-int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2]);
+int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]);
/* Undo */
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index b204fc75255..1b3fd24ae22 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -99,7 +99,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
MVert *mvert;
- int *index, i, j;
+ int *index, i, j;
if (unode->maxvert) {
/* regular mesh restore */
@@ -224,7 +224,7 @@ static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode
SculptSession *ss = ob->sculpt;
MVert *mvert;
float *vmask;
- int *index, i, j;
+ int *index, i, j;
if (unode->maxvert) {
/* regular mesh restore */
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 42361577b6e..3fc504ba02e 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -99,7 +99,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
- /* loop through channels, and set up drawing depending on their type */
+ /* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
y = (float)ACHANNEL_FIRST;
@@ -190,7 +190,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* if in NLA there's a strip active, map the view */
if (ac->datatype == ANIMCONT_ACTION) {
- /* adt= ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */
+ /* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */
/* start and end of action itself */
calc_action_range(ac->data, &act_start, &act_end, 0);
@@ -320,7 +320,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* Increment the step */
y -= ACHANNEL_STEP;
- }
+ }
glDisable(GL_BLEND);
/* Draw keyframes
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 7635f85a37e..ae78b71f2ad 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -132,7 +132,7 @@ void ACTION_OT_new(wmOperatorType *ot)
/* api callbacks */
ot->exec = act_new_exec;
- // NOTE: this is used in the NLA too...
+ /* NOTE: this is used in the NLA too... */
//ot->poll = ED_operator_action_active;
/* flags */
@@ -234,8 +234,8 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
int filter;
/* get data to filter, from Action or Dopesheet */
- // XXX: what is sel doing here?!
- // Commented it, was breaking things (eg. the "auto preview range" tool).
+ /* XXX: what is sel doing here?!
+ * Commented it, was breaking things (eg. the "auto preview range" tool). */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@@ -254,8 +254,9 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
/* find gp-frame which is less than or equal to cframe */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- *min = MIN2(*min, gpf->framenum);
- *max = MAX2(*max, gpf->framenum);
+ const float framenum = (float)gpf->framenum;
+ *min = min_ff(*min, framenum);
+ *max = max_ff(*max, framenum);
}
}
else if (ale->datatype == ALE_MASKLAY) {
@@ -267,8 +268,9 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
masklay_shape;
masklay_shape = masklay_shape->next)
{
- *min = MIN2(*min, masklay_shape->frame);
- *max = MAX2(*max, masklay_shape->frame);
+ const float framenum = (float)masklay_shape->frame;
+ *min = min_ff(*min, framenum);
+ *max = max_ff(*max, framenum);
}
}
else {
@@ -284,8 +286,8 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
}
/* try to set cur using these values, if they're more extreme than previously set values */
- *min = MIN2(*min, tmin);
- *max = MAX2(*max, tmax);
+ *min = min_ff(*min, tmin);
+ *max = max_ff(*max, tmax);
}
}
@@ -493,7 +495,7 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
/* copy keyframes */
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
/* FIXME... */
- BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for Grease Pencil mode");
+ BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for grease pencil mode");
return OPERATOR_CANCELLED;
}
else if (ac.datatype == ANIMCONT_MASK) {
@@ -502,7 +504,7 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else {
- if (copy_action_keys(&ac)) {
+ if (copy_action_keys(&ac)) {
BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer");
return OPERATOR_CANCELLED;
}
@@ -542,8 +544,8 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
/* paste keyframes */
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
- // FIXME...
- BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for Grease Pencil or Mask mode");
+ /* FIXME... */
+ BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for grease pencil or mask mode");
return OPERATOR_CANCELLED;
}
else {
@@ -588,7 +590,7 @@ void ACTION_OT_paste(wmOperatorType *ot)
static EnumPropertyItem prop_actkeys_insertkey_types[] = {
{1, "ALL", 0, "All Channels", ""},
{2, "SEL", 0, "Only Selected Channels", ""},
- {3, "GROUP", 0, "In Active Group", ""}, // xxx not in all cases
+ {3, "GROUP", 0, "In Active Group", ""}, /* XXX not in all cases */
{0, NULL, 0, NULL, NULL}
};
@@ -976,8 +978,8 @@ void ACTION_OT_sample(wmOperatorType *ot)
/* defines for set extrapolation-type for selected keyframes tool */
static EnumPropertyItem prop_actkeys_expo_types[] = {
- {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", ""},
- {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", ""},
+ {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"},
+ {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"},
{MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"},
{CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"},
@@ -1010,7 +1012,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
if (mode == MAKE_CYCLIC_EXPO) {
/* only add if one doesn't exist */
if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) {
- // TODO: add some more preset versions which set different extrapolation options?
+ /* TODO: add some more preset versions which set different extrapolation options? */
add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES);
}
}
@@ -1319,7 +1321,7 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
- /* init edit data */
+ /* init edit data */
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -1353,9 +1355,9 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
void ACTION_OT_frame_jump(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Jump to Frame";
+ ot->name = "Jump to Keyframes";
ot->idname = "ACTION_OT_frame_jump";
- ot->description = "Set the current frame to the average frame of the selected keyframes";
+ ot->description = "Set the current frame to the average frame value of selected keyframes";
/* api callbacks */
ot->exec = actkeys_framejump_exec;
@@ -1369,10 +1371,14 @@ void ACTION_OT_frame_jump(wmOperatorType *ot)
/* defines for snap keyframes tool */
static EnumPropertyItem prop_actkeys_snap_types[] = {
- {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", ""},
- {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry?
- {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry?
- {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""},
+ {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame",
+ "Snap selected keyframes to the current frame"},
+ {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame",
+ "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame offsets)"},
+ {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second",
+ "Snap selected keyframes to the nearest second"},
+ {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker",
+ "Snap selected keyframes to the nearest marker"},
{0, NULL, 0, NULL, NULL}
};
@@ -1431,7 +1437,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
- // XXX...
+ /* XXX... */
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
return OPERATOR_PASS_THROUGH;
@@ -1473,9 +1479,12 @@ void ACTION_OT_snap(wmOperatorType *ot)
/* defines for mirror keyframes tool */
static EnumPropertyItem prop_actkeys_mirror_types[] = {
- {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", ""},
- {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", ""},
- {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", ""},
+ {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame",
+ "Flip times of selected keyframes using the current frame as the mirror line"},
+ {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0",
+ "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"},
+ {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker",
+ "Flip times of selected keyframes using the first selected marker as the reference point"},
{0, NULL, 0, NULL, NULL}
};
@@ -1495,14 +1504,10 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
ked.scene = ac->scene;
/* for 'first selected marker' mode, need to find first selected marker first! */
- // XXX should this be made into a helper func in the API?
+ /* XXX should this be made into a helper func in the API? */
if (mode == ACTKEYS_MIRROR_MARKER) {
- TimeMarker *marker = NULL;
-
- /* find first selected marker */
- marker = ED_markers_get_first_selected(ac->markers);
+ TimeMarker *marker = ED_markers_get_first_selected(ac->markers);
- /* store marker's time (if available) */
if (marker)
ked.f1 = (float)marker->frame;
else
@@ -1545,7 +1550,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
- // XXX...
+ /* XXX... */
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
return OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index c684ae1de51..10085d8a149 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -111,7 +111,7 @@ enum {
ACTKEYS_SNAP_CFRA = 1,
ACTKEYS_SNAP_NEAREST_FRAME,
ACTKEYS_SNAP_NEAREST_SECOND,
- ACTKEYS_SNAP_NEAREST_MARKER,
+ ACTKEYS_SNAP_NEAREST_MARKER,
} eActKeys_Snap_Mode;
/* defines for mirror keyframes
@@ -121,7 +121,7 @@ enum {
ACTKEYS_MIRROR_CFRA = 1,
ACTKEYS_MIRROR_YAXIS,
ACTKEYS_MIRROR_XAXIS,
- ACTKEYS_MIRROR_MARKER,
+ ACTKEYS_MIRROR_MARKER,
} eActKeys_Mirror_Mode;
/* ***************************************** */
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index e4a161e3e22..cca71bb1331 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -168,9 +168,8 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* action_edit.c */
- /* snap - current frame to selected keys */
- // TODO: maybe since this is called jump, we're better to have it on <something>-J?
- WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ /* jump to selected keyframes */
+ WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0);
/* menu + single-step transform */
WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 5da348b2a84..d0f76c21019 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -763,7 +763,7 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
if (leftright == ACTKEYS_LRSEL_LEFT) {
ked.f1 = MINAFRAMEF;
ked.f2 = (float)(CFRA + 0.1f);
- }
+ }
else {
ked.f1 = (float)(CFRA - 0.1f);
ked.f2 = MAXFRAMEF;
@@ -785,7 +785,7 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else if (ale->type == ANIMTYPE_GPLAYER)
+ else if (ale->type == ANIMTYPE_GPLAYER)
ED_gplayer_frames_select_border(ale->data, ked.f1, ked.f2, select_mode);
else if (ale->type == ANIMTYPE_MASKLAYER)
ED_masklayer_frames_select_border(ale->data, ked.f1, ked.f2, select_mode);
@@ -869,7 +869,7 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
- else
+ else
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
}
@@ -1081,7 +1081,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
/* dopesheet summary covers everything */
summary_to_keylist(ac, &anim_keys, NULL);
}
- else if (ale->type == ANIMTYPE_GROUP) {
+ else if (ale->type == ANIMTYPE_GROUP) {
// TODO: why don't we just give groups key_data too?
bActionGroup *agrp = (bActionGroup *)ale->data;
agroup_to_keylist(adt, agrp, &anim_keys, NULL);
@@ -1144,7 +1144,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_
agrp->flag |= AGRP_SELECTED;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
- }
+ }
else if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = ale->data;
@@ -1210,7 +1210,7 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
return OPERATOR_CANCELLED;
/* get useful pointers from animation context data */
- /* ar= ac.ar; */ /* UNUSED */
+ /* ar = ac.ar; */ /* UNUSED */
/* select mode is either replace (deselect all, then add) or add/extend */
if (RNA_boolean_get(op->ptr, "extend"))
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index f5ba0f4b139..812923747d7 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -129,7 +129,7 @@ static SpaceLink *action_new(const bContext *C)
/* not spacelink itself */
static void action_free(SpaceLink *UNUSED(sl))
{
-// SpaceAction *saction= (SpaceAction *) sl;
+// SpaceAction *saction = (SpaceAction *) sl;
}
@@ -377,7 +377,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_refresh(sa);
break;
case NC_SCENE:
- switch (wmn->data) {
+ switch (wmn->data) {
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
case ND_OB_SELECT:
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
@@ -433,7 +433,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn)
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
break;
- }
+ }
break;
case NC_WINDOW:
if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 2cbcbcdbc9a..35344f2c5a4 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -193,7 +193,7 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
typedef struct RegionDrawCB {
struct RegionDrawCB *next, *prev;
- void (*draw)(const struct bContext *, struct ARegion *, void *);
+ void (*draw)(const struct bContext *, struct ARegion *, void *);
void *customdata;
int type;
@@ -239,7 +239,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
for (rdc = ar->type->drawcalls.first; rdc; rdc = rdc->next) {
if (rdc->type == type)
rdc->draw(C, ar, rdc->customdata);
- }
+ }
}
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index c41d2521ee8..2da70468f0c 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -236,7 +236,7 @@ static int buttons_context_path_material(ButsContextPath *path, int for_texture)
if (ma) {
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
path->len++;
- }
+ }
return 1;
}
}
@@ -680,9 +680,9 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
/************************* Context Callback ************************/
const char *buttons_context_dir[] = {
- "world", "object", "mesh", "armature", "lattice", "curve",
+ "texture_slot", "world", "object", "mesh", "armature", "lattice", "curve",
"meta_ball", "lamp", "speaker", "camera", "material", "material_slot",
- "texture", "texture_slot", "texture_user", "bone", "edit_bone",
+ "texture", "texture_user", "bone", "edit_bone",
"pose_bone", "particle_system", "particle_system_editable", "particle_settings",
"cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL
};
@@ -697,7 +697,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
/* here we handle context, getting data from precomputed path */
if (CTX_data_dir(member)) {
- CTX_data_dir_set(result, buttons_context_dir);
+ /* 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)
+ CTX_data_dir_set(result, buttons_context_dir + 1);
+ else
+ CTX_data_dir_set(result, buttons_context_dir);
return 1;
}
else if (CTX_data_equals(member, "world")) {
@@ -889,7 +894,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else
CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
return 1;
- }
+ }
else if (CTX_data_equals(member, "particle_settings")) {
/* only available when pinned */
PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings);
@@ -900,7 +905,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
}
else {
/* get settings from active particle system instead */
- PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSystem);
+ ptr = get_pointer_type(path, &RNA_ParticleSystem);
if (ptr && ptr->data) {
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index c8cf69e3e17..d40426a5bc9 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -162,7 +162,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
char *str;
if (CTX_wm_space_file(C)) {
- BKE_report(op->reports, RPT_ERROR, "Can't activate a file selector, one already open");
+ BKE_report(op->reports, RPT_ERROR, "Cannot activate a file selector, one already open");
return OPERATOR_CANCELLED;
}
@@ -207,7 +207,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
* user-prefs exception - campbell */
if (RNA_struct_find_property(op->ptr, "relative_path")) {
if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
- /* annoying exception!, if were dealign with the user prefs, default relative to be off */
+ /* annoying exception!, if were dealing with the user prefs, default relative to be off */
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS && (ptr.data != &U));
}
}
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index a75de7bc37f..798fdece79a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -323,7 +323,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
/* currently works by redraws... if preview is set, it (re)starts job */
sbuts->preview = 1;
break;
- }
+ }
break;
case NC_WORLD:
buttons_area_redraw(sa, BCONTEXT_WORLD);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 6cef23a98f4..157dc3282b9 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -119,6 +119,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
int *points, totseg, i, a;
float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1);
MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *act_object = BKE_tracking_object_get_active(tracking);
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(&clip->tracking);
MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
@@ -214,15 +215,15 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx;
UI_ThemeColor(TH_CFRAME);
- gpuSingleFilledRecti(x, 0, x + framelen, 8);
+ gpuSingleFilledRecti(x, 0, x + ceilf(framelen), 8);
clip_draw_curfra_label(sc->user.framenr, x, 8.0f);
/* solver keyframes */
gpuCurrentColor4ub(175, 255, 0, 255);
gpuImmediateFormat_V2();
- draw_keyframe(tracking->settings.keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
- draw_keyframe(tracking->settings.keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
+ draw_keyframe(act_object->keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
+ draw_keyframe(act_object->keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
gpuImmediateUnformat();
/* movie clip animation */
@@ -255,7 +256,6 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
int width, int height, float zoomx, float zoomy)
{
int x, y;
- MovieClip *clip = ED_space_clip_get_clip(sc);
/* find window pixel coordinates of origin */
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
@@ -318,6 +318,15 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
IMB_display_buffer_release(cache_handle);
}
+}
+
+static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int height, float zoomx, float zoomy)
+{
+ int x, y;
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+
+ /* find window pixel coordinates of origin */
+ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
/* draw boundary border for frame if stabilization is enabled */
if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
@@ -752,7 +761,7 @@ static float get_shortest_pattern_side(MovieTrackingMarker *marker)
cur_len = len_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]);
- len = minf(cur_len, len);
+ len = min_ff(cur_len, len);
}
return len;
@@ -824,11 +833,11 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
dy = 6.0f / height / sc->zoom;
side = get_shortest_pattern_side(marker);
- patdx = minf(dx * 2.0f / 3.0f, side / 6.0f);
- patdy = minf(dy * 2.0f / 3.0f, side * width / height / 6.0f);
+ patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f);
+ patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f);
- searchdx = minf(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f);
- searchdy = minf(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f);
+ searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f);
+ searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f);
px[0] = 1.0f / sc->zoom / width / sc->scale;
px[1] = 1.0f / sc->zoom / height / sc->scale;
@@ -1506,6 +1515,7 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
}
if (width && height) {
+ draw_stabilization_border(sc, ar, width, height, zoomx, zoomy);
draw_tracking_tracks(sc, ar, clip, width, height, zoomx, zoomy);
draw_distortion(sc, ar, clip, width, height, zoomx, zoomy);
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 20e9404b833..20ccdf74890 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -44,6 +44,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLI_rect.h"
#include "GPU_compatibility.h"
@@ -394,7 +395,7 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit)
zoomx = (float)width / w / aspx;
zoomy = (float)height / h / aspy;
- newzoom = 1.0f / power_of_2(1.0f / minf(zoomx, zoomy));
+ newzoom = 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy));
if (fit || sc->zoom > newzoom)
sc->zoom = newzoom;
@@ -692,7 +693,7 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsign
context->start_frame = clip->start_frame;
context->frame_offset = clip->frame_offset;
- strcpy(context->colorspace, clip->colorspace_settings.name);
+ BLI_strncpy(context->colorspace, clip->colorspace_settings.name, sizeof(context->colorspace));
}
else {
/* displaying exactly the same image which was loaded t oa texture,
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 5c338f3e6f1..4e53f34359e 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -41,6 +41,8 @@
#include "BLI_math.h"
#include "BLI_rect.h"
+#include "BLF_translation.h"
+
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_report.h"
@@ -180,7 +182,7 @@ static int open_exec(bContext *C, wmOperator *op)
BLI_join_dirfile(str, sizeof(str), dir_only, file_only);
}
else {
- BKE_reportf(op->reports, RPT_ERROR, "No files selected to be opened");
+ BKE_report(op->reports, RPT_ERROR, "No files selected to be opened");
return OPERATOR_CANCELLED;
}
@@ -195,8 +197,8 @@ static int open_exec(bContext *C, wmOperator *op)
if (op->customdata)
MEM_freeN(op->customdata);
- BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str,
- errno ? strerror(errno) : "Unsupported movie clip format");
+ BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s", str,
+ errno ? strerror(errno) : TIP_("unsupported movie clip format"));
return OPERATOR_CANCELLED;
}
@@ -514,9 +516,14 @@ static int view_zoom_exec(bContext *C, wmOperator *op)
static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if (event->type == MOUSEZOOM) {
- float factor;
+ float delta, factor;
+
+ delta = event->x - event->prevx + event->y - event->prevy;
+
+ if (U.uiflag & USER_ZOOM_INVERT)
+ delta *= -1;
- factor = 1.0f + (event->x - event->prevx + event->y - event->prevy) / 300.0f;
+ factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sclip_zoom_set_factor_exec(C, event, factor);
@@ -533,11 +540,16 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
{
ViewZoomData *vpd = op->customdata;
- float factor;
+ float delta, factor;
switch (event->type) {
case MOUSEMOVE:
- factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f;
+ delta = event->x - vpd->x + event->y - vpd->y;
+
+ if (U.uiflag & USER_ZOOM_INVERT)
+ delta *= -1;
+
+ factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sclip_zoom_set(C, vpd->zoom * factor, vpd->location);
ED_region_tag_redraw(CTX_wm_region(C));
@@ -579,7 +591,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot)
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER;
/* properties */
- RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX,
+ RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX,
"Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
}
@@ -700,7 +712,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot)
ot->poll = ED_space_clip_view_clip_poll;
/* properties */
- RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX,
+ RNA_def_float(ot->srna, "ratio", 0.0f, -FLT_MAX, FLT_MAX,
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
}
@@ -735,7 +747,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
zoomx = (float) width / (w + 2 * margin);
zoomy = (float) height / (h + 2 * margin);
- sclip_zoom_set(C, minf(zoomx, zoomy), NULL);
+ sclip_zoom_set(C, min_ff(zoomx, zoomy), NULL);
}
else {
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
@@ -743,7 +755,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
zoomy = (float) height / h;
/* find the zoom value that will fit the image in the image space */
- sclip_zoom_set(C, 1.0f / power_of_2(1.0f / minf(zoomx, zoomy)), NULL);
+ sclip_zoom_set(C, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
}
else
sclip_zoom_set(C, 1.0f, NULL);
@@ -1053,7 +1065,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
if (clip->anim) {
pj->index_context = IMB_anim_index_rebuild_context(clip->anim, clip->proxy.build_tc_flag,
- clip->proxy.build_size_flag, clip->proxy.quality);
+ clip->proxy.build_size_flag, clip->proxy.quality);
}
WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index aeed42c9c81..fb0a352a8e0 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -65,11 +65,12 @@
#include "clip_intern.h" // own include
-void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack *track, void *userdata,
- void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord,
- int scene_framenr, float val),
- void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
- void (*segment_end)(void *userdata))
+void clip_graph_tracking_values_iterate_track(
+ SpaceClip *sc, MovieTrackingTrack *track, void *userdata,
+ void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord,
+ int scene_framenr, float val),
+ void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
+ void (*segment_end)(void *userdata))
{
MovieClip *clip = ED_space_clip_get_clip(sc);
int width, height, coord;
@@ -124,11 +125,12 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack
}
}
-void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
- void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int coord, int scene_framenr, float val),
- void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
- void (*segment_end)(void *userdata))
+void clip_graph_tracking_values_iterate(
+ SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
+ void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int coord, int scene_framenr, float val),
+ void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
+ void (*segment_end)(void *userdata))
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 97f7d7bf132..d97b112e95d 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -154,7 +154,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
+ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
"Location", "Location of marker on frame", -1.0f, 1.0f);
}
@@ -372,8 +372,8 @@ static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker,
dx = size / width / sc->zoom;
dy = size / height / sc->zoom;
- dx = minf(dx, (max[0] - min[0]) / 6.0f);
- dy = minf(dy, (max[1] - min[1]) / 6.0f);
+ dx = min_ff(dx, (max[0] - min[0]) / 6.0f);
+ dy = min_ff(dy, (max[1] - min[1]) / 6.0f);
return IN_RANGE_INCL(co[0], slide_zone[0] - dx, slide_zone[0] + dx) &&
IN_RANGE_INCL(co[1], slide_zone[1] - dy, slide_zone[1] + dy);
@@ -424,14 +424,14 @@ static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker,
cur_len = len_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]);
- len = minf(cur_len, len);
+ len = min_ff(cur_len, len);
}
dx = 12.0f / width / sc->zoom;
dy = 12.0f / height / sc->zoom;
- dx = minf(dx, len * 2.0f / 3.0f);
- dy = minf(dy, len * width / height * 2.0f / 3.0f);
+ dx = min_ff(dx, len * 2.0f / 3.0f);
+ dy = min_ff(dy, len * width / height * 2.0f / 3.0f);
for (i = 0; i < 4; i++) {
float crn[2];
@@ -462,8 +462,8 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki
dx = 12.0f / width / sc->zoom;
dy = 12.0f / height / sc->zoom;
- dx = minf(dx, (pat_max[0] - pat_min[0]) / 2.0f);
- dy = minf(dy, (pat_max[1] - pat_min[1]) / 2.0f);
+ dx = min_ff(dx, (pat_max[0] - pat_min[0]) / 2.0f);
+ dy = min_ff(dy, (pat_max[1] - pat_min[1]) / 2.0f);
return co[0] >= pos[0] - dx && co[0] <= pos[0] + dx && co[1] >= pos[1] - dy && co[1] <= pos[1] + dy;
}
@@ -855,8 +855,8 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
vec[0] *= data->width;
vec[1] *= data->height;
- data->corners[a][0] = (vec[0] * cos(angle) - vec[1] * sin(angle)) / data->width;
- data->corners[a][1] = (vec[1] * cos(angle) + vec[0] * sin(angle)) / data->height;
+ data->corners[a][0] = (vec[0] * cosf(angle) - vec[1] * sinf(angle)) / data->width;
+ data->corners[a][1] = (vec[1] * cosf(angle) + vec[0] * sinf(angle)) / data->height;
}
BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);
@@ -1018,7 +1018,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit
if (frames_limit == 0)
frames_limit = track->frames_limit;
else
- frames_limit = MIN2(frames_limit, track->frames_limit);
+ frames_limit = min_ii(frames_limit, (int)track->frames_limit);
}
}
}
@@ -1343,7 +1343,6 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
MovieClip *clip = ED_space_clip_get_clip(sc);
Scene *scene = CTX_data_scene(C);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingSettings *settings = &clip->tracking.settings;
MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
int width, height;
@@ -1359,7 +1358,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
scj->user = sc->user;
scj->context = BKE_tracking_reconstruction_context_new(tracking, object,
- settings->keyframe1, settings->keyframe2, width, height);
+ object->keyframe1, object->keyframe2, width, height);
tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats");
@@ -1397,11 +1396,10 @@ static void solve_camera_freejob(void *scv)
}
solved = BKE_tracking_reconstruction_finish(scj->context, tracking);
-
if (!solved)
- BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details");
+ BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct (see console for details)");
else
- BKE_reportf(scj->reports, RPT_INFO, "Average re-projection error %.3f", tracking->reconstruction.error);
+ BKE_reportf(scj->reports, RPT_INFO, "Average re-projection error: %.3f", tracking->reconstruction.error);
/* set currently solved clip as active for scene */
if (scene->clip)
@@ -1411,7 +1409,7 @@ static void solve_camera_freejob(void *scv)
id_us_plus(&clip->id);
/* set blender camera focal length so result would look fine there */
- if (scene->camera) {
+ if (scene->camera && GS(scene->camera->id.name) == ID_CA) {
Camera *camera = (Camera *)scene->camera->data;
int width, height;
@@ -2767,7 +2765,7 @@ static int join_tracks_exec(bContext *C, wmOperator *op)
next = track->next;
if (TRACK_VIEW_SELECTED(sc, track) && track != act_track) {
- BKE_tracking_tracks_join(act_track, track);
+ BKE_tracking_tracks_join(tracking, act_track, track);
if (tracking->stabilization.rot_track == track)
tracking->stabilization.rot_track = act_track;
@@ -2859,14 +2857,14 @@ static int set_solver_keyframe_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
- MovieTrackingSettings *settings = &tracking->settings;
+ MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
int keyframe = RNA_enum_get(op->ptr, "keyframe");
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
if (keyframe == 0)
- settings->keyframe1 = framenr;
+ object->keyframe1 = framenr;
else
- settings->keyframe2 = framenr;
+ object->keyframe2 = framenr;
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
@@ -2946,6 +2944,19 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot)
/********************** add 2d stabilization tracks operator *********************/
+static int stabilize_2d_poll(bContext *C)
+{
+ if (ED_space_clip_tracking_poll(C)) {
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
+
+ return tracking_object->flag & TRACKING_OBJECT_CAMERA;
+ }
+
+ return FALSE;
+}
+
static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
@@ -2987,7 +2998,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_add_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3047,7 +3058,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_remove_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3090,7 +3101,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_select_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3127,7 +3138,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_set_rotation_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3373,7 +3384,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op)
object = BKE_tracking_object_get_active(tracking);
if (object->flag & TRACKING_OBJECT_CAMERA) {
- BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking can't be deleted");
+ BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking cannot be deleted");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index 8591966e645..1d4262270f5 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -107,7 +107,7 @@ static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx
{
float dist = dist_to_crns(co, pos, crns);
- return dist < maxf(epsx, epsy);
+ return dist < max_ff(epsx, epsy);
}
static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *track)
@@ -128,8 +128,8 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *
epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1],
fabsf(pat_min[1]), fabsf(pat_max[1])) / 2;
- epsx = maxf(epsx, 2.0f / width);
- epsy = maxf(epsy, 2.0f / height);
+ epsx = max_ff(epsx, 2.0f / width);
+ epsy = max_ff(epsy, 2.0f / height);
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy))
@@ -291,7 +291,6 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
MovieTrackingTrack *track = tracking_marker_check_slide(C, event, NULL, NULL, NULL);
if (track) {
- SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
clip->tracking.act_track = track;
@@ -477,7 +476,7 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
select = !RNA_boolean_get(op->ptr, "deselect");
do_lasso_select_marker(C, mcords, mcords_tot, select);
- MEM_freeN(mcords);
+ MEM_freeN((void *)mcords);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index 08a0ad8672c..93c6ce472f8 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -84,7 +84,7 @@ typedef struct ConsoleDrawContext {
#if 0 /* used by textview, may use later */
int *xy; // [2]
int *sel; // [2]
- int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start.
+ int *pos_pick; /* bottom of view == 0, top of file == combine chars, end of line is lower then start. */
int *mval; // [2]
int draw;
#endif
@@ -94,12 +94,14 @@ void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_du
{
/* fake the edit line being in the scroll buffer */
ConsoleLine *cl = sc->history.last;
+ int prompt_len = strlen(sc->prompt);
+
cl_dummy->type = CONSOLE_LINE_INPUT;
- cl_dummy->len = cl_dummy->len_alloc = strlen(sc->prompt) + cl->len;
+ cl_dummy->len = prompt_len + cl->len;
cl_dummy->len_alloc = cl_dummy->len + 1;
cl_dummy->line = MEM_mallocN(cl_dummy->len_alloc, "cl_dummy");
- memcpy(cl_dummy->line, sc->prompt, (cl_dummy->len_alloc - cl->len));
- memcpy(cl_dummy->line + ((cl_dummy->len_alloc - cl->len)) - 1, cl->line, cl->len + 1);
+ memcpy(cl_dummy->line, sc->prompt, prompt_len);
+ memcpy(cl_dummy->line + prompt_len, cl->line, cl->len + 1);
BLI_addtail(&sc->scrollback, cl_dummy);
}
void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
@@ -158,12 +160,13 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
const int prompt_len = strlen(sc->prompt);
const int cursor_loc = cl->cursor + prompt_len;
+ const int line_len = cl->len + prompt_len;
int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
int pen[2];
xy[1] += tvc->lheight / 6;
/* account for wrapping */
- if (cl->len < tvc->console_width) {
+ if (line_len < tvc->console_width) {
/* simple case, no wrapping */
pen[0] = tvc->cwidth * cursor_loc;
pen[1] = -2;
@@ -171,7 +174,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
else {
/* wrap */
pen[0] = tvc->cwidth * (cursor_loc % tvc->console_width);
- pen[1] = -2 + (((cl->len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight);
+ pen[1] = -2 + (((line_len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight);
}
/* cursor */
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 7efcbcceb3c..d3ae5373a18 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -39,6 +39,7 @@
#include "BLI_string.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "BKE_context.h"
#include "BKE_text.h" /* only for character utility funcs */
@@ -449,7 +450,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
memmove(ci->line + len, ci->line, ci->len);
memset(ci->line, ' ', len);
ci->len += len;
+ BLI_assert(ci->len >= 0);
console_line_cursor_set(ci, ci->cursor + len);
+ console_select_offset(sc, len);
console_textview_update_rect(sc, ar);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -495,9 +498,10 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
memmove(ci->line, ci->line + len, (ci->len - len) + 1);
ci->len -= len;
- console_line_cursor_set(ci, ci->cursor - len);
+ BLI_assert(ci->len >= 0);
- //console_select_offset(sc, -4);
+ console_line_cursor_set(ci, ci->cursor - len);
+ console_select_offset(sc, -len);
console_textview_update_rect(sc, ar);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -554,6 +558,7 @@ static int console_delete_exec(bContext *C, wmOperator *op)
if (stride) {
memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1);
ci->len -= stride;
+ BLI_assert(ci->len >= 0);
done = TRUE;
}
}
@@ -570,6 +575,7 @@ static int console_delete_exec(bContext *C, wmOperator *op)
ci->cursor -= stride; /* same as above */
memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1);
ci->len -= stride;
+ BLI_assert(ci->len >= 0);
done = TRUE;
}
}
@@ -580,7 +586,7 @@ static int console_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else {
- console_select_offset(sc, -1);
+ console_select_offset(sc, -stride);
}
console_textview_update_rect(sc, ar);
@@ -650,7 +656,7 @@ static int console_clear_exec(bContext *C, wmOperator *op)
short scrollback = RNA_boolean_get(op->ptr, "scrollback");
short history = RNA_boolean_get(op->ptr, "history");
- /*ConsoleLine *ci= */ console_history_verify(C);
+ /*ConsoleLine *ci = */ console_history_verify(C);
if (scrollback) { /* last item in mistory */
while (sc->scrollback.first)
@@ -803,7 +809,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot)
ot->poll = ED_operator_console_active;
/* properties */
- RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position");
+ RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position");
RNA_def_int(ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000);
RNA_def_boolean(ot->srna, "remove_duplicates", 0, "Remove Duplicates", "Remove duplicate items in the history");
}
@@ -904,8 +910,8 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
for (cl = sc->scrollback.first; cl; cl = cl->next) {
if (sel[0] <= cl->len && sel[1] >= 0) {
- int sta = MAX2(sel[0], 0);
- int end = MIN2(sel[1], cl->len);
+ int sta = max_ii(sel[0], 0);
+ int end = min_ii(sel[1], cl->len);
if (BLI_dynstr_get_len(buf_dyn))
BLI_dynstr_append(buf_dyn, "\n");
@@ -1050,7 +1056,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *eve
static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op)
{
-// SpaceConsole *sc= CTX_wm_space_console(C);
+// SpaceConsole *sc = CTX_wm_space_console(C);
SetConsoleCursor *scu = op->customdata;
#if 0
@@ -1067,7 +1073,7 @@ static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op)
static int console_modal_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceConsole *sc = CTX_wm_space_console(C);
-// ARegion *ar= CTX_wm_region(C);
+// ARegion *ar = CTX_wm_region(C);
SetConsoleCursor *scu;
op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor");
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index d8d71d72382..4fc9b281854 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -91,7 +91,7 @@ static SpaceLink *console_new(const bContext *UNUSED(C))
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
+ //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
return (SpaceLink *)sconsole;
}
@@ -162,7 +162,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
{
-// SpaceConsole *sc= CTX_wm_space_console(C);
+// SpaceConsole *sc = CTX_wm_space_console(C);
if (drag->type == WM_DRAG_ID)
return 1;
return 0;
@@ -184,7 +184,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
{
-// SpaceConsole *sc= CTX_wm_space_console(C);
+ // SpaceConsole *sc = CTX_wm_space_console(C);
if (drag->type == WM_DRAG_PATH)
return 1;
return 0;
@@ -359,7 +359,7 @@ static void console_header_area_draw(const bContext *C, ARegion *ar)
static void console_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
- // SpaceInfo *sinfo= sa->spacedata.first;
+ // SpaceInfo *sinfo = sa->spacedata.first;
/* context changes */
switch (wmn->category) {
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 7b07aa0099a..8ad1dc23254 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -259,21 +259,23 @@ static int get_file_icon(struct direntry *file)
else if (file->flags & BLENDERFILE)
return ICON_FILE_BLEND;
else if (file->flags & BLENDERFILE_BACKUP)
- return ICON_FILE_BLEND;
+ return ICON_FILE_BACKUP;
else if (file->flags & IMAGEFILE)
return ICON_FILE_IMAGE;
else if (file->flags & MOVIEFILE)
return ICON_FILE_MOVIE;
else if (file->flags & PYSCRIPTFILE)
return ICON_FILE_SCRIPT;
- else if (file->flags & SOUNDFILE)
+ else if (file->flags & SOUNDFILE)
return ICON_FILE_SOUND;
- else if (file->flags & FTFONTFILE)
+ else if (file->flags & FTFONTFILE)
return ICON_FILE_FONT;
- else if (file->flags & BTXFILE)
+ else if (file->flags & BTXFILE)
return ICON_FILE_BLANK;
- else if (file->flags & COLLADAFILE)
+ else if (file->flags & COLLADAFILE)
return ICON_FILE_BLANK;
+ else if (file->flags & TEXTFILE)
+ return ICON_FILE_TEXT;
else
return ICON_FILE_BLANK;
}
@@ -282,7 +284,7 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon,
{
uiBut *but;
int x, y;
- /*float alpha=1.0f;*/
+ // float alpha = 1.0f;
x = sx;
y = sy - height;
@@ -500,7 +502,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
sx += (int)(v2d->tot.xmin + 2.0f);
sy = (int)(v2d->tot.ymax - sy);
- file = filelist_file(files, i);
+ file = filelist_file(files, i);
UI_ThemeColor4(TH_TEXT);
@@ -550,7 +552,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
if (params->display == FILE_SHORTDISPLAY) {
sx += (int)layout->column_widths[COLUMN_NAME] + 12;
if (!(file->type & S_IFDIR)) {
- file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
+ file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
sx += (int)layout->column_widths[COLUMN_SIZE] + 12;
}
}
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index fcbeb064e4d..763b18788de 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -307,7 +307,7 @@ void FILE_OT_select_border(wmOperatorType *ot)
ot->poll = ED_operator_file_active;
ot->cancel = WM_border_select_cancel;
- /* rna */
+ /* properties */
WM_operator_properties_gesture_border(ot, 1);
}
@@ -347,6 +347,8 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
void FILE_OT_select(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Activate/Select File";
ot->description = "Activate/select file";
@@ -356,10 +358,13 @@ void FILE_OT_select(wmOperatorType *ot)
ot->invoke = file_select_invoke;
ot->poll = ED_operator_file_active;
- /* rna */
- RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
- RNA_def_boolean(ot->srna, "fill", FALSE, "Fill", "Select everything beginning with the last selection");
- RNA_def_boolean(ot->srna, "open", TRUE, "Open", "Open a directory when selecting it");
+ /* properties */
+ prop = RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "fill", FALSE, "Fill", "Select everything beginning with the last selection");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "open", TRUE, "Open", "Open a directory when selecting it");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
@@ -404,9 +409,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot)
ot->exec = file_select_all_exec;
ot->poll = ED_operator_file_active;
- /* rna */
-
-
+ /* properties */
}
/* ---------- BOOKMARKS ----------- */
@@ -432,6 +435,8 @@ static int bookmark_select_exec(bContext *C, wmOperator *op)
void FILE_OT_select_bookmark(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Select Directory";
ot->description = "Select a bookmarked directory";
@@ -441,7 +446,9 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
ot->exec = bookmark_select_exec;
ot->poll = ED_operator_file_active;
- RNA_def_string(ot->srna, "dir", "", 256, "Dir", "");
+ /* properties */
+ prop = RNA_def_string(ot->srna, "dir", "", FILE_MAXDIR, "Dir", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -498,6 +505,8 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op)
void FILE_OT_delete_bookmark(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Delete Bookmark";
ot->description = "Delete selected bookmark";
@@ -507,7 +516,9 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot)
ot->exec = bookmark_delete_exec;
ot->poll = ED_operator_file_active;
- RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000);
+ /* properties */
+ prop = RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
@@ -543,7 +554,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
{
View2D *v2d = &ar->v2d;
FileSelectParams *params;
- int numfiles, origfile;
+ int numfiles, origfile;
if (sfile == NULL || sfile->files == NULL) return 0;
@@ -819,7 +830,8 @@ void FILE_OT_execute(struct wmOperatorType *ot)
/* api callbacks */
ot->exec = file_exec;
ot->poll = file_operator_poll;
-
+
+ /* properties */
prop = RNA_def_boolean(ot->srna, "need_active", 0, "Need Active",
"Only execute if there's an active selected file in the file list");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -837,7 +849,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
file_change_dir(C, 0);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
- }
+ }
return OPERATOR_FINISHED;
@@ -930,7 +942,7 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
file_change_dir(C, 1);
- }
+ }
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
return OPERATOR_FINISHED;
@@ -1093,7 +1105,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
if (generate_name) {
/* create a new, non-existing folder name */
if (!new_folder_path(sfile->params->dir, path, name)) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't create new folder name");
+ BKE_report(op->reports, RPT_ERROR, "Could not create new folder name");
return OPERATOR_CANCELLED;
}
}
@@ -1102,9 +1114,9 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
BLI_dir_create_recursive(path);
if (!BLI_exists(path)) {
- BKE_report(op->reports, RPT_ERROR, "Couldn't create new folder");
+ BKE_report(op->reports, RPT_ERROR, "Could not create new folder");
return OPERATOR_CANCELLED;
- }
+ }
/* now remember file to jump into editing */
BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE);
@@ -1123,6 +1135,8 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
void FILE_OT_directory_new(struct wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Create New Directory";
ot->description = "Create a new directory";
@@ -1133,7 +1147,8 @@ void FILE_OT_directory_new(struct wmOperatorType *ot)
ot->exec = file_directory_new_exec;
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
- RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Name of new directory");
+ prop = RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Name of new directory");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -1412,11 +1427,11 @@ static int file_rename_poll(bContext *C)
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile && sfile->params) {
- if (sfile->params->active_file < 0) {
+ if (sfile->params->active_file < 0) {
poll = 0;
}
else {
- char dir[FILE_MAX], group[FILE_MAX];
+ char dir[FILE_MAX], group[FILE_MAX];
if (filelist_islibrary(sfile->files, dir, group)) poll = 0;
}
}
@@ -1445,11 +1460,11 @@ static int file_delete_poll(bContext *C)
struct direntry *file;
if (sfile && sfile->params) {
- if (sfile->params->active_file < 0) {
+ if (sfile->params->active_file < 0) {
poll = 0;
}
else {
- char dir[FILE_MAX], group[FILE_MAX];
+ char dir[FILE_MAX], group[FILE_MAX];
if (filelist_islibrary(sfile->files, dir, group)) poll = 0;
file = filelist_file(sfile->files, sfile->params->active_file);
if (file && S_ISDIR(file->type)) poll = 0;
@@ -1470,7 +1485,7 @@ int file_delete_exec(bContext *C, wmOperator *UNUSED(op))
file = filelist_file(sfile->files, sfile->params->active_file);
BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname);
- BLI_delete(str, 0, 0);
+ BLI_delete(str, 0, 0);
ED_fileselect_clear(C, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index a7054909aaa..a159c88221e 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -135,6 +135,16 @@ static void file_panel_system(const bContext *C, Panel *pa)
file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0);
}
+static void file_panel_system_bookmarks(const bContext *C, Panel *pa)
+{
+ SpaceFile *sfile = CTX_wm_space_file(C);
+
+ if (sfile && !(U.uiflag & USER_HIDE_SYSTEM_BOOKMARKS) ) {
+ file_panel_category(C, pa, FS_CATEGORY_SYSTEM_BOOKMARKS, &sfile->systemnr, ICON_BOOKMARKS, 0);
+ }
+
+}
+
static void file_panel_bookmarks(const bContext *C, Panel *pa)
{
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -193,7 +203,7 @@ static void file_panel_operator(const bContext *C, Panel *pa)
{
SpaceFile *sfile = CTX_wm_space_file(C);
wmOperator *op = sfile->op;
- // int empty= 1, flag;
+ // int empty = 1, flag;
uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
@@ -212,6 +222,12 @@ void file_panels_register(ARegionType *art)
pt->draw = file_panel_system;
BLI_addtail(&art->paneltypes, pt);
+ pt = MEM_callocN(sizeof(PanelType), "spacetype file system bookmarks");
+ strcpy(pt->idname, "FILE_PT_system_bookmarks");
+ strcpy(pt->label, N_("System Bookmarks"));
+ pt->draw = file_panel_system_bookmarks;
+ BLI_addtail(&art->paneltypes, pt);
+
pt = MEM_callocN(sizeof(PanelType), "spacetype file bookmarks");
strcpy(pt->idname, "FILE_PT_bookmarks");
strcpy(pt->label, N_("Bookmarks"));
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index d3b4df05aa9..a49b75477e4 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -143,7 +143,8 @@ typedef struct FolderList {
#define SPECIAL_IMG_FONTFILE 8
#define SPECIAL_IMG_UNKNOWNFILE 9
#define SPECIAL_IMG_LOADING 10
-#define SPECIAL_IMG_MAX SPECIAL_IMG_LOADING + 1
+#define SPECIAL_IMG_BACKUP 11
+#define SPECIAL_IMG_MAX SPECIAL_IMG_BACKUP + 1
static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX];
@@ -300,7 +301,7 @@ static int is_hidden_file(const char *filename, short hide_dot)
if ( (len > 0) && (filename[len - 1] == '~') ) {
is_hidden = 1; /* ignore file~ */
}
- }
+ }
}
else {
if (((filename[0] == '.') && (filename[1] == 0) )) {
@@ -360,7 +361,7 @@ void filelist_filter(FileList *filelist)
struct direntry *file = &filelist->filelist[i];
if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) {
num_filtered++;
- }
+ }
}
if (filelist->fidx) {
@@ -420,7 +421,7 @@ void filelist_free_icons(void)
}
}
-//-----------------FOLDERLIST (previous/next) --------------//
+/* -----------------FOLDERLIST (previous/next) -------------- */
ListBase *folderlist_new(void)
{
ListBase *p = MEM_callocN(sizeof(ListBase), "folderlist");
@@ -520,7 +521,7 @@ static void filelist_read_main(struct FileList *filelist);
static void filelist_read_library(struct FileList *filelist);
static void filelist_read_dir(struct FileList *filelist);
-//------------------FILELIST------------------------//
+/* ------------------FILELIST------------------------ */
FileList *filelist_new(short type)
{
FileList *p = MEM_callocN(sizeof(FileList), "filelist");
@@ -557,7 +558,7 @@ void filelist_free(struct FileList *filelist)
}
for (i = 0; i < filelist->numfiles; ++i) {
- if (filelist->filelist[i].image) {
+ if (filelist->filelist[i].image) {
IMB_freeImBuf(filelist->filelist[i].image);
}
filelist->filelist[i].image = NULL;
@@ -573,7 +574,7 @@ void filelist_free(struct FileList *filelist)
filelist->numfiles = 0;
free(filelist->filelist);
- filelist->filelist = NULL;
+ filelist->filelist = NULL;
filelist->filter = 0;
filelist->filter_glob[0] = '\0';
filelist->numfiltered = 0;
@@ -683,6 +684,9 @@ ImBuf *filelist_geticon(struct FileList *filelist, int index)
else if (file->flags & IMAGEFILE) {
ibuf = gSpecialFileImages[SPECIAL_IMG_LOADING];
}
+ else if (file->flags & BLENDERFILE_BACKUP) {
+ ibuf = gSpecialFileImages[SPECIAL_IMG_BACKUP];
+ }
return ibuf;
}
@@ -740,6 +744,7 @@ void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob
BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob));
}
+/* would recognize .blend as well */
static int file_is_blend_backup(const char *str)
{
short a, b;
@@ -748,7 +753,9 @@ static int file_is_blend_backup(const char *str)
a = strlen(str);
b = 7;
- if (a == 0 || b >= a) ;
+ if (a == 0 || b >= a) {
+ /* pass */
+ }
else {
char *loc;
@@ -779,6 +786,7 @@ static int file_extension_type(const char *relname)
}
else if (BLI_testextensie(relname, ".txt") ||
BLI_testextensie(relname, ".glsl") ||
+ BLI_testextensie(relname, ".osl") ||
BLI_testextensie(relname, ".data"))
{
return TEXTFILE;
@@ -789,7 +797,7 @@ static int file_extension_type(const char *relname)
BLI_testextensie(relname, ".otf") ||
BLI_testextensie(relname, ".otc"))
{
- return FTFONTFILE;
+ return FTFONTFILE;
}
else if (BLI_testextensie(relname, ".btx")) {
return BTXFILE;
@@ -800,14 +808,14 @@ static int file_extension_type(const char *relname)
else if (BLI_testextensie_array(relname, imb_ext_image) ||
(G.have_quicktime && BLI_testextensie_array(relname, imb_ext_image_qt)))
{
- return IMAGEFILE;
+ return IMAGEFILE;
}
else if (BLI_testextensie_array(relname, imb_ext_movie)) {
- return MOVIEFILE;
+ return MOVIEFILE;
}
else if (BLI_testextensie_array(relname, imb_ext_audio)) {
return SOUNDFILE;
- }
+ }
return 0;
}
@@ -815,8 +823,10 @@ int ED_file_extension_icon(const char *relname)
{
int type = file_extension_type(relname);
- if (type == BLENDERFILE || type == BLENDERFILE_BACKUP)
+ if (type == BLENDERFILE)
return ICON_FILE_BLEND;
+ else if (type == BLENDERFILE_BACKUP)
+ return ICON_FILE_BACKUP;
else if (type == IMAGEFILE)
return ICON_FILE_IMAGE;
else if (type == MOVIEFILE)
@@ -831,6 +841,8 @@ int ED_file_extension_icon(const char *relname)
return ICON_FILE_BLANK;
else if (type == COLLADAFILE)
return ICON_FILE_BLANK;
+ else if (type == TEXTFILE)
+ return ICON_FILE_TEXT;
return ICON_FILE_BLANK;
}
@@ -932,7 +944,7 @@ void filelist_parent(struct FileList *filelist)
void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check)
{
struct direntry *file = filelist_file(filelist, index);
- if (file != NULL) {
+ if (file != NULL) {
int check_ok = 0;
switch (check) {
case CHECK_DIRS:
@@ -967,7 +979,7 @@ void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType
/* select all valid files between first and last indicated */
if ( (sel->first >= 0) && (sel->first < filelist->numfiltered) && (sel->last >= 0) && (sel->last < filelist->numfiltered) ) {
int current_file;
- for (current_file = sel->first; current_file <= sel->last; current_file++) {
+ for (current_file = sel->first; current_file <= sel->last; current_file++) {
filelist_select_file(filelist, current_file, select, flag, check);
}
}
@@ -1034,7 +1046,7 @@ void filelist_from_library(struct FileList *filelist)
struct ImBuf *ima;
int ok, i, nprevs, nnames, idcode;
char filename[FILE_MAX];
- char dir[FILE_MAX], group[GROUP_MAX];
+ char dir[FILE_MAX], group[GROUP_MAX];
/* name test */
ok = filelist_islibrary(filelist, dir, group);
@@ -1223,21 +1235,22 @@ void filelist_from_main(struct FileList *filelist)
if (ok) {
if (!filelist->hide_dot || id->name[2] != '.') {
memset(files, 0, sizeof(struct direntry));
- if (id->lib == NULL)
+ if (id->lib == NULL) {
files->relname = BLI_strdup(id->name + 2);
+ }
else {
- files->relname = MEM_mallocN(FILE_MAX + 32, "filename for lib");
- sprintf(files->relname, "%s | %s", id->lib->name, id->name + 2);
+ files->relname = MEM_mallocN(FILE_MAX + (MAX_ID_NAME - 2), "filename for lib");
+ BLI_snprintf(files->relname, FILE_MAX + (MAX_ID_NAME - 2) + 3, "%s | %s", id->lib->name, id->name + 2);
}
files->type |= S_IFREG;
-#if 0 // XXXXX TODO show the selection status of the objects
+#if 0 /* XXXXX TODO show the selection status of the objects */
if (!filelist->has_func) { /* F4 DATA BROWSE */
if (idcode == ID_OB) {
if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE;
}
else if (idcode == ID_SCE) {
if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE;
- }
+ }
}
#endif
files->nr = totbl + 1;
@@ -1246,10 +1259,10 @@ void filelist_from_main(struct FileList *filelist)
if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) {
files->flags |= IMAGEFILE;
}
- if (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us);
- else if (id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us);
- else if (fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us);
- else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us);
+ if (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us);
+ else if (id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us);
+ else if (fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us);
+ else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us);
if (id->lib) {
if (totlib == 0) firstlib = files;
@@ -1298,7 +1311,7 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float
if (limg->flags & IMAGEFILE) {
limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE);
}
- else if (limg->flags & BLENDERFILE) {
+ else if (limg->flags & (BLENDERFILE | BLENDERFILE_BACKUP)) {
limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND);
}
else if (limg->flags & MOVIEFILE) {
@@ -1355,7 +1368,7 @@ void thumbnails_start(struct FileList *filelist, const struct bContext *C)
tj->filelist = filelist;
for (idx = 0; idx < filelist->numfiles; idx++) {
if (!filelist->filelist[idx].image) {
- if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE)) ) {
+ if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE | BLENDERFILE_BACKUP)) ) {
FileImage *limg = MEM_callocN(sizeof(struct FileImage), "loadimage");
BLI_strncpy(limg->path, filelist->filelist[idx].path, FILE_MAX);
limg->index = idx;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 1fa89e5db9a..778a3f4df3e 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -94,6 +94,9 @@ FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile)
return sfile->params;
}
+/**
+ * \note RNA_struct_property_is_set_ex is used here because we wan't
+ * the previously used settings to be used here rather then overriding them */
short ED_fileselect_set_params(SpaceFile *sfile)
{
FileSelectParams *params;
@@ -124,7 +127,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
else
params->type = FILE_SPECIAL;
- if (is_filepath && RNA_struct_property_is_set(op->ptr, "filepath")) {
+ if (is_filepath && RNA_struct_property_is_set_ex(op->ptr, "filepath", FALSE)) {
char name[FILE_MAX];
RNA_string_get(op->ptr, "filepath", name);
if (params->type == FILE_LOADLIB) {
@@ -136,12 +139,12 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
}
else {
- if (is_directory && RNA_struct_property_is_set(op->ptr, "directory")) {
+ if (is_directory && RNA_struct_property_is_set_ex(op->ptr, "directory", FALSE)) {
RNA_string_get(op->ptr, "directory", params->dir);
sfile->params->file[0] = '\0';
}
- if (is_filename && RNA_struct_property_is_set(op->ptr, "filename")) {
+ if (is_filename && RNA_struct_property_is_set_ex(op->ptr, "filename", FALSE)) {
RNA_string_get(op->ptr, "filename", params->file);
}
}
@@ -161,12 +164,12 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->filter = 0;
if (RNA_struct_find_property(op->ptr, "filter_blender"))
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
+ if (RNA_struct_find_property(op->ptr, "filter_backup"))
+ params->filter |= RNA_boolean_get(op->ptr, "filter_backup") ? BLENDERFILE_BACKUP : 0;
if (RNA_struct_find_property(op->ptr, "filter_image"))
params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0;
if (RNA_struct_find_property(op->ptr, "filter_movie"))
params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0;
- if (RNA_struct_find_property(op->ptr, "filter_text"))
- params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0;
if (RNA_struct_find_property(op->ptr, "filter_python"))
params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0;
if (RNA_struct_find_property(op->ptr, "filter_font"))
@@ -228,7 +231,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
if (is_relative_path) {
- if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
+ if (!RNA_struct_property_is_set_ex(op->ptr, "relative_path", FALSE)) {
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
}
}
@@ -307,7 +310,7 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
CLAMP(rowmin, 0, layout->rows - 1);
CLAMP(colmax, 0, layout->columns - 1);
CLAMP(rowmax, 0, layout->rows - 1);
- }
+ }
if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) {
sel.first = -1;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index a1b467bf79d..37ec527e88e 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -80,9 +80,9 @@ struct _FSMenuEntry {
typedef struct FSMenu {
FSMenuEntry *fsmenu_system;
+ FSMenuEntry *fsmenu_system_bookmarks;
FSMenuEntry *fsmenu_bookmarks;
FSMenuEntry *fsmenu_recent;
-
} FSMenu;
static FSMenu *g_fsmenu = NULL;
@@ -103,6 +103,9 @@ static FSMenuEntry *fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory ca
case FS_CATEGORY_SYSTEM:
fsm_head = fsmenu->fsmenu_system;
break;
+ case FS_CATEGORY_SYSTEM_BOOKMARKS:
+ fsm_head = fsmenu->fsmenu_system_bookmarks;
+ break;
case FS_CATEGORY_BOOKMARKS:
fsm_head = fsmenu->fsmenu_bookmarks;
break;
@@ -119,6 +122,9 @@ static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category,
case FS_CATEGORY_SYSTEM:
fsmenu->fsmenu_system = fsm_head;
break;
+ case FS_CATEGORY_SYSTEM_BOOKMARKS:
+ fsmenu->fsmenu_system_bookmarks = fsm_head;
+ break;
case FS_CATEGORY_BOOKMARKS:
fsmenu->fsmenu_bookmarks = fsm_head;
break;
@@ -336,9 +342,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
/* Adding Desktop and My Documents */
if (read_bookmarks) {
SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
#else
@@ -371,26 +377,26 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
home = getenv("HOME");
if (read_bookmarks && home) {
BLI_snprintf(line, 256, "%s/", home);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
BLI_snprintf(line, 256, "%s/Desktop/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Documents/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Pictures/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Music/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Movies/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
#else
@@ -450,7 +456,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
FSRefMakePath(&dir, path, FILE_MAX);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
+ if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) {
+ /* /net and /home are meaningless on OSX, home folders are stored in /Users */
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
+ }
}
/* Finally get user favorite places */
@@ -473,7 +482,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
continue;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
CFRelease(pathString);
CFRelease(cfURL);
@@ -491,10 +500,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (read_bookmarks && home) {
BLI_snprintf(line, FILE_MAXDIR, "%s/", home);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
@@ -565,13 +574,17 @@ void fsmenu_refresh_system_category(struct FSMenu *fsmenu)
fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM, NULL);
+ fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
+ fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, NULL);
+
/* Add all entries to system category */
- fsmenu_read_system(fsmenu, FALSE);
+ fsmenu_read_system(fsmenu, TRUE);
}
void fsmenu_free(struct FSMenu *fsmenu)
{
fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
+ fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
fsmenu_free_category(fsmenu, FS_CATEGORY_BOOKMARKS);
fsmenu_free_category(fsmenu, FS_CATEGORY_RECENT);
MEM_freeN(fsmenu);
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index 30730578085..1b69eb09fce 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -39,6 +39,7 @@
typedef enum FSMenuCategory {
FS_CATEGORY_SYSTEM,
+ FS_CATEGORY_SYSTEM_BOOKMARKS,
FS_CATEGORY_BOOKMARKS,
FS_CATEGORY_RECENT
} FSMenuCategory;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 1b8b7d4c523..b5f7b92d09b 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -198,7 +198,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa))
params->active_file = -1; // added this so it opens nicer (ton)
}
filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT);
- filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0);
+ filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0);
filelist_setfilter_types(sfile->files, params->filter_glob);
if (filelist_empty(sfile->files)) {
@@ -480,7 +480,7 @@ static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
ED_region_panels_init(wm, ar);
/* own keymaps */
- keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
+ keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
@@ -504,7 +504,7 @@ static void file_header_area_init(wmWindowManager *wm, ARegion *ar)
ED_region_header_init(ar);
- keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
+ keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
@@ -596,7 +596,7 @@ void ED_spacetype_file(void)
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
art->init = file_header_area_init;
art->draw = file_header_area_draw;
- // art->listener= file_header_area_listener;
+ // art->listener = file_header_area_listener;
BLI_addhead(&st->regiontypes, art);
/* regions: ui */
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 0d56b02e086..8bb57a32090 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -77,7 +77,7 @@
static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int event)
{
- //Scene *scene= CTX_data_scene(C);
+ //Scene *scene = CTX_data_scene(C);
switch (event) {
@@ -148,6 +148,7 @@ static void graph_panel_view(const bContext *C, Panel *pa)
row = uiLayoutSplit(sub, 0.7f, TRUE);
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
+
row = uiLayoutSplit(sub, 0.7f, TRUE);
uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
@@ -298,7 +299,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
if (RNA_path_resolve(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop) && fcu_prop) {
/* determine the unit for this property */
unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
- }
+ }
/* interpolation */
col = uiLayoutColumn(layout, FALSE);
@@ -308,44 +309,43 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
* - we use the button-versions of the calls so that we can attach special update handlers
* and unit conversion magic that cannot be achieved using a purely RNA-approach
*/
- // XXX:
col = uiLayoutColumn(layout, TRUE);
/* keyframe itself */
{
uiItemL(col, IFACE_("Key:"), ICON_NONE);
-
+
but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
-
+
but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
uiButSetUnitType(but, unit);
}
-
+
/* previous handle - only if previous was Bezier interpolation */
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
-
+
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
-
+
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
uiButSetUnitType(but, unit);
}
-
+
/* next handle - only if current is Bezier interpolation */
if (bezt->ipo == BEZT_IPO_BEZ) {
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
-
+
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
-
+
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
@@ -407,7 +407,7 @@ static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg))
if (ELEM(NULL, id, fcu))
return;
- /* call API method to remove this driver */
+ /* call API method to remove this driver */
ANIM_remove_driver(reports, id, fcu->rna_path, fcu->array_index, 0);
}
@@ -437,7 +437,7 @@ static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSE
ChannelDriver *driver = fcu->driver;
/* clear invalid flags */
- fcu->flag &= ~FCURVE_DISABLED; // XXX?
+ fcu->flag &= ~FCURVE_DISABLED;
driver->flag &= ~DRIVER_FLAG_INVALID;
}
@@ -467,7 +467,6 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
/* Target Property */
- // TODO: make this less technical...
if (dtar->id) {
PointerRNA root_ptr;
@@ -630,12 +629,12 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* errors? */
if (driver->flag & DRIVER_FLAG_INVALID)
- uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
+ uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_ERROR);
}
else {
/* errors? */
if (driver->flag & DRIVER_FLAG_INVALID)
- uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
+ uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
}
col = uiLayoutColumn(pa->layout, TRUE);
@@ -706,15 +705,15 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
graph_panel_driverVar__transChan(box, ale->id, dvar);
break;
}
-
+
/* value of variable */
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
char valBuf[32];
-
+
box = uiLayoutBox(col);
row = uiLayoutRow(box, TRUE);
uiItemL(row, IFACE_("Value:"), ICON_NONE);
-
+
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
uiItemL(row, valBuf, ICON_NONE);
}
@@ -724,8 +723,8 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
MEM_freeN(ale);
}
-/* ******************* f-modifiers ******************************** */
-/* all the drawing code is in editors/animation/fmodifier_ui.c */
+/* ******************* F-Modifiers ******************************** */
+/* All the drawing code is in editors/animation/fmodifier_ui.c */
#define B_FMODIFIER_REDRAW 20
@@ -757,7 +756,9 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
row = uiLayoutRow(pa->layout, FALSE);
block = uiLayoutGetBlock(row);
- // XXX for now, this will be a operator button which calls a 'add modifier' operator
+ /* this is an operator button which calls a 'add modifier' operator...
+ * a menu might be nicer but would be tricky as we need some custom filtering
+ */
uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"),
10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve"));
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 442253d3c70..096e9ee1116 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -84,7 +84,7 @@ static float fcurve_display_alpha(FCurve *fcu)
/* Envelope -------------- */
-// TODO: draw a shaded poly showing the region of influence too!!!
+/* TODO: draw a shaded poly showing the region of influence too!!! */
static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
@@ -102,13 +102,13 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
gpuVertex2f(v2d->cur.xmin, env->midval + env->max);
gpuVertex2f(v2d->cur.xmax, env->midval + env->max);
- gpuEnd(); // GL_LINES
+ gpuEnd(); /* GL_LINES */
setlinestyle(0);
/* set size of vertices (non-adjustable for now) */
glPointSize(2.0f);
- // for now, point color is fixed, and is white
+ /* for now, point color is fixed, and is white */
gpuCurrentColor3x(CPACK_WHITE);
/* we use bgl points not standard gl points, to workaround vertex
@@ -161,7 +161,7 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
}
else {
/* no check for selection here, as curve is not editable... */
- // XXX perhaps we don't want to even draw points? maybe add an option for that later
+ /* XXX perhaps we don't want to even draw points? maybe add an option for that later */
gpuSprite3fv(bezt->vec[1]);
}
}
@@ -246,7 +246,7 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel)
/* Curve's points ARE BEING edited */
if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset);
else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset);
- }
+ }
else {
/* Curve's points CANNOT BE edited */
if (sel) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, alphaOffset);
@@ -302,7 +302,7 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
)
{
return 0;
- }
+ }
else {
return 1;
}
@@ -388,7 +388,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
}
}
- gpuEnd(); // GL_LINES
+ gpuEnd(); /* GL_LINES */
}
/* Samples ---------------- */
@@ -410,7 +410,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc
gpuVertex2f(-0.7f, +0.7f);
gpuVertex2f(+0.7f, -0.7f);
- gpuEnd(); // GL_LINES
+ gpuEnd(); /* GL_LINES */
/* restore view transform */
gpuScale(xscale / hsize, yscale / hsize, 1.0);
@@ -487,7 +487,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
* chosen here is just the coarsest value which still looks reasonable...
*/
/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
- // TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted?
+ /* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */
samplefreq = dx / U.v2d_min_gridsize;
if (samplefreq < 0.00001f) samplefreq = 0.00001f;
@@ -533,7 +533,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
v[1] = prevfpt->vec[1];
- }
+ }
else {
/* extrapolate linear dosnt use the handle, use the next points center instead */
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
@@ -571,7 +571,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
/* based on last keyframe's value */
v[1] = prevfpt->vec[1];
- }
+ }
else {
/* extrapolate linear dosnt use the handle, use the previous points center instead */
fpt = prevfpt - 1;
@@ -614,13 +614,13 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
v1[1] = prevbezt->vec[1][1];
- }
+ }
else if (prevbezt->ipo == BEZT_IPO_LIN) {
/* extrapolate linear dosnt use the handle, use the next points center instead */
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
if (fac) fac = 1.0f / fac;
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
- }
+ }
else {
/* based on angle of handle 1 (relative to keyframe) */
fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
@@ -639,7 +639,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
}
/* draw curve between first and last keyframe (if there are enough to do so) */
- // TODO: optimize this to not have to calc stuff out of view too?
+ /* TODO: optimize this to not have to calc stuff out of view too? */
while (b--) {
if (prevbezt->ipo == BEZT_IPO_CONST) {
/* Constant-Interpolation: draw segment between previous keyframe and next, but holding same value */
@@ -663,7 +663,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
*/
/* resol depends on distance between points (not just horizontal) OR is a fixed high res */
- // TODO: view scale should factor into this someday too...
+ /* TODO: view scale should factor into this someday too... */
if (fcu->driver)
resol = 32;
else
@@ -677,7 +677,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
}
else {
/* clamp resolution to max of 32 */
- // NOTE: higher values will crash
+ /* NOTE: higher values will crash */
if (resol > 32) resol = 32;
v1[0] = prevbezt->vec[1][0];
@@ -720,14 +720,14 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
/* based on last keyframe's value */
v1[1] = prevbezt->vec[1][1];
- }
+ }
else if (prevbezt->ipo == BEZT_IPO_LIN) {
/* extrapolate linear dosnt use the handle, use the previous points center instead */
bezt = prevbezt - 1;
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
if (fac) fac = 1.0f / fac;
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
- }
+ }
else {
/* based on angle of handle 1 (relative to keyframe) */
fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
@@ -824,7 +824,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
}
if (((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) || (fcu->flag & FCURVE_MUTED)) {
/* muted curves are drawn in a grayish hue */
- // XXX should we have some variations?
+ /* XXX should we have some variations? */
UI_ThemeColorShade(TH_HEADER, 50);
}
else {
@@ -943,7 +943,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
height = (float)((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2));
UI_view2d_totRect_set(v2d, ar->winx, height);
- /* loop through channels, and set up drawing depending on their type */
+ /* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
y = (float)ACHANNEL_FIRST;
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 7107a6a2369..453549ebf79 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -332,7 +332,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
ChannelDriver *driver = fcu->driver;
FPoint *fpt;
float unitFac;
- int cfra;
+ int cfra;
/* disable driver so that it don't muck up the sampling process */
fcu->driver = NULL;
@@ -724,7 +724,7 @@ static int graphkeys_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* copy keyframes */
- if (copy_graph_keys(&ac)) {
+ if (copy_graph_keys(&ac)) {
BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer");
return OPERATOR_CANCELLED;
}
@@ -1143,9 +1143,9 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
RNA_float_get(op->ptr, "attack"),
RNA_float_get(op->ptr, "release"),
RNA_float_get(op->ptr, "threshold"),
- RNA_boolean_get(op->ptr, "accumulate"),
+ RNA_boolean_get(op->ptr, "use_accumulate"),
RNA_boolean_get(op->ptr, "use_additive"),
- RNA_boolean_get(op->ptr, "square"),
+ RNA_boolean_get(op->ptr, "use_square"),
RNA_float_get(op->ptr, "sthreshold"),
FPS, &sbi.length);
@@ -1225,15 +1225,27 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot)
/* properties */
WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE,
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
- RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00);
- RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00);
- RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1);
- RNA_def_float(ot->srna, "release", 0.2, 0.0, 5.0, "Release time", "", 0.01, 0.2);
- RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.01, 0.1);
- RNA_def_boolean(ot->srna, "accumulate", 0, "Accumulate", "");
- RNA_def_boolean(ot->srna, "use_additive", 0, "Additive", "");
- RNA_def_boolean(ot->srna, "square", 0, "Square", "");
- RNA_def_float(ot->srna, "sthreshold", 0.1, 0.0, 1.0, "Square Threshold", "", 0.01, 0.1);
+ RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency",
+ "Cutoff frequency of a high-pass filter that is applied to the audio data", 0.1, 1000.00);
+ RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency",
+ "Cutoff frequency of a low-pass filter that is applied to the audio data", 0.1, 1000.00);
+ RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time",
+ "Value for the hull curve calculation that tells how fast the hull curve can rise "
+ "(the lower the value the steeper it can rise)", 0.01, 0.1);
+ RNA_def_float(ot->srna, "release", 0.2, 0.0, 5.0, "Release time",
+ "Value for the hull curve calculation that tells how fast the hull curve can fall "
+ "(the lower the value the steeper it can fall)", 0.01, 0.2);
+ RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold",
+ "Minimum amplitude value needed to influence the hull curve", 0.01, 0.1);
+ RNA_def_boolean(ot->srna, "use_accumulate", 0, "Accumulate",
+ "Only the positive differences of the hull curve amplitudes are summarized to produce the output");
+ RNA_def_boolean(ot->srna, "use_additive", 0, "Additive",
+ "The amplitudes of the hull curve are summarized (or, when Accumulate is enabled, "
+ "both positive and negative differences are accumulated)");
+ RNA_def_boolean(ot->srna, "use_square", 0, "Square",
+ "The output is a square curve (negative values always result in -1, and positive ones in 1)");
+ RNA_def_float(ot->srna, "sthreshold", 0.1, 0.0, 1.0, "Square Threshold",
+ "Square only: all values with an absolute amplitude lower than that result in 0", 0.01, 0.1);
}
/* ******************** Sample Keyframes Operator *********************** */
@@ -1309,8 +1321,8 @@ void GRAPH_OT_sample(wmOperatorType *ot)
/* defines for set extrapolation-type for selected keyframes tool */
static EnumPropertyItem prop_graphkeys_expo_types[] = {
- {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", ""},
- {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", ""},
+ {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"},
+ {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"},
{MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"},
{CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"},
@@ -1614,7 +1626,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
else if (ELEM3(fcu->array_index, 0, 1, 2) == 0) {
BKE_reportf(op->reports, RPT_WARNING,
"Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)",
- (ale->id) ? ale->id->name : "<No ID>", fcu->rna_path, fcu->array_index);
+ (ale->id) ? ale->id->name : TIP_("<No ID>"), fcu->rna_path, fcu->array_index);
continue;
}
@@ -1711,13 +1723,16 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
/* updates + finishing warnings */
if (failed == groups) {
BKE_report(op->reports, RPT_ERROR,
- "No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected");
+ "No Euler Rotations could be corrected, ensure each rotation has keys for all components, "
+ "and that F-Curves for these are in consecutive XYZ order and selected");
return OPERATOR_CANCELLED;
}
else {
if (failed) {
BKE_report(op->reports, RPT_ERROR,
- "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected");
+ "Some Euler Rotations could not be corrected due to missing/unselected/out-of-order F-Curves, "
+ "ensure each rotation has keys for all components, and that F-Curves for these are in "
+ "consecutive XYZ order and selected");
}
/* validate keyframes after editing */
@@ -1808,9 +1823,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
void GRAPH_OT_frame_jump(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Jump to Frame";
+ ot->name = "Jump to Keyframes";
ot->idname = "GRAPH_OT_frame_jump";
- ot->description = "Set the current frame to the average frame of the selected keyframes";
+ ot->description = "Place the cursor on the midpoint of selected keyframes";
/* api callbacks */
ot->exec = graphkeys_framejump_exec;
@@ -1824,12 +1839,18 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot)
/* defines for snap keyframes tool */
static EnumPropertyItem prop_graphkeys_snap_types[] = {
- {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", ""},
- {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", ""},
- {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry?
- {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry?
- {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""},
- {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", ""},
+ {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame",
+ "Snap selected keyframes to the current frame"},
+ {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value",
+ "Set values of selected keyframes to the cursor value (Y/Horizontal component)"},
+ {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame",
+ "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame offsets)"},
+ {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second",
+ "Snap selected keyframes to the nearest second"},
+ {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker",
+ "Snap selected keyframes to the nearest marker"},
+ {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles",
+ "Flatten handles for a smoother transition"},
{0, NULL, 0, NULL, NULL}
};
@@ -1932,11 +1953,16 @@ void GRAPH_OT_snap(wmOperatorType *ot)
/* defines for mirror keyframes tool */
static EnumPropertyItem prop_graphkeys_mirror_types[] = {
- {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", ""},
- {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", ""},
- {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", ""},
- {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", ""},
- {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", ""},
+ {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame",
+ "Flip times of selected keyframes using the current frame as the mirror line"},
+ {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value",
+ "Flip values of selected keyframes using the cursor value (Y/Horizontal component) as the mirror line"},
+ {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0",
+ "Flip times of selected keyframes, effectively reversing the order they appear in"},
+ {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0",
+ "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"},
+ {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker",
+ "Flip times of selected keyframes using the first selected marker as the reference point"},
{0, NULL, 0, NULL, NULL}
};
@@ -2170,7 +2196,7 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
if (fcm)
set_active_fmodifier(&fcu->modifiers, fcm);
else {
- BKE_report(op->reports, RPT_ERROR, "Modifier couldn't be added, see console for details");
+ BKE_report(op->reports, RPT_ERROR, "Modifier could not be added (see console for details)");
break;
}
}
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index eb657169970..b2dbf764c1d 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -123,7 +123,7 @@ enum {
GRAPHKEYS_SNAP_CFRA = 1,
GRAPHKEYS_SNAP_NEAREST_FRAME,
GRAPHKEYS_SNAP_NEAREST_SECOND,
- GRAPHKEYS_SNAP_NEAREST_MARKER,
+ GRAPHKEYS_SNAP_NEAREST_MARKER,
GRAPHKEYS_SNAP_HORIZONTAL,
GRAPHKEYS_SNAP_VALUE,
} eGraphKeys_Snap_Mode;
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 08b13b49f55..9b031c015a9 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -346,9 +346,8 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* graph_edit.c */
- /* snap - current frame to selected keys */
- // TODO: maybe since this is called jump, we're better to have it on <something>-J?
- WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ /* jump to selected keyframes */
+ WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0);
/* menu + single-step transform */
WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index e2fc1657379..978b3224850 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -757,7 +757,7 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
if (leftright == GRAPHKEYS_LRSEL_LEFT) {
ked.f1 = MINAFRAMEF;
ked.f2 = (float)(CFRA + 0.1f);
- }
+ }
else {
ked.f1 = (float)(CFRA - 0.1f);
ked.f2 = MAXFRAMEF;
@@ -835,7 +835,7 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEven
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
- else
+ else
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
}
@@ -1113,7 +1113,7 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
- if (nvi == NULL)
+ if (nvi == NULL)
return;
/* deselect all other curves? */
@@ -1241,7 +1241,7 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
- if (nvi == NULL)
+ if (nvi == NULL)
return;
/* get frame number on which elements should be selected */
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 9150c85c45b..84ce12ba9eb 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -437,7 +437,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_refresh(sa);
break;
case NC_SCENE:
- switch (wmn->data) {
+ switch (wmn->data) {
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
case ND_OB_SELECT:
sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
@@ -457,7 +457,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_refresh(sa);
break;
case ND_TRANSFORM:
- break; /*do nothing*/
+ break; /*do nothing*/
default: /* just redrawing the view will do */
ED_area_tag_redraw(sa);
@@ -559,13 +559,13 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
switch (fcu->array_index) {
case 0:
- col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f;
+ UI_GetThemeColor3fv(TH_AXIS_X, col);
break;
case 1:
- col[0] = 0.0f; col[1] = 1.0f; col[2] = 0.0f;
+ UI_GetThemeColor3fv(TH_AXIS_Y, col);
break;
case 2:
- col[0] = 0.0f; col[1] = 0.0f; col[2] = 1.0f;
+ UI_GetThemeColor3fv(TH_AXIS_Z, col);
break;
default:
/* 'unknown' color - bluish so as to not conflict with handles */
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 59416dcf0c3..ae7a718ab5b 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -191,7 +191,7 @@ void image_preview_event(int event)
waitcursor(0);
WM_event_add_notifier(C, NC_IMAGE, ima_v);
- }
+ }
}
@@ -722,8 +722,10 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
split = uiLayoutSplit(layout, 0.0f, FALSE);
col = uiLayoutColumn(split, TRUE);
+ uiLayoutSetEnabled(col, 0);
uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
+
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -759,9 +761,10 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man
uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
/* only display depth setting if multiple depths can be used */
- if ((ELEM6(depth_ok,
+ if ((ELEM7(depth_ok,
R_IMF_CHAN_DEPTH_1,
R_IMF_CHAN_DEPTH_8,
+ R_IMF_CHAN_DEPTH_10,
R_IMF_CHAN_DEPTH_12,
R_IMF_CHAN_DEPTH_16,
R_IMF_CHAN_DEPTH_24,
@@ -801,9 +804,13 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man
uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE);
}
+ if (imf->imtype == R_IMF_IMTYPE_DPX) {
+ uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
+ }
+
if (imf->imtype == R_IMF_IMTYPE_CINEON) {
#if 1
- uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma: 1.0"), ICON_NONE);
+ uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma:1.7"), ICON_NONE);
#else
uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 6dc9cafac18..f418deeb1c9 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -587,7 +587,7 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d)
}
else {
/* assume that UI_view2d_restore(C) has been called... */
- //SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
+ //SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
/* draw grease-pencil ('screen' strokes) */
draw_gpencil_view2d(C, 0);
@@ -799,7 +799,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
xoffs = scene->r.disprect.xmin;
yoffs = scene->r.disprect.ymin;
gpuCurrentColor3x(CPACK_BLACK);
- calc_image_view(sima, 'f');
+ calc_image_view(sima, 'f');
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
gpuSingleFilledRectf(0.0f, 0.0f, 1.0f, 1.0f);
gpuLoadIdentity();
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 2f01483d23f..4ca2f8888f8 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -79,7 +79,7 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
if (sima->image && ID_REAL_USERS(sima->image) <= 0)
- sima->image->id.us = MAX2(sima->image->id.us, 0) + 1;
+ sima->image->id.us = max_ii(sima->image->id.us, 0) + 1;
if (obedit)
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
@@ -98,7 +98,7 @@ void ED_space_image_set_mask(bContext *C, SpaceImage *sima, Mask *mask)
/* weak, but same as image/space */
if (sima->mask_info.mask && ID_REAL_USERS(sima->mask_info.mask) <= 0)
- sima->mask_info.mask->id.us = MAX2(sima->mask_info.mask->id.us, 0) + 1;
+ sima->mask_info.mask->id.us = max_ii(sima->mask_info.mask->id.us, 0) + 1;
if (C) {
WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 4f57b2249d1..ce3c6e1fd26 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -39,6 +39,8 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "DNA_object_types.h"
#include "DNA_node_types.h"
#include "DNA_packedFile_types.h"
@@ -183,7 +185,7 @@ static int space_image_poll(bContext *C)
int space_image_main_area_poll(bContext *C)
{
SpaceImage *sima = CTX_wm_space_image(C);
- // XXX ARegion *ar= CTX_wm_region(C);
+ // XXX ARegion *ar = CTX_wm_region(C);
if (sima)
return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW);
@@ -430,11 +432,16 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (event->type == MOUSEZOOM) {
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
- float factor, location[2];
+ float delta, factor, location[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
- factor = 1.0f + (event->x - event->prevx + event->y - event->prevy) / 300.0f;
+ delta = event->x - event->prevx + event->y - event->prevy;
+
+ if (U.uiflag & USER_ZOOM_INVERT)
+ delta *= -1;
+
+ factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sima_zoom_set(sima, ar, sima->zoom * factor, location);
ED_region_tag_redraw(CTX_wm_region(C));
@@ -452,11 +459,16 @@ static int image_view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
ViewZoomData *vpd = op->customdata;
- float factor;
+ float delta, factor;
switch (event->type) {
case MOUSEMOVE:
- factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f;
+ delta = event->x - vpd->x + event->y - vpd->y;
+
+ if (U.uiflag & USER_ZOOM_INVERT)
+ delta *= -1;
+
+ factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sima_zoom_set(sima, ar, vpd->zoom * factor, vpd->location);
ED_region_tag_redraw(CTX_wm_region(C));
@@ -496,7 +508,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
ot->flag = OPTYPE_BLOCKING;
/* properties */
- RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX,
+ RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX,
"Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
}
@@ -541,7 +553,7 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *
sima->xof += pan_x;
sima->yof += pan_y;
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -589,7 +601,7 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
/* find the zoom value that will fit the image in the image space */
zoomx = width / w;
zoomy = height / h;
- sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / minf(zoomx, zoomy)), NULL);
+ sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
}
else
sima_zoom_set(sima, ar, 1.0f, NULL);
@@ -606,7 +618,7 @@ void IMAGE_OT_view_all(wmOperatorType *ot)
/* identifiers */
ot->name = "View All";
ot->idname = "IMAGE_OT_view_all";
- ot->description = "View the whole picture";
+ ot->description = "View the entire image";
/* api callbacks */
ot->exec = image_view_all_exec;
@@ -793,14 +805,14 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
/* identifiers */
ot->name = "View Zoom Ratio";
ot->idname = "IMAGE_OT_view_zoom_ratio";
- ot->description = "Set zoom ration of the view";
+ ot->description = "Set zoom ratio of the view";
/* api callbacks */
ot->exec = image_view_zoom_ratio_exec;
ot->poll = space_image_main_area_poll;
/* properties */
- RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX,
+ RNA_def_float(ot->srna, "ratio", 0.0f, -FLT_MAX, FLT_MAX,
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
}
@@ -848,7 +860,8 @@ static int image_open_exec(bContext *C, wmOperator *op)
if (!ima) {
if (op->customdata) MEM_freeN(op->customdata);
- BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", str, errno ? strerror(errno) : "Unsupported image format");
+ BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s",
+ str, errno ? strerror(errno) : TIP_("unsupported image format"));
return OPERATOR_CANCELLED;
}
@@ -1137,7 +1150,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
else {
simopts->im_format.imtype = BKE_ftype_to_imtype(ibuf->ftype);
}
- //simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
+ //simopts->subimtype = scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
simopts->im_format.quality = ibuf->ftype & 0xff;
BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath));
@@ -1259,8 +1272,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
BKE_image_release_renderresult(scene, ima);
}
else {
- if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy))
- {
+ if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
ok = TRUE;
}
}
@@ -1304,7 +1316,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
}
}
else {
- BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", simopts->filepath);
+ BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s", simopts->filepath);
}
@@ -1486,7 +1498,7 @@ static int image_save_exec(bContext *C, wmOperator *op)
save_image_doit(C, sima, op, &simopts, FALSE);
}
else {
- BKE_reportf(op->reports, RPT_ERROR, "Can not save image, path '%s' is not writable", simopts.filepath);
+ BKE_reportf(op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", simopts.filepath);
return OPERATOR_CANCELLED;
}
@@ -1527,7 +1539,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
}
if (sima->image->type == IMA_TYPE_MULTILAYER) {
- BKE_report(op->reports, RPT_ERROR, "Can't save multilayer sequences");
+ BKE_report(op->reports, RPT_ERROR, "Cannot save multilayer sequences");
return OPERATOR_CANCELLED;
}
@@ -1549,7 +1561,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
BLI_strncpy(di, ibuf->name, FILE_MAX);
BLI_splitdirstring(di, fi);
- BKE_reportf(op->reports, RPT_INFO, "%d Image(s) will be saved in %s", tot, di);
+ BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di);
for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next) {
if (ibuf->userflags & IB_BITMAPDIRTY) {
@@ -1563,7 +1575,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
break;
}
- BKE_reportf(op->reports, RPT_INFO, "Saved: %s\n", ibuf->name);
+ BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name);
ibuf->userflags &= ~IB_BITMAPDIRTY;
}
}
@@ -1673,16 +1685,24 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
}
- else if (sima)
+ else if (sima) {
ED_space_image_set(sima, scene, obedit, ima);
+ }
+ else {
+ Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+ if (tex && tex->type == TEX_IMAGE) {
+ tex->ima = ima;
+ ED_area_tag_redraw(CTX_wm_area(C));
+ }
+ }
- // XXX other users?
BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
return OPERATOR_FINISHED;
}
/* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */
+/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for uiIDContextProperty(), image is not being that way */
static int image_new_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
return WM_operator_props_dialog_popup(C, op, 300, 100);
@@ -1835,7 +1855,7 @@ static int image_pack_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- BKE_report(op->reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG");
+ BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
return OPERATOR_CANCELLED;
}
@@ -2353,8 +2373,8 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
WM_cursor_time(CTX_wm_window(C), scene->r.cfra);
- // XXX scene->nodetree->test_break= blender_test_break;
- // XXX scene->nodetree->test_break= NULL;
+ // XXX scene->nodetree->test_break = blender_test_break;
+ // XXX scene->nodetree->test_break = NULL;
BKE_image_all_free_anim_ibufs(scene->r.cfra);
ntreeCompositTagAnimated(scene->nodetree);
@@ -2420,8 +2440,7 @@ static int image_record_composite_exec(bContext *C, wmOperator *op)
if (!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
- while (image_record_composite_apply(C, op))
- ;
+ while (image_record_composite_apply(C, op)) {}
image_record_composite_exit(C, op);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 5d3327d0ecc..f0b3e70f359 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -414,8 +414,9 @@ static void image_refresh(const bContext *C, ScrArea *sa)
/* don't need to check for pin here, see above */
sima->image = tf->tpage;
- if (sima->flag & SI_EDITTILE) ;
- else sima->curtile = tf->tile;
+ if ((sima->flag & SI_EDITTILE) == 0) {
+ sima->curtile = tf->tile;
+ }
}
}
}
@@ -456,7 +457,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_redraw(sa);
}
break;
- case NC_SPACE:
+ case NC_SPACE:
if (wmn->data == ND_SPACE_IMAGE) {
image_scopes_tag_refresh(sa);
ED_area_tag_redraw(sa);
@@ -549,7 +550,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
int width, height, winx, winy;
#if 0
- if (image_preview_active(curarea, &width, &height)) ;
+ if (image_preview_active(curarea, &width, &height)) {}
else
#endif
ED_space_image_get_size(sima, &width, &height);
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index b014f3cc33e..4de77d1f89a 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -136,7 +136,7 @@ static int report_textview_skip__internal(TextViewContext *tvc)
static int report_textview_begin(TextViewContext *tvc)
{
- // SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
+ // SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
ReportList *reports = (ReportList *)tvc->arg2;
tvc->lheight = 14; //sc->lheight;
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 805ff1794c9..131908bc9db 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -124,7 +124,7 @@ static const EnumPropertyItem unpack_all_method_items[] = {
{PF_WRITE_LOCAL, "WRITE_LOCAL", 0, "Write files to current directory (overwrite existing files)", ""},
{PF_USE_ORIGINAL, "USE_ORIGINAL", 0, "Use files in original location (create when necessary)", ""},
{PF_WRITE_ORIGINAL, "WRITE_ORIGINAL", 0, "Write files to original location (overwrite existing files)", ""},
- {PF_KEEP, "KEEP", 0, "Disable AutoPack, keep all packed files", ""},
+ {PF_KEEP, "KEEP", 0, "Disable Auto-pack, keep all packed files", ""},
/* {PF_ASK, "ASK", 0, "Ask for each file", ""}, */
{0, NULL, 0, NULL, NULL}};
@@ -150,7 +150,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
count = countPackedFiles(bmain);
if (!count) {
- BKE_report(op->reports, RPT_WARNING, "No packed files. Autopack disabled");
+ BKE_report(op->reports, RPT_WARNING, "No packed files (auto-pack disabled)");
G.fileflags &= ~G_AUTOPACK;
return OPERATOR_CANCELLED;
}
@@ -196,7 +196,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
if (!G.relbase_valid) {
- BKE_report(op->reports, RPT_WARNING, "Can't set relative paths with an unsaved blend file");
+ BKE_report(op->reports, RPT_WARNING, "Cannot set relative paths with an unsaved blend file");
return OPERATOR_CANCELLED;
}
@@ -229,7 +229,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
if (!G.relbase_valid) {
- BKE_report(op->reports, RPT_WARNING, "Can't set absolute paths with an unsaved blend file");
+ BKE_report(op->reports, RPT_WARNING, "Cannot set absolute paths with an unsaved blend file");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 2324f735a33..049a50f89fc 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -68,9 +68,9 @@ int info_report_mask(SpaceInfo *UNUSED(sinfo))
// TODO, get this working again!
static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
{
-// SpaceInfo *sc= CTX_wm_space_info(C);
-// ReportList *reports= CTX_wm_reports(C);
-// int report_mask= info_report_mask(sc);
+// SpaceInfo *sc = CTX_wm_space_info(C);
+// ReportList *reports = CTX_wm_reports(C);
+// int report_mask = info_report_mask(sc);
// Report *report;
#if 0
@@ -223,7 +223,7 @@ static int borderselect_exec(bContext *C, wmOperator *op)
int extend = RNA_boolean_get(op->ptr, "extend");
Report *report_min, *report_max, *report;
- //View2D *v2d= UI_view2d_fromcontext(C);
+ //View2D *v2d = UI_view2d_fromcontext(C);
rcti rect;
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index f7bf7715436..98aa2ca0a9c 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -58,6 +58,7 @@
#include "UI_view2d.h"
#include "info_intern.h" /* own include */
+#include "BLO_readfile.h"
/* ******************** default callbacks for info space ***************** */
@@ -93,7 +94,7 @@ static SpaceLink *info_new(const bContext *UNUSED(C))
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
+ //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
return (SpaceLink *)sinfo;
}
@@ -228,7 +229,7 @@ static void info_header_area_draw(const bContext *C, ARegion *ar)
static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
- // SpaceInfo *sinfo= sa->spacedata.first;
+ // SpaceInfo *sinfo = sa->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -249,7 +250,7 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY))
ED_region_tag_redraw(ar);
break;
- case NC_WM:
+ case NC_WM:
if (wmn->data == ND_JOB)
ED_region_tag_redraw(ar);
break;
@@ -257,7 +258,7 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
if (wmn->data == ND_RENDER_RESULT)
ED_region_tag_redraw(ar);
break;
- case NC_SPACE:
+ case NC_SPACE:
if (wmn->data == ND_SPACE_INFO)
ED_region_tag_redraw(ar);
break;
@@ -271,11 +272,16 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
{
struct RecentFile *recent;
+ char file [FILE_MAX];
uiLayout *layout = menu->layout;
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
if (G.recent_files.first) {
for (recent = G.recent_files.first; (recent); recent = recent->next) {
- uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ BLI_split_file_part(recent->filepath, file, sizeof(file));
+ if (BLO_has_bfile_extension(file))
+ uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ else
+ uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
}
}
else {
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index 219535d90d5..e7ed566198e 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -38,7 +38,6 @@
#include "GPU_colors.h"
#include "GPU_primitives.h"
-
#include "BIF_glutil.h"
#include "ED_datafiles.h"
@@ -66,8 +65,8 @@ typedef struct ConsoleDrawContext {
static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int lheight)
{
if (sel[0] <= str_len_draw && sel[1] >= 0) {
- int sta = MAX2(sel[0], 0);
- int end = MIN2(sel[1], str_len_draw);
+ int sta = max_ii(sel[0], 0);
+ int end = min_ii(sel[1], str_len_draw);
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_halftone);
@@ -127,7 +126,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
return 1;
}
- if (str_len > cdc->console_width) { /* wrap? */
+ if (tot_lines > 1) { /* wrap? */
const int initial_offset = ((tot_lines - 1) * cdc->console_width);
const char *line_stride = str + initial_offset; /* advance to the last line and draw it first */
diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt
index 1df58a3d647..7cae2cf839f 100644
--- a/source/blender/editors/space_logic/CMakeLists.txt
+++ b/source/blender/editors/space_logic/CMakeLists.txt
@@ -51,4 +51,8 @@ endif()
add_definitions(-DGLEW_STATIC)
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
blender_add_lib(bf_editor_space_logic "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_logic/SConscript b/source/blender/editors/space_logic/SConscript
index 6beb3ecb48f..e63d88ea5de 100644
--- a/source/blender/editors/space_logic/SConscript
+++ b/source/blender/editors/space_logic/SConscript
@@ -3,7 +3,7 @@ Import ('env')
sources = env.Glob('*.c')
-incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
+incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../makesrna ../interface ../../blenloader'
@@ -12,4 +12,7 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('WITH_GAMEENGINE')
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
+
env.BlenderLib ( 'bf_editors_space_game', sources, Split(incs), defs, libtype=['core'], priority=[120] )
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index abdfa0ef4dd..e898a1baf74 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -52,8 +52,8 @@
static int logic_properties(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= logic_has_buttons_region(sa);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = logic_has_buttons_region(sa);
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -100,9 +100,9 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot)
static int cut_links_exec(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
float mcoords[256][2];
- int i= 0;
+ int i = 0;
RNA_BEGIN (op->ptr, itemptr, "path")
{
@@ -113,7 +113,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
(int)loc[0], (int)loc[1],
&mcoords[i][0], &mcoords[i][1]);
i++;
- if (i>= 256) break;
+ if (i >= 256) break;
}
RNA_END;
@@ -121,23 +121,23 @@ static int cut_links_exec(bContext *C, wmOperator *op)
uiBlock *block;
uiLinkLine *line, *nline;
uiBut *but;
- for (block= ar->uiblocks.first; block; block= block->next) {
- but= block->buttons.first;
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ but = block->buttons.first;
while (but) {
if (but->type==LINK && but->link) {
- for (line= but->link->lines.first; line; line= nline) {
- nline= line->next;
+ for (line = but->link->lines.first; line; line = nline) {
+ nline = line->next;
if (cut_links_intersect(line, mcoords, i)) {
ui_delete_linkline(line, but);
}
}
}
- but= but->next;
+ but = but->next;
}
}
return OPERATOR_FINISHED;
- }
+ }
return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
}
@@ -159,7 +159,7 @@ void LOGIC_OT_links_cut(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
- prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
+ prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index f2013e405e2..74be7c46d26 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -138,7 +138,7 @@ static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **o
*ob = edit_object_property_get(C, op);
if (!*ob) return NULL;
- sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name));
+ sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name));
return sens;
}
@@ -177,7 +177,7 @@ static bController *edit_controller_property_get(bContext *C, wmOperator *op, Ob
*ob = edit_object_property_get(C, op);
if (!*ob) return NULL;
- cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name));
+ cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name));
return cont;
}
@@ -216,7 +216,7 @@ static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object
*ob = edit_object_property_get(C, op);
if (!*ob) return NULL;
- act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name));
+ act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name));
return act;
}
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 9d140bdc878..b6b3b5cbd9f 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -56,6 +56,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_sca.h"
+#include "BKE_screen.h"
#include "ED_util.h"
@@ -64,7 +65,10 @@
#include "GPU_primitives.h"
+#include "BLF_translation.h"
+
#include "UI_interface.h"
+#include "UI_view2d.h"
#include "RNA_access.h"
@@ -103,8 +107,8 @@ static int vergname(const void *v1, const void *v2)
{
char **x1, **x2;
- x1= (char **)v1;
- x2= (char **)v2;
+ x1 = (char **)v1;
+ x2 = (char **)v2;
return BLI_natstrcmp(*x1, *x2);
}
@@ -135,7 +139,7 @@ void make_unique_prop_names(bContext *C, char *str)
propcount+= BLI_countlist(&ob->sensors);
propcount+= BLI_countlist(&ob->controllers);
propcount+= BLI_countlist(&ob->actuators);
- }
+ }
if (propcount==0) {
if (idar) MEM_freeN(idar);
return;
@@ -150,22 +154,22 @@ void make_unique_prop_names(bContext *C, char *str)
ob= (Object *)idar[a];
prop= ob->prop.first;
while (prop) {
- names[nr++]= prop->name;
+ names[nr++] = prop->name;
prop= prop->next;
}
sens= ob->sensors.first;
while (sens) {
- names[nr++]= sens->name;
+ names[nr++] = sens->name;
sens= sens->next;
}
cont= ob->controllers.first;
while (cont) {
- names[nr++]= cont->name;
+ names[nr++] = cont->name;
cont= cont->next;
}
act= ob->actuators.first;
while (act) {
- names[nr++]= act->name;
+ names[nr++] = act->name;
act= act->next;
}
}
@@ -525,7 +529,7 @@ static const char *actuator_name(int type)
case ACT_ARMATURE:
return "Armature";
case ACT_STEERING:
- return "Steering";
+ return "Steering";
}
return "unknown";
}
@@ -679,7 +683,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
ob= ob->id.next;
}
}
- }
+ }
/* now we count */
ob= bmain->object.first;
@@ -688,8 +692,8 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
ob= ob->id.next;
}
- if (*count==0) return NULL;
- if (*count>24) *count= 24; /* temporal */
+ if (*count == 0) return NULL;
+ if (*count > 24) *count = 24; /* temporal */
idar= MEM_callocN((*count)*sizeof(void *), "idar");
@@ -698,16 +702,16 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
/* make the active object always the first one of the list */
if (obact) {
- idar[0]= (ID *)obact;
+ idar[0] = (ID *)obact;
nr++;
}
while (ob) {
if ((ob->scavisflag) && (ob != obact)) {
- idar[nr]= (ID *)ob;
+ idar[nr] = (ID *)ob;
nr++;
}
- if (nr>=24) break;
+ if (nr >= 24) break;
ob= ob->id.next;
}
@@ -769,11 +773,11 @@ static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP);
uiBlockSetButmFunc(block, do_sensor_menu, NULL);
- uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, BUTM, 1, "Show Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
- uiDefBut(block, BUTM, 1, "Hide Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Show Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Hide Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, "");
uiBlockSetDirection(block, UI_TOP);
uiEndBlock(C, block);
@@ -818,11 +822,11 @@ static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP);
uiBlockSetButmFunc(block, do_controller_menu, NULL);
- uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, BUTM, 1, "Show Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, "");
- uiDefBut(block, BUTM, 1, "Hide Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Show Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Hide Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, "");
uiBlockSetDirection(block, UI_TOP);
uiEndBlock(C, block);
@@ -867,11 +871,11 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP);
uiBlockSetButmFunc(block, do_actuator_menu, NULL);
- uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, BUTM, 1, "Show Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
- uiDefBut(block, BUTM, 1, "Hide Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Show Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
+ uiDefBut(block, BUTM, 1, IFACE_("Hide Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, "");
uiBlockSetDirection(block, UI_TOP);
uiEndBlock(C, block);
@@ -902,7 +906,7 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c
/* use this for a fake extra empy space around the buttons */
uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, "");
- for (offset=0; offset<15; offset+=5) {
+ for (offset=0; offset<15; offset += 5) {
uiBlockBeginAlign(block);
for (stbit=0; stbit<5; stbit++) {
but = uiDefButBitI(block, TOG, (1<<(stbit+offset)), (stbit+offset), "", (short)(xco+12*stbit+13*offset), yco, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, "");
@@ -982,13 +986,13 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
sub = uiLayoutRow(row, FALSE);
uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") ||
RNA_boolean_get(ptr, "use_pulse_false_level")));
- uiItemR(sub, ptr, "frequency", 0, "Freq", ICON_NONE);
+ uiItemR(sub, ptr, "frequency", 0, IFACE_("Freq"), ICON_NONE);
row = uiLayoutRow(split, TRUE);
uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", ICON_NONE);
+ uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, IFACE_("Invert"), ICON_NONE);
}
/* sensors in alphabetical order */
@@ -1011,7 +1015,7 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr)
uiLayout *row;
if (ob->type != OB_ARMATURE) {
- uiItemL(layout, "Sensor only available for armatures", ICON_NONE);
+ uiItemL(layout, IFACE_("Sensor only available for armatures"), ICON_NONE);
return;
}
@@ -1113,7 +1117,7 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr)
uiLayout *row, *col;
row = uiLayoutRow(layout, FALSE);
- uiItemL(row, "Key:", ICON_NONE);
+ uiItemL(row, IFACE_("Key:"), ICON_NONE);
col = uiLayoutColumn(row, FALSE);
uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE);
uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE);
@@ -1123,11 +1127,11 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr)
col = uiLayoutColumn(layout, FALSE);
uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE);
row = uiLayoutRow(col, FALSE);
- uiItemL(row, "First Modifier:", ICON_NONE);
+ uiItemL(row, IFACE_("First Modifier:"), ICON_NONE);
uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE);
row = uiLayoutRow(col, FALSE);
- uiItemL(row, "Second Modifier:", ICON_NONE);
+ uiItemL(row, IFACE_("Second Modifier:"), ICON_NONE);
uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE);
RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
@@ -1313,7 +1317,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i
uiItemR(row, ptr, "type", 0, "", ICON_NONE);
uiItemR(row, ptr, "name", 0, "", ICON_NONE);
/* XXX provisory for Blender 2.50Beta */
- uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, "Set controller state index (from 1 to 30)");
+ uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, IFACE_("Set controller state index (from 1 to 30)"));
}
else {
uiItemL(row, controller_name(cont->type), ICON_NONE);
@@ -1481,7 +1485,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr)
PropertyRNA *bones_prop = NULL;
if (ob->type != OB_ARMATURE) {
- uiItemL(layout, "Actuator only available for armatures", ICON_NONE);
+ uiItemL(layout, IFACE_("Actuator only available for armatures"), ICON_NONE);
return;
}
@@ -1587,7 +1591,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext
row = uiLayoutRow(layout, FALSE);
col = uiLayoutColumn(row, TRUE);
- uiItemL(col, "Range:", ICON_NONE);
+ uiItemL(col, IFACE_("Range:"), ICON_NONE);
uiItemR(col, ptr, "range", 0, "", ICON_NONE);
col = uiLayoutColumn(row, TRUE);
@@ -1685,7 +1689,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr)
break;
case ACT_EDOB_REPLACE_MESH:
if (ob->type != OB_MESH) {
- uiItemL(layout, "Mode only available for mesh objects", ICON_NONE);
+ uiItemL(layout, IFACE_("Mode only available for mesh objects"), ICON_NONE);
break;
}
split = uiLayoutSplit(layout, 0.6, FALSE);
@@ -1703,7 +1707,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr)
break;
case ACT_EDOB_DYNAMICS:
if (ob->type != OB_MESH) {
- uiItemL(layout, "Mode only available for mesh objects", ICON_NONE);
+ uiItemL(layout, IFACE_("Mode only available for mesh objects"), ICON_NONE);
break;
}
uiItemR(layout, ptr, "dynamic_operation", 0, NULL, ICON_NONE);
@@ -1773,7 +1777,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr)
uiLayout *split, *row, *col, *sub;
int physics_type;
- ob = (Object *)ptr->id.data;
+ ob = (Object *)ptr->id.data;
RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
physics_type = RNA_enum_get(&settings_ptr, "physics_type");
@@ -1791,8 +1795,8 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr)
uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE);
uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) {
- uiItemL(layout, "Dynamic Object Settings:", ICON_NONE);
+ if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) {
+ uiItemL(layout, IFACE_("Dynamic Object Settings:"), ICON_NONE);
split = uiLayoutSplit(layout, 0.9, FALSE);
row = uiLayoutRow(split, FALSE);
uiItemR(row, ptr, "force", 0, NULL, ICON_NONE);
@@ -1942,7 +1946,7 @@ static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr)
break;
case ACT_RANDOM_BOOL_UNIFORM:
- uiItemL(row, "Choose between true and false, 50% chance each", ICON_NONE);
+ uiItemL(row, IFACE_("Choose between true and false, 50% chance each"), ICON_NONE);
break;
case ACT_RANDOM_BOOL_BERNOUILLI:
@@ -2005,7 +2009,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr)
uiLayout *row;
if (ob->type != OB_MESH) {
- uiItemL(layout, "Actuator only available for mesh objects", ICON_NONE);
+ uiItemL(layout, IFACE_("Actuator only available for mesh objects"), ICON_NONE);
return;
}
@@ -2043,7 +2047,7 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C)
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
if (!RNA_pointer_get(ptr, "sound").data) {
- uiItemL(layout, "Select a sound from the list or load a new one", ICON_NONE);
+ uiItemL(layout, IFACE_("Select a sound from the list or load a new one"), ICON_NONE);
return;
}
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
@@ -2207,15 +2211,13 @@ void logic_buttons(bContext *C, ARegion *ar)
SpaceLogic *slogic= CTX_wm_space_logic(C);
Object *ob= CTX_data_active_object(C);
ID **idar;
-
PointerRNA logic_ptr, settings_ptr, object_ptr;
-
uiLayout *layout, *row, *box;
uiBlock *block;
uiBut *but;
char uiblockstr[32];
short a, count;
- int xco, yco, width;
+ int xco, yco, width, height;
if (ob==NULL) return;
@@ -2269,15 +2271,15 @@ void logic_buttons(bContext *C, ARegion *ar)
/* ****************** Controllers ****************** */
- xco= 420; yco= 170; width= 300;
+ xco= 420; yco= -10; width= 300;
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle());
row = uiLayoutRow(layout, TRUE);
- uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
+ uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
- uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, "Sel", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, "Act", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, "Link", ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, IFACE_("Link"), ICON_NONE);
for (a=0; a<count; a++) {
bController *cont;
@@ -2300,11 +2302,11 @@ void logic_buttons(bContext *C, ARegion *ar)
uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT);
row = uiLayoutRow(split, TRUE);
- uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers");
+ uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers"));
RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
uiLayoutSetContextPointer(row, "object", &object_ptr);
- uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE);
+ uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE);
if (RNA_boolean_get(&settings_ptr, "show_state_panel")) {
@@ -2312,8 +2314,8 @@ void logic_buttons(bContext *C, ARegion *ar)
split = uiLayoutSplit(box, 0.2f, FALSE);
col = uiLayoutColumn(split, FALSE);
- uiItemL(col, "Visible", ICON_NONE);
- uiItemL(col, "Initial", ICON_NONE);
+ uiItemL(col, IFACE_("Visible"), ICON_NONE);
+ uiItemL(col, IFACE_("Initial"), ICON_NONE);
subsplit = uiLayoutSplit(split, 0.85f, FALSE);
col = uiLayoutColumn(subsplit, FALSE);
@@ -2372,20 +2374,20 @@ void logic_buttons(bContext *C, ARegion *ar)
}
}
uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
-
+ height = yco;
/* ****************** Sensors ****************** */
- xco= 10; yco= 170; width= 340;
+ xco= 10; yco= -10; width= 340;
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle());
row = uiLayoutRow(layout, TRUE);
- uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
+ uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
- uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, "Sel", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, "Act", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, "Link", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, "State", ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, IFACE_("Link"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, IFACE_("State"), ICON_NONE);
for (a=0; a<count; a++) {
bSensor *sens;
@@ -2397,11 +2399,11 @@ void logic_buttons(bContext *C, ARegion *ar)
if ((ob->scavisflag & OB_VIS_SENS) == 0) continue;
row = uiLayoutRow(layout, TRUE);
- uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors");
+ uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors"));
RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
uiLayoutSetContextPointer(row, "object", &object_ptr);
- uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE);
+ uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE);
if ((ob->scaflag & OB_SHOWSENS) == 0) continue;
@@ -2441,19 +2443,20 @@ void logic_buttons(bContext *C, ARegion *ar)
}
}
uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
+ height = MIN2(height, yco);
/* ****************** Actuators ****************** */
- xco= 800; yco= 170; width= 340;
+ xco= 800; yco= -10; width= 340;
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle());
row = uiLayoutRow(layout, TRUE);
- uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
+ uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
- uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, "Sel", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, "Act", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, "Link", ICON_NONE);
- uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, "State", ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, IFACE_("Link"), ICON_NONE);
+ uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, IFACE_("State"), ICON_NONE);
for (a=0; a<count; a++) {
bActuator *act;
@@ -2467,11 +2470,11 @@ void logic_buttons(bContext *C, ARegion *ar)
}
row = uiLayoutRow(layout, TRUE);
- uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators");
+ uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators"));
RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
uiLayoutSetContextPointer(row, "object", &object_ptr);
- uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE);
+ uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE);
if ((ob->scaflag & OB_SHOWACT) == 0) continue;
@@ -2512,13 +2515,21 @@ void logic_buttons(bContext *C, ARegion *ar)
}
}
uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
+ height = MIN2(height, yco);
+
+ UI_view2d_totRect_set(&ar->v2d, 1150, height);
-
+ /* set the view */
+ UI_view2d_view_ortho(&ar->v2d);
+
uiComposeLinks(block);
uiEndBlock(C, block);
uiDrawBlock(C, block);
+ /* restore view matrix */
+ UI_view2d_view_restore(C);
+
if (idar) MEM_freeN(idar);
}
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
index a7004c7db07..87b0f8e75f8 100644
--- a/source/blender/editors/space_logic/space_logic.c
+++ b/source/blender/editors/space_logic/space_logic.c
@@ -61,20 +61,20 @@ ARegion *logic_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
- ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
/* add subdiv level; after header */
- ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ 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");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype= RGN_TYPE_UI;
- arnew->alignment= RGN_ALIGN_LEFT;
+ arnew->regiontype = RGN_TYPE_UI;
+ arnew->alignment = RGN_ALIGN_LEFT;
arnew->flag = RGN_FLAG_HIDDEN;
@@ -83,8 +83,9 @@ ARegion *logic_has_buttons_region(ScrArea *sa)
/* ******************** default callbacks for image space ***************** */
-static SpaceLink *logic_new(const bContext *UNUSED(C))
+static SpaceLink *logic_new(const bContext *C)
{
+ ScrArea *sa= CTX_wm_area(C);
ARegion *ar;
SpaceLogic *slogic;
@@ -92,10 +93,10 @@ static SpaceLink *logic_new(const bContext *UNUSED(C))
slogic->spacetype= SPACE_LOGIC;
/* default options */
- slogic->scaflag = (BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) |
- (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) |
- (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) |
- (BUTS_SENS_STATE|BUTS_ACT_STATE);
+ slogic->scaflag = ((BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) |
+ (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) |
+ (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) |
+ (BUTS_SENS_STATE|BUTS_ACT_STATE));
/* header */
@@ -119,28 +120,26 @@ static SpaceLink *logic_new(const bContext *UNUSED(C))
ar->regiontype= RGN_TYPE_WINDOW;
ar->v2d.tot.xmin = 0.0f;
- ar->v2d.tot.ymin = 0.0f;
- ar->v2d.tot.xmax = 1280;
- ar->v2d.tot.ymax = 240.0f;
+ ar->v2d.tot.ymax = 0.0f;
+ ar->v2d.tot.xmax = 1150.0f;
+ ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy;
- ar->v2d.cur.xmin = 0.0f;
- ar->v2d.cur.ymin = 0.0f;
- ar->v2d.cur.xmax = 1280.0f;
- ar->v2d.cur.ymax = 240.0f;
+ ar->v2d.cur = ar->v2d.tot;
- ar->v2d.min[0]= 1.0f;
- ar->v2d.min[1]= 1.0f;
+ ar->v2d.min[0] = 1.0f;
+ ar->v2d.min[1] = 1.0f;
- ar->v2d.max[0]= 32000.0f;
- ar->v2d.max[1]= 32000.0f;
+ ar->v2d.max[0] = 32000.0f;
+ ar->v2d.max[1] = 32000.0f;
- ar->v2d.minzoom= 0.5f;
- ar->v2d.maxzoom= 1.21f;
-
- ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT;
- ar->v2d.keeptot= 0;
+ ar->v2d.minzoom = 0.5f;
+ ar->v2d.maxzoom = 1.5f;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT;
+ ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X;
+ ar->v2d.keepofs = V2D_KEEPOFS_Y;
return (SpaceLink *)slogic;
}
@@ -182,6 +181,9 @@ static void logic_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0);
+
+ WM_keymap_add_item(keymap, "VIEW2D_OT_reset", HOMEKEY, KM_PRESS, 0, 0);
+
}
static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa))
@@ -233,7 +235,7 @@ static void logic_main_area_init(wmWindowManager *wm, ARegion *ar)
wmKeyMap *keymap;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
+
/* own keymaps */
keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -258,7 +260,7 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 18e983047cd..d75946c4317 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -71,7 +71,7 @@
static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event)
{
- //Scene *scene= CTX_data_scene(C);
+ //Scene *scene = CTX_data_scene(C);
switch (event) {
@@ -156,7 +156,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA
found = -1;
}
}
- }
+ }
break;
}
@@ -242,7 +242,7 @@ static void nla_panel_animdata(const bContext *C, Panel *pa)
if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
return;
- /* adt= adt_ptr.data; */
+ /* adt = adt_ptr.data; */
block = uiLayoutGetBlock(layout);
uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL);
@@ -405,7 +405,7 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE);
sub = uiLayoutColumn(col, TRUE);
- uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence"));
+ uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence"));
uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE);
col = uiLayoutColumn(layout, TRUE);
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index b3a869ed57d..95e75d0e4fc 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -199,7 +199,7 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
- }
+ }
break;
case ANIMTYPE_NLATRACK:
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index ffb311173e1..8962b88dbae 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -165,7 +165,7 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col
/* normal, unselected strip - use (hardly noticeable) blue tinge */
UI_GetThemeColor3fv(TH_NLA_TRANSITION, color);
}
- }
+ }
else if (strip->type == NLASTRIP_TYPE_META) {
/* Meta Clip */
// TODO: should temporary metas get different colors too?
@@ -535,7 +535,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
*/
v2d->tot.ymin = (float)(-height);
- /* loop through channels, and set up drawing depending on their type */
+ /* loop through channels, and set up drawing depending on their type */
y = (float)(-NLACHANNEL_HEIGHT(snla));
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -642,7 +642,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
bAnimListElem *ale;
float x = 0.0f;
- /* loop through channels, and set up drawing depending on their type */
+ /* loop through channels, and set up drawing depending on their type */
for (ale = anim_data->first; ale; ale = ale->next) {
const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
@@ -723,7 +723,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
// draw backdrops only...
ANIM_channel_draw(ac, ale, yminc, ymaxc);
break;
- }
+ }
/* if special types, draw manually for now... */
if (do_draw) {
@@ -751,7 +751,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
/* even more */
offset = 21;
indent = 1;
- }
+ }
break;
default:
@@ -788,7 +788,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
gpuCurrentColor3fv(color);
}
else {
- float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3 : 1.0f;
+ float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
gpuCurrentColor4f(color[0], color[1], color[2], alpha);
}
@@ -860,8 +860,6 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
/* draw NLA-action line 'status-icons' - only when there's an action */
if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) {
- AnimData *adt = ale->adt;
-
offset += 16;
/* now draw some indicator icons */
@@ -952,7 +950,7 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar)
glEnable(GL_BLEND);
- /* loop through channels, and set up drawing depending on their type */
+ /* loop through channels, and set up drawing depending on their type */
for (ale = anim_data.first; ale; ale = ale->next) {
const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 950060dde5f..3740c3fae5e 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -121,9 +121,9 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
/* if no blocks, popup error? */
if (anim_data.first == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweakmode for");
+ BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for");
return OPERATOR_CANCELLED;
- }
+ }
/* for each AnimData block with NLA-data, try setting it in tweak-mode */
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -147,7 +147,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
}
else {
- BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweakmode on");
+ BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweak mode on");
return OPERATOR_CANCELLED;
}
@@ -190,9 +190,9 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op)
/* if no blocks, popup error? */
if (anim_data.first == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweakmode for");
+ BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for");
return OPERATOR_CANCELLED;
- }
+ }
/* for each AnimData block with NLA-data, try exitting tweak-mode */
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -266,8 +266,8 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
/* only consider selected strips? */
if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
/* extend range if appropriate */
- *min = minf(*min, strip->start);
- *max = maxf(*max, strip->end);
+ *min = min_ff(*min, strip->start);
+ *max = max_ff(*max, strip->end);
}
}
}
@@ -398,14 +398,16 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action"));
if (act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No valid Action to add");
+ BKE_report(op->reports, RPT_ERROR, "No valid action to add");
//printf("Add strip - actname = '%s'\n", actname);
return OPERATOR_CANCELLED;
}
else if (act->idroot == 0) {
/* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */
BKE_reportf(op->reports, RPT_WARNING,
- "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems",
+ "Action '%s' does not specify what datablocks it can be used on "
+ "(try setting the 'ID Root Type' setting from the Datablocks Editor "
+ "for this action to avoid future problems)",
act->id.name + 2);
}
@@ -431,7 +433,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
*/
if ((act->idroot) && (act->idroot != GS(ale->id->name))) {
BKE_reportf(op->reports, RPT_ERROR,
- "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'",
+ "Could not add action '%s' as it cannot be used relative to ID-blocks of type '%s'",
act->id.name + 2, ale->id->name);
continue;
}
@@ -1362,7 +1364,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
"Cannot swap selected strips as they will not be able to fit in their new places");
}
else {
- BKE_reportf(op->reports, RPT_WARNING,
+ BKE_reportf(op->reports, RPT_WARNING,
"Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places",
sa->name, sb->name);
}
@@ -2021,7 +2023,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
set_active_fmodifier(&strip->modifiers, fcm);
else {
BKE_reportf(op->reports, RPT_ERROR,
- "Modifier couldn't be added to (%s : %s) (see console for details)",
+ "Modifier could not be added to (%s : %s) (see console for details)",
nlt->name, strip->name);
}
}
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 3a74d0b4c9c..54ade829c0d 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -256,7 +256,7 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0);
/* duplicate */
- WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
/* delete */
WM_keymap_add_item(keymap, "NLA_OT_delete", XKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 79be0d0a194..97553b7aa56 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -390,7 +390,7 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri
if (leftright == NLAEDIT_LRSEL_LEFT) {
xmin = MINAFRAMEF;
xmax = (float)(CFRA + 0.1f);
- }
+ }
else {
xmin = (float)(CFRA - 0.1f);
xmax = MAXFRAMEF;
@@ -471,7 +471,7 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_int_set(op->ptr, "mode", NLAEDIT_LRSEL_LEFT);
- else
+ else
RNA_int_set(op->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
}
@@ -582,7 +582,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight NLA-Track */
- if (ale->type == ANIMTYPE_NLATRACK) {
+ if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
nlt->flag |= NLATRACK_SELECTED;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index b54443f327e..e5cc6bf4bc7 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -110,6 +110,43 @@ static void node_socket_button_default(const bContext *C, uiBlock *block,
}
}
+static void node_socket_button_string(const bContext *C, uiBlock *block,
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *name, int x, int y, int width)
+{
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ uiBut *bt;
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+ const char *ui_name = IFACE_(name);
+ float slen;
+
+ UI_ThemeColor(TH_TEXT);
+ slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+ while (slen > (width * 0.5f) && *ui_name) {
+ ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
+ slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+ }
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ if (name[0] == '\0')
+ slen = 0.0;
+
+ bt = uiDefButR(block, TEX, B_NODE_EXEC, "",
+ x, y + 1, width - slen, NODE_DY - 2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, "");
+ if (node)
+ uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+
+ if (slen > 0.0f)
+ uiDefBut(block, LABEL, 0, IFACE_(name), x + (width - slen), y + 2, slen, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
+ }
+}
+
typedef struct SocketComponentMenuArgs {
PointerRNA ptr;
int x, y, width;
@@ -211,9 +248,9 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
if (*ui_name) {
uiDefBut(block, LABEL, 0, ui_name,
- (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
- (short)slen, (short)NODE_DY,
- NULL, 0, 0, 0, 0, "");
+ (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
+ (short)slen, (short)NODE_DY,
+ NULL, 0, 0, 0, 0, "");
}
}
@@ -284,7 +321,7 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr
RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
col = uiLayoutColumn(layout, FALSE);
- uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0);
+ uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE);
}
@@ -488,8 +525,9 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
bNodeSocket *sock, *gsock;
float locx, locy;
rctf *rect= &gnode->totr;
- float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
- float group_header= 26*U.dpi/72;
+ const float dpi_fac = UI_DPI_ICON_FAC;
+ const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
+ const float group_header = 26 * dpi_fac;
int counter;
int dy;
@@ -666,7 +704,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode,
bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
{
- const float dpi_fac = U.dpi / 72.0f;
+ const float dpi_fac = UI_DPI_ICON_FAC;
bNodeTree *ngroup= (bNodeTree*)gnode->id;
bNodeSocketType *stype= ntreeGetSocketType(gsock ? gsock->type : sock->type);
uiBut *bt;
@@ -778,9 +816,9 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
uiLayout *layout;
PointerRNA ptr;
rctf rect= gnode->totr;
- const float dpi_fac = U.dpi / 72.0f;
- float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
- float group_header = 26 * dpi_fac;
+ const float dpi_fac = UI_DPI_ICON_FAC;
+ const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
+ const float group_header = 26 * dpi_fac;
int index;
@@ -835,7 +873,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
- mini((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
+ min_ii((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL);
uiBlockLayoutResolve(gnode->block, NULL, NULL);
@@ -896,11 +934,6 @@ static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
}
-static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "max_iterations", 0, NULL, ICON_NONE);
-}
-
/* XXX Does a bounding box update by iterating over all children.
* Not ideal to do this in every draw call, but doing as transform callback doesn't work,
* since the child node totr rects are not updated properly at that point.
@@ -1180,16 +1213,6 @@ static void node_common_set_butfunc(bNodeType *ntype)
ntype->drawfunc= node_draw_group;
ntype->drawupdatefunc= node_update_group;
break;
- case NODE_FORLOOP:
-// ntype->uifunc= node_common_buts_group;
- ntype->drawfunc= node_draw_group;
- ntype->drawupdatefunc= node_update_group;
- break;
- case NODE_WHILELOOP:
- ntype->uifunc= node_common_buts_whileloop;
- ntype->drawfunc= node_draw_group;
- ntype->drawupdatefunc= node_update_group;
- break;
case NODE_FRAME:
ntype->drawfunc = node_draw_frame;
ntype->drawupdatefunc= node_update_frame;
@@ -1395,16 +1418,84 @@ static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), Po
uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
}
+static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "space", 0, "", 0);
+
+ if (RNA_enum_get(ptr, "space") == SHD_NORMAL_MAP_TANGENT) {
+ PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
+
+ if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
+ PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
+ uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
+ }
+ else
+ uiItemR(layout, ptr, "uv_map", 0, "", 0);
+ }
+}
+
+static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ uiLayout *split, *row;
+
+ split = uiLayoutSplit(layout, 0.0f, FALSE);
+
+ uiItemR(split, ptr, "direction_type", 0, "", 0);
+
+ row = uiLayoutRow(split, FALSE);
+
+ if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) {
+ PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
+
+ if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
+ PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
+ uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
+ }
+ else
+ uiItemR(row, ptr, "uv_map", 0, "", 0);
+ }
+ else
+ uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
+}
+
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
}
+static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *row;
+
+ row = uiLayoutRow(layout, FALSE);
+ uiItemR(row, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, TRUE);
+
+ if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
+ uiItemR(row, ptr, "script", 0, "", ICON_NONE);
+ else
+ uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
+
+ uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
+}
+
+static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ uiItemS(layout);
+
+ node_shader_buts_script(layout, C, ptr);
+
+ /* not implemented yet
+ if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL)
+ uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);*/
+}
+
/* only once called */
static void node_shader_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
- /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
+ /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
case SH_NODE_MATERIAL:
case SH_NODE_MATERIAL_EXT:
@@ -1479,10 +1570,21 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_TEX_COORD:
ntype->uifunc = node_shader_buts_tex_coord;
break;
+ case SH_NODE_NORMAL_MAP:
+ ntype->uifunc = node_shader_buts_normal_map;
+ break;
+ case SH_NODE_TANGENT:
+ ntype->uifunc = node_shader_buts_tangent;
+ break;
case SH_NODE_BSDF_GLOSSY:
case SH_NODE_BSDF_GLASS:
+ case SH_NODE_BSDF_REFRACTION:
ntype->uifunc= node_shader_buts_glossy;
break;
+ case SH_NODE_SCRIPT:
+ ntype->uifunc = node_shader_buts_script;
+ ntype->uifuncbut = node_shader_buts_script_details;
+ break;
}
}
@@ -2157,17 +2259,17 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C
split = uiLayoutSplit(layout, 0.0f, FALSE);
col = uiLayoutColumn(split, FALSE);
- uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1);
+ uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
col = uiLayoutColumn(split, FALSE);
- uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1);
+ uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
col = uiLayoutColumn(split, FALSE);
- uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1);
+ uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE);
@@ -2176,17 +2278,17 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C
split = uiLayoutSplit(layout, 0.0f, FALSE);
col = uiLayoutColumn(split, FALSE);
- uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1);
+ uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
col = uiLayoutColumn(split, FALSE);
- uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1);
+ uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
col = uiLayoutColumn(split, FALSE);
- uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1);
+ uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE);
}
@@ -2198,23 +2300,23 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS
if (RNA_enum_get(ptr, "correction_method")== 0) {
- uiTemplateColorWheel(layout, ptr, "lift", 1, 1, 0, 1);
+ uiTemplateColorPicker(layout, ptr, "lift", 1, 1, 0, 1);
uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
- uiTemplateColorWheel(layout, ptr, "gamma", 1, 1, 1, 1);
+ uiTemplateColorPicker(layout, ptr, "gamma", 1, 1, 1, 1);
uiItemR(layout, ptr, "gamma", 0, NULL, ICON_NONE);
- uiTemplateColorWheel(layout, ptr, "gain", 1, 1, 1, 1);
+ uiTemplateColorPicker(layout, ptr, "gain", 1, 1, 1, 1);
uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE);
}
else {
- uiTemplateColorWheel(layout, ptr, "offset", 1, 1, 0, 1);
+ uiTemplateColorPicker(layout, ptr, "offset", 1, 1, 0, 1);
uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
- uiTemplateColorWheel(layout, ptr, "power", 1, 1, 0, 1);
+ uiTemplateColorPicker(layout, ptr, "power", 1, 1, 0, 1);
uiItemR(layout, ptr, "power", 0, NULL, ICON_NONE);
- uiTemplateColorWheel(layout, ptr, "slope", 1, 1, 0, 1);
+ uiTemplateColorPicker(layout, ptr, "slope", 1, 1, 0, 1);
uiItemR(layout, ptr, "slope", 0, NULL, ICON_NONE);
}
}
@@ -2596,7 +2698,7 @@ static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, Point
static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
- /* bNode *node= ptr->data; */ /* UNUSED */
+ /* bNode *node = ptr->data; */ /* UNUSED */
uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
@@ -2655,7 +2757,7 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN
static void node_composit_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
- /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
+ /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
case CMP_NODE_IMAGE:
ntype->uifunc= node_composit_buts_image;
@@ -3073,6 +3175,9 @@ void ED_node_init_butfuncs(void)
case SOCK_BOOLEAN:
stype->buttonfunc = node_socket_button_default;
break;
+ case SOCK_STRING:
+ stype->buttonfunc = node_socket_button_string;
+ break;
case SOCK_VECTOR:
stype->buttonfunc = node_socket_button_components;
break;
@@ -3099,7 +3204,6 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
void *lock;
ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
- SpaceNode *snode = CTX_wm_space_node(C);
float x, y;
unsigned char *display_buffer;
void *cache_handle;
@@ -3228,7 +3332,7 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)
float zoomx, zoomy;
zoomx= (float)sa->winx/ibuf->x;
zoomy= (float)sa->winy/ibuf->y;
- zoom = minf(zoomx, zoomy);
+ zoom = min_ff(zoomx, zoomy);
}
x = (sa->winx-zoom*ibuf->x)/2 + snode->xof;
@@ -3567,7 +3671,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
}
do_shaded = TRUE;
do_triple = TRUE;
- }
+ }
else {
th_col1 = TH_REDALERT;
}
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index 99d49fa1e8f..04d2947ce89 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -31,10 +31,15 @@
#include <errno.h>
+#include "MEM_guardedalloc.h"
+
#include "DNA_node_types.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLF_translation.h"
+
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_library.h"
@@ -131,14 +136,105 @@ static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int
return 0;
}
+typedef struct bNodeSocketLink {
+ struct bNodeSocketLink *next, *prev;
+
+ struct bNodeSocket *sock;
+ struct bNodeLink *link;
+ float point[2];
+} bNodeSocketLink;
+
+static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket *sock, bNodeLink *link, float point[2])
+{
+ bNodeSocketLink *socklink, *prev;
+
+ socklink = MEM_callocN(sizeof(bNodeSocketLink), "socket link");
+ socklink->sock = sock;
+ socklink->link = link;
+ copy_v2_v2(socklink->point, point);
+
+ for (prev = lb->last; prev; prev = prev->prev) {
+ if (prev->sock == sock)
+ break;
+ }
+ BLI_insertlinkafter(lb, prev, socklink);
+ return socklink;
+}
+
+static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLink *socklink, int in_out)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNodeTree *ntree = snode->edittree;
+ bNode *reroute_node = NULL;
+ bNodeSocket *cursock = socklink->sock;
+ float insert_point[2];
+ int num_links;
+
+ zero_v2(insert_point);
+ num_links = 0;
+
+ while (socklink && socklink->sock == cursock) {
+ if (!(socklink->link->flag & NODE_LINK_TEST)) {
+ socklink->link->flag |= NODE_LINK_TEST;
+
+ /* create the reroute node for this cursock */
+ if (!reroute_node) {
+ bNodeTemplate ntemp;
+ ntemp.type = NODE_REROUTE;
+ reroute_node = nodeAddNode(ntree, &ntemp);
+
+ /* add a single link to/from the reroute node to replace multiple links */
+ if (in_out == SOCK_OUT) {
+ nodeAddLink(ntree, socklink->link->fromnode, socklink->link->fromsock, reroute_node, reroute_node->inputs.first);
+ }
+ else {
+ nodeAddLink(ntree, reroute_node, reroute_node->outputs.first, socklink->link->tonode, socklink->link->tosock);
+ }
+ }
+
+ /* insert the reroute node into the link */
+ if (in_out == SOCK_OUT) {
+ socklink->link->fromnode = reroute_node;
+ socklink->link->fromsock = reroute_node->outputs.first;
+ }
+ else {
+ socklink->link->tonode = reroute_node;
+ socklink->link->tosock = reroute_node->inputs.first;
+ }
+
+ add_v2_v2(insert_point, socklink->point);
+ ++num_links;
+ }
+ socklink = socklink->next;
+ }
+
+ if (num_links > 0) {
+ bNode *gnode = node_tree_get_editgroup(snode->nodetree);
+
+ /* average cut point from shared links */
+ mul_v2_fl(insert_point, 1.0f / num_links);
+
+ if (gnode) {
+ nodeFromView(gnode, insert_point[0], insert_point[1], &reroute_node->locx, &reroute_node->locy);
+ }
+ else {
+ reroute_node->locx = insert_point[0];
+ reroute_node->locy = insert_point[1];
+ }
+ }
+
+ return socklink;
+}
+
static int add_reroute_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
- bNode *gnode = node_tree_get_editgroup(snode->nodetree);
+ bNodeTree *ntree = snode->edittree;
float mcoords[256][2];
int i = 0;
-
+
+ /* Get the cut path */
RNA_BEGIN(op->ptr, itemptr, "path")
{
float loc[2];
@@ -152,46 +248,52 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
RNA_END;
if (i > 1) {
+ ListBase output_links, input_links;
bNodeLink *link;
- float insertPoint[2];
-
- for (link = snode->edittree->links.first; link; link = link->next) {
- if (add_reroute_intersect_check(link, mcoords, i, insertPoint)) {
- bNodeTemplate ntemp;
- bNode *rerouteNode;
-
- /* always first */
- ED_preview_kill_jobs(C);
-
- node_deselect_all(snode);
-
- ntemp.type = NODE_REROUTE;
- rerouteNode = nodeAddNode(snode->edittree, &ntemp);
- if (gnode) {
- nodeFromView(gnode, insertPoint[0], insertPoint[1], &rerouteNode->locx, &rerouteNode->locy);
- }
- else {
- rerouteNode->locx = insertPoint[0];
- rerouteNode->locy = insertPoint[1];
- }
-
- nodeAddLink(snode->edittree, link->fromnode, link->fromsock, rerouteNode, rerouteNode->inputs.first);
- link->fromnode = rerouteNode;
- link->fromsock = rerouteNode->outputs.first;
-
- /* always last */
- ntreeUpdateTree(snode->edittree);
- snode_notify(C, snode);
- snode_dag_update(C, snode);
-
- return OPERATOR_FINISHED; // add one reroute at the time.
+ bNodeSocketLink *socklink;
+ float insert_point[2];
+
+ /* always first */
+ ED_preview_kill_jobs(C);
+
+ node_deselect_all(snode);
+
+ /* Find cut links and sort them by sockets */
+ output_links.first = output_links.last = NULL;
+ input_links.first = input_links.last = NULL;
+ for (link = ntree->links.first; link; link = link->next) {
+ 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);
+
+ /* Clear flag */
+ link->flag &= ~NODE_LINK_TEST;
}
}
-
- return OPERATOR_CANCELLED;
-
+
+ /* Create reroute nodes for intersected links.
+ * Only one reroute if links share the same input/output socket.
+ */
+ socklink = output_links.first;
+ while (socklink) {
+ socklink = add_reroute_do_socket_section(C, socklink, SOCK_OUT);
+ }
+ socklink = input_links.first;
+ while (socklink) {
+ socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN);
+ }
+
+ BLI_freelistN(&output_links);
+ BLI_freelistN(&input_links);
+
+ /* always last */
+ ntreeUpdateTree(ntree);
+ snode_notify(C, snode);
+ snode_dag_update(C, snode);
+
+ return OPERATOR_FINISHED;
}
-
+
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
@@ -240,7 +342,8 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
ima = BKE_image_load_exists(path);
if (!ima) {
- BKE_reportf(op->reports, RPT_ERROR, "Can't read image: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported format");
+ BKE_reportf(op->reports, RPT_ERROR, "Cannot read image '%s': %s",
+ path, errno ? strerror(errno) : TIP_("unsupported format"));
return OPERATOR_CANCELLED;
}
}
@@ -250,7 +353,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
ima = (Image *)BKE_libblock_find_name(ID_IM, name);
if (!ima) {
- BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name);
+ BKE_reportf(op->reports, RPT_ERROR, "Image '%s' not found", name);
return OPERATOR_CANCELLED;
}
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f62f5a0a273..5e50c9fc287 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -103,7 +103,7 @@ void ED_node_changed_update(ID *id, bNode *node)
nodeUpdateID(nodetree, node->id);
WM_main_add_notifier(NC_SCENE | ND_NODES, id);
- }
+ }
else if (treetype == NTREE_TEXTURE) {
DAG_id_tag_update(id, 0);
WM_main_add_notifier(NC_TEXTURE | ND_NODES, id);
@@ -393,7 +393,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->totr.xmin = locx;
node->totr.xmax = locx + node->width;
node->totr.ymax = locy;
- node->totr.ymin = minf(dy, locy - 2 * NODE_DY);
+ node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY);
/* Set the block bounds to clip mouse events from underlying nodes.
* Add a margin for sockets on each side.
@@ -508,25 +508,16 @@ int node_get_colorid(bNode *node)
/* note: in node_edit.c is similar code, for untangle node */
static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
{
- ListBase links;
bNodeLink *link;
- if (node->typeinfo->internal_connect == NULL)
- return;
-
- /* Get default muting links. */
- links = node->typeinfo->internal_connect(snode->edittree, node);
-
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- for (link = 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, 0, TH_WIRE, 0, TH_WIRE);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
-
- BLI_freelistN(&links);
}
/* this might have some more generic use */
@@ -670,7 +661,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
bNodeSocket *sock;
rctf *rct = &node->totr;
float iconofs;
- /* float socket_size= NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */
+ /* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */
float iconbutw = 0.8f * UI_UNIT_X;
int color_id = node_get_colorid(node);
char showname[128]; /* 128 used below */
@@ -857,7 +848,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
rctf *rct = &node->totr;
float dx, centy = BLI_rctf_cent_y(rct);
float hiddenrad = BLI_rctf_size_y(rct) / 2.0f;
- float socket_size = NODE_SOCKSIZE * U.dpi / 72;
+ float socket_size = NODE_SOCKSIZE * UI_DPI_ICON_FAC;
int color_id = node_get_colorid(node);
char showname[128]; /* 128 is used below */
@@ -920,7 +911,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
/* disable lines */
if (node->flag & NODE_MUTED)
- node_draw_mute_line(&ar->v2d, snode, node);
+ node_draw_mute_line(&ar->v2d, snode, node);
if (node->flag & SELECT)
UI_ThemeColor(TH_SELECT);
@@ -937,7 +928,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
(int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
(short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
- }
+ }
gpuImmediateFormat_C4_V2(); // DOODLE: 4 theme colored lines
gpuBegin(GL_LINES);
@@ -1119,7 +1110,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
/* aspect+font, set each time */
snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx;
snode->aspect_sqrt = sqrtf(snode->aspect);
- // XXX snode->curfont= uiSetCurFont_ext(snode->aspect);
+ // XXX snode->curfont = uiSetCurFont_ext(snode->aspect);
/* grid */
UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2);
@@ -1149,7 +1140,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
#ifdef WITH_COMPOSITOR
if (snode->nodetree->type == NTREE_COMPOSIT) {
COM_startReadHighlights();
- }
+ }
#endif
node_draw_nodetree(C, ar, snode, snode->nodetree);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 64a8d96a74f..62e941d3148 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -35,6 +35,7 @@
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
+#include "DNA_text_types.h"
#include "DNA_world_types.h"
#include "BLI_math.h"
@@ -54,6 +55,7 @@
#include "BKE_scene.h"
#include "BKE_texture.h"
+#include "RE_engine.h"
#include "RE_pipeline.h"
@@ -1622,7 +1624,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op))
for (node = snode->edittree->nodes.first; node; node = node->next) {
/* Only allow muting of nodes having a mute func! */
- if ((node->flag & SELECT) && node->typeinfo->internal_connect) {
+ if ((node->flag & SELECT) && node->typeinfo->update_internal_links) {
node->flag ^= NODE_MUTED;
snode_update(snode, node);
}
@@ -1935,7 +1937,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
bNodeTree *ntree = snode->edittree;
bNode *gnode = node_tree_get_editgroup(snode->nodetree);
float gnode_x = 0.0f, gnode_y = 0.0f;
- bNode *node, *new_node;
+ bNode *node;
bNodeLink *link, *newlink;
ED_preview_kill_jobs(C);
@@ -1950,6 +1952,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
+ bNode *new_node;
new_node = nodeCopyNode(NULL, node);
BKE_node_clipboard_add_node(new_node);
}
@@ -1971,7 +1974,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
}
/* transform to basic view space. child node location is relative to parent */
- if (!new_node->parent) {
+ if (!new_node->parent) {
new_node->locx += gnode_x;
new_node->locy += gnode_y;
}
@@ -2136,3 +2139,120 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/* ********************** Shader Script Update ******************/
+
+typedef struct ScriptUpdateData {
+ RenderEngine *engine;
+ RenderEngineType *type;
+
+ Text *text;
+ int found;
+} ScriptUpdateData;
+
+static int node_shader_script_update_poll(bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
+ bNode *node;
+ Text *text;
+
+ /* test if we have a render engine that supports shaders scripts */
+ 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 && node->type == SH_NODE_SCRIPT) {
+ NodeShaderScript *nss = node->storage;
+
+ if (node->id || nss->filepath[0]) {
+ return 1;
+ }
+ }
+
+ /* see if we have a text datablock in context */
+ text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
+ if (text)
+ return 1;
+
+ /* we don't check if text datablock is actually in use, too slow for poll */
+
+ return 0;
+}
+
+static void node_shader_script_update_text(void *data_, ID *UNUSED(id), bNodeTree *ntree)
+{
+ ScriptUpdateData *data = (ScriptUpdateData *)data_;
+ bNode *node;
+
+ /* update each script that is using this text datablock */
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP) {
+ node_shader_script_update_text(data_, NULL, (bNodeTree *)node->id);
+ }
+ else if (node->type == SH_NODE_SCRIPT && node->id == &data->text->id) {
+ data->type->update_script_node(data->engine, ntree, node);
+ data->found = TRUE;
+ }
+ }
+}
+
+static int node_shader_script_update_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ScriptUpdateData data;
+ PointerRNA nodeptr = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript);
+
+ /* setup render engine */
+ data.type = RE_engines_find(scene->r.engine);
+ data.engine = RE_engine_create(data.type);
+ data.engine->reports = op->reports;
+ data.text = NULL;
+ data.found = FALSE;
+
+ if (nodeptr.data) {
+ /* update single node */
+ bNodeTree *ntree = nodeptr.id.data;
+ bNode *node = nodeptr.data;
+
+ data.type->update_script_node(data.engine, ntree, node);
+
+ data.found = TRUE;
+ }
+ else {
+ /* update all nodes using text datablock */
+ data.text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
+
+ if (data.text) {
+ bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER);
+
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(bmain, &data, node_shader_script_update_text);
+
+ if (!data.found)
+ BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done");
+ }
+ }
+
+ RE_engine_free(data.engine);
+
+ return (data.found)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+}
+
+void NODE_OT_shader_script_update(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Script Node Update";
+ ot->description = "Update shader script node with new sockets and options from the script";
+ ot->idname = "NODE_OT_shader_script_update";
+
+ /* api callbacks */
+ ot->exec = node_shader_script_update_exec;
+ ot->poll = node_shader_script_update_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index b76cc05af5c..5f8b5db7766 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -583,7 +583,7 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
ntreeUpdateTree(snode->nodetree);
}
else {
- BKE_report(op->reports, RPT_WARNING, "Can't ungroup");
+ BKE_report(op->reports, RPT_WARNING, "Cannot ungroup");
return OPERATOR_CANCELLED;
}
@@ -755,13 +755,13 @@ static int node_group_separate_exec(bContext *C, wmOperator *op)
switch (type) {
case NODE_GS_COPY:
if (!node_group_separate_selected(snode->nodetree, gnode, 1)) {
- BKE_report(op->reports, RPT_WARNING, "Can't separate nodes");
+ BKE_report(op->reports, RPT_WARNING, "Cannot separate nodes");
return OPERATOR_CANCELLED;
}
break;
case NODE_GS_MOVE:
if (!node_group_separate_selected(snode->nodetree, gnode, 0)) {
- BKE_report(op->reports, RPT_WARNING, "Can't separate nodes");
+ BKE_report(op->reports, RPT_WARNING, "Cannot separate nodes");
return OPERATOR_CANCELLED;
}
break;
@@ -875,7 +875,7 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode)
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeLink *link, *linkn;
bNode *node, *nextn;
- bNodeSocket *gsock;
+ bNodeSocket *gsock, *sock;
ListBase anim_basepaths = {NULL, NULL};
float min[2], max[2];
@@ -982,8 +982,42 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode)
}
}
+ /* auto-add interface for "solo" nodes */
+ node = ((bNodeTree *)gnode->id)->nodes.first;
+ if (node && !node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ int skip = FALSE;
+
+ for (link = ((bNodeTree *)gnode->id)->links.first; link; link = link->next)
+ if (link->tosock == sock)
+ skip = TRUE;
+
+ if (skip == TRUE)
+ continue;
+
+ gsock = node_group_expose_socket(ngroup, sock, SOCK_IN);
+ node_group_add_extern_socket(ntree, &gnode->inputs, SOCK_IN, gsock);
+ nodeAddLink(ngroup, NULL, gsock, node, sock);
+ }
+
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ int skip = FALSE;
+
+ for (link = ((bNodeTree *)gnode->id)->links.first; link; link = link->next)
+ if (link->fromsock == sock)
+ skip = TRUE;
+
+ if (skip == TRUE)
+ continue;
+
+ gsock = node_group_expose_socket(ngroup, sock, SOCK_OUT);
+ node_group_add_extern_socket(ntree, &gnode->outputs, SOCK_OUT, gsock);
+ nodeAddLink(ngroup, NULL, gsock, node, sock);
+ }
+ }
+
/* update of the group tree */
- ngroup->update |= NTREE_UPDATE;
+ ngroup->update |= NTREE_UPDATE | NTREE_UPDATE_LINKS;
/* update of the tree containing the group instance node */
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
@@ -1036,7 +1070,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
int type = RNA_enum_get(op->ptr, "type");
if (snode->edittree != snode->nodetree) {
- BKE_report(op->reports, RPT_WARNING, "Can not add a new Group in a Group");
+ BKE_report(op->reports, RPT_WARNING, "Cannot add a new group in a group");
return OPERATOR_CANCELLED;
}
@@ -1049,7 +1083,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
}
if (gnode) {
- BKE_report(op->reports, RPT_WARNING, "Can not add RenderLayer in a Group");
+ BKE_report(op->reports, RPT_WARNING, "Cannot add a Render Layers node in a group");
return OPERATOR_CANCELLED;
}
}
@@ -1062,21 +1096,21 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
gnode = node_group_make_from_selected(snode->nodetree);
}
else {
- BKE_report(op->reports, RPT_WARNING, "Can not make Group");
+ BKE_report(op->reports, RPT_WARNING, "Cannot make group");
return OPERATOR_CANCELLED;
}
break;
case NODE_GM_INSERT:
gnode = nodeGetActive(snode->nodetree);
if (!gnode || gnode->type != NODE_GROUP) {
- BKE_report(op->reports, RPT_WARNING, "No active Group node");
+ BKE_report(op->reports, RPT_WARNING, "No active group node");
return OPERATOR_CANCELLED;
}
if (node_group_make_test(snode->nodetree, gnode)) {
node_group_make_insert_selected(snode->nodetree, gnode);
}
else {
- BKE_report(op->reports, RPT_WARNING, "Can not insert into Group");
+ BKE_report(op->reports, RPT_WARNING, "Cannot insert into group");
return OPERATOR_CANCELLED;
}
break;
diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c
index 5ab698cd415..e82917feb21 100644
--- a/source/blender/editors/space_node/node_header.c
+++ b/source/blender/editors/space_node/node_header.c
@@ -138,12 +138,6 @@ static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
case NODE_GROUP:
ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type);
break;
- case NODE_FORLOOP:
- ntemp.ngroup = ntreeAddTree("For Loop", snode->treetype, ntemp.type);
- break;
- case NODE_WHILELOOP:
- ntemp.ngroup = ntreeAddTree("While Loop", snode->treetype, ntemp.type);
- break;
default:
ntemp.ngroup = NULL;
}
@@ -199,15 +193,11 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
/* XXX hack: negative numbers used for empty group types */
if (node_tree_has_type(ntree->type, NODE_GROUP))
uiItemV(layout, IFACE_("New Group"), 0, -NODE_GROUP);
- if (node_tree_has_type(ntree->type, NODE_FORLOOP))
- uiItemV(layout, IFACE_("New For Loop"), 0, -NODE_FORLOOP);
- if (node_tree_has_type(ntree->type, NODE_WHILELOOP))
- uiItemV(layout, IFACE_("New While Loop"), 0, -NODE_WHILELOOP);
uiItemS(layout);
for (ngroup = bmain->nodetree.first, event = 0; ngroup; ngroup = ngroup->id.next, ++event) {
/* only use group trees */
- if (ngroup->type == ntree->type && ELEM3(ngroup->nodetype, NODE_GROUP, NODE_FORLOOP, NODE_WHILELOOP)) {
+ if (ngroup->type == ntree->type && ngroup->nodetype == NODE_GROUP) {
uiItemV(layout, ngroup->id.name + 2, 0, event);
}
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 36ebddc8d22..45509e02226 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -206,6 +206,8 @@ void NODE_OT_output_file_move_active_socket(struct wmOperatorType *ot);
void NODE_OT_clipboard_copy(struct wmOperatorType *ot);
void NODE_OT_clipboard_paste(struct wmOperatorType *ot);
+void NODE_OT_shader_script_update(struct wmOperatorType *ot);
+
extern const char *node_context_dir[];
// XXXXXX
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 560ef9e8a29..64e5f67a348 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -117,6 +117,8 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_clipboard_copy);
WM_operatortype_append(NODE_OT_clipboard_paste);
+
+ WM_operatortype_append(NODE_OT_shader_script_update);
}
void ED_operatormacros_node(void)
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index fec7366ee73..7fa48c48ad6 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -136,7 +136,7 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in
int a = 0;
for (sock = node->inputs.first; sock; sock = sock->next) {
- maxtype = MAX2(sock->type, maxtype);
+ maxtype = max_ii(sock->type, maxtype);
}
/* find sockets of higher 'types' first (i.e. image) */
@@ -1368,7 +1368,7 @@ static bNodeSocket *socket_best_match(ListBase *sockets)
/* find type range */
for (sock = sockets->first; sock; sock = sock->next)
- maxtype = MAX2(sock->type, maxtype);
+ maxtype = max_ii(sock->type, maxtype);
/* try all types, starting from 'highest' (i.e. colors, vectors, values) */
for (type = maxtype; type >= 0; --type) {
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index cdadf5dfd1a..1971e3ae101 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -593,7 +593,7 @@ static int node_lasso_select_exec(bContext *C, wmOperator *op)
select = !RNA_boolean_get(op->ptr, "deselect");
do_lasso_select_node(C, mcords, mcords_tot, select);
- MEM_freeN(mcords);
+ MEM_freeN((void *)mcords);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 3d93a6c14a1..23f4e948794 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -122,6 +122,7 @@ static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to
return;
nodeRemLink(ntree, sock_to->link);
+ sock_to->flag |= SOCK_COLLAPSED;
nodeUpdate(ntree, node_to);
ntreeUpdateTree(ntree);
@@ -136,6 +137,7 @@ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bN
return;
node_remove_linked(ntree, sock_to->link->fromnode);
+ sock_to->flag |= SOCK_COLLAPSED;
nodeUpdate(ntree, node_to);
ntreeUpdateTree(ntree);
@@ -147,7 +149,7 @@ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bN
static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to, bNodeTemplate *ntemp, int sock_num)
{
bNode *node_from;
- bNodeSocket *sock_from;
+ bNodeSocket *sock_from_tmp;
bNode *node_prev = NULL;
/* unlink existing node */
@@ -183,8 +185,9 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
nodeSetActive(ntree, node_from);
/* add link */
- sock_from = BLI_findlink(&node_from->outputs, sock_num);
- nodeAddLink(ntree, node_from, sock_from, node_to, sock_to);
+ sock_from_tmp = BLI_findlink(&node_from->outputs, sock_num);
+ nodeAddLink(ntree, node_from, sock_from_tmp, node_to, sock_to);
+ sock_to->flag &= ~SOCK_COLLAPSED;
/* copy input sockets from previous node */
if (node_prev && node_from != node_prev) {
@@ -289,8 +292,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR])
BLI_strncpy(node_name, node->typeinfo->name, UI_MAX_NAME_STR);
if (node->inputs.first == NULL &&
- node->outputs.first != node->outputs.last &&
- !(node->typeinfo->flag & NODE_OPTIONS))
+ node->outputs.first != node->outputs.last)
{
BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", IFACE_(node_name), IFACE_(sock->link->fromsock->name));
}
@@ -613,7 +615,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
/* input linked to a node */
uiTemplateNodeLink(split, ntree, node, input);
- if (!(input->flag & SOCK_COLLAPSED)) {
+ if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) {
if (depth == 0)
uiItemS(layout);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index b70d66f60b4..4d2512cdc93 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -111,7 +111,6 @@ static SpaceLink *node_new(const bContext *UNUSED(C))
BLI_addtail(&snode->regionbase, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_RIGHT;
- ar->flag = RGN_FLAG_HIDDEN;
/* main area */
ar = MEM_callocN(sizeof(ARegion), "main area for node");
@@ -254,6 +253,15 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
}
}
break;
+
+ case NC_MOVIECLIP:
+ if (wmn->action == NA_EDITED) {
+ if (type == NTREE_COMPOSIT) {
+ if (nodeUpdateID(snode->nodetree, wmn->reference))
+ ED_area_tag_refresh(sa);
+ }
+ }
+ break;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index c8e004e14de..324d9e3e6fe 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -36,6 +36,7 @@
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
+#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
@@ -94,7 +95,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w)
{
TreeElement *te = lb->first;
while (te) {
-// TreeStoreElem *tselem= TREESTORE(te);
+// TreeStoreElem *tselem = TREESTORE(te);
// XXX fixme... te->xend is not set yet
if (!TSELEM_OPEN(tselem, soops)) {
@@ -240,9 +241,9 @@ static int group_select_flag(Group *gr)
void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
{
- Scene *scene = (Scene *)poin;
+ Scene *scene = (Scene *)poin;
GroupObject *gob;
- Group *gr = (Group *)poin2;
+ Group *gr = (Group *)poin2;
if (group_restrict_flag(gr, flag)) {
for (gob = gr->gobject.first; gob; gob = gob->next) {
@@ -311,7 +312,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
WM_event_add_notifier(C, NC_SCENE, NULL); break;
default:
WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break;
- }
+ }
/* Check the library target exists */
if (te->idcode == ID_LI) {
Library *lib = (Library *)tselem->id;
@@ -635,7 +636,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
search[0] = 0;
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
/* fake button, it holds space for search items */
uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
@@ -644,7 +645,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
uiBoundsBlock(block, 6);
- uiBlockSetDirection(block, UI_DOWN);
+ uiBlockSetDirection(block, UI_DOWN);
uiEndBlock(C, block);
event = *(win->eventstate); /* XXX huh huh? make api call */
@@ -791,7 +792,9 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
wmKeyMapItem *kmi = te->directdata;
/* modal map? */
- if (kmi->propvalue) ;
+ if (kmi->propvalue) {
+ /* pass */
+ }
else {
uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys + 1, butw1, UI_UNIT_Y - 1, "Assign new Operator");
}
@@ -1006,6 +1009,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
case eModifierType_Bevel:
UI_icon_draw(x, y, ICON_MOD_BEVEL); break;
case eModifierType_Smooth:
+ case eModifierType_LaplacianSmooth:
UI_icon_draw(x, y, ICON_MOD_SMOOTH); break;
case eModifierType_SimpleDeform:
UI_icon_draw(x, y, ICON_MOD_SIMPLEDEFORM); break;
@@ -1046,7 +1050,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
/* Default */
case eModifierType_None:
case eModifierType_ShapeKey:
- case NUM_MODIFIER_TYPES:
+ case NUM_MODIFIER_TYPES:
UI_icon_draw(x, y, ICON_DOT); break;
}
break;
@@ -1257,7 +1261,7 @@ static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, i
for (ten = te->subtree.first; ten; ten = ten->next) {
outliner_set_coord_tree_element(soops, ten, startx + UI_UNIT_X, starty);
- }
+ }
}
@@ -1401,7 +1405,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
offsx += UI_UNIT_X;
- }
+ }
glDisable(GL_BLEND);
/* name */
@@ -1416,11 +1420,15 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
/* closed item, we draw the icons, not when it's a scene, or master-server list though */
if (!TSELEM_OPEN(tselem, soops)) {
if (te->subtree.first) {
- if (tselem->type == 0 && te->idcode == ID_SCE) ;
- else if (tselem->type != TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */
+ if (tselem->type == 0 && te->idcode == ID_SCE) {
+ /* pass */
+ }
+ else if (tselem->type != TSE_R_LAYER) {
+ /* this tree element always has same amount of branches, so don't draw */
+
int tempx = startx + offsx;
- // divider
+ /* divider */
UI_ThemeColorShade(TH_BACK, -40);
gpuSingleFilledRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4);
@@ -1434,7 +1442,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
}
}
}
- }
+ }
/* store coord and continue, we need coordinates for elements outside view too */
te->xs = (float)startx;
te->ys = (float)*starty;
@@ -1445,7 +1453,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
for (ten = te->subtree.first; ten; ten = ten->next)
outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty);
- }
+ }
else {
for (ten = te->subtree.first; ten; ten = ten->next)
outliner_set_coord_tree_element(soops, te, startx, starty);
@@ -1544,7 +1552,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio
{
TreeElement *te;
int starty, startx;
- float col[4];
+ float col[3];
if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
/* struct marks */
@@ -1666,7 +1674,7 @@ void draw_outliner(const bContext *C)
/* get actual width of column 1 */
outliner_rna_width(soops, &soops->tree, &sizex_rna, 0);
- sizex_rna = MAX2(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX);
+ sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX);
/* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */
if (soops->outlinevis == SO_KEYMAP)
@@ -1719,7 +1727,7 @@ void draw_outliner(const bContext *C)
}
/* draw edit buttons if nessecery */
- outliner_buttons(C, block, ar, soops, &soops->tree);
+ outliner_buttons(C, block, ar, soops, &soops->tree);
uiEndBlock(C, block);
uiDrawBlock(C, block);
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 2ec23091019..23766d6a6fe 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -81,7 +81,7 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te)
for (te = te->parent; te; te = te->parent) {
tselem = TREESTORE(te);
- if (tselem->flag & TSE_CLOSED) {
+ if (tselem->flag & TSE_CLOSED) {
tselem->flag &= ~TSE_CLOSED;
retval = 1;
}
@@ -197,10 +197,10 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem,
}
else if (tselem->id->lib) {
// XXX error_libdata();
- }
+ }
else if (te->idcode == ID_LI && te->parent) {
BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library");
- }
+ }
else {
tselem->flag |= TSE_TEXTBUT;
ED_region_tag_redraw(ar);
@@ -368,12 +368,14 @@ void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *
static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb);
+ DAG_id_type_tag(bmain, ID_OB);
WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
ED_region_tag_redraw(ar);
@@ -464,11 +466,13 @@ void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElemen
static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
Scene *scene = CTX_data_scene(C);
outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb);
+ DAG_id_type_tag(bmain, ID_OB);
WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene);
return OPERATOR_FINISHED;
@@ -726,7 +730,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
/* determine which type of search to do */
if (again && last_find) {
- /* no popup panel - previous + user wanted to search for next after previous */
+ /* no popup panel - previous + user wanted to search for next after previous */
BLI_strncpy(name, soops->search_string, sizeof(name));
flags = soops->search_flags;
@@ -742,7 +746,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
/* pop up panel - no previous, or user didn't want search after previous */
name[0] = '\0';
// XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) {
-// te= outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound);
+// te = outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound);
// }
// else return; /* XXX RETURN! XXX */
}
@@ -782,7 +786,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
}
else {
/* no tree-element found */
- BKE_report(reports, RPT_WARNING, "Not found: %s", name);
+ BKE_reportf(reports, RPT_WARNING, "Not found: %s", name);
}
}
#endif
@@ -994,7 +998,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
char buf[128], *name;
temnext = (TreeElement *)(ld->next->data);
- /* tsenext= TREESTORE(temnext); */ /* UNUSED */
+ /* tsenext = TREESTORE(temnext); */ /* UNUSED */
nextptr = &temnext->rnaptr;
name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL);
@@ -1340,7 +1344,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
/* check for invalid states */
if (ks == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Keying Set");
+ BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set");
return OPERATOR_CANCELLED;
}
if (soutliner == NULL)
@@ -1854,7 +1858,7 @@ static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
assign_material(ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, ma);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 823de61d044..4668dfa1386 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -236,7 +236,7 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo
if (ob == NULL) return 0; // no active object
- /*tselem= TREESTORE(te);*/ /*UNUSED*/
+ /*tselem = TREESTORE(te);*/ /*UNUSED*/
/* find buttons area (note, this is undefined really still, needs recode in blender) */
/* XXX removed finding sbuts */
@@ -250,8 +250,8 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo
if (set) {
if (sbuts) {
- // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c
- // XXX sbuts->texfrom= 1;
+ // XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
+ // XXX sbuts->texfrom = 1;
}
// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture
wrld->texact = te->index;
@@ -264,8 +264,8 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo
Lamp *la = (Lamp *)tselemp->id;
if (set) {
if (sbuts) {
- // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c
- // XXX sbuts->texfrom= 2;
+ // XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
+ // XXX sbuts->texfrom = 2;
}
// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture
la->texact = te->index;
@@ -280,8 +280,8 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo
Material *ma = (Material *)tselemp->id;
if (set) {
if (sbuts) {
- //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c
- // XXX sbuts->texfrom= 0;
+ //sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
+ // XXX sbuts->texfrom = 0;
}
// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture
ma->texact = (char)te->index;
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index bf76fdda61e..3b83279e09d 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -158,11 +158,16 @@ static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEl
totcol = mb->totcol;
matar = mb->mat;
}
+ else {
+ BLI_assert(0);
+ }
- for (a = 0; a < totcol; a++) {
- if (a == te->index && matar[a]) {
- matar[a]->id.us--;
- matar[a] = NULL;
+ if (LIKELY(matar != NULL)) {
+ for (a = 0; a < totcol; a++) {
+ if (a == te->index && matar[a]) {
+ matar[a]->id.us--;
+ matar[a] = NULL;
+ }
}
}
}
@@ -811,7 +816,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
ED_undo_push(C, "Unlink world");
break;
default:
- BKE_report(op->reports, RPT_WARNING, "Not Yet");
+ BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
break;
}
}
@@ -844,7 +849,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
break;
default:
- BKE_report(op->reports, RPT_WARNING, "Not Yet");
+ BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
break;
}
}
@@ -974,15 +979,15 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action"));
if (act == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No valid Action to add");
+ BKE_report(op->reports, RPT_ERROR, "No valid action to add");
return OPERATOR_CANCELLED;
}
else if (act->idroot == 0) {
/* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */
BKE_reportf(op->reports, RPT_WARNING,
- "Action '%s' does not specify what datablocks it can be used on. "
- "Try setting the 'ID Root Type' setting from the Datablocks Editor "
- "for this Action to avoid future problems",
+ "Action '%s' does not specify what datablocks it can be used on "
+ "(try setting the 'ID Root Type' setting from the Datablocks Editor "
+ "for this action to avoid future problems)",
act->id.name + 2);
}
@@ -1160,37 +1165,50 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
event = RNA_enum_get(op->ptr, "type");
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
- if (datalevel == TSE_POSE_CHANNEL) {
- if (event > 0) {
+ if (event <= 0)
+ return OPERATOR_CANCELLED;
+
+ switch (datalevel) {
+ case TSE_POSE_CHANNEL:
+ {
outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
ED_undo_push(C, "PoseChannel operation");
}
- }
- else if (datalevel == TSE_BONE) {
- if (event > 0) {
+ break;
+
+ case TSE_BONE:
+ {
outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
ED_undo_push(C, "Bone operation");
}
- }
- else if (datalevel == TSE_EBONE) {
- if (event > 0) {
+ break;
+
+ case TSE_EBONE:
+ {
outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
ED_undo_push(C, "EditBone operation");
}
- }
- else if (datalevel == TSE_SEQUENCE) {
- if (event > 0) {
+ break;
+
+ case TSE_SEQUENCE:
+ {
Scene *scene = CTX_data_scene(C);
outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb, scene);
}
- }
- else if (datalevel == TSE_RNA_STRUCT) {
- if (event == 5) {
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, data_select_linked_cb, C);
- }
+ break;
+
+ case TSE_RNA_STRUCT:
+ if (event == 5) {
+ outliner_do_data_operation(soops, datalevel, event, &soops->tree, data_select_linked_cb, C);
+ }
+ break;
+
+ default:
+ BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
+ break;
}
return OPERATOR_FINISHED;
@@ -1262,12 +1280,15 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S
else {
if (datalevel == TSE_ANIM_DATA)
WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL);
- else if (datalevel == TSE_DRIVER_BASE)
- /* do nothing... no special ops needed yet */;
- else if (ELEM3(datalevel, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS))
- /*WM_operator_name_call(C, "OUTLINER_OT_renderdata_operation", WM_OP_INVOKE_REGION_WIN, NULL)*/;
- else
+ else if (datalevel == TSE_DRIVER_BASE) {
+ /* do nothing... no special ops needed yet */
+ }
+ else if (ELEM3(datalevel, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) {
+ /*WM_operator_name_call(C, "OUTLINER_OT_renderdata_operation", WM_OP_INVOKE_REGION_WIN, NULL)*/
+ }
+ else {
WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL);
+ }
}
}
@@ -1289,11 +1310,13 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *even
SpaceOops *soops = CTX_wm_space_outliner(C);
TreeElement *te;
float fmval[2];
-
+
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1);
for (te = soops->tree.first; te; te = te->next) {
- if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break;
+ if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) {
+ break;
+ }
}
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 3e1ce1fea6e..af890a81ad6 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -553,16 +553,16 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
if (md->type == eModifierType_Lattice) {
outliner_add_element(soops, &te->subtree, ((LatticeModifierData *) md)->object, te, TSE_LINKED_OB, 0);
- }
+ }
else if (md->type == eModifierType_Curve) {
outliner_add_element(soops, &te->subtree, ((CurveModifierData *) md)->object, te, TSE_LINKED_OB, 0);
- }
+ }
else if (md->type == eModifierType_Armature) {
outliner_add_element(soops, &te->subtree, ((ArmatureModifierData *) md)->object, te, TSE_LINKED_OB, 0);
- }
+ }
else if (md->type == eModifierType_Hook) {
outliner_add_element(soops, &te->subtree, ((HookModifierData *) md)->object, te, TSE_LINKED_OB, 0);
- }
+ }
else if (md->type == eModifierType_ParticleSystem) {
TreeElement *ten;
ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys;
@@ -590,7 +590,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
/* duplicated group */
if (ob->dup_group)
- outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0);
+ outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0);
}
// can be inlined if necessary
@@ -731,7 +731,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_AC:
{
// XXX do we want to be exposing the F-Curves here?
- //bAction *act= (bAction *)id;
+ //bAction *act = (bAction *)id;
}
break;
case ID_AR:
@@ -769,7 +769,9 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
else {
/* do not extend Armature when we have posemode */
tselem = TREESTORE(te->parent);
- if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) ;
+ if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) {
+ /* pass */
+ }
else {
Bone *curBone;
for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
@@ -811,9 +813,15 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
te->parent = parent;
te->index = index; // for data arays
- if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) ;
- else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) ;
- else if (type == TSE_ANIM_DATA) ;
+ if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) {
+ /* pass */
+ }
+ else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
+ /* pass */
+ }
+ else if (type == TSE_ANIM_DATA) {
+ /* pass */
+ }
else {
te->name = id->name + 2; // default, can be overridden by Library or non-ID data
te->idcode = GS(id->name);
@@ -1055,8 +1063,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
if (key[0]) {
wmOperatorType *ot = NULL;
- if (kmi->propvalue) ;
- else ot = WM_operatortype_find(kmi->idname, 0);
+ if (kmi->propvalue) {
+ /* pass */
+ }
+ else {
+ ot = WM_operatortype_find(kmi->idname, 0);
+ }
if (ot || kmi->propvalue) {
TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a);
@@ -1136,7 +1148,7 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t
}
if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name))
- /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
+ /* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
p = p->next;
}
}
@@ -1519,7 +1531,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
while (seq) {
op = need_add_seq_dup(seq);
if (op == 1) {
- /* ten= */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0);
+ /* ten = */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0);
}
else if (op == 0) {
ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0);
@@ -1557,7 +1569,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
wmKeyMap *km;
for (km = wm->defaultconf->keymaps.first; km; km = km->next) {
- /* ten= */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0);
+ /* ten = */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0);
}
}
else {
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index 3563cc96861..558e3dc65d4 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -60,4 +60,8 @@ endif()
add_definitions(-DGLEW_STATIC)
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript
index ec06eacae9c..0b429ae750b 100644
--- a/source/blender/editors/space_sequencer/SConscript
+++ b/source/blender/editors/space_sequencer/SConscript
@@ -8,7 +8,12 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../makesrna ../../blenloader ../../blenfont'
incs += ' #/intern/audaspace/intern'
+defs = []
+
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']
-env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] )
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
+
+env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), defs, libtype=['core'], priority=[100] )
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index ff895c06d57..8155f9d645e 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -325,7 +325,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
clip = BLI_findlink(&CTX_data_main(C)->movieclip, RNA_enum_get(op->ptr, "clip"));
if (clip == NULL) {
- BKE_report(op->reports, RPT_ERROR, "MovieClip not found");
+ BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
return OPERATOR_CANCELLED;
}
@@ -553,7 +553,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
}
if (seq_load.tot_success == 0) {
- BKE_reportf(op->reports, RPT_ERROR, "File \"%s\" could not be loaded", seq_load.path);
+ BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", seq_load.path);
return OPERATOR_CANCELLED;
}
@@ -719,7 +719,9 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
seq->endstill = seq_load.end_frame - seq_load.start_frame;
}
}
-
+
+ BKE_sequence_init_colorspace(seq);
+
BKE_sequence_calc_disp(scene, seq);
BKE_sequencer_sort(scene);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index c0f96052d81..dd57566ff91 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -286,8 +286,8 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
drawmeta_stipple(1);
for (seq = seqm->seqbase.first; seq; seq = seq->next) {
- chan_min = MIN2(chan_min, seq->machine);
- chan_max = MAX2(chan_max, seq->machine);
+ chan_min = min_ii(chan_min, seq->machine);
+ chan_max = max_ii(chan_max, seq->machine);
}
chan_range = (chan_max - chan_min) + 1;
@@ -356,7 +356,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
y2 = seq->machine + SEQ_STRIP_OFSTOP;
/* set up co-ordinates/dimensions for either left or right handle */
- if (direction == SEQ_LEFTHANDLE) {
+ if (direction == SEQ_LEFTHANDLE) {
rx1 = x1;
rx2 = x1 + handsize_clamped * 0.75f;
@@ -424,7 +424,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
y1 = y2 + 0.05f;
}
UI_view2d_text_cache_add(v2d, x1, y1, numstr, col);
- }
+ }
}
static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
@@ -825,7 +825,7 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val)
/* if mouse over a sequence && LEFTMOUSE */
if (val) {
-// XXX special_seq_update= find_nearest_seq(&x);
+// XXX special_seq_update = find_nearest_seq(&x);
}
else special_seq_update = NULL;
}
@@ -928,6 +928,13 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
unsigned char *display_buffer;
void *cache_handle = NULL;
+ if (G.is_rendering == FALSE) {
+ /* stop all running jobs, except screen one. currently previews frustrate Render
+ * needed to make so sequencer's rendering doesn't conflict with compositor
+ */
+ WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
+ }
+
render_size = sseq->render_size;
if (render_size == 0) {
render_size = scene->r.size;
@@ -1205,7 +1212,7 @@ static void draw_seq_backdrop(View2D *v2d)
gpuDrawFilledRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
/* Alternating horizontal stripes */
- i = maxi(1, ((int)v2d->cur.ymin) - 1);
+ i = max_ii(1, ((int)v2d->cur.ymin) - 1);
gpuBegin(GL_QUADS);
while (i < v2d->cur.ymax) {
@@ -1224,7 +1231,7 @@ static void draw_seq_backdrop(View2D *v2d)
gpuEnd();
/* Darker lines separating the horizontal bands */
- i = maxi(1, ((int)v2d->cur.ymin) - 1);
+ i = max_ii(1, ((int)v2d->cur.ymin) - 1);
UI_ThemeColor(TH_GRID);
gpuBegin(GL_LINES);
@@ -1258,8 +1265,8 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
/* boundbox and selection tests for NOT drawing the strip... */
if ((seq->flag & SELECT) != sel) continue;
else if (seq == last_seq) continue;
- else if (MIN2(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
- else if (MAX2(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) 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;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 204930e82a6..7270516aa51 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -46,6 +46,8 @@
#include "BLI_utildefines.h"
#include "BLI_threads.h"
+#include "BLF_translation.h"
+
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
@@ -507,7 +509,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
if (seq->type == SEQ_TYPE_SOUND_RAM && BKE_sequence_effect_get_num_inputs(type) != 0) {
- *error_str = "Can't apply effects to audio sequence strips";
+ *error_str = N_("Cannot apply effects to audio sequence strips");
return 0;
}
if ((seq != activeseq) && (seq != seq2)) {
@@ -515,7 +517,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
else if (seq1 == NULL) seq1 = seq;
else if (seq3 == NULL) seq3 = seq;
else {
- *error_str = "Can't apply effect to more than 3 sequence strips";
+ *error_str = N_("Cannot apply effect to more than 3 sequence strips");
return 0;
}
}
@@ -537,21 +539,21 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
return 1; /* succsess */
case 1:
if (seq2 == NULL) {
- *error_str = "Need at least one selected sequence strip";
+ *error_str = N_("At least one selected sequence strip is needed");
return 0;
}
if (seq1 == NULL) seq1 = seq2;
if (seq3 == NULL) seq3 = seq2;
case 2:
if (seq1 == NULL || seq2 == NULL) {
- *error_str = "Need 2 selected sequence strips";
+ *error_str = N_("2 selected sequence strips are needed");
return 0;
}
if (seq3 == NULL) seq3 = seq2;
}
if (seq1 == NULL && seq2 == NULL && seq3 == NULL) {
- *error_str = "TODO: in what cases does this happen?";
+ *error_str = N_("TODO: in what cases does this happen?");
return 0;
}
@@ -579,7 +581,9 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
seq2 = del_seq_find_replace_recurs(scene, seq->seq2);
seq3 = del_seq_find_replace_recurs(scene, seq->seq3);
- if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) ;
+ if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) {
+ /* pass */
+ }
else if (seq1 || seq2 || seq3) {
seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3;
seq->seq2 = (seq2) ? seq2 : (seq1) ? seq1 : seq3;
@@ -678,7 +682,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe)
seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
- if (seqn) {
+ if (seqn) {
seqn->flag |= SELECT;
/* Second Strip! */
@@ -699,7 +703,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe)
seqn->anim_startofs += cutframe - ts.start;
seqn->anim_endofs = ts.anim_endofs;
seqn->endstill = ts.endstill;
- }
+ }
/* strips with extended stillframes after */
else if (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)) {
@@ -771,7 +775,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe)
seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
- if (seqn) {
+ if (seqn) {
seqn->flag |= SELECT;
/* Second Strip! */
@@ -789,7 +793,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe)
seqn->startofs = cutframe - ts.start;
seqn->endofs = ts.endofs;
seqn->endstill = ts.endstill;
- }
+ }
/* strips with extended stillframes after */
else if (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)) {
@@ -1054,7 +1058,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
{
if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
/* simple but no anim update */
- /* seq->start= snap_frame-seq->startofs+seq->startstill; */
+ /* seq->start = snap_frame-seq->startofs+seq->startstill; */
BKE_sequence_translate(scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
}
@@ -1382,7 +1386,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
seq_is_predecessor(seq2, last_seq) ||
seq_is_predecessor(seq3, last_seq))
{
- BKE_report(op->reports, RPT_ERROR, "Can't reassign inputs: no cycles allowed");
+ BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed");
return OPERATOR_CANCELLED;
}
@@ -1572,7 +1576,7 @@ static int apply_unique_name_cb(Sequence *seq, void *arg_pt)
Scene *scene = (Scene *)arg_pt;
char name[sizeof(seq->name) - 2];
- strcpy(name, seq->name + 2);
+ BLI_strncpy_utf8(name, seq->name + 2, sizeof(name));
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
BKE_sequencer_dupe_animdata(scene, name, seq->name + 2);
return 1;
@@ -1851,7 +1855,7 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "length", 1, 1, 1000, "Length", "Length of each frame", 1, INT_MAX);
+ RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000);
}
@@ -1950,7 +1954,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
while (seq) {
next = seq->next;
if (seq != seqm && (seq->flag & SELECT)) {
- channel_max = MAX2(seq->machine, channel_max);
+ channel_max = max_ii(seq->machine, channel_max);
BLI_remlink(ed->seqbasep, seq);
BLI_addtail(&seqm->seqbase, seq);
}
@@ -2127,7 +2131,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
zoomY = ((float)height) / ((float)imgheight);
sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY;
- sseq->zoom = 1.0f / power_of_2(1 / minf(zoomX, zoomY));
+ sseq->zoom = 1.0f / power_of_2(1 / min_ff(zoomX, zoomY));
}
else {
sseq->zoom = 1.0f;
@@ -2186,7 +2190,7 @@ void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot)
ot->poll = ED_operator_sequencer_active;
/* properties */
- RNA_def_float(ot->srna, "ratio", 1.0f, 0.0f, FLT_MAX,
+ RNA_def_float(ot->srna, "ratio", 1.0f, -FLT_MAX, FLT_MAX,
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
}
@@ -2253,11 +2257,11 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
- xmin = MIN2(xmin, seq->startdisp);
- xmax = MAX2(xmax, seq->enddisp);
+ xmin = min_ii(xmin, seq->startdisp);
+ xmax = max_ii(xmax, seq->enddisp);
- ymin = MIN2(ymin, seq->machine);
- ymax = MAX2(ymax, seq->machine);
+ ymin = min_ii(ymin, seq->machine);
+ ymax = max_ii(ymax, seq->machine);
}
}
@@ -2618,7 +2622,6 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
- Sequence *seq;
ListBase nseqbase = {NULL, NULL};
@@ -2654,8 +2657,11 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
seqbase_clipboard_frame = scene->r.cfra;
/* Need to remove anything that references the current scene */
- for (seq = seqbase_clipboard.first; seq; seq = seq->next) {
- seq_copy_del_sound(scene, seq);
+ {
+ Sequence *seq;
+ for (seq = seqbase_clipboard.first; seq; seq = seq->next) {
+ seq_copy_del_sound(scene, seq);
+ }
}
return OPERATOR_FINISHED;
@@ -2738,7 +2744,7 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
const char *error_msg;
if (BKE_sequencer_active_get_pair(scene, &seq_act, &seq_other) == 0) {
- BKE_report(op->reports, RPT_ERROR, "Must select 2 strips");
+ BKE_report(op->reports, RPT_ERROR, "Please select two strips");
return OPERATOR_CANCELLED;
}
@@ -2901,7 +2907,7 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op)
}
if (*seq_1 == NULL || *seq_2 == NULL) {
- BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, can't swap");
+ BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap");
return OPERATOR_CANCELLED;
}
else {
@@ -3038,7 +3044,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
seq->anim_startofs = seq->anim_endofs = 0;
/* correct start/end frames so we don't move
- * important not to set seq->len= len; allow the function to handle it */
+ * important not to set seq->len = len; allow the function to handle it */
BKE_sequence_reload_new_file(scene, seq, TRUE);
BKE_sequence_calc(scene, seq);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index be33b782fdf..192f45ac918 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -353,7 +353,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
else {
/* deselect_markers(0, 0); */ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */
- marker->flag |= SELECT;
+ marker->flag |= SELECT;
}
}
@@ -399,7 +399,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
else {
- // seq= find_nearest_seq(scene, v2d, &hand, mval);
+ // seq = find_nearest_seq(scene, v2d, &hand, mval);
act_orig = ed->act_seq;
@@ -414,8 +414,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
}
- else
- if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ else if (seq->type == SEQ_TYPE_SOUND_RAM) {
if (seq->strip) {
BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
}
@@ -1167,7 +1166,7 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op)
extend = RNA_boolean_get(op->ptr, "extend");
if (actseq == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No Active Sequence!");
+ BKE_report(op->reports, RPT_ERROR, "No active sequence!");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 7bfe58cb50a..e8d47016608 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -311,7 +311,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
SpaceSeq *sseqn = MEM_dupallocN(sl);
/* clear or remove stuff from old */
-// XXX sseq->gpd= gpencil_data_duplicate(sseq->gpd);
+// XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd);
return (SpaceLink *)sseqn;
}
@@ -363,7 +363,7 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
static void sequencer_main_area_draw(const bContext *C, ARegion *ar)
{
-// ScrArea *sa= CTX_wm_area(C);
+// ScrArea *sa = CTX_wm_area(C);
/* NLE - strip editing timeline interface */
draw_timeline_seq(C, ar);
diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt
index 51973a393f2..57bea148048 100644
--- a/source/blender/editors/space_text/CMakeLists.txt
+++ b/source/blender/editors/space_text/CMakeLists.txt
@@ -57,4 +57,8 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
+if(WITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
blender_add_lib(bf_editor_text "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_text/SConscript b/source/blender/editors/space_text/SConscript
index 6ad6427f1d3..373564520c8 100644
--- a/source/blender/editors/space_text/SConscript
+++ b/source/blender/editors/space_text/SConscript
@@ -10,4 +10,7 @@ incs += ' ../../python ../../makesrna ../../blenfont ../../blenloader'
if env['WITH_BF_PYTHON']:
defs.append('WITH_PYTHON')
+if env['WITH_BF_INTERNATIONAL']:
+ defs.append('WITH_INTERNATIONAL')
+
env.BlenderLib ( 'bf_editors_space_text', sources, Split(incs), defs, libtype=['core'], priority=[95] )
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index eacdb8281a5..f546c90c82c 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -431,7 +431,7 @@ static void text_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceText *st = CTX_wm_space_text(C);
- //View2D *v2d= &ar->v2d;
+ //View2D *v2d = &ar->v2d;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 1969c1c9183..d352e9f7b41 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -151,7 +151,7 @@ int flatten_string(SpaceText *st, FlattenString *fs, const char *in)
in++;
}
else {
- size_t len = BLI_str_utf8_size(in);
+ size_t len = BLI_str_utf8_size_safe(in);
flatten_string_append(fs, in, r, len);
in += len;
total++;
@@ -335,7 +335,7 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next)
if (*str == '\\') {
*fmt = prev; fmt++; str++;
if (*str == '\0') break;
- *fmt = prev; fmt++; str += BLI_str_utf8_size(str);
+ *fmt = prev; fmt++; str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
@@ -356,14 +356,14 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next)
}
*fmt = 'l';
- str += BLI_str_utf8_size(str) - 1;
+ str += BLI_str_utf8_size_safe(str) - 1;
}
/* Not in a string... */
else {
/* Deal with comments first */
if (prev == '#' || *str == '#') {
*fmt = '#';
- str += BLI_str_utf8_size(str) - 1;
+ str += BLI_str_utf8_size_safe(str) - 1;
}
else if (*str == '"' || *str == '\'') {
/* Strings */
@@ -392,7 +392,7 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next)
*fmt = 'n';
}
else {
- str += BLI_str_utf8_size(str) - 1;
+ str += BLI_str_utf8_size_safe(str) - 1;
*fmt = 'q';
}
/* Punctuation */
@@ -400,7 +400,7 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next)
*fmt = '!';
/* Identifiers and other text (no previous ws. or delims. so text continues) */
else if (prev == 'q') {
- str += BLI_str_utf8_size(str) - 1;
+ str += BLI_str_utf8_size_safe(str) - 1;
*fmt = 'q';
}
/* Not ws, a digit, punct, or continuing text. Must be new, check for special words */
@@ -420,7 +420,7 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next)
*fmt = prev;
}
else {
- str += BLI_str_utf8_size(str) - 1;
+ str += BLI_str_utf8_size_safe(str) - 1;
*fmt = 'q';
}
}
@@ -568,7 +568,7 @@ void wrap_offset(SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int *
end = max;
chop = 1;
*offc = 0;
- for (i = 0, j = 0; linep->line[j]; j += BLI_str_utf8_size(linep->line + j)) {
+ for (i = 0, j = 0; linep->line[j]; j += BLI_str_utf8_size_safe(linep->line + j)) {
int chars;
/* Mimic replacement of tabs */
@@ -633,7 +633,7 @@ void wrap_offset_in_line(SpaceText *st, ARegion *ar, TextLine *linein, int cursi
*offc = 0;
cursin = txt_utf8_offset_to_index(linein->line, cursin);
- for (i = 0, j = 0; linein->line[j]; j += BLI_str_utf8_size(linein->line + j)) {
+ for (i = 0, j = 0; linein->line[j]; j += BLI_str_utf8_size_safe(linein->line + j)) {
/* Mimic replacement of tabs */
ch = linein->line[j];
@@ -678,7 +678,7 @@ int text_get_char_pos(SpaceText *st, const char *line, int cur)
{
int a = 0, i;
- for (i = 0; i < cur && line[i]; i += BLI_str_utf8_size(line + i)) {
+ for (i = 0; i < cur && line[i]; i += BLI_str_utf8_size_safe(line + i)) {
if (line[i] == '\t')
a += st->tabnumber - a % st->tabnumber;
else
@@ -691,7 +691,7 @@ static const char *txt_utf8_get_nth(const char *str, int n)
{
int pos = 0;
while (str[pos] && n--) {
- pos += BLI_str_utf8_size(str + pos);
+ pos += BLI_str_utf8_size_safe(str + pos);
}
return str + pos;
}
@@ -712,7 +712,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
start = 0; mstart = 0;
end = max; mend = txt_utf8_get_nth(str, max) - str;
- for (i = 0, mi = 0; str[mi]; i++, mi += BLI_str_utf8_size(str + mi)) {
+ for (i = 0, mi = 0; str[mi]; i++, mi += BLI_str_utf8_size_safe(str + mi)) {
if (i - start >= max) {
int ox;
char last_format;
@@ -1118,7 +1118,7 @@ int text_get_visible_lines(SpaceText *st, ARegion *ar, const char *str)
lines = 1;
start = 0;
end = max;
- for (i = 0, j = 0; str[j]; j += BLI_str_utf8_size(str + j)) {
+ for (i = 0, j = 0; str[j]; j += BLI_str_utf8_size_safe(str + j)) {
/* Mimic replacement of tabs */
ch = str[j];
if (ch == '\t') {
@@ -1241,7 +1241,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
barheight = (ltexth > 0) ? (st->viewlines * pix_available) / ltexth : 0;
pix_bardiff = 0;
if (barheight < 20) {
- pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */
+ pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */
barheight = 20;
}
barstart = (ltexth > 0) ? ((pix_available - pix_bardiff) * st->top) / ltexth : 0;
@@ -1268,9 +1268,9 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
/* the scrollbar is non-linear sized */
if (pix_bardiff > 0) {
/* the start of the highlight is in the current viewport */
- if (ltexth && st->viewlines && lhlstart >= st->top && lhlstart <= st->top + st->viewlines) {
+ if (ltexth && st->viewlines && lhlstart >= st->top && lhlstart <= st->top + st->viewlines) {
/* speed the progresion of the start of the highlight through the scrollbar */
- hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines);
+ hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines);
}
else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) {
/* push hl start down */
@@ -1281,35 +1281,35 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
hlstart = barstart;
}
- if (hlend <= hlstart) {
+ if (hlend <= hlstart) {
hlend = hlstart + 2;
}
/* the end of the highlight is in the current viewport */
- if (ltexth && st->viewlines && lhlend >= st->top && lhlend <= st->top + st->viewlines) {
+ if (ltexth && st->viewlines && lhlend >= st->top && lhlend <= st->top + st->viewlines) {
/* speed the progresion of the end of the highlight through the scrollbar */
hlend = (((pix_available - pix_bardiff) * lhlend) / ltexth) + (pix_bardiff * (lhlend - st->top) / st->viewlines);
}
else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) {
/* push hl end up */
hlend = barstart;
- }
+ }
else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) {
/* fill out end */
hlend = barstart + barheight;
}
- if (hlend <= hlstart) {
+ if (hlend <= hlstart) {
hlstart = hlend - 2;
- }
- }
+ }
+ }
}
else {
hlstart = 0;
hlend = 0;
}
- if (hlend - hlstart < 2) {
+ if (hlend - hlstart < 2) {
hlend = hlstart + 2;
}
@@ -1334,7 +1334,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0);
uiSetRoundBox(UI_CNR_ALL);
- rad = 0.4f * mini(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
+ rad = 0.4f * min_ii(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
UI_GetThemeColor3ubv(TH_HILITE, col);
col[3] = 48;
gpuCurrentColor4ubv(col);
@@ -1461,7 +1461,7 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
x += SUGG_LIST_WIDTH * st->cwidth + 50;
}
- /* top= */ /* UNUSED */ y = ar->winy - st->lheight * l - 2;
+ /* top = */ /* UNUSED */ y = ar->winy - st->lheight * l - 2;
boxw = DOC_WIDTH * st->cwidth + 20;
boxh = (DOC_HEIGHT + 1) * st->lheight;
@@ -1758,7 +1758,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
if (b > 0) {
/* opening bracket, search forward for close */
fc++;
- c += BLI_str_utf8_size(linep->line + c);
+ c += BLI_str_utf8_size_safe(linep->line + c);
while (linep) {
while (c < linep->len) {
if (linep->format && linep->format[fc] != 'l' && linep->format[fc] != '#') {
@@ -1776,7 +1776,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
}
}
fc++;
- c += BLI_str_utf8_size(linep->line + c);
+ c += BLI_str_utf8_size_safe(linep->line + c);
}
if (endl) break;
linep = linep->next;
@@ -1821,7 +1821,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
if (!endl || endc == -1)
return;
- UI_ThemeColor(TH_HILITE);
+ UI_ThemeColor(TH_HILITE);
x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
y = ar->winy - st->lheight;
@@ -1860,6 +1860,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
char linenr[12];
int i, x, y, winx, linecount = 0, lineno = 0;
int wraplinecount = 0, wrap_skip = 0;
+ int margin_column_x;
if (st->lheight) st->viewlines = (int)ar->winy / st->lheight;
else st->viewlines = 0;
@@ -1907,7 +1908,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
text_font_begin(st);
st->cwidth = BLF_fixed_width(mono);
- st->cwidth = MAX2(st->cwidth, 1);
+ st->cwidth = MAX2(st->cwidth, (char)1);
/* draw line numbers background */
if (st->showlinenrs) {
@@ -1972,12 +1973,16 @@ void draw_text_main(SpaceText *st, ARegion *ar)
if (st->flags & ST_SHOW_MARGIN) {
UI_ThemeColor(TH_HILITE);
- gpuImmediateFormat_V2();
- gpuBegin(GL_LINES);
- gpuVertex2i(x + st->cwidth * st->margin_column, 0);
- gpuVertex2i(x + st->cwidth * st->margin_column, ar->winy - 2);
- gpuEnd();
- gpuImmediateUnformat();
+ margin_column_x = x + st->cwidth * (st->margin_column - st->left);
+
+ if (margin_column_x >= x) {
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(x + st->cwidth * st->margin_column, 0);
+ gpuVertex2i(x + st->cwidth * st->margin_column, ar->winy - 2);
+ gpuEnd();
+ gpuImmediateUnformat();
+ }
}
/* draw other stuff */
@@ -1997,7 +2002,7 @@ void text_update_character_width(SpaceText *st)
{
text_font_begin(st);
st->cwidth = BLF_fixed_width(mono);
- st->cwidth = MAX2(st->cwidth, 1);
+ st->cwidth = MAX2(st->cwidth, (char)1);
text_font_end(st);
}
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 75b8e2f218d..1be50a54b68 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -44,6 +44,8 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLF_translation.h"
+
#include "PIL_time.h"
#include "BKE_context.h"
@@ -93,7 +95,7 @@ static int text_edit_poll(bContext *C)
return 0;
if (text->id.lib) {
- // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
+ // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
return 0;
}
@@ -109,7 +111,7 @@ static int text_space_edit_poll(bContext *C)
return 0;
if (text->id.lib) {
- // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
+ // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
return 0;
}
@@ -129,7 +131,7 @@ static int text_region_edit_poll(bContext *C)
return 0;
if (text->id.lib) {
- // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
+ // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
return 0;
}
@@ -463,7 +465,8 @@ static void txt_write_file(Text *text, ReportList *reports)
fp = BLI_fopen(filepath, "w");
if (fp == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error writing file");
+ BKE_reportf(reports, RPT_ERROR, "Unable to save '%s': %s",
+ filepath, errno ? strerror(errno) : TIP_("unknown error writing file"));
return;
}
@@ -482,7 +485,8 @@ static void txt_write_file(Text *text, ReportList *reports)
}
else {
text->mtime = 0;
- BKE_reportf(reports, RPT_WARNING, "Unable to stat \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error starrng file");
+ BKE_reportf(reports, RPT_WARNING, "Unable to stat '%s': %s",
+ filepath, errno ? strerror(errno) : TIP_("unknown error stating file"));
}
if (text->flags & TXT_ISDIRTY)
@@ -970,21 +974,17 @@ static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op))
{
Text *text = CTX_data_edit_text(C);
- if (txt_has_sel(text)) {
- text_drawcache_tag_update(CTX_wm_space_text(C), 0);
-
- txt_order_cursors(text);
- txt_unindent(text);
+ text_drawcache_tag_update(CTX_wm_space_text(C), 0);
- text_update_edited(text);
+ txt_order_cursors(text);
+ txt_unindent(text);
- text_update_cursor_moved(C);
- WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+ text_update_edited(text);
- return OPERATOR_FINISHED;
- }
+ text_update_cursor_moved(C);
+ WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
- return OPERATOR_CANCELLED;
+ return OPERATOR_FINISHED;
}
void TEXT_OT_unindent(wmOperatorType *ot)
@@ -1503,7 +1503,7 @@ static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int
end = max;
chop = loop = 1;
- for (i = 0, j = 0; loop; j += BLI_str_utf8_size(linein->line + j)) {
+ for (i = 0, j = 0; loop; j += BLI_str_utf8_size_safe(linein->line + j)) {
int chars;
/* Mimic replacement of tabs */
ch = linein->line[j];
@@ -1682,7 +1682,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, short sel)
chop = loop = 1;
*charp = 0;
- for (i = 0, j = 0; loop; j += BLI_str_utf8_size((*linep)->line + j)) {
+ for (i = 0, j = 0; loop; j += BLI_str_utf8_size_safe((*linep)->line + j)) {
int chars;
/* Mimic replacement of tabs */
ch = (*linep)->line[j];
@@ -1750,7 +1750,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel)
chop = loop = 1;
*charp = 0;
- for (i = 0, j = 0; loop; j += BLI_str_utf8_size((*linep)->line + j)) {
+ for (i = 0, j = 0; loop; j += BLI_str_utf8_size_safe((*linep)->line + j)) {
int chars;
/* Mimic replacement of tabs */
ch = (*linep)->line[j];
@@ -1948,7 +1948,7 @@ static int text_move_cursor(bContext *C, int type, int select)
txt_move_left(text, select);
break;
- case NEXT_CHAR:
+ case NEXT_CHAR:
txt_move_right(text, select);
break;
@@ -2462,7 +2462,7 @@ static int flatten_len(SpaceText *st, const char *str)
{
int i, total = 0;
- for (i = 0; str[i]; i += BLI_str_utf8_size(str + i)) {
+ for (i = 0; str[i]; i += BLI_str_utf8_size_safe(str + i)) {
if (str[i] == '\t') {
total += st->tabnumber - total % st->tabnumber;
}
@@ -2475,7 +2475,7 @@ static int flatten_len(SpaceText *st, const char *str)
static int flatten_index_to_offset(SpaceText *st, const char *str, int index)
{
int i, j;
- for (i = 0, j = 0; i < index; j += BLI_str_utf8_size(str + j))
+ for (i = 0, j = 0; i < index; j += BLI_str_utf8_size_safe(str + j))
if (str[j] == '\t')
i += st->tabnumber - i % st->tabnumber;
else
@@ -2519,7 +2519,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
int j = 0, curs = 0, endj = 0; /* mem */
int chop = 1; /* flags */
- for (; loop; j += BLI_str_utf8_size(linep->line + j)) {
+ for (; loop; j += BLI_str_utf8_size_safe(linep->line + j)) {
int chars;
/* Mimic replacement of tabs */
@@ -2669,7 +2669,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event)
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
- }
+ }
else if (!st->wordwrap && (event->mval[0] < 0 || event->mval[0] > ar->winx)) {
if (event->mval[0] > ar->winx) st->left++;
else if (event->mval[0] < 0 && st->left > 0) st->left--;
@@ -2679,7 +2679,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event)
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
// XXX PIL_sleep_ms(10);
- }
+ }
else {
text_cursor_set_to_pos(st, ar, event->mval[0], event->mval[1], 1);
@@ -2688,7 +2688,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event)
ssel->old[0] = event->mval[0];
ssel->old[1] = event->mval[1];
- }
+ }
}
static void text_cursor_set_exit(bContext *C, wmOperator *op)
@@ -2945,7 +2945,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, wmEvent *event)
size_t len;
if (event->utf8_buf[0]) {
- len = BLI_str_utf8_size(event->utf8_buf);
+ len = BLI_str_utf8_size_safe(event->utf8_buf);
memcpy(str, event->utf8_buf, len);
}
else {
@@ -3352,7 +3352,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
/* identifiers */
ot->name = "To 3D Object";
ot->idname = "TEXT_OT_to_3d_object";
- ot->description = "Create 3d text object from active text data block";
+ ot->description = "Create 3D text object from active text data block";
/* api callbacks */
ot->exec = text_to_3d_object_exec;
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 9018c654e00..811d391190a 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -53,7 +53,9 @@ set(SRC
view3d_edit.c
view3d_fly.c
view3d_header.c
+ view3d_iterators.c
view3d_ops.c
+ view3d_project.c
view3d_select.c
view3d_snap.c
view3d_toolbar.c
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
index 9244aee07ea..5937d5f0988 100644
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ b/source/blender/editors/space_view3d/drawanimviz.c
@@ -85,7 +85,7 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar)
void draw_motion_path_instance(Scene *scene,
Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath)
{
- //RegionView3D *rv3d= ar->regiondata;
+ //RegionView3D *rv3d = ar->regiondata;
bMotionPathVert *mpv, *mpv_start;
int i, stepsize = avs->path_step;
int sfra, efra, sind, len;
@@ -151,11 +151,11 @@ void draw_motion_path_instance(Scene *scene,
if ((sfra + i) < CFRA) {
/* black - before cfra */
if (sel) {
- // intensity= 0.5f;
+ // intensity = 0.5f;
intensity = SET_INTENSITY(sfra, i, CFRA, 0.25f, 0.75f);
}
else {
- //intensity= 0.8f;
+ //intensity = 0.8f;
intensity = SET_INTENSITY(sfra, i, CFRA, 0.68f, 0.92f);
}
UI_ThemeAppendColorBlend(TH_WIRE, TH_BACK, intensity);
@@ -181,7 +181,7 @@ void draw_motion_path_instance(Scene *scene,
intensity = 0.99f;
}
UI_ThemeAppendColorBlendShade(TH_CFRAME, TH_BACK, intensity, 10);
- }
+ }
/* draw a vertex with this color */
gpuVertex3fv(mpv->co);
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index c37b131272c..dadb3f3b5f7 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -101,7 +101,7 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan)
}
/* only try to set custom color if enabled for armature */
- if (arm->flag & ARM_COL_CUSTOM) {
+ if (arm->flag & ARM_COL_CUSTOM) {
/* currently, a bone can only use a custom color set if it's group (if it has one),
* has been set to use one
*/
@@ -573,7 +573,7 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
/* this routine doesn't call get_matrix_editbone() that calculates it */
ebone->length = len_v3v3(ebone->head, ebone->tail);
- /*length= ebone->length;*/ /*UNUSED*/
+ /*length = ebone->length;*/ /*UNUSED*/
tail = ebone->rad_tail;
dist = ebone->dist;
if (ebone->parent && (ebone->flag & BONE_CONNECTED))
@@ -584,7 +584,7 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
tailvec = ebone->tail;
}
else {
- /*length= pchan->bone->length;*/ /*UNUSED*/
+ /*length = pchan->bone->length;*/ /*UNUSED*/
tail = pchan->bone->rad_tail;
dist = pchan->bone->dist;
if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED))
@@ -695,7 +695,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4],
/* this routine doesn't call get_matrix_editbone() that calculates it */
ebone->length = len_v3v3(ebone->head, ebone->tail);
- /*length= ebone->length;*/ /*UNUSED*/
+ /*length = ebone->length;*/ /*UNUSED*/
tail = ebone->rad_tail;
if (ebone->parent && (boneflag & BONE_CONNECTED))
head = ebone->parent->rad_tail;
@@ -705,7 +705,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4],
tailvec = ebone->tail;
}
else {
- /*length= pchan->bone->length;*/ /*UNUSED*/
+ /*length = pchan->bone->length;*/ /*UNUSED*/
tail = pchan->bone->rad_tail;
if ((pchan->parent) && (boneflag & BONE_CONNECTED))
head = pchan->parent->bone->rad_tail;
@@ -1005,7 +1005,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
gpuEnd();
/* tip */
- if (G.f & G_PICKSEL) {
+ if (G.f & G_PICKSEL) {
/* no bitmap in selection mode, crashes 3d cards... */
glLoadName(id | BONESEL_TIP);
gpuBegin(GL_POINTS);
@@ -1174,7 +1174,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl
gpuDisableColorMaterial();
gpuDisableLighting();
}
- else {
+ else {
/* wire */
if (armflag & ARM_POSEMODE) {
if (constflag) {
@@ -1190,9 +1190,9 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl
/* restore colors */
set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
}
- }
+ }
- draw_b_bone_boxes(OB_WIRE, pchan, xwidth, length, zwidth);
+ draw_b_bone_boxes(OB_WIRE, pchan, xwidth, length, zwidth);
}
}
@@ -1318,7 +1318,7 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
else if (armflag & ARM_POSEMODE) {
if (constflag) {
/* draw constraint colors */
- if (set_pchan_gpuCurrentColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
+ if (set_pchan_gpuCurrentColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
glEnable(GL_BLEND);
draw_bone_solid_octahedral();
@@ -1329,10 +1329,10 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
/* restore colors */
set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
}
- }
+ }
draw_bone_octahedral();
}
- else {
+ else {
/* solid */
if (armflag & ARM_POSEMODE)
set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, constflag);
@@ -1727,7 +1727,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (use_custom && pchan->custom_tx) {
gpuMultMatrix(pchan->custom_tx->pose_mat);
- }
+ }
else {
gpuMultMatrix(pchan->pose_mat);
}
@@ -1789,7 +1789,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
*/
if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == 0)) {
/* object tag, for bordersel optim */
- glLoadName(index & 0xFFFF);
+ glLoadName(index & 0xFFFF);
index = -1;
}
}
@@ -1816,7 +1816,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (pchan->custom_tx) {
gpuMultMatrix(pchan->custom_tx->pose_mat);
- }
+ }
else {
gpuMultMatrix(pchan->pose_mat);
}
@@ -1855,7 +1855,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
/* stick or wire bones have not been drawn yet so don't clear object selection in this case */
if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && draw_wire) {
/* object tag, for bordersel optim */
- glLoadName(index & 0xFFFF);
+ glLoadName(index & 0xFFFF);
index = -1;
}
}
@@ -1926,7 +1926,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
glLoadName(index & 0xFFFF);
pchan_draw_IK_root_lines(pchan, !(do_dashed & 2));
}
- }
+ }
}
}
@@ -1980,7 +1980,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
/* restore things */
if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt > OB_WIRE) && (arm->flag & ARM_POSEMODE))
bglPolygonOffset(rv3d->dist, 0.0);
- }
+ }
/* restore */
glDisable(GL_CULL_FACE);
@@ -2064,7 +2064,7 @@ static void get_matrix_editbone(EditBone *eBone, float bmat[][4])
float mat[3][3];
/* Compose the parent transforms (i.e. their translations) */
- sub_v3_v3v3(delta, eBone->tail, eBone->head);
+ sub_v3_v3v3(delta, eBone->tail, eBone->head);
eBone->length = (float)sqrt(delta[0] * delta[0] + delta[1] * delta[1] + delta[2] * delta[2]);
@@ -2215,9 +2215,16 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
}
/* restore */
- if (index != -1) glLoadName(-1);
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) ;
- else if (dt > OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f);
+ if (index != -1) {
+ glLoadName(-1);
+ }
+
+ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
+ /* pass */
+ }
+ else if (dt > OB_WIRE) {
+ bglPolygonOffset(rv3d->dist, 0.0f);
+ }
/* finally names and axes */
if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) {
@@ -2240,7 +2247,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
mid_v3_v3v3(vec, eBone->head, eBone->tail);
glRasterPos3fv(vec);
view3d_cached_text_draw_add(vec, eBone->name, 10, 0, col);
- }
+ }
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES) {
gpuPushMatrix();
@@ -2628,7 +2635,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
}
draw_pose_paths(scene, v3d, ar, ob);
}
- }
+ }
}
draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline);
arm->flag &= ~ARM_POSEMODE;
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 7776df84647..20d5e8ee69c 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -393,7 +393,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
}
- else {
+ else {
glDisable(GL_CULL_FACE);
}
gpuLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
@@ -548,8 +548,7 @@ static void update_tface_color_layer(DerivedMesh *dm)
}
else {
float col[3];
- Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1);
-
+
if (ma) {
if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
else copy_v3_v3(col, &ma->r);
@@ -650,7 +649,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
int a, totpoly = me->totpoly;
/* fake values to pass to GPU_render_text() */
- MCol tmp_mcol[4] = {{0}};
+ MCol tmp_mcol[4] = {{0}};
MCol *tmp_mcol_pt = mloopcol ? tmp_mcol : NULL;
MTFace tmp_tf = {{{0}}};
@@ -717,7 +716,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
/* COLOR */
if (mloopcol) {
- unsigned int totloop_clamp = MIN2(4, mp->totloop);
+ unsigned int totloop_clamp = min_ii(4, mp->totloop);
unsigned int j;
lcol = &mloopcol[mp->loopstart];
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 9fe8265b08e..8cb4d1ff308 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -27,10 +27,6 @@
* \ingroup spview3d
*/
-
-#include <string.h>
-#include <math.h>
-
#include "MEM_guardedalloc.h"
#include "DNA_camera_types.h"
@@ -40,21 +36,14 @@
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_meta_types.h"
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
-#include "DNA_speaker_types.h"
#include "DNA_world_types.h"
-#include "DNA_armature_types.h"
#include "DNA_object_types.h"
-#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
-#include "BLI_rand.h"
-#include "BLI_utildefines.h"
#include "BKE_anim.h" /* for the where_on_path function */
#include "BKE_armature.h"
@@ -79,13 +68,10 @@
#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_unit.h"
-#include "BKE_movieclip.h"
#include "BKE_tracking.h"
#include "BKE_tessmesh.h"
-#include "smoke_API.h"
-
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -101,16 +87,13 @@
#include "ED_screen.h"
#include "ED_sculpt.h"
#include "ED_types.h"
-#include "ED_curve.h" /* for curve_editnurbs */
-#include "ED_armature.h"
#include "UI_resources.h"
#include "WM_api.h"
-#include "wm_subwindow.h"
#include "BLF_api.h"
-#include "view3d_intern.h" /* own include */
+#include "view3d_intern.h" /* bad level include */
typedef enum eWireDrawMode {
OBDRAW_WIRE_OFF = 0,
@@ -118,28 +101,6 @@ typedef enum eWireDrawMode {
OBDRAW_WIRE_ON_DEPTH = 2
} eWireDrawMode;
-/* user data structures for derived mesh callbacks */
-typedef struct foreachScreenVert_userData {
- void (*func)(void *userData, BMVert *eve, int x, int y, int index);
- void *userData;
- ViewContext vc;
- eV3DClipTest clipVerts;
-} foreachScreenVert_userData;
-
-typedef struct foreachScreenEdge_userData {
- void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index);
- void *userData;
- ViewContext vc;
- rcti win_rect; /* copy of: vc.ar->winx/winy, use for faster tests, minx/y will always be 0 */
- eV3DClipTest clipVerts;
-} foreachScreenEdge_userData;
-
-typedef struct foreachScreenFace_userData {
- void (*func)(void *userData, BMFace *efa, int x, int y, int index);
- void *userData;
- ViewContext vc;
-} foreachScreenFace_userData;
-
typedef struct drawDMVerts_userData {
BMEditMesh *em; /* BMESH BRANCH ONLY */
@@ -172,7 +133,8 @@ typedef struct drawDMFacesSel_userData {
BMEditMesh *em; /* BMESH BRANCH ONLY */
BMFace *efa_act;
- int *orig_index;
+ int *orig_index_mf_to_mpoly;
+ int *orig_index_mp_to_orig;
} drawDMFacesSel_userData;
typedef struct drawDMNormal_userData {
@@ -271,12 +233,13 @@ static int check_alpha_pass(Base *base)
}
/***/
-static unsigned int colortab[24] =
-{0x0, 0xFF88FF, 0xFFBBFF,
- 0x403000, 0xFFFF88, 0xFFFFBB,
- 0x104040, 0x66CCCC, 0x77CCCC,
- 0x104010, 0x55BB55, 0x66FF66,
- 0xFFFFFF};
+static unsigned int colortab[24] = {
+ 0x0, 0xFF88FF, 0xFFBBFF,
+ 0x403000, 0xFFFF88, 0xFFFFBB,
+ 0x104040, 0x66CCCC, 0x77CCCC,
+ 0x104010, 0x55BB55, 0x66FF66,
+ 0xFFFFFF
+};
static void draw_xyz_wire(const float c[3], float size, int axis)
@@ -549,7 +512,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
gpuTranslate(0.0f, 0.0f, 0.0f);
/* Calculate Image scale */
- scale = (ob->empty_drawsize / (float)MAX2(ima_x * sca_x, ima_y * sca_y));
+ scale = (ob->empty_drawsize / max_ff((float)ima_x * sca_x, (float)ima_y * sca_y));
/* Set the object scale */
gpuScale(scale * sca_x, scale * sca_y, 1.0f);
@@ -705,10 +668,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
mul_m4_v3(mat, vos->vec);
if (ED_view3d_project_short_ex(ar,
- (vos->flag & V3D_CACHE_TEXT_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob,
- (vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0,
- vos->vec, vos->sco,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
+ (vos->flag & V3D_CACHE_TEXT_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob,
+ (vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0,
+ vos->vec, vos->sco,
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK)
{
tot++;
}
@@ -779,7 +742,9 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
if (depth_write) {
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
- else glDepthMask(1);
+ else {
+ glDepthMask(1);
+ }
gpuMatrixMode(GL_PROJECTION);
gpuPopMatrix();
@@ -1738,29 +1703,6 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
gpuEndSprites();
}
-void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPoint *bp, int x, int y), void *userData)
-{
- Object *obedit = vc->obedit;
- Lattice *lt = obedit->data;
- BPoint *bp = lt->editlatt->latt->def;
- DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS);
- float *co = dl ? dl->verts : NULL;
- int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
- ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */
-
- for (i = 0; i < N; i++, bp++, co += 3) {
- if (bp->hide == 0) {
- int screen_co[2];
- if (ED_view3d_project_int_object(vc->ar, dl ? co : bp->vec, screen_co,
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, bp, screen_co[0], screen_co[1]);
- }
- }
- }
-}
-
static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int use_wcol)
{
int index = ((w * lt->pntsv + v) * lt->pntsu) + u;
@@ -1863,53 +1805,6 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
/* ***************** ******************** */
-/* Note! - foreach funcs should be called while drawing or directly after
- * if not, ED_view3d_init_mats_rv3d() can be used for selection tools
- * but would not give correct results with dupli's for eg. which don't
- * use the object matrix in the usual way */
-static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const float co[3],
- const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
-{
- foreachScreenVert_userData *data = userData;
- BMVert *eve = EDBM_vert_at_index(data->vc.em, index);
-
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- const eV3DProjTest flag = (data->clipVerts == V3D_CLIP_TEST_OFF) ?
- V3D_PROJ_TEST_NOP :
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN;
- int screen_co[2];
-
- if (ED_view3d_project_int_object(data->vc.ar, co, screen_co, flag) != V3D_PROJ_RET_SUCCESS) {
- return;
- }
-
- data->func(data->userData, eve, screen_co[0], screen_co[1], index);
- }
-}
-
-void mesh_foreachScreenVert(
- ViewContext *vc,
- void (*func)(void *userData, BMVert *eve, int x, int y, int index),
- void *userData, eV3DClipTest clipVerts)
-{
- foreachScreenVert_userData data;
- DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
-
- data.vc = *vc;
- data.func = func;
- data.userData = userData;
- data.clipVerts = clipVerts;
-
- if (clipVerts != V3D_CLIP_TEST_OFF)
- ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
-
- EDBM_index_arrays_init(vc->em, 1, 0, 0);
- dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data);
- EDBM_index_arrays_free(vc->em);
-
- dm->release(dm);
-}
-
/* draw callback */
static void drawSelectedVertices__mapFunc(void *userData, int index, const float co[3],
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
@@ -1938,286 +1833,9 @@ static void drawSelectedVertices(DerivedMesh *dm, Mesh *me)
gpuEnd();
}
-static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const float v0co[3], const float v1co[3])
-{
- foreachScreenEdge_userData *data = userData;
- BMEdge *eed = EDBM_edge_at_index(data->vc.em, index);
-
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- int screen_co_a[2];
- int screen_co_b[2];
-
- const eV3DProjTest flag = (data->clipVerts == V3D_CLIP_TEST_RV3D_CLIPPING) ?
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN :
- V3D_PROJ_TEST_NOP;
-
- if (ED_view3d_project_int_object(data->vc.ar, v0co, screen_co_a, flag) != V3D_PROJ_RET_SUCCESS) {
- return;
- }
- if (ED_view3d_project_int_object(data->vc.ar, v1co, screen_co_b, flag) != V3D_PROJ_RET_SUCCESS) {
- return;
- }
-
- if (data->clipVerts == V3D_CLIP_TEST_RV3D_CLIPPING) {
- /* pass */
- }
- else {
- if (data->clipVerts == V3D_CLIP_TEST_REGION) {
- if (!BLI_rcti_isect_segment(&data->win_rect, screen_co_a, screen_co_b)) {
- return;
- }
- }
- }
-
- data->func(data->userData, eed,
- screen_co_a[0], screen_co_a[1],
- screen_co_b[0], screen_co_b[1], index);
- }
-}
-
-void mesh_foreachScreenEdge(
- ViewContext *vc,
- void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index),
- void *userData, eV3DClipTest clipVerts)
-{
- foreachScreenEdge_userData data;
- DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
-
- data.vc = *vc;
-
- data.win_rect.xmin = 0;
- data.win_rect.ymin = 0;
- data.win_rect.xmax = vc->ar->winx;
- data.win_rect.ymax = vc->ar->winy;
-
- data.func = func;
- data.userData = userData;
- data.clipVerts = clipVerts;
-
- if (clipVerts != V3D_CLIP_TEST_OFF)
- ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
-
- EDBM_index_arrays_init(vc->em, 0, 1, 0);
- dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);
- EDBM_index_arrays_free(vc->em);
-
- dm->release(dm);
-}
-
-static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
-{
- foreachScreenFace_userData *data = userData;
- BMFace *efa = EDBM_face_at_index(data->vc.em, index);
-
- if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- int screen_co[2];
- if (ED_view3d_project_int_object(data->vc.ar, cent, screen_co,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- data->func(data->userData, efa, screen_co[0], screen_co[1], index);
- }
- }
-}
-
-void mesh_foreachScreenFace(
- ViewContext *vc,
- void (*func)(void *userData, BMFace *efa, int x, int y, int index),
- void *userData)
-{
- foreachScreenFace_userData data;
- DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
-
- data.vc = *vc;
- data.func = func;
- data.userData = userData;
-
- ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
-
- EDBM_index_arrays_init(vc->em, 0, 0, 1);
- dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data);
- EDBM_index_arrays_free(vc->em);
-
- dm->release(dm);
-}
-
-void nurbs_foreachScreenVert(
- ViewContext *vc,
- void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y),
- void *userData)
-{
- Curve *cu = vc->obedit->data;
- Nurb *nu;
- int i;
- ListBase *nurbs = BKE_curve_editNurbs_get(cu);
-
- ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
-
- for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER) {
- for (i = 0; i < nu->pntsu; i++) {
- BezTriple *bezt = &nu->bezt[i];
-
- if (bezt->hide == 0) {
- int screen_co[2];
-
- if (cu->drawflag & CU_HIDE_HANDLES) {
- if (ED_view3d_project_int_object(vc->ar, bezt->vec[1], screen_co,
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, nu, NULL, bezt, 1, screen_co[0], screen_co[1]);
- }
- }
- else {
- if (ED_view3d_project_int_object(vc->ar, bezt->vec[0], screen_co,
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, nu, NULL, bezt, 0, screen_co[0], screen_co[1]);
- }
- if (ED_view3d_project_int_object(vc->ar, bezt->vec[1], screen_co,
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, nu, NULL, bezt, 1, screen_co[0], screen_co[1]);
- }
- if (ED_view3d_project_int_object(vc->ar, bezt->vec[2], screen_co,
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, nu, NULL, bezt, 2, screen_co[0], screen_co[1]);
- }
- }
- }
- }
- }
- else {
- for (i = 0; i < nu->pntsu * nu->pntsv; i++) {
- BPoint *bp = &nu->bp[i];
-
- if (bp->hide == 0) {
- int screen_co[2];
- if (ED_view3d_project_int_object(vc->ar, bp->vec, screen_co,
- V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, nu, bp, NULL, -1, screen_co[0], screen_co[1]);
- }
- }
- }
- }
- }
-}
-
-/* ED_view3d_init_mats_rv3d must be called first */
-void mball_foreachScreenElem(
- struct ViewContext *vc,
- void (*func)(void *userData, struct MetaElem *ml, int x, int y),
- void *userData)
-{
- MetaBall *mb = (MetaBall *)vc->obedit->data;
- MetaElem *ml;
-
- for (ml = mb->editelems->first; ml; ml = ml->next) {
- int screen_co[2];
- if (ED_view3d_project_int_object(vc->ar, &ml->x, screen_co,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- func(userData, ml, screen_co[0], screen_co[1]);
- }
- }
-}
-
-/* ED_view3d_init_mats_rv3d must be called first */
-void armature_foreachScreenBone(
- struct ViewContext *vc,
- void (*func)(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1),
- void *userData)
-{
- bArmature *arm = vc->obedit->data;
- EditBone *ebone;
-
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (EBONE_VISIBLE(arm, ebone)) {
- int screen_co_a[2], screen_co_b[2];
- int points_proj_tot = 0;
-
- /* project head location to screenspace */
- if (ED_view3d_project_int_object(vc->ar, ebone->head, screen_co_a,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- points_proj_tot++;
- }
- else {
- screen_co_a[0] = IS_CLIPPED; /* weak */
- /* screen_co_a[1]: intentionally dont set this so we get errors on misuse */
- }
-
- /* project tail location to screenspace */
- if (ED_view3d_project_int_object(vc->ar, ebone->tail, screen_co_b,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- points_proj_tot++;
- }
- else {
- screen_co_b[0] = IS_CLIPPED; /* weak */
- /* screen_co_b[1]: intentionally dont set this so we get errors on misuse */
- }
-
- if (points_proj_tot) { /* at least one point's projection worked */
- func(userData, ebone,
- screen_co_a[0], screen_co_a[1],
- screen_co_b[0], screen_co_b[1]);
- }
- }
- }
-}
-
-/* ED_view3d_init_mats_rv3d must be called first */
-/* almost _exact_ copy of #armature_foreachScreenBone */
-void pose_foreachScreenBone(
- struct ViewContext *vc,
- void (*func)(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1),
- void *userData)
-{
- bArmature *arm = vc->obact->data;
- bPose *pose = vc->obact->pose;
- bPoseChannel *pchan;
-
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (PBONE_VISIBLE(arm, pchan->bone)) {
- int screen_co_a[2], screen_co_b[2];
- int points_proj_tot = 0;
-
- /* project head location to screenspace */
- if (ED_view3d_project_int_object(vc->ar, pchan->pose_head, screen_co_a,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- points_proj_tot++;
- }
- else {
- screen_co_a[0] = IS_CLIPPED; /* weak */
- /* screen_co_a[1]: intentionally dont set this so we get errors on misuse */
- }
-
- /* project tail location to screenspace */
- if (ED_view3d_project_int_object(vc->ar, pchan->pose_tail, screen_co_b,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
- {
- points_proj_tot++;
- }
- else {
- screen_co_b[0] = IS_CLIPPED; /* weak */
- /* screen_co_b[1]: intentionally dont set this so we get errors on misuse */
- }
-
- if (points_proj_tot) { /* at least one point's projection worked */
- func(userData, pchan,
- screen_co_a[0], screen_co_a[1],
- screen_co_b[0], screen_co_b[1]);
- }
- }
- }
-}
-
/* ************** DRAW MESH ****************** */
-/* First section is all the "simple" draw routines,
+/* First section is all the "simple" draw routines,
* ones that just pass some sort of primitive to GL,
* with perhaps various options to control lighting,
* color, etc.
@@ -2465,7 +2083,7 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(drawDMEdgesSel_userData *d
}
}
-static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
+static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act)
{
drawDMEdgesSel_userData data;
@@ -2490,7 +2108,7 @@ static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index)
return DM_DRAW_OPTION_NORMALLY;
}
-static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm)
+static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm)
{
gpuImmediateFormat_C4_V3(); /* XXX: jwilkins, C4 only because CCG age visualization may be enabled */
dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em);
@@ -2602,11 +2220,11 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
unsigned char *col, *next_col;
- if (!data->orig_index)
+ if (!data->orig_index_mf_to_mpoly)
return 0;
- efa = EDBM_face_at_index(data->em, data->orig_index[index]);
- next_efa = EDBM_face_at_index(data->em, data->orig_index[next_index]);
+ efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index));
+ next_efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index));
if (efa == next_efa)
return 1;
@@ -2624,7 +2242,7 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
}
/* also draws the active face */
-static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
+static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
unsigned char *selCol, unsigned char *actCol, BMFace *efa_act)
{
drawDMFacesSel_userData data;
@@ -2634,7 +2252,12 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
data.cols[1] = selCol;
data.cols[2] = actCol;
data.efa_act = efa_act;
- data.orig_index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ /* double lookup */
+ data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ data.orig_index_mp_to_orig = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
+ if ((data.orig_index_mf_to_mpoly && data.orig_index_mp_to_orig) == FALSE) {
+ data.orig_index_mf_to_mpoly = data.orig_index_mp_to_orig = NULL;
+ }
gpuImmediateFormat_C4_V3();
dm->drawMappedFaces(
@@ -2739,9 +2362,9 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
/* EditMesh drawing routines*/
-static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit,
+static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit,
BMEditMesh *em, DerivedMesh *cageDM, BMVert *eve_act,
- RegionView3D *rv3d)
+ RegionView3D *rv3d)
{
ToolSettings *ts = scene->toolsettings;
int sel;
@@ -2861,7 +2484,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d,
glEnable(GL_DEPTH_TEST);
}
}
-}
+}
static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit)
{
@@ -3126,7 +2749,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
if (ese->type == BM_FACE) {
efa_act = (BMFace *)ese->data;
}
- else
+ else
#endif
if (ese->htype == BM_EDGE) {
eed_act = (BMEdge *)ese->ele;
@@ -3304,13 +2927,12 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
{
-
if ((v3d->transp == FALSE) && /* not when we draw the transparent pass */
(ob->mode & OB_MODE_ALL_PAINT) == FALSE) /* not when painting (its distracting) - campbell */
{
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(0);
-
+
/* if transparent, we cannot draw the edges for solid select... edges have no material info.
* drawFacesSolid() doesn't draw the transparent faces */
if (ob->dtx & OB_DRAWTRANSP) {
@@ -6998,7 +6620,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* code for new particle system */
if ((warning_recursive == 0) &&
(ob->particlesystem.first) &&
- (dflag & DRAW_PICKING) == 0 &&
(ob != scene->obedit)
)
{
@@ -7087,73 +6708,80 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
/* only draw domains */
- if (smd->domain && smd->domain->fluid) {
- if (CFRA < smd->domain->point_cache[0]->startframe) {
- /* don't show smoke before simulation starts, this could be made an option in the future */
- }
- else if (!smd->domain->wt || !(smd->domain->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
-// #if 0
- smd->domain->tex = NULL;
- GPU_create_smoke(smd, 0);
- draw_volume(ar, smd->domain->tex,
- smd->domain->p0, smd->domain->p1,
- smd->domain->res, smd->domain->dx * smd->domain->scale,
- smd->domain->tex_shadow);
- GPU_free_smoke(smd);
-// #endif
-#if 0
- int x, y, z;
- float *density = smoke_get_density(smd->domain->fluid);
+ if (smd->domain) {
+ SmokeDomainSettings *sds = smd->domain;
+ float p0[3], p1[3], viewnormal[3];
+ BoundBox bb;
- gpuLoadMatrix(rv3d->viewmat);
- // gpuMultMatrix(ob->obmat);
-
- if (ob->flag & SELECT) {
- gpuCurrentColor3x(CPACK_WHITE);
- }
- glDepthMask(GL_FALSE);
- glEnable(GL_BLEND);
-
+ gpuLoadMatrix(rv3d->viewmat);
+ gpuMultMatrix(ob->obmat);
- // glPointSize(3.0);
- gpuBeginSprites();
+ if (ob->flag & SELECT) {
+ gpuCurrentColor3x(CPACK_WHITE);
+ }
+
+ /* draw adaptive domain bounds */
+ if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
+ /* draw domain max bounds */
+ VECSUBFAC(p0, sds->p0, sds->cell_size, sds->adapt_res);
+ VECADDFAC(p1, sds->p1, sds->cell_size, sds->adapt_res);
+ BKE_boundbox_init_from_minmax(&bb, p0, p1);
+ draw_box(bb.vec);
+
+ /* draw base resolution bounds */
+#if 0
+ BKE_boundbox_init_from_minmax(&bb, sds->p0, sds->p1);
+ draw_box(bb.vec);
+#endif
+ }
- for (x = 0; x < smd->domain->res[0]; x++) {
- for (y = 0; y < smd->domain->res[1]; y++) {
- for (z = 0; z < smd->domain->res[2]; z++) {
- float tmp[3];
- int index = smoke_get_index(x, smd->domain->res[0], y, smd->domain->res[1], z);
-
- if (density[index] > FLT_EPSILON) {
- float color[3];
- copy_v3_v3(tmp, smd->domain->p0);
- tmp[0] += smd->domain->dx * x + smd->domain->dx * 0.5;
- tmp[1] += smd->domain->dx * y + smd->domain->dx * 0.5;
- tmp[2] += smd->domain->dx * z + smd->domain->dx * 0.5;
- color[0] = color[1] = color[2] = density[index];
- gpuColor3fv(color);
- gpuSprite3fv(tmp);
- }
- }
- }
+ /* don't show smoke before simulation starts, this could be made an option in the future */
+ if (smd->domain->fluid && CFRA >= smd->domain->point_cache[0]->startframe) {
+
+ // get view vector
+ copy_v3_v3(viewnormal, rv3d->viewinv[2]);
+ mul_mat3_m4_v3(ob->imat, viewnormal);
+ normalize_v3(viewnormal);
+
+ /* set dynamic boundaries to draw the volume */
+ p0[0] = sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0];
+ p0[1] = sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1];
+ p0[2] = sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2];
+ p1[0] = sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0];
+ p1[1] = sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1];
+ p1[2] = sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2];
+
+ /* scale cube to global space to equalize volume slicing on all axises
+ * (its scaled back before drawing) */
+ mul_v3_v3(p0, ob->size);
+ mul_v3_v3(p1, ob->size);
+
+ if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
+ smd->domain->tex = NULL;
+ GPU_create_smoke(smd, 0);
+ draw_smoke_volume(sds, ob, sds->tex,
+ p0, p1,
+ sds->res, sds->dx, sds->scale * sds->maxres,
+ viewnormal, sds->tex_shadow, sds->tex_flame);
+ GPU_free_smoke(smd);
+ }
+ else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
+ sds->tex = NULL;
+ GPU_create_smoke(smd, 1);
+ draw_smoke_volume(sds, ob, sds->tex,
+ p0, p1,
+ sds->res_wt, sds->dx, sds->scale * sds->maxres,
+ viewnormal, sds->tex_shadow, sds->tex_flame);
+ GPU_free_smoke(smd);
}
- gpuEndSprites();
- glPointSize(1.0);
-
- gpuMultMatrix(ob->obmat);
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE);
+ /* smoke debug render */
+#ifdef SMOKE_DEBUG_VELOCITY
+ draw_smoke_velocity(smd->domain, ob);
+#endif
+#ifdef SMOKE_DEBUG_HEAT
+ draw_smoke_heat(smd->domain, ob);
#endif
- }
- else if (smd->domain->wt && (smd->domain->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
- smd->domain->tex = NULL;
- GPU_create_smoke(smd, 1);
- draw_volume(ar, smd->domain->tex,
- smd->domain->p0, smd->domain->p1,
- smd->domain->res_wt, smd->domain->dx_wt * smd->domain->scale,
- smd->domain->tex_shadow);
- GPU_free_smoke(smd);
}
}
}
@@ -7659,7 +7287,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
/* assumes all matrices/etc set OK */
/* helper function for drawing object instances - meshes */
-static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d,
+static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d,
Object *ob, const short dt, int outline)
{
Mesh *me = ob->data;
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 45b57069dcc..f60c0ea6075 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -36,6 +36,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_smoke_types.h"
#include "DNA_view3d_types.h"
#include "BLI_utildefines.h"
@@ -133,7 +134,7 @@ static int intersect_edges(float *points, float a, float b, float c, float d, fl
int i;
float t;
int numpoints = 0;
-
+
for (i = 0; i < 12; i++) {
t = -(a * edges[i][0][0] + b * edges[i][0][1] + c * edges[i][0][2] + d) /
(a * edges[i][1][0] + b * edges[i][1][1] + c * edges[i][1][2]);
@@ -157,12 +158,12 @@ static int convex(const float p0[3], const float up[3], const float a[3], const
return dot_v3v3(up, tmp) >= 0;
}
-void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int res[3], float dx, GPUTexture *tex_shadow)
+void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
+ GPUTexture *tex, float min[3], float max[3],
+ int res[3], float dx, float UNUSED(base_scale), float viewnormal[3],
+ GPUTexture *tex_shadow, GPUTexture *tex_flame)
{
- RegionView3D *rv3d = ar->regiondata;
-
- float viewnormal[3];
- int i, j, n, good_index;
+ int i, j, k, n, good_index;
float d /*, d0 */ /* UNUSED */, dd, ds;
float *points = NULL;
int numpoints = 0;
@@ -194,28 +195,77 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
{{-1.0f, 1.0f, -1.0f}, {2.0f, 0.0f, 0.0f}}
};
+ unsigned char *spec_data;
+ float *spec_pixels;
+ GPUTexture *tex_spec;
+
/* Fragment program to calculate the view3d of smoke */
- /* using 2 textures, density and shadow */
- static const char *text =
- "!!ARBfp1.0\n"
- "PARAM dx = program.local[0];\n"
- "PARAM darkness = program.local[1];\n"
- "PARAM f = {1.442695041, 1.442695041, 1.442695041, 0.01};\n"
- "TEMP temp, shadow, value;\n"
- "TEX temp, fragment.texcoord[0], texture[0], 3D;\n"
- "TEX shadow, fragment.texcoord[0], texture[1], 3D;\n"
- "MUL value, temp, darkness;\n"
- "MUL value, value, dx;\n"
- "MUL value, value, f;\n"
- "EX2 temp, -value.r;\n"
- "SUB temp.a, 1.0, temp.r;\n"
- "MUL temp.r, temp.r, shadow.r;\n"
- "MUL temp.g, temp.g, shadow.r;\n"
- "MUL temp.b, temp.b, shadow.r;\n"
- "MOV result.color, temp;\n"
- "END\n";
- static GLuint prog;
+ /* using 4 textures, density, shadow, flame and flame spectrum */
+ const char *shader_basic =
+ "!!ARBfp1.0\n"
+ "PARAM dx = program.local[0];\n"
+ "PARAM darkness = program.local[1];\n"
+ "PARAM render = program.local[2];\n"
+ "PARAM f = {1.442695041, 1.442695041, 1.442695041, 0.01};\n"
+ "TEMP temp, shadow, flame, spec, value;\n"
+ "TEX temp, fragment.texcoord[0], texture[0], 3D;\n"
+ "TEX shadow, fragment.texcoord[0], texture[1], 3D;\n"
+ "TEX flame, fragment.texcoord[0], texture[2], 3D;\n"
+ "TEX spec, flame.r, texture[3], 1D;\n"
+ /* calculate shading factor from density */
+ "MUL value.r, temp.a, darkness.a;\n"
+ "MUL value.r, value.r, dx.r;\n"
+ "MUL value.r, value.r, f.r;\n"
+ "EX2 temp, -value.r;\n"
+ /* alpha */
+ "SUB temp.a, 1.0, temp.r;\n"
+ /* shade colors */
+ "MUL temp.r, temp.r, shadow.r;\n"
+ "MUL temp.g, temp.g, shadow.r;\n"
+ "MUL temp.b, temp.b, shadow.r;\n"
+ "MUL temp.r, temp.r, darkness.r;\n"
+ "MUL temp.g, temp.g, darkness.g;\n"
+ "MUL temp.b, temp.b, darkness.b;\n"
+ /* for now this just replace smoke shading if rendering fire */
+ "CMP result.color, render.r, temp, spec;\n"
+ "END\n";
+
+ /* color shader */
+ const char *shader_color =
+ "!!ARBfp1.0\n"
+ "PARAM dx = program.local[0];\n"
+ "PARAM darkness = program.local[1];\n"
+ "PARAM render = program.local[2];\n"
+ "PARAM f = {1.442695041, 1.442695041, 1.442695041, 1.442695041};\n"
+ "TEMP temp, shadow, flame, spec, value;\n"
+ "TEX temp, fragment.texcoord[0], texture[0], 3D;\n"
+ "TEX shadow, fragment.texcoord[0], texture[1], 3D;\n"
+ "TEX flame, fragment.texcoord[0], texture[2], 3D;\n"
+ "TEX spec, flame.r, texture[3], 1D;\n"
+ /* unpremultiply volume texture */
+ "RCP value.r, temp.a;\n"
+ "MUL temp.r, temp.r, value.r;\n"
+ "MUL temp.g, temp.g, value.r;\n"
+ "MUL temp.b, temp.b, value.r;\n"
+ /* calculate shading factor from density */
+ "MUL value.r, temp.a, darkness.a;\n"
+ "MUL value.r, value.r, dx.r;\n"
+ "MUL value.r, value.r, f.r;\n"
+ "EX2 value.r, -value.r;\n"
+ /* alpha */
+ "SUB temp.a, 1.0, value.r;\n"
+ /* shade colors */
+ "MUL temp.r, temp.r, shadow.r;\n"
+ "MUL temp.g, temp.g, shadow.r;\n"
+ "MUL temp.b, temp.b, shadow.r;\n"
+ "MUL temp.r, temp.r, value.r;\n"
+ "MUL temp.g, temp.g, value.r;\n"
+ "MUL temp.b, temp.b, value.r;\n"
+ /* for now this just replace smoke shading if rendering fire */
+ "CMP result.color, render.r, temp, spec;\n"
+ "END\n";
+ static GLuint prog;
float size[3];
@@ -225,6 +275,33 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
}
tstart();
+ /* generate flame spectrum texture */
+ #define SPEC_WIDTH 256
+ #define FIRE_THRESH 7
+ #define MAX_FIRE_ALPHA 0.06f
+ #define FULL_ON_FIRE 100
+ spec_data = malloc(SPEC_WIDTH * 4 * sizeof(unsigned char));
+ flame_get_spectrum(spec_data, SPEC_WIDTH, 1500, 3000);
+ spec_pixels = malloc(SPEC_WIDTH * 4 * 16 * 16 * sizeof(float));
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ for (k = 0; k < SPEC_WIDTH; k++) {
+ int index = (j * SPEC_WIDTH * 16 + i * SPEC_WIDTH + k) * 4;
+ if (k >= FIRE_THRESH) {
+ spec_pixels[index] = ((float)spec_data[k * 4]) / 255.0f;
+ spec_pixels[index + 1] = ((float)spec_data[k * 4 + 1]) / 255.0f;
+ spec_pixels[index + 2] = ((float)spec_data[k * 4 + 2]) / 255.0f;
+ spec_pixels[index + 3] = MAX_FIRE_ALPHA * (
+ (k > FULL_ON_FIRE) ? 1.0f : (k - FIRE_THRESH) / ((float)FULL_ON_FIRE - FIRE_THRESH));
+ }
+ else {
+ spec_pixels[index] = spec_pixels[index + 1] = spec_pixels[index + 2] = spec_pixels[index + 3] = 0.0f;
+ }
+ }
+ }
+ }
+
+ tex_spec = GPU_texture_create_1D(SPEC_WIDTH, spec_pixels, NULL);
sub_v3_v3v3(size, max, min);
@@ -298,31 +375,17 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend);
glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth);
- gpuLoadMatrix(rv3d->viewmat);
- // gpuMultMatrix(ob->obmat);
-
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
-#if 0
- printf("Viewinv:\n");
- printf("%f, %f, %f\n", rv3d->viewinv[0][0], rv3d->viewinv[0][1], rv3d->viewinv[0][2]);
- printf("%f, %f, %f\n", rv3d->viewinv[1][0], rv3d->viewinv[1][1], rv3d->viewinv[1][2]);
- printf("%f, %f, %f\n", rv3d->viewinv[2][0], rv3d->viewinv[2][1], rv3d->viewinv[2][2]);
-#endif
-
- /* get view vector */
- copy_v3_v3(viewnormal, rv3d->viewinv[2]);
- normalize_v3(viewnormal);
-
/* find cube vertex that is closest to the viewer */
for (i = 0; i < 8; i++) {
float x, y, z;
- x = cv[i][0] - viewnormal[0]*size[0]*0.5f;
- y = cv[i][1] - viewnormal[1]*size[1]*0.5f;
- z = cv[i][2] - viewnormal[2]*size[2]*0.5f;
+ x = cv[i][0] - viewnormal[0] * size[0] * 0.5f;
+ y = cv[i][1] - viewnormal[1] * size[1] * 0.5f;
+ z = cv[i][2] - viewnormal[2] * size[2] * 0.5f;
if ((x >= min[0]) && (x <= max[0]) &&
(y >= min[1]) && (y <= max[1]) &&
@@ -345,12 +408,19 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
glGenProgramsARB(1, &prog);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog);
- glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(text), text);
+ /* set shader */
+ if (sds->active_fields & SM_ACTIVE_COLORS)
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(shader_color), shader_color);
+ else
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(shader_basic), shader_basic);
/* cell spacing */
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, dx, dx, dx, 1.0);
/* custom parameter for smoke style (higher = thicker) */
- glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 7.0, 7.0, 7.0, 1.0);
+ if (sds->active_fields & SM_ACTIVE_COLORS)
+ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 1.0, 1.0, 1.0, 10.0);
+ else
+ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, sds->active_color[0], sds->active_color[1], sds->active_color[2], 10.0);
}
else
printf("Your gfx card does not support 3D View smoke drawing.\n");
@@ -361,6 +431,11 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
else
printf("No volume shadow\n");
+ if (tex_flame) {
+ GPU_texture_bind(tex_flame, 2);
+ GPU_texture_bind(tex_spec, 3);
+ }
+
if (!GPU_non_power_of_two_support()) {
cor[0] = (float)res[0] / (float)power_of_2_max_i(res[0]);
cor[1] = (float)res[1] / (float)power_of_2_max_i(res[1]);
@@ -374,7 +449,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
/* d0 = (viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); */ /* UNUSED */
ds = (ABS(viewnormal[0]) * size[0] + ABS(viewnormal[1]) * size[1] + ABS(viewnormal[2]) * size[2]);
- dd = ds / 96.f;
+ dd = MAX3(sds->global_size[0], sds->global_size[1], sds->global_size[2]) / 128.f;
n = 0;
good_index = i;
@@ -417,7 +492,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
}
}
- // printf("numpoints: %d\n", numpoints);
+ /* render fire slice */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* non-default blend function */
+ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, 1.0, 0.0, 0.0, 0.0);
gpuImmediateFormat_T3_C4_V3();
gpuBegin(GL_TRIANGLE_FAN);
gpuCurrentColor3x(CPACK_WHITE);
@@ -427,12 +504,26 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
(points[i * 3 + 1] - min[1]) * cor[1] / size[1],
(points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
gpuVertex3f(
- points[i * 3 + 0],
- points[i * 3 + 1],
- points[i * 3 + 2]);
+ points[i * 3 + 0] / ob->size[0],
+ points[i * 3 + 1] / ob->size[1],
+ points[i * 3 + 2] / ob->size[2]);
+ }
+ gpuEnd();
+
+ /* render smoke slice */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, -1.0, 0.0, 0.0, 0.0);
+ gpuBegin(GL_POLYGON);
+ gpuColor3f(1.0, 1.0, 1.0);
+ for (i = 0; i < numpoints; i++) {
+ gpuTexCoord3f((points[i * 3 + 0] - min[0]) * cor[0] / size[0],
+ (points[i * 3 + 1] - min[1]) * cor[1] / size[1],
+ (points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
+ gpuVertex3f(points[i * 3 + 0] / ob->size[0], points[i * 3 + 1] / ob->size[1], points[i * 3 + 2] / ob->size[2]);
}
gpuEnd();
gpuImmediateUnformat();
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* return to default blend function */
}
n++;
}
@@ -443,6 +534,14 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
if (tex_shadow)
GPU_texture_unbind(tex_shadow);
GPU_texture_unbind(tex);
+ if (tex_flame) {
+ GPU_texture_unbind(tex_flame);
+ GPU_texture_unbind(tex_spec);
+ }
+ GPU_texture_free(tex_spec);
+
+ free(spec_data);
+ free(spec_pixels);
if (GLEW_ARB_fragment_program) {
glDisable(GL_FRAGMENT_PROGRAM_ARB);
@@ -457,6 +556,109 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r
if (gl_depth) {
glEnable(GL_DEPTH_TEST);
- glDepthMask(GL_TRUE);
+ glDepthMask(GL_TRUE);
}
}
+
+#ifdef SMOKE_DEBUG_VELOCITY
+void draw_smoke_velocity(SmokeDomainSettings *domain, Object *ob)
+{
+ float x, y, z;
+ float x0, y0, z0;
+ int *base_res = domain->base_res;
+ int *res = domain->res;
+ int *res_min = domain->res_min;
+ int *res_max = domain->res_max;
+ float *vel_x = smoke_get_velocity_x(domain->fluid);
+ float *vel_y = smoke_get_velocity_y(domain->fluid);
+ float *vel_z = smoke_get_velocity_z(domain->fluid);
+
+ float min[3];
+ float *cell_size = domain->cell_size;
+ float step_size = ((float)MAX3(base_res[0], base_res[1], base_res[2])) / 16.f;
+ float vf = domain->scale / 16.f * 2.f; /* velocity factor */
+
+ glLineWidth(1.0f);
+
+ /* set first position so that it doesn't jump when domain moves */
+ x0 = res_min[0] + fmod(-(float)domain->shift[0] + res_min[0], step_size);
+ y0 = res_min[1] + fmod(-(float)domain->shift[1] + res_min[1], step_size);
+ z0 = res_min[2] + fmod(-(float)domain->shift[2] + res_min[2], step_size);
+ if (x0 < res_min[0]) x0 += step_size;
+ if (y0 < res_min[1]) y0 += step_size;
+ if (z0 < res_min[2]) z0 += step_size;
+ add_v3_v3v3(min, domain->p0, domain->obj_shift_f);
+
+ for (x = floor(x0); x < res_max[0]; x += step_size)
+ for (y = floor(y0); y < res_max[1]; y += step_size)
+ for (z = floor(z0); z < res_max[2]; z += step_size) {
+ int index = (floor(x) - res_min[0]) + (floor(y) - res_min[1]) * res[0] + (floor(z) - res_min[2]) * res[0] * res[1];
+
+ float pos[3] = {min[0] + ((float)x + 0.5f) * cell_size[0], min[1] + ((float)y + 0.5f) * cell_size[1], min[2] + ((float)z + 0.5f) * cell_size[2]};
+ float vel = sqrtf(vel_x[index] * vel_x[index] + vel_y[index] * vel_y[index] + vel_z[index] * vel_z[index]);
+
+ /* draw heat as scaled "arrows" */
+ if (vel >= 0.01f) {
+ float col_g = 1.0f - vel;
+ CLAMP(col_g, 0.0f, 1.0f);
+ glColor3f(1.0f, col_g, 0.0f);
+ glPointSize(10.0f * vel);
+
+ glBegin(GL_LINES);
+ glVertex3f(pos[0], pos[1], pos[2]);
+ glVertex3f(pos[0] + vel_x[index] * vf, pos[1] + vel_y[index] * vf, pos[2] + vel_z[index] * vf);
+ glEnd();
+ glBegin(GL_POINTS);
+ glVertex3f(pos[0] + vel_x[index] * vf, pos[1] + vel_y[index] * vf, pos[2] + vel_z[index] * vf);
+ glEnd();
+ }
+ }
+}
+#endif
+
+#ifdef SMOKE_DEBUG_HEAT
+void draw_smoke_heat(SmokeDomainSettings *domain, Object *ob)
+{
+ float x, y, z;
+ float x0, y0, z0;
+ int *base_res = domain->base_res;
+ int *res = domain->res;
+ int *res_min = domain->res_min;
+ int *res_max = domain->res_max;
+ float *heat = smoke_get_heat(domain->fluid);
+
+ float min[3];
+ float *cell_size = domain->cell_size;
+ float step_size = ((float)MAX3(base_res[0], base_res[1], base_res[2])) / 16.f;
+ float vf = domain->scale / 16.f * 2.f; /* velocity factor */
+
+ /* set first position so that it doesn't jump when domain moves */
+ x0 = res_min[0] + fmod(-(float)domain->shift[0] + res_min[0], step_size);
+ y0 = res_min[1] + fmod(-(float)domain->shift[1] + res_min[1], step_size);
+ z0 = res_min[2] + fmod(-(float)domain->shift[2] + res_min[2], step_size);
+ if (x0 < res_min[0]) x0 += step_size;
+ if (y0 < res_min[1]) y0 += step_size;
+ if (z0 < res_min[2]) z0 += step_size;
+ add_v3_v3v3(min, domain->p0, domain->obj_shift_f);
+
+ for (x = floor(x0); x < res_max[0]; x += step_size)
+ for (y = floor(y0); y < res_max[1]; y += step_size)
+ for (z = floor(z0); z < res_max[2]; z += step_size) {
+ int index = (floor(x) - res_min[0]) + (floor(y) - res_min[1]) * res[0] + (floor(z) - res_min[2]) * res[0] * res[1];
+
+ float pos[3] = {min[0] + ((float)x + 0.5f) * cell_size[0], min[1] + ((float)y + 0.5f) * cell_size[1], min[2] + ((float)z + 0.5f) * cell_size[2]};
+
+ /* draw heat as different sized points */
+ if (heat[index] >= 0.01f) {
+ float col_gb = 1.0f - heat[index];
+ CLAMP(col_gb, 0.0f, 1.0f);
+ glColor3f(1.0f, col_gb, col_gb);
+ glPointSize(24.0f * heat[index]);
+
+ glBegin(GL_POINTS);
+ glVertex3f(pos[0], pos[1], pos[2]);
+ glEnd();
+ }
+ }
+}
+#endif
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c2101b2e30e..88b100c6c13 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -186,7 +186,7 @@ int ED_view3d_context_user_region(bContext *C, View3D **v3d_r, ARegion **ar_r)
ar_unlock_user = ar;
break;
}
- }
+ }
}
}
@@ -720,7 +720,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
case NC_BRUSH:
if (wmn->action == NA_EDITED)
ED_region_tag_redraw_overlay(ar);
- break;
+ break;
case NC_MATERIAL:
switch (wmn->data) {
case ND_SHADING_DRAW:
@@ -749,12 +749,12 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
break;
}
break;
- case NC_IMAGE:
+ case NC_IMAGE:
/* this could be more fine grained checks if we had
* more context than just the region */
ED_region_tag_redraw(ar);
break;
- case NC_TEXTURE:
+ case NC_TEXTURE:
/* same as above */
ED_region_tag_redraw(ar);
break;
@@ -883,7 +883,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
case ND_KEYFRAME:
if (wmn->action == NA_EDITED)
ED_region_tag_redraw(ar);
- break;
+ break;
}
break;
case NC_SCENE:
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index c8aca5674a4..bf14d915412 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -86,13 +86,15 @@
#define B_REDR 2
#define B_OBJECTPANELMEDIAN 1008
+#define NBR_TRANSFORM_PROPERTIES 7
+
/* temporary struct for storing transform properties */
typedef struct {
float ob_eul[4]; /* used for quat too... */
float ob_scale[3]; /* need temp space due to linked values */
float ob_dims[3];
short link_scale;
- float ve_median[9];
+ float ve_median[NBR_TRANSFORM_PROPERTIES];
int curdef;
float *defweightp;
} TransformProperties;
@@ -131,17 +133,38 @@ static float compute_scale_factor(const float ve_median, const float median)
/* is used for both read and write... */
static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float lim)
{
+/* Get rid of those ugly magic numbers, even in a single func they become confusing! */
+/* Location, common to all. */
+/* XXX Those two *must* remain contiguous (used as array)! */
+#define LOC_X 0
+#define LOC_Y 1
+#define LOC_Z 2
+/* Meshes... */
+#define M_CREASE 3
+#define M_WEIGHT 4
+/* XXX Those two *must* remain contiguous (used as array)! */
+#define M_SKIN_X 5
+#define M_SKIN_Y 6
+/* Curves... */
+#define C_BWEIGHT 3
+#define C_WEIGHT 4
+#define C_RADIUS 5
+#define C_TILT 6
+/*Lattice... */
+#define L_WEIGHT 4
+
uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : NULL;
MDeformVert *dvert = NULL;
TransformProperties *tfp;
- float median[9], ve_median[9];
- int tot, totw, totweight, totedge, totradius, totskinradius;
+ float median[NBR_TRANSFORM_PROPERTIES], ve_median[NBR_TRANSFORM_PROPERTIES];
+ int tot, totedgedata, totcurvedata, totlattdata, totskinradius, totcurvebweight;
+ int meshdata = FALSE;
char defstr[320];
- PointerRNA radius_ptr;
+ PointerRNA data_ptr;
- median[0] = median[1] = median[2] = median[3] = median[4] = median[5] = median[6] = median[7] = median[8] = 0.0;
- tot = totw = totweight = totedge = totradius = totskinradius = 0;
- defstr[0] = 0;
+ fill_vn_fl(median, NBR_TRANSFORM_PROPERTIES, 0.0f);
+ tot = totedgedata = totcurvedata = totlattdata = totskinradius = totcurvebweight = 0;
+ defstr[0] = '\0';
/* make sure we got storage */
if (v3d->properties_storage == NULL)
@@ -162,11 +185,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
evedef = eve;
tot++;
- add_v3_v3(median, eve->co);
+ add_v3_v3(&median[LOC_X], eve->co);
vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN);
if (vs) {
- add_v2_v2(median + 7, vs->radius); /* Third val not used currently. */
+ add_v2_v2(&median[M_SKIN_X], vs->radius); /* Third val not used currently. */
totskinradius++;
}
}
@@ -176,12 +199,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
float *f;
- totedge++;
+ totedgedata++;
f = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
- median[3] += f ? *f : 0.0f;
+ median[M_CREASE] += f ? *f : 0.0f;
f = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
- median[6] += f ? *f : 0.0f;
+ median[M_WEIGHT] += f ? *f : 0.0f;
}
}
@@ -211,6 +234,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
tfp->defweightp = &dvert->dw[0].weight;
}
}
+
+ meshdata = totedgedata || totskinradius;
}
else if (ob->type == OB_CURVE || ob->type == OB_SURF) {
Curve *cu = ob->data;
@@ -229,22 +254,24 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
a = nu->pntsu;
while (a--) {
if (bezt->f2 & SELECT) {
- add_v3_v3(median, bezt->vec[1]);
+ add_v3_v3(&median[LOC_X], bezt->vec[1]);
tot++;
- median[4] += bezt->weight;
- totweight++;
- median[5] += bezt->radius;
- totradius++;
- selp = bezt;
- seltype = &RNA_BezierSplinePoint;
+ median[C_WEIGHT] += bezt->weight;
+ median[C_RADIUS] += bezt->radius;
+ median[C_TILT] += bezt->alfa;
+ if (!totcurvedata) { /* I.e. first time... */
+ selp = bezt;
+ seltype = &RNA_BezierSplinePoint;
+ }
+ totcurvedata++;
}
else {
if (bezt->f1 & SELECT) {
- add_v3_v3(median, bezt->vec[0]);
+ add_v3_v3(&median[LOC_X], bezt->vec[0]);
tot++;
}
if (bezt->f3 & SELECT) {
- add_v3_v3(median, bezt->vec[2]);
+ add_v3_v3(&median[LOC_X], bezt->vec[2]);
tot++;
}
}
@@ -256,16 +283,18 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- add_v3_v3(median, bp->vec);
- median[3] += bp->vec[3];
- totw++;
+ add_v3_v3(&median[LOC_X], bp->vec);
+ median[C_BWEIGHT] += bp->vec[3];
+ totcurvebweight++;
tot++;
- median[4] += bp->weight;
- totweight++;
- median[5] += bp->radius;
- totradius++;
- selp = bp;
- seltype = &RNA_SplinePoint;
+ median[C_WEIGHT] += bp->weight;
+ median[C_RADIUS] += bp->radius;
+ median[C_TILT] += bp->alfa;
+ if (!totcurvedata) { /* I.e. first time... */
+ selp = bp;
+ seltype = &RNA_SplinePoint;
+ }
+ totcurvedata++;
}
bp++;
}
@@ -273,84 +302,102 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
nu = nu->next;
}
- if (totradius == 1)
- RNA_pointer_create(&cu->id, seltype, selp, &radius_ptr);
+ if (totcurvedata == 1)
+ RNA_pointer_create(&cu->id, seltype, selp, &data_ptr);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
BPoint *bp;
int a;
+ StructRNA *seltype = NULL;
+ void *selp = NULL;
a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
bp = lt->editlatt->latt->def;
while (a--) {
if (bp->f1 & SELECT) {
- add_v3_v3(median, bp->vec);
+ add_v3_v3(&median[LOC_X], bp->vec);
tot++;
- median[4] += bp->weight;
- totweight++;
+ median[L_WEIGHT] += bp->weight;
+ if (!totlattdata) { /* I.e. first time... */
+ selp = bp;
+ seltype = &RNA_LatticePoint;
+ }
+ totlattdata++;
}
bp++;
}
+
+ if (totlattdata == 1)
+ RNA_pointer_create(&lt->id, seltype, selp, &data_ptr);
}
if (tot == 0) {
uiDefBut(block, LABEL, 0, IFACE_("Nothing selected"), 0, 130, 200, 20, NULL, 0, 0, 0, 0, "");
return;
}
- median[0] /= (float)tot;
- median[1] /= (float)tot;
- median[2] /= (float)tot;
- if (totedge) {
- median[3] /= (float)totedge;
- median[6] /= (float)totedge;
- }
- else if (totw)
- median[3] /= (float)totw;
- if (totweight)
- median[4] /= (float)totweight;
- if (totradius)
- median[5] /= (float)totradius;
- if (totskinradius) {
- median[7] /= (float)totskinradius;
- median[8] /= (float)totskinradius;
- }
+ /* Location, X/Y/Z */
+ mul_v3_fl(&median[LOC_X], 1.0f / (float)tot);
if (v3d->flag & V3D_GLOBAL_STATS)
- mul_m4_v3(ob->obmat, median);
+ mul_m4_v3(ob->obmat, &median[LOC_X]);
+
+ if (meshdata) {
+ if (totedgedata) {
+ median[M_CREASE] /= (float)totedgedata;
+ median[M_WEIGHT] /= (float)totedgedata;
+ }
+ if (totskinradius) {
+ median[M_SKIN_X] /= (float)totskinradius;
+ median[M_SKIN_Y] /= (float)totskinradius;
+ }
+ }
+ else if (totcurvedata) {
+ median[C_WEIGHT] /= (float)totcurvedata;
+ median[C_RADIUS] /= (float)totcurvedata;
+ median[C_TILT] /= (float)totcurvedata;
+ if (totcurvebweight)
+ median[C_BWEIGHT] /= (float)totcurvebweight;
+ }
+ else if (totlattdata)
+ median[L_WEIGHT] /= (float)totlattdata;
if (block) { /* buttons */
uiBut *but;
int yi = 200;
const int buth = 20 * UI_DPI_ICON_FAC;
const int but_margin = 2;
+ const char *c;
memcpy(tfp->ve_median, median, sizeof(tfp->ve_median));
uiBlockBeginAlign(block);
if (tot == 1) {
- uiDefBut(block, LABEL, 0, IFACE_("Vertex:"), 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, "");
- }
- else {
- uiDefBut(block, LABEL, 0, IFACE_("Median:"), 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, "");
+ if (totcurvedata) /* Curve */
+ c = IFACE_("Control Point:");
+ else /* Mesh or lattice */
+ c = IFACE_("Vertex:");
}
+ else
+ c = IFACE_("Median:");
+ uiDefBut(block, LABEL, 0, c, 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
/* Should be no need to translate these. */
but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "X:", 0, yi -= buth, 200, buth,
- &(tfp->ve_median[0]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, "");
+ &(tfp->ve_median[LOC_X]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, "");
uiButSetUnitType(but, PROP_UNIT_LENGTH);
but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Y:", 0, yi -= buth, 200, buth,
- &(tfp->ve_median[1]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, "");
+ &(tfp->ve_median[LOC_Y]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, "");
uiButSetUnitType(but, PROP_UNIT_LENGTH);
but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Z:", 0, yi -= buth, 200, buth,
- &(tfp->ve_median[2]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, "");
+ &(tfp->ve_median[LOC_Z]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, "");
uiButSetUnitType(but, PROP_UNIT_LENGTH);
- if (totw == tot) {
+ if (totcurvebweight == tot) {
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "W:", 0, yi -= buth, 200, buth,
- &(tfp->ve_median[3]), 0.01, 100.0, 1, 3, "");
+ &(tfp->ve_median[C_BWEIGHT]), 0.01, 100.0, 1, 3, "");
}
uiBlockBeginAlign(block);
@@ -362,60 +409,60 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&v3d->flag, 0, 0, 0, 0, "Displays local values");
uiBlockEndAlign(block);
- if (totweight == 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Weight:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[4]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal"));
+ /* Meshes... */
+ if (meshdata) {
+ if (totedgedata) {
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN,
+ totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"),
+ 0, yi -= buth + but_margin, 200, buth,
+ &(tfp->ve_median[M_CREASE]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier"));
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN,
+ totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
+ 0, yi -= buth + but_margin, 200, buth,
+ &(tfp->ve_median[M_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier"));
+ }
+ if (totskinradius) {
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN,
+ totskinradius == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"),
+ 0, yi -= buth + but_margin, 200, buth,
+ &(tfp->ve_median[M_SKIN_X]), 0.0, 100.0, 1, 3, TIP_("X radius used by Skin modifier"));
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN,
+ totskinradius == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"),
+ 0, yi -= buth + but_margin, 200, buth,
+ &(tfp->ve_median[M_SKIN_Y]), 0.0, 100.0, 1, 3, TIP_("Y radius used by Skin modifier"));
+ }
}
- else if (totweight > 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"),
- 0, yi -= buth, 200, buth,
- &(tfp->ve_median[4]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal"));
+ /* Curve... */
+ else if (totcurvedata == 1) {
+ uiDefButR(block, NUM, 0, "Weight", 0, yi -= buth + but_margin, 200, buth,
+ &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL);
+ uiDefButR(block, NUM, 0, "Radius", 0, yi -= buth + but_margin, 200, buth,
+ &data_ptr, "radius", 0, 0.0, 100.0, 1, 3, NULL);
+ uiDefButR(block, NUM, 0, "Tilt", 0, yi -= buth + but_margin, 200, buth,
+ &data_ptr, "tilt", 0, -M_PI * 2.0, M_PI * 2.0, 1, 3, NULL);
}
-
- if (totradius == 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Radius:"),
+ else if (totcurvedata > 1) {
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"),
0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[5]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points"));
- }
- else if (totradius > 1) {
+ &(tfp->ve_median[C_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal"));
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius:"),
0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[5]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points"));
+ &(tfp->ve_median[C_RADIUS]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points"));
+ but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Tilt:"),
+ 0, yi -= buth + but_margin, 200, buth,
+ &(tfp->ve_median[C_TILT]), -M_PI * 2.0, M_PI * 2.0, 1, 3,
+ TIP_("Tilt of curve control points"));
+ uiButSetUnitType(but, PROP_UNIT_ROTATION);
}
-
- if (totskinradius == 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Radius X:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[7]), 0.0, 100.0, 1, 3, TIP_("X radius used by Skin modifier"));
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Radius Y:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[8]), 0.0, 100.0, 1, 3, TIP_("Y radius used by Skin modifier"));
+ /* Lattice... */
+ else if (totlattdata == 1) {
+ uiDefButR(block, NUM, 0, "Weight", 0, yi -= buth + but_margin, 200, buth,
+ &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL);
}
- else if (totskinradius > 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius X:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[7]), 0.0, 100.0, 1, 3, TIP_("Median X radius used by Skin modifier"));
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius Y:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[8]), 0.0, 100.0, 1, 3, TIP_("Median Y radius used by Skin modifier"));
- }
-
- if (totedge == 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Crease:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[3]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier"));
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Bevel Weight:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[6]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier"));
- }
- else if (totedge > 1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Crease:"),
- 0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[3]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier"));
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Bevel Weight:"),
+ else if (totlattdata > 1) {
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"),
0, yi -= buth + but_margin, 200, buth,
- &(tfp->ve_median[6]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier"));
+ &(tfp->ve_median[L_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal"));
}
uiBlockEndAlign(block);
@@ -423,42 +470,40 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
else { /* apply */
+ int i;
+
memcpy(ve_median, tfp->ve_median, sizeof(tfp->ve_median));
if (v3d->flag & V3D_GLOBAL_STATS) {
invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_v3(ob->imat, median);
- mul_m4_v3(ob->imat, ve_median);
+ mul_m4_v3(ob->imat, &median[LOC_X]);
+ mul_m4_v3(ob->imat, &ve_median[LOC_X]);
}
- sub_v3_v3v3(median, ve_median, median);
- median[3] = ve_median[3] - median[3];
- median[4] = ve_median[4] - median[4];
- median[5] = ve_median[5] - median[5];
- median[6] = ve_median[6] - median[6];
- median[7] = ve_median[7] - median[7];
- median[8] = ve_median[8] - median[8];
+ i = NBR_TRANSFORM_PROPERTIES;
+ while (i--)
+ median[i] = ve_median[i] - median[i];
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
BMesh *bm = em->bm;
- BMVert *eve;
BMIter iter;
- if (len_v3(median) > 0.000001f) {
+ if (len_v3(&median[LOC_X]) > 0.000001f) {
+ BMVert *eve;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- add_v3_v3(eve->co, median);
+ add_v3_v3(eve->co, &median[LOC_X]);
}
}
EDBM_mesh_normals_update(em);
}
- if (median[3] != 0.0f) {
+ if (median[M_CREASE] != 0.0f) {
BMEdge *eed;
- const float sca = compute_scale_factor(ve_median[3], median[3]);
+ const float sca = compute_scale_factor(ve_median[M_CREASE], median[M_CREASE]);
if (ELEM(sca, 0.0f, 1.0f)) {
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
@@ -494,9 +539,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
- if (median[6] != 0.0f) {
+ if (median[M_WEIGHT] != 0.0f) {
BMEdge *eed;
- const float sca = compute_scale_factor(ve_median[6], median[6]);
+ const float sca = compute_scale_factor(ve_median[M_WEIGHT], median[M_WEIGHT]);
if (ELEM(sca, 0.0f, 1.0f)) {
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
@@ -532,11 +577,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
- if (median[7] != 0.0f) {
+ if (median[M_SKIN_X] != 0.0f) {
BMVert *eve;
/* That one is not clamped to [0.0, 1.0]. */
- float sca = ve_median[7];
- if (ve_median[7] - median[7] == 0.0f) {
+ float sca = ve_median[M_SKIN_X];
+ if (ve_median[M_SKIN_X] - median[M_SKIN_X] == 0.0f) {
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN);
@@ -546,7 +591,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
else {
- sca /= (ve_median[7] - median[7]);
+ sca /= (ve_median[M_SKIN_X] - median[M_SKIN_X]);
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN);
@@ -556,11 +601,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
}
- if (median[8] != 0.0f) {
+ if (median[M_SKIN_Y] != 0.0f) {
BMVert *eve;
/* That one is not clamped to [0.0, 1.0]. */
- float sca = ve_median[8];
- if (ve_median[8] - median[8] == 0.0f) {
+ float sca = ve_median[M_SKIN_Y];
+ if (ve_median[M_SKIN_Y] - median[M_SKIN_Y] == 0.0f) {
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN);
@@ -570,7 +615,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
else {
- sca /= (ve_median[8] - median[8]);
+ sca /= (ve_median[M_SKIN_Y] - median[M_SKIN_Y]);
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN);
@@ -589,7 +634,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
BezTriple *bezt;
int a;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- const float scale_w = compute_scale_factor(ve_median[4], median[4]);
+ const float scale_w = compute_scale_factor(ve_median[C_WEIGHT], median[C_WEIGHT]);
nu = nurbs->first;
while (nu) {
@@ -598,11 +643,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
a = nu->pntsu;
while (a--) {
if (bezt->f2 & SELECT) {
- add_v3_v3(bezt->vec[0], median);
- add_v3_v3(bezt->vec[1], median);
- add_v3_v3(bezt->vec[2], median);
+ add_v3_v3(bezt->vec[0], &median[LOC_X]);
+ add_v3_v3(bezt->vec[1], &median[LOC_X]);
+ add_v3_v3(bezt->vec[2], &median[LOC_X]);
- if (median[4] != 0.0f) {
+ if (median[C_WEIGHT] != 0.0f) {
if (ELEM(scale_w, 0.0f, 1.0f)) {
bezt->weight = scale_w;
}
@@ -613,14 +658,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
- bezt->radius += median[5];
+ bezt->radius += median[C_RADIUS];
+ bezt->alfa += median[C_TILT];
}
else {
if (bezt->f1 & SELECT) {
- add_v3_v3(bezt->vec[0], median);
+ add_v3_v3(bezt->vec[0], &median[LOC_X]);
}
if (bezt->f3 & SELECT) {
- add_v3_v3(bezt->vec[2], median);
+ add_v3_v3(bezt->vec[2], &median[LOC_X]);
}
}
bezt++;
@@ -631,10 +677,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- add_v3_v3(bp->vec, median);
- bp->vec[3] += median[3];
+ add_v3_v3(bp->vec, &median[LOC_X]);
+ bp->vec[3] += median[C_BWEIGHT];
- if (median[4] != 0.0f) {
+ if (median[C_WEIGHT] != 0.0f) {
if (ELEM(scale_w, 0.0f, 1.0f)) {
bp->weight = scale_w;
}
@@ -645,7 +691,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
}
- bp->radius += median[5];
+ bp->radius += median[C_RADIUS];
+ bp->alfa += median[C_TILT];
}
bp++;
}
@@ -660,15 +707,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
Lattice *lt = ob->data;
BPoint *bp;
int a;
- const float scale_w = compute_scale_factor(ve_median[4], median[4]);
+ const float scale_w = compute_scale_factor(ve_median[L_WEIGHT], median[L_WEIGHT]);
a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
bp = lt->editlatt->latt->def;
while (a--) {
if (bp->f1 & SELECT) {
- add_v3_v3(bp->vec, median);
+ add_v3_v3(bp->vec, &median[LOC_X]);
- if (median[4] != 0.0f) {
+ if (median[L_WEIGHT] != 0.0f) {
if (ELEM(scale_w, 0.0f, 1.0f)) {
bp->weight = scale_w;
}
@@ -685,7 +732,28 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
/* ED_undo_push(C, "Transform properties"); */
}
+
+/* Clean up! */
+/* Location, common to all. */
+#undef LOC_X
+#undef LOC_Y
+#undef LOC_Z
+/* Meshes (and lattice)... */
+#undef M_CREASE
+#undef M_WEIGHT
+#undef M_SKIN_X
+#undef M_SKIN_Y
+/* Curves... */
+#undef C_BWEIGHT
+#undef C_WEIGHT
+#undef C_RADIUS
+#undef C_TILT
+/* Lattice... */
+#undef L_WEIGHT
}
+#undef NBR_TRANSFORM_PROPERTIES
+
+
#define B_VGRP_PNL_COPY 1
#define B_VGRP_PNL_NORMALIZE 2
#define B_VGRP_PNL_EDIT_SINGLE 8 /* or greater */
@@ -1155,13 +1223,12 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
if (ob == NULL)
return;
- lim = 10000.0f * MAX2(1.0f, v3d->grid);
+ lim = 10000.0f * max_ff(1.0f, v3d->grid);
block = uiLayoutGetBlock(pa->layout);
uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
col = uiLayoutColumn(pa->layout, FALSE);
- /* row = uiLayoutRow(col, FALSE); */ /* UNUSED */
RNA_id_pointer_create(&ob->id, &obptr);
if (ob == obedit) {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 176ef119cb9..2c85dc62edb 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -331,7 +331,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
if (dx < GRID_MIN_PX_D) {
rv3d->gridview *= sublines;
dx *= sublines;
- if (dx < GRID_MIN_PX_D) ;
+ if (dx < GRID_MIN_PX_D) {
+ /* pass */
+ }
else {
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx);
@@ -513,7 +515,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
GPU_print_error("sdsd");
}
- /* draw the Z axis line */
+ /* draw the Z axis line */
/* check for the 'show Z axis' preference */
if (v3d->gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) {
int axis;
@@ -540,12 +542,8 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
gpuEnd();
gpuImmediateUnformat();
}
-
-
-
-
- if (v3d->zbuf && scene->obedit) glDepthMask(1);
+ if (v3d->zbuf && scene->obedit) glDepthMask(1);
}
static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
@@ -553,7 +551,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
int co[2];
/* we don't want the clipping for cursor */
- if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
gpuImmediateFormat_V2(); // DOODLE: view3d cursor, 2 stippled circles, 4 mono lines
setlinestyle(0);
@@ -640,7 +638,7 @@ static void draw_view_axis(RegionView3D *rv3d)
/* axis alpha (rvibright has range 0-10) */
const int bright = 25*U.rvibright + U.rvibright/51;
-
+
float axis[3][3] = {
{ 1, 0, 0 },
{ 0, 1, 0 },
@@ -656,12 +654,8 @@ static void draw_view_axis(RegionView3D *rv3d)
const unsigned char label[] = "xyz";
GLboolean showLabel[3];
- const GLubyte color[3][4] = {
- { 220, 0, 0, bright },
- { 0, 220, 0, bright },
- { 30, 30, 220, bright },
- };
-
+ GLubyte color[3][4];
+
const GLfloat jitter[4][3] = {
{ -size/2, 0, 0 },
{ 0, -size/2, 0 },
@@ -673,6 +667,12 @@ static void draw_view_axis(RegionView3D *rv3d)
int i;
+ UI_GetThemeColor3ubv(TH_AXIS_X, color[0]);
+ UI_GetThemeColor3ubv(TH_AXIS_Y, color[1]);
+ UI_GetThemeColor3ubv(TH_AXIS_Z, color[2]);
+
+ color[0][3] = color[1][3] = color [2][3] = bright;
+
for (i = 0; i < 3; i++) {
mul_qt_v3(rv3d->viewquat, axis[i]);
mul_qt_v3(rv3d->viewquat, offset[i]);
@@ -1111,7 +1111,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons
static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
{
- float fac, a;
+ float hmargin, vmargin;
float x1, x2, y1, y2;
float x1i, x2i, y1i, y2i;
float x3, y3, x4, y4;
@@ -1263,20 +1263,15 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
gpuImmediateUnformat();
if (ca->flag & CAM_SHOWTITLESAFE) {
- fac = 0.1;
-
- a = fac * (x2 - x1);
- x1 += a;
- x2 -= a;
-
- a = fac * (y2 - y1);
- y1 += a;
- y2 -= a;
-
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
- uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
+ hmargin = 0.1f * (x2 - x1);
+ vmargin = 0.05f * (y2 - y1);
+ uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f);
+
+ hmargin = 0.035f * (x2 - x1);
+ vmargin = 0.035f * (y2 - y1);
+ uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1+vmargin, x2 - hmargin, y2 - vmargin, 2.0f);
}
if (ca && (ca->flag & CAM_SHOWSENSOR)) {
/* determine sensor fit, and get sensor x/y, for auto fit we
@@ -1477,7 +1472,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax,
(ymaxc - yminc + 1),
GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- glReadBuffer(GL_BACK);
+ glReadBuffer(GL_BACK);
if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
@@ -1510,7 +1505,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax,
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int size,
- unsigned int min, unsigned int max, int *dist, short strict,
+ unsigned int min, unsigned int max, float *r_dist, short strict,
void *handle, unsigned int (*indextest)(void *handle, unsigned int index))
{
struct ImBuf *buf;
@@ -1519,7 +1514,7 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int
int a, b, rc, nr, amount, dirvec[4][2];
int distance = 0;
unsigned int index = 0;
- short indexok = 0;
+ short indexok = 0;
amount = (size - 1) / 2;
@@ -1548,13 +1543,13 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int
if (strict) {
indexok = indextest(handle, *tbuf - min + 1);
if (indexok) {
- *dist = (short) sqrt( (float)distance);
+ *r_dist = sqrtf((float)distance);
index = *tbuf - min + 1;
goto exit;
}
}
else {
- *dist = (short) sqrt( (float)distance); /* XXX, this distance is wrong - */
+ *r_dist = sqrtf((float)distance); /* XXX, this distance is wrong - */
index = *tbuf - min + 1; /* messy yah, but indices start at 1 */
goto exit;
}
@@ -1688,7 +1683,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
/* apply offset last - camera offset is different to offset in blender units */
/* so this has some sane way of working - this matches camera's shift _exactly_ */
{
- const float max_dim = maxf(x2 - x1, y2 - y1);
+ const float max_dim = max_ff(x2 - x1, y2 - y1);
const float xof_scale = bgpic->xof * max_dim;
const float yof_scale = bgpic->yof * max_dim;
@@ -1737,7 +1732,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
/* calc window coord */
initgrabz(rv3d, 0.0, 0.0, 0.0);
ED_view3d_win_to_delta(ar, mval_f, tvec);
- fac = maxf(fabsf(tvec[0]), maxf(fabsf(tvec[1]), fabsf(tvec[2]))); /* largest abs axis */
+ fac = max_ff(fabsf(tvec[0]), max_ff(fabsf(tvec[1]), fabsf(tvec[2]))); /* largest abs axis */
fac = 1.0f / fac;
asp = (float)ibuf->y / (float)ibuf->x;
@@ -1765,7 +1760,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
/* for some reason; zoomlevels down refuses to use GL_ALPHA_SCALE */
if (zoomx < 1.0f || zoomy < 1.0f) {
- float tzoom = minf(zoomx, zoomy);
+ float tzoom = min_ff(zoomx, zoomy);
int mip = 0;
if ((ibuf->userflags & IB_MIPMAP_INVALID) != 0) {
@@ -2071,7 +2066,7 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas
void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
{
- int x, y, w, h;
+ int x, y, w, h;
rcti r;
/* clamp rect by area */
@@ -2169,7 +2164,7 @@ float view3d_depth_near(ViewDepths *d)
int i = (int)d->w * (int)d->h; /* cast to avoid short overflow */
/* far is both the starting 'far' value
- * and the closest value found. */
+ * and the closest value found. */
while (i--) {
depth = *depths++;
if ((depth < far) && (depth > near)) {
@@ -2185,7 +2180,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
short zbuf = v3d->zbuf;
RegionView3D *rv3d = ar->regiondata;
- setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
+ setwinmatrixview3d(ar, v3d, NULL);
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
@@ -2220,7 +2215,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *))
U.glalphaclip = 0.5; /* not that nice but means we wont zoom into billboards */
U.obcenter_dia = 0;
- setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
+ setwinmatrixview3d(ar, v3d, NULL);
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
@@ -2418,6 +2413,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
+ /* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */
ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE, FALSE);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
@@ -2507,7 +2503,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
if (winmat)
copy_m4_m4(rv3d->winmat, winmat);
else
- setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */
+ setwinmatrixview3d(ar, v3d, NULL);
/* setup view matrix */
if (viewmat)
@@ -2525,7 +2521,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
/* note: '1.0f / len_v3(v1)' replaced 'len_v3(rv3d->viewmat[0])'
* because of float point precision problems at large values [#23908] */
float v1[3], v2[3];
- float len1, len2;
+ float len_px, len_sc;
v1[0] = rv3d->persmat[0][0];
v1[1] = rv3d->persmat[1][0];
@@ -2535,10 +2531,10 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
v2[1] = rv3d->persmat[1][1];
v2[2] = rv3d->persmat[2][1];
- len1 = 1.0f / len_v3(v1);
- len2 = 1.0f / len_v3(v2);
+ len_px = 2.0f / sqrtf(min_ff(len_squared_v3(v1), len_squared_v3(v2)));
+ len_sc = (float)MAX2(ar->winx, ar->winy);
- rv3d->pixsize = (2.0f * MAX2(len1, len2)) / (float)MAX2(ar->winx, ar->winy);
+ rv3d->pixsize = len_px / len_sc;
}
}
@@ -2555,6 +2551,16 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
gpuLoadMatrix(rv3d->viewmat);
}
+void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d)
+{
+ /* shadow buffers, before we setup matrices */
+ if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
+ gpu_update_lamps_shadows(scene, v3d);
+}
+
+/* ED_view3d_draw_offscreen_init should be called before this to initialize
+ * stuff like shadow buffers
+ */
void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
int winx, int winy, float viewmat[][4], float winmat[][4],
int do_bgpic, int colormanage_background)
@@ -2588,10 +2594,6 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* free images which can have changed on frame-change
* warning! can be slow so only free animated images - campbell */
GPU_free_images_anim();
-
- /* shadow buffers, before we setup matrices */
- if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
- gpu_update_lamps_shadows(scene, v3d);
/* set background color, fallback on the view background color
* (if active clip is set but frame is failed to load fallback to horizon color as background) */
@@ -2734,6 +2736,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
if (ofs == NULL)
return NULL;
+ ED_view3d_draw_offscreen_init(scene, v3d);
+
GPU_offscreen_bind(ofs);
/* render 3d view */
@@ -2862,7 +2866,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
if (fps + 0.5f < (float)(FPS)) {
UI_ThemeColor(TH_REDALERT);
BLI_snprintf(printable, sizeof(printable), "fps: %.2f", fps);
- }
+ }
else {
UI_ThemeColor(TH_TEXT_HI);
BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps + 0.5f));
@@ -2900,8 +2904,8 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
engine = RE_engine_create(type);
- engine->tile_x = ceil(ar->winx / (float)scene->r.xparts);
- engine->tile_y = ceil(ar->winy / (float)scene->r.yparts);
+ engine->tile_x = scene->r.tilex;
+ engine->tile_y = scene->r.tiley;
type->view_update(engine, C);
@@ -2919,12 +2923,20 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
rctf viewborder;
rcti cliprct;
- ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
+ if (rv3d->persp == RV3D_CAMOB) {
+ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
- cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
- cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
- cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
- cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
+ cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
+ cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
+ cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
+ cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
+ }
+ else {
+ cliprct.xmin = v3d->render_border.xmin * ar->winx;
+ cliprct.xmax = v3d->render_border.xmax * ar->winx;
+ cliprct.ymin = v3d->render_border.ymin * ar->winy;
+ cliprct.ymax = v3d->render_border.ymax * ar->winy;
+ }
cliprct.xmin += ar->winrct.xmin;
cliprct.xmax += ar->winrct.xmin;
@@ -3024,10 +3036,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
v3d->zbuf = FALSE;
/* enables anti-aliasing for 3D view drawing */
-#if 0
- if (!(U.gameflags & USER_DISABLE_AA))
- glEnable(GL_MULTISAMPLE_ARB);
-#endif
+ if (U.ogl_multisamples)
+ if (!(U.gameflags & USER_DISABLE_AA))
+ glEnable(GL_MULTISAMPLE_ARB);
+
/* needs to be done always, gridview is adjusted in drawgrid() now */
rv3d->gridview = v3d->grid;
@@ -3140,12 +3152,12 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
BIF_draw_manipulator(C);
-#if 0
/* Disable back anti-aliasing */
- if (!(U.gameflags & USER_DISABLE_AA))
- glDisable(GL_MULTISAMPLE_ARB);
-#endif
+ if (U.ogl_multisamples)
+ if (!(U.gameflags & USER_DISABLE_AA))
+ glDisable(GL_MULTISAMPLE_ARB);
+
if (v3d->zbuf) {
v3d->zbuf = FALSE;
glDisable(GL_DEPTH_TEST);
@@ -3168,50 +3180,64 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- Object *ob;
-
- if (rv3d->persp == RV3D_CAMOB)
+ if (rv3d->persp == RV3D_CAMOB) {
drawviewborder(scene, ar, v3d);
+ }
+ else if (v3d->flag2 & V3D_RENDER_BORDER) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ setlinestyle(3);
+ gpuColor3x(0x4040FF);
+
+ glRectf(v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
+ v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
+
+ setlinestyle(0);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ }
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ Object *ob;
+
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
// if (v3d->flag2 & V3D_DISPGP)
draw_gpencil_view3d(scene, v3d, ar, 0);
drawcursor(scene, ar, v3d);
+
+ if (U.uiflag & USER_SHOW_ROTVIEWICON)
+ draw_view_axis(rv3d);
+ else
+ draw_view_icon(rv3d);
+
+ ob = OBACT;
+ if (U.uiflag & USER_DRAWVIEWINFO)
+ draw_selected_name(scene, ob);
}
-
- if (U.uiflag & USER_SHOW_ROTVIEWICON)
- draw_view_axis(rv3d);
- else
- draw_view_icon(rv3d);
-
- ob = OBACT;
- if (U.uiflag & USER_DRAWVIEWINFO)
- draw_selected_name(scene, ob);
if (rv3d->render_engine) {
view3d_main_area_draw_engine_info(rv3d, ar);
return;
}
- if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) {
- draw_viewport_fps(scene, ar);
- }
- else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
- draw_viewport_name(ar, v3d);
- }
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) {
+ draw_viewport_fps(scene, ar);
+ }
+ else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
+ draw_viewport_name(ar, v3d);
+ }
- if (grid_unit) { /* draw below the viewport name */
- char numstr[32] = "";
+ if (grid_unit) { /* draw below the viewport name */
+ char numstr[32] = "";
- UI_ThemeColor(TH_TEXT_HI);
- if (v3d->grid != 1.0f) {
- BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
- }
+ UI_ThemeColor(TH_TEXT_HI);
+ if (v3d->grid != 1.0f) {
+ BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
+ }
- BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f,
- numstr[0] ? numstr : grid_unit, sizeof(numstr));
+ BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f,
+ numstr[0] ? numstr : grid_unit, sizeof(numstr));
+ }
}
}
@@ -3221,7 +3247,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
const char *grid_unit = NULL;
- int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER));
+ int draw_border = FALSE;
+
+ if (rv3d->persp == RV3D_CAMOB)
+ draw_border = scene->r.mode & R_BORDER;
+ else
+ draw_border = v3d->flag2 & V3D_RENDER_BORDER;
/* draw viewport using opengl */
if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) {
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index f1f7025e453..ef2b500eec9 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -97,6 +97,7 @@ int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d)
void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d)
{
if (ED_view3d_camera_lock_check(v3d, rv3d)) {
+ rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs);
ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
}
}
@@ -895,6 +896,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* changed since 2.4x, use the camera view */
if (vod->v3d->camera) {
+ rv3d->dist = ED_view3d_offset_distance(vod->v3d->camera->obmat, rv3d->ofs);
ED_view3d_from_object(vod->v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
}
@@ -922,7 +924,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_FINISHED;
}
- else {
+ else {
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -930,18 +932,6 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
-static int view3d_camera_active_poll(bContext *C)
-{
- if (ED_operator_view3d_active(C)) {
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- if (rv3d && rv3d->persp == RV3D_CAMOB) {
- return 1;
- }
- }
-
- return 0;
-}
-
/* test for unlocked camera view in quad view */
static int view3d_camera_user_poll(bContext *C)
{
@@ -967,7 +957,6 @@ static int viewrotate_cancel(bContext *C, wmOperator *op)
void VIEW3D_OT_rotate(wmOperatorType *ot)
{
-
/* identifiers */
ot->name = "Rotate view";
ot->description = "Rotate the view";
@@ -1004,8 +993,10 @@ void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4])
* -- zooming
* -- panning in rotationally-locked views
*/
-static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+static int ndof_orbit_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ViewOpsData *vod = op->customdata;
+
if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
else {
@@ -1086,6 +1077,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
rot[1] = rot[2] = 0.0;
rot[3] = sin(angle);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
+
}
else {
float rot[4];
@@ -1100,6 +1092,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS)
axis[1] = -axis[1];
+
/* transform rotation axis from view to world coordinates */
mul_qt_v3(view_inv, axis);
@@ -1112,7 +1105,22 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
/* apply rotation */
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
-
+
+ }
+
+ /* rotate around custom center */
+ if (vod && vod->use_dyn_ofs) {
+ float q1[4];
+
+ /* compute the post multiplication quat, to rotate the offset correctly */
+ conjugate_qt_qt(q1, vod->oldquat);
+ mul_qt_qtqt(q1, q1, rv3d->viewquat);
+
+ conjugate_qt(q1); /* conj == inv for unit quat */
+ copy_v3_v3(rv3d->ofs, vod->ofs);
+ sub_v3_v3(rv3d->ofs, vod->dyn_ofs);
+ mul_qt_v3(q1, rv3d->ofs);
+ add_v3_v3(rv3d->ofs, vod->dyn_ofs);
}
}
}
@@ -1279,6 +1287,9 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
float axis[3];
#endif
+ /* inverse view */
+ invert_qt_qt(view_inv, rv3d->viewquat);
+
if (U.ndof_flag & NDOF_PANX_INVERT_AXIS)
pan_vec[0] = -lateral_sensitivity * ndof->tvec[0];
else
@@ -1297,12 +1308,11 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
mul_v3_fl(pan_vec, speed * dt);
/* transform motion from view to world coordinates */
- invert_qt_qt(view_inv, rv3d->viewquat);
mul_qt_v3(view_inv, pan_vec);
/* move center of view opposite of hand motion (this is camera mode, not object mode) */
sub_v3_v3(rv3d->ofs, pan_vec);
-
+
if (U.ndof_flag & NDOF_TURNTABLE) {
/* turntable view code by John Aughey, adapted for 3D mouse by [mce] */
float angle, rot[4];
@@ -1362,13 +1372,29 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* apply rotation */
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
-
+
}
+
+ /* rotate around custom center */
+ if (vod && vod->use_dyn_ofs) {
+ float q1[4];
+
+ /* compute the post multiplication quat, to rotate the offset correctly */
+ conjugate_qt_qt(q1, vod->oldquat);
+ mul_qt_qtqt(q1, q1, rv3d->viewquat);
+
+ conjugate_qt(q1); /* conj == inv for unit quat */
+ copy_v3_v3(rv3d->ofs, vod->ofs);
+ sub_v3_v3(rv3d->ofs, vod->dyn_ofs);
+ mul_qt_v3(q1, rv3d->ofs);
+ add_v3_v3(rv3d->ofs, vod->dyn_ofs);
+ }
+
}
ED_view3d_camera_lock_sync(v3d, rv3d);
ED_region_tag_redraw(CTX_wm_region(C));
- viewops_data_free(C, op);
+ viewops_data_free(C, op);
return OPERATOR_FINISHED;
}
}
@@ -1515,7 +1541,7 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
viewmove_apply(vod, event->prevx, event->prevy);
ED_view3d_depth_tag_update(vod->rv3d);
- viewops_data_free(C, op);
+ viewops_data_free(C, op);
return OPERATOR_FINISHED;
}
@@ -1638,7 +1664,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
if (use_cam_zoom) {
float delta;
delta = (x - vod->origx + y - vod->origy) / 10.0f;
- vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? delta : -delta);
+ vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? -delta : delta);
CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
}
@@ -1693,11 +1719,11 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
if (use_cam_zoom) {
/* zfac is ignored in this case, see below */
#if 0
- zfac = vod->camzoom0 * (2.0f * ((len2 / len1) - 1.0f) + 1.0f) / vod->rv3d->camzoom;
+ zfac = vod->camzoom0 * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->camzoom;
#endif
}
else {
- zfac = vod->dist0 * (2.0f * ((len2 / len1) - 1.0f) + 1.0f) / vod->rv3d->dist;
+ zfac = vod->dist0 * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->dist;
}
}
@@ -1890,12 +1916,12 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (U.uiflag & USER_ZOOM_HORIZ) {
vod->origx = vod->oldx = event->x;
- viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, FALSE);
+ viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, (U.uiflag & USER_ZOOM_INVERT) == 0);
}
else {
/* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */
vod->origy = vod->oldy = vod->origy + event->x - event->prevx;
- viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, FALSE);
+ viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, (U.uiflag & USER_ZOOM_INVERT) == 0);
}
ED_view3d_depth_tag_update(vod->rv3d);
@@ -1973,7 +1999,7 @@ static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_inv
if (zoom_invert)
SWAP(float, len1, len2);
- zfac = 1.0f + ((len2 - len1) * 0.01f * vod->rv3d->dist);
+ zfac = 1.0f + ((len1 - len2) * 0.01f * vod->rv3d->dist);
}
if (zfac != 1.0f)
@@ -2053,7 +2079,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
normalize_v3(mousevec);
}
- /* v3d= sa->spacedata.first; */ /* UNUSED */
+ /* v3d = sa->spacedata.first; */ /* UNUSED */
rv3d = ar->regiondata;
/* overwrite the mouse vector with the view direction (zoom into the center) */
@@ -2109,13 +2135,13 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (U.uiflag & USER_ZOOM_HORIZ) {
vod->origx = vod->oldx = event->x;
- viewdolly_apply(vod, event->prevx, event->prevy, FALSE);
+ viewdolly_apply(vod, event->prevx, event->prevy, (U.uiflag & USER_ZOOM_INVERT) == 0);
}
else {
/* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */
vod->origy = vod->oldy = vod->origy + event->x - event->prevx;
- viewdolly_apply(vod, event->prevx, event->prevy, FALSE);
+ viewdolly_apply(vod, event->prevx, event->prevy, (U.uiflag & USER_ZOOM_INVERT) == 0);
}
ED_view3d_depth_tag_update(vod->rv3d);
@@ -2180,21 +2206,98 @@ void VIEW3D_OT_dolly(wmOperatorType *ot)
RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX);
}
+static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
+ const float min[3], const float max[3],
+ int ok_dist)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ float afm[3];
+ float size;
+
+ /* SMOOTHVIEW */
+ float new_ofs[3];
+ float new_dist;
+
+ sub_v3_v3v3(afm, max, min);
+ size = MAX3(afm[0], afm[1], afm[2]);
+ if (ok_dist) {
+ /* fix up zoom distance if needed */
+
+ if (rv3d->is_persp) {
+ if (size <= v3d->near * 1.5f) {
+ /* do not zoom closer than the near clipping plane */
+ size = v3d->near * 1.5f;
+ }
+ }
+ else { /* ortho */
+ if (size < 0.0001f) {
+ /* bounding box was a single point so do not zoom */
+ ok_dist = 0;
+ }
+ else {
+ /* adjust zoom so it looks nicer */
+ size *= 0.7f;
+ }
+ }
+ }
+
+ mid_v3_v3v3(new_ofs, min, max);
+ negate_v3(new_ofs);
+
+ new_dist = size;
+
+ /* correction for window aspect ratio */
+ if (ar->winy > 2 && ar->winx > 2) {
+ size = (float)ar->winx / (float)ar->winy;
+ if (size < 1.0f) size = 1.0f / size;
+ new_dist *= size;
+ }
+
+ if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) {
+ rv3d->persp = RV3D_PERSP;
+ view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
+ }
+ else {
+ view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
+ }
+
+ /* smooth view does viewlock RV3D_BOXVIEW copy */
+}
+
+/* same as view3d_from_minmax but for all regions (except cameras) */
+static void view3d_from_minmax_multi(bContext *C, View3D *v3d,
+ const float min[3], const float max[3],
+ const int ok_dist)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar;
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+ /* when using all regions, don't jump out of camera view,
+ * but _do_ allow locked cameras to be moved */
+ if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
+ view3d_from_minmax(C, v3d, ar, min, max, ok_dist);
+ }
+ }
+ }
+}
static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
{
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
Scene *scene = CTX_data_scene(C);
Base *base;
float *curs;
- const short skip_camera = ED_view3d_camera_lock_check(v3d, rv3d);
-
+ const short use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
+ const short skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
+ /* any one of the regions may be locked */
+ (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
int center = RNA_boolean_get(op->ptr, "center");
- float size, min[3], max[3], afm[3];
+ float min[3], max[3];
int ok = 1, onedone = FALSE;
if (center) {
@@ -2231,37 +2334,16 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in
return OPERATOR_FINISHED;
}
- sub_v3_v3v3(afm, max, min);
- size = 0.7f * MAX3(afm[0], afm[1], afm[2]);
- if (size == 0.0f) ok = 0;
-
- if (ok) {
- float new_dist;
- float new_ofs[3];
-
- new_dist = size;
- new_ofs[0] = -(min[0] + max[0]) / 2.0f;
- new_ofs[1] = -(min[1] + max[1]) / 2.0f;
- new_ofs[2] = -(min[2] + max[2]) / 2.0f;
-
- /* correction for window aspect ratio */
- if (ar->winy > 2 && ar->winx > 2) {
- size = (float)ar->winx / (float)ar->winy;
- if (size < 1.0f) size = 1.0f / size;
- new_dist *= size;
- }
-
- if ((rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(v3d, rv3d)) {
- rv3d->persp = RV3D_PERSP;
- view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
- }
- else {
- view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
- }
+ if (ok == 0) {
+ return OPERATOR_FINISHED;
}
-// XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ if (use_all_regions) {
+ view3d_from_minmax_multi(C, v3d, min, max, TRUE);
+ }
+ else {
+ view3d_from_minmax(C, v3d, ar, min, max, TRUE);
+ }
return OPERATOR_FINISHED;
}
@@ -2269,6 +2351,8 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in
void VIEW3D_OT_view_all(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "View All";
ot->description = "View all objects in scene";
@@ -2281,25 +2365,25 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
/* flags */
ot->flag = 0;
+ prop = RNA_def_boolean(ot->srna, "use_all_regions", 0, "All Regions", "View selected for all regions");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(ot->srna, "center", 0, "Center", "");
}
/* like a localview without local!, was centerview() in 2.4x */
-static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
+static int viewselected_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
Scene *scene = CTX_data_scene(C);
Object *ob = OBACT;
Object *obedit = CTX_data_edit_object(C);
- float size, min[3], max[3], afm[3];
+ float min[3], max[3];
int ok = 0, ok_dist = 1;
- const short skip_camera = ED_view3d_camera_lock_check(v3d, rv3d);
-
- /* SMOOTHVIEW */
- float new_ofs[3];
- float new_dist;
+ const short use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
+ const short skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
+ /* any one of the regions may be locked */
+ (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
INIT_MINMAX(min, max);
@@ -2370,54 +2454,17 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- if (ok == 0) return OPERATOR_FINISHED;
-
- sub_v3_v3v3(afm, max, min);
- size = MAX3(afm[0], afm[1], afm[2]);
-
- if (ok_dist) {
- /* fix up zoom distance if needed */
-
- if (rv3d->is_persp) {
- if (size <= v3d->near * 1.5f) {
- /* do not zoom closer than the near clipping plane */
- size = v3d->near * 1.5f;
- }
- }
- else { /* ortho */
- if (size < 0.0001f) {
- /* bounding box was a single point so do not zoom */
- ok_dist = 0;
- }
- else {
- /* adjust zoom so it looks nicer */
- size *= 0.7f;
- }
- }
- }
-
- add_v3_v3v3(new_ofs, min, max);
- mul_v3_fl(new_ofs, -0.5f);
-
- new_dist = size;
-
- /* correction for window aspect ratio */
- if (ar->winy > 2 && ar->winx > 2) {
- size = (float)ar->winx / (float)ar->winy;
- if (size < 1.0f) size = 1.0f / size;
- new_dist *= size;
+ if (ok == 0) {
+ return OPERATOR_FINISHED;
}
- if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) {
- rv3d->persp = RV3D_PERSP;
- view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
+ if (use_all_regions) {
+ view3d_from_minmax_multi(C, v3d, min, max, ok_dist);
}
else {
- view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
+ view3d_from_minmax(C, v3d, ar, min, max, ok_dist);
}
- /* smooth view does viewlock RV3D_BOXVIEW copy */
-
// XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
return OPERATOR_FINISHED;
@@ -2425,6 +2472,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_view_selected(wmOperatorType *ot)
{
+ PropertyRNA *prop;
/* identifiers */
ot->name = "View Selected";
@@ -2437,6 +2485,10 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot)
/* flags */
ot->flag = 0;
+
+ /* rna later */
+ prop = RNA_def_boolean(ot->srna, "use_all_regions", 0, "All Regions", "View selected for all regions");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int view_lock_clear_exec(bContext *C, wmOperator *UNUSED(op))
@@ -2579,7 +2631,7 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was
xfac = (float)ar->winx / (float)(size[0] + 4);
yfac = (float)ar->winy / (float)(size[1] + 4);
- rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(minf(xfac, yfac));
+ rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(min_ff(xfac, yfac));
CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
@@ -2609,42 +2661,71 @@ static int render_border_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
Scene *scene = CTX_data_scene(C);
rcti rect;
- rctf vb;
+ rctf vb, border;
+
+ int camera_only = RNA_boolean_get(op->ptr, "camera_only");
+
+ if (camera_only && rv3d->persp != RV3D_CAMOB)
+ return OPERATOR_PASS_THROUGH;
/* get border select values using rna */
WM_operator_properties_border_to_rcti(op, &rect);
/* calculate range */
- ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
- scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb);
- scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_rctf_size_y(&vb);
- scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_rctf_size_x(&vb);
- scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_rctf_size_y(&vb);
+ if (rv3d->persp == RV3D_CAMOB) {
+ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
+ }
+ else {
+ vb.xmin = 0;
+ vb.ymin = 0;
+ vb.xmax = ar->winx;
+ vb.ymax = ar->winy;
+ }
+
+ border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb);
+ border.ymin = ((float)rect.ymin - vb.ymin) / BLI_rctf_size_y(&vb);
+ border.xmax = ((float)rect.xmax - vb.xmin) / BLI_rctf_size_x(&vb);
+ border.ymax = ((float)rect.ymax - vb.ymin) / BLI_rctf_size_y(&vb);
/* actually set border */
- CLAMP(scene->r.border.xmin, 0.0f, 1.0f);
- CLAMP(scene->r.border.ymin, 0.0f, 1.0f);
- CLAMP(scene->r.border.xmax, 0.0f, 1.0f);
- CLAMP(scene->r.border.ymax, 0.0f, 1.0f);
+ CLAMP(border.xmin, 0.0f, 1.0f);
+ CLAMP(border.ymin, 0.0f, 1.0f);
+ CLAMP(border.xmax, 0.0f, 1.0f);
+ CLAMP(border.ymax, 0.0f, 1.0f);
+
+ if (rv3d->persp == RV3D_CAMOB) {
+ scene->r.border = border;
+
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ }
+ else {
+ v3d->render_border = border;
+
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ }
/* drawing a border surrounding the entire camera view switches off border rendering
* or the border covers no pixels */
- if ((scene->r.border.xmin <= 0.0f && scene->r.border.xmax >= 1.0f &&
- scene->r.border.ymin <= 0.0f && scene->r.border.ymax >= 1.0f) ||
- (scene->r.border.xmin == scene->r.border.xmax ||
- scene->r.border.ymin == scene->r.border.ymax))
+ if ((border.xmin <= 0.0f && border.xmax >= 1.0f &&
+ border.ymin <= 0.0f && border.ymax >= 1.0f) ||
+ (border.xmin == border.xmax || border.ymin == border.ymax))
{
- scene->r.mode &= ~R_BORDER;
+ if (rv3d->persp == RV3D_CAMOB)
+ scene->r.mode &= ~R_BORDER;
+ else
+ v3d->flag2 &= ~V3D_RENDER_BORDER;
}
else {
- scene->r.mode |= R_BORDER;
+ if (rv3d->persp == RV3D_CAMOB)
+ scene->r.mode |= R_BORDER;
+ else
+ v3d->flag2 |= V3D_RENDER_BORDER;
}
-
- WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
return OPERATOR_FINISHED;
@@ -2654,7 +2735,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Render Border";
- ot->description = "Set the boundaries of the border render and enables border render";
+ ot->description = "Set the boundaries of the border render and enable border render";
ot->idname = "VIEW3D_OT_render_border";
/* api callbacks */
@@ -2663,7 +2744,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
- ot->poll = view3d_camera_active_poll;
+ ot->poll = ED_operator_view3d_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2671,7 +2752,56 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
/* rna */
WM_operator_properties_border(ot);
+ RNA_def_boolean(ot->srna, "camera_only", 0, "Camera Only", "Set render border for camera view and final render only");
+}
+
+/* ********************* Clear render border operator ****************** */
+
+static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
+ Scene *scene = CTX_data_scene(C);
+ rctf *border = NULL;
+
+ if (rv3d->persp == RV3D_CAMOB) {
+ scene->r.mode &= ~R_BORDER;
+ border = &scene->r.border;
+
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ }
+ else {
+ v3d->flag2 &= ~V3D_RENDER_BORDER;
+ border = &v3d->render_border;
+
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ }
+
+ border->xmin = 0.0f;
+ border->ymin = 0.0f;
+ border->xmax = 1.0f;
+ border->ymax = 1.0f;
+
+ return OPERATOR_FINISHED;
+
+}
+
+void VIEW3D_OT_clear_render_border(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Clear Render Border";
+ ot->description = "Clear the boundaries of the border render and disable border render";
+ ot->idname = "VIEW3D_OT_clear_render_border";
+
+ /* api callbacks */
+ ot->exec = clear_render_border_exec;
+ ot->poll = ED_operator_view3d_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
/* ********************* Border Zoom operator ****************** */
static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
@@ -2733,7 +2863,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* no depths to use, we cant do anything! */
if (depth_close == FLT_MAX) {
- BKE_report(op->reports, RPT_ERROR, "Depth Too Large");
+ BKE_report(op->reports, RPT_ERROR, "Depth too large");
return OPERATOR_CANCELLED;
}
@@ -2791,7 +2921,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* work out the ratios, so that everything selected fits when we zoom */
xscale = (BLI_rcti_size_x(&rect) / vb[0]);
yscale = (BLI_rcti_size_y(&rect) / vb[1]);
- new_dist *= maxf(xscale, yscale);
+ new_dist *= max_ff(xscale, yscale);
/* zoom in as required, or as far as we can go */
dist_range_min = 0.001f * v3d->grid;
@@ -2904,7 +3034,7 @@ static EnumPropertyItem prop_view_items[] = {
{RV3D_VIEW_RIGHT, "RIGHT", 0, "Right", "View From the Right"},
{RV3D_VIEW_TOP, "TOP", 0, "Top", "View From the Top"},
{RV3D_VIEW_BOTTOM, "BOTTOM", 0, "Bottom", "View From the Bottom"},
- {RV3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the active camera"},
+ {RV3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the Active Camera"},
{0, NULL, 0, NULL, NULL}
};
@@ -3128,7 +3258,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
/* identifiers */
ot->name = "View numpad";
- ot->description = "Set the view";
+ ot->description = "Use a preset viewpoint";
ot->idname = "VIEW3D_OT_viewnumpad";
/* api callbacks */
@@ -3138,8 +3268,8 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
/* flags */
ot->flag = 0;
- prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "Preset viewpoint to use");
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -3216,7 +3346,9 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot)
/* flags */
ot->flag = 0;
- RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit");
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit");
}
static EnumPropertyItem prop_view_pan_items[] = {
@@ -3265,7 +3397,9 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot)
/* flags */
ot->flag = 0;
- RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan");
+
+ /* Properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan");
}
static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op))
@@ -3293,7 +3427,7 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot)
{
/* identifiers */
ot->name = "View Persp/Ortho";
- ot->description = "Switch the current view from perspective/orthographic";
+ ot->description = "Switch the current view from perspective/orthographic projection";
ot->idname = "VIEW3D_OT_view_persportho";
/* api callbacks */
@@ -3409,7 +3543,8 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot)
/* flags */
ot->flag = 0;
-
+
+ /* properties */
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Background image index to remove", 0, INT_MAX);
}
@@ -3537,7 +3672,7 @@ static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *
/* flip = */ initgrabz(rv3d, fp[0], fp[1], fp[2]);
}
- if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
short depth_used = FALSE;
if (U.uiflag & USER_ZBUF_CURSOR) { /* maybe this should be accessed some other way */
@@ -3811,6 +3946,18 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m
return (*depth == FLT_MAX) ? 0 : 1;
}
+float ED_view3d_offset_distance(float mat[4][4], float ofs[3]) {
+ float pos[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ float dir[4] = {0.0f, 0.0f, 1.0f, 0.0f};
+
+ mul_m4_v4(mat, pos);
+ add_v3_v3(pos, ofs);
+ mul_m4_v4(mat, dir);
+ normalize_v3(dir);
+
+ return dot_v3v3(pos, dir);
+}
+
/**
* Set the view transformation from a 4x4 matrix.
*
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 7c03876b0c4..64e72962e13 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -27,7 +27,7 @@
/* defines VIEW3D_OT_fly modal operator */
//#define NDOF_FLY_DEBUG
-//#define NDOF_FLY_DRAW_TOOMUCH // is this needed for ndof? - commented so redraw doesnt thrash - campbell
+//#define NDOF_FLY_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -293,6 +293,11 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event
puts("\n-- fly begin --");
#endif
+ /* sanity check: for rare but possible case (if lib-linking the camera fails) */
+ if ((fly->rv3d->persp == RV3D_CAMOB) && (fly->v3d->camera == NULL)) {
+ fly->rv3d->persp = RV3D_PERSP;
+ }
+
if (fly->rv3d->persp == RV3D_CAMOB && fly->v3d->camera->id.lib) {
BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an external library");
return FALSE;
@@ -430,7 +435,6 @@ static int flyEnd(bContext *C, FlyInfo *fly)
ED_region_draw_cb_exit(fly->ar->type, fly->draw_handle_pixel);
rv3d->dist = fly->dist_backup;
-
if (fly->state == FLY_CANCEL) {
/* Revert to original view? */
if (fly->persp_backup == RV3D_CAMOB) { /* a camera view */
@@ -445,12 +449,16 @@ static int flyEnd(bContext *C, FlyInfo *fly)
else {
/* Non Camera we need to reset the view back to the original location bacause the user canceled*/
copy_qt_qt(rv3d->viewquat, fly->rot_backup);
- copy_v3_v3(rv3d->ofs, fly->ofs_backup);
rv3d->persp = fly->persp_backup;
}
+ /* always, is set to zero otherwise */
+ copy_v3_v3(rv3d->ofs, fly->ofs_backup);
}
else if (fly->persp_backup == RV3D_CAMOB) { /* camera */
DAG_id_tag_update(fly->root_parent ? &fly->root_parent->id : &v3d->camera->id, OB_RECALC_OB);
+
+ /* always, is set to zero otherwise */
+ copy_v3_v3(rv3d->ofs, fly->ofs_backup);
}
else { /* not camera */
@@ -557,7 +565,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event)
time_wheel = (float)(time_currwheel - fly->time_lastwheel);
fly->time_lastwheel = time_currwheel;
/* Mouse wheel delays range from (0.5 == slow) to (0.01 == fast) */
- time_wheel = 1.0f + (10.0f - (20.0f * minf(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */
+ time_wheel = 1.0f + (10.0f - (20.0f * min_ff(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */
if (fly->speed < 0.0f) {
fly->speed = 0.0f;
@@ -575,7 +583,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event)
time_currwheel = PIL_check_seconds_timer();
time_wheel = (float)(time_currwheel - fly->time_lastwheel);
fly->time_lastwheel = time_currwheel;
- time_wheel = 1.0f + (10.0f - (20.0f * minf(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */
+ time_wheel = 1.0f + (10.0f - (20.0f * min_ff(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */
if (fly->speed > 0.0f) {
fly->speed = 0;
@@ -799,8 +807,8 @@ static int flyApply(bContext *C, FlyInfo *fly)
ymargin = ar->winy / 20.0f;
// UNUSED
- // cent_orig[0]= ar->winrct.xmin + ar->winx/2;
- // cent_orig[1]= ar->winrct.ymin + ar->winy/2;
+ // cent_orig[0] = ar->winrct.xmin + ar->winx / 2;
+ // cent_orig[1] = ar->winrct.ymin + ar->winy / 2;
{
@@ -851,7 +859,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
#endif
time_current = PIL_check_seconds_timer();
time_redraw = (float)(time_current - fly->time_lastdraw);
- time_redraw_clamped = minf(0.05f, time_redraw); /* clamp redraw time to avoid jitter in roll correction */
+ time_redraw_clamped = min_ff(0.05f, time_redraw); /* clamp redraw time to avoid jitter in roll correction */
fly->time_lastdraw = time_current;
/* Scale the time to use shift to scale the speed down- just like
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index b2ae63df662..d8fcc7e12e7 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -167,7 +167,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
}
else {
v3d->lay |= (1 << 20) - 1;
- }
+ }
}
else {
int bit;
@@ -452,7 +452,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
const float dpi_fac = UI_DPI_FAC;
int is_paint = 0;
- RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);
RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 5aecbc5ed76..0dd3be0e7fc 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -40,6 +40,7 @@ struct ARegionType;
struct BoundBox;
struct DerivedMesh;
struct Object;
+struct SmokeDomainSettings;
struct ViewContext;
struct bAnimVizSettings;
struct bContext;
@@ -50,8 +51,6 @@ struct wmNDOFMotionData;
struct wmOperatorType;
struct wmWindowManager;
-#define BL_NEAR_CLIP 0.001
-
/* drawing flags: */
enum {
DRAW_PICKING = (1 << 0),
@@ -97,6 +96,7 @@ void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
void VIEW3D_OT_manipulator(struct wmOperatorType *ot);
void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot);
void VIEW3D_OT_render_border(struct wmOperatorType *ot);
+void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
void view3d_boxview_copy(ScrArea *sa, ARegion *ar);
@@ -175,7 +175,7 @@ int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[][4], struct BoundB
void view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *,
float *ofs, float *quat, float *dist, float *lens);
-void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */
+void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect);
void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d);
void fly_modal_keymap(struct wmKeyConfig *keyconf);
@@ -210,7 +210,20 @@ ARegion *view3d_has_tools_region(ScrArea *sa);
extern const char *view3d_context_dir[]; /* doc access */
/* draw_volume.c */
-void draw_volume(struct ARegion *ar, struct GPUTexture *tex, float min[3], float max[3], int res[3], float dx, struct GPUTexture *tex_shadow);
+void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob,
+ struct GPUTexture *tex, float min[3], float max[3],
+ int res[3], float dx, float base_scale, float viewnormal[3],
+ struct GPUTexture *tex_shadow, struct GPUTexture *tex_flame);
+
+//#define SMOKE_DEBUG_VELOCITY
+//#define SMOKE_DEBUG_HEAT
+
+#ifdef SMOKE_DEBUG_VELOCITY
+void draw_smoke_velocity(struct SmokeDomainSettings *domain, struct Object *ob);
+#endif
+#ifdef SMOKE_DEBUG_HEAT
+void draw_smoke_heat(struct SmokeDomainSettings *domain, struct Object *ob);
+#endif
/* workaround for trivial but noticeable camera bug caused by imprecision
* between view border calculation in 2D/3D space, workaround for bug [#28037].
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
new file mode 100644
index 00000000000..b928e060ca0
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -0,0 +1,416 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation, full recode and added functions
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/object/view3d_iterators.c
+ * \ingroup spview3d
+ */
+
+#include "DNA_curve_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_meta_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
+
+#include "BKE_armature.h"
+#include "BKE_curve.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_displist.h"
+
+#include "bmesh.h"
+
+#include "ED_mesh.h"
+#include "ED_screen.h"
+#include "ED_armature.h"
+#include "ED_object.h"
+#include "ED_view3d.h"
+
+
+typedef struct foreachScreenVert_userData {
+ void (*func)(void *userData, BMVert *eve, const float screen_co_b[2], int index);
+ void *userData;
+ ViewContext vc;
+ eV3DProjTest clip_flag;
+} foreachScreenVert_userData;
+
+/* user data structures for derived mesh callbacks */
+typedef struct foreachScreenEdge_userData {
+ void (*func)(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index);
+ void *userData;
+ ViewContext vc;
+ rctf win_rect; /* copy of: vc.ar->winx/winy, use for faster tests, minx/y will always be 0 */
+ eV3DProjTest clip_flag;
+} foreachScreenEdge_userData;
+
+typedef struct foreachScreenFace_userData {
+ void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index);
+ void *userData;
+ ViewContext vc;
+ eV3DProjTest clip_flag;
+} foreachScreenFace_userData;
+
+
+/* Note! - foreach funcs should be called while drawing or directly after
+ * if not, ED_view3d_init_mats_rv3d() can be used for selection tools
+ * but would not give correct results with dupli's for eg. which don't
+ * use the object matrix in the usual way */
+
+/* ------------------------------------------------------------------------ */
+
+static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const float co[3],
+ const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
+{
+ foreachScreenVert_userData *data = userData;
+ BMVert *eve = EDBM_vert_at_index(data->vc.em, index);
+
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ float screen_co[2];
+
+ if (ED_view3d_project_float_object(data->vc.ar, co, screen_co, data->clip_flag) != V3D_PROJ_RET_OK) {
+ return;
+ }
+
+ data->func(data->userData, eve, screen_co, index);
+ }
+}
+
+void mesh_foreachScreenVert(
+ ViewContext *vc,
+ void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index),
+ void *userData, eV3DProjTest clip_flag)
+{
+ foreachScreenVert_userData data;
+ DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+
+ data.vc = *vc;
+ data.func = func;
+ data.userData = userData;
+ data.clip_flag = clip_flag;
+
+ if (clip_flag & V3D_PROJ_TEST_CLIP_BB) {
+ ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
+ }
+
+ EDBM_index_arrays_init(vc->em, 1, 0, 0);
+ dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data);
+ EDBM_index_arrays_free(vc->em);
+
+ dm->release(dm);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const float v0co[3], const float v1co[3])
+{
+ foreachScreenEdge_userData *data = userData;
+ BMEdge *eed = EDBM_edge_at_index(data->vc.em, index);
+
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+ float screen_co_a[2];
+ float screen_co_b[2];
+ eV3DProjTest clip_flag_nowin = data->clip_flag &= ~V3D_PROJ_TEST_CLIP_WIN;
+
+ if (ED_view3d_project_float_object(data->vc.ar, v0co, screen_co_a, clip_flag_nowin) != V3D_PROJ_RET_OK) {
+ return;
+ }
+ if (ED_view3d_project_float_object(data->vc.ar, v1co, screen_co_b, clip_flag_nowin) != V3D_PROJ_RET_OK) {
+ return;
+ }
+
+ if (data->clip_flag & V3D_PROJ_TEST_CLIP_WIN) {
+ if (!BLI_rctf_isect_segment(&data->win_rect, screen_co_a, screen_co_b)) {
+ return;
+ }
+ }
+
+ data->func(data->userData, eed, screen_co_a, screen_co_b, index);
+ }
+}
+
+void mesh_foreachScreenEdge(
+ ViewContext *vc,
+ void (*func)(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index),
+ void *userData, eV3DProjTest clip_flag)
+{
+ foreachScreenEdge_userData data;
+ DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+
+ data.vc = *vc;
+
+ data.win_rect.xmin = 0;
+ data.win_rect.ymin = 0;
+ data.win_rect.xmax = vc->ar->winx;
+ data.win_rect.ymax = vc->ar->winy;
+
+ data.func = func;
+ data.userData = userData;
+ data.clip_flag = clip_flag;
+
+ if (clip_flag & V3D_PROJ_TEST_CLIP_BB) {
+ ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
+ }
+
+ EDBM_index_arrays_init(vc->em, 0, 1, 0);
+ dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);
+ EDBM_index_arrays_free(vc->em);
+
+ dm->release(dm);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
+{
+ foreachScreenFace_userData *data = userData;
+ BMFace *efa = EDBM_face_at_index(data->vc.em, index);
+
+ if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
+ float screen_co[2];
+ if (ED_view3d_project_float_object(data->vc.ar, cent, screen_co, data->clip_flag) == V3D_PROJ_RET_OK) {
+ data->func(data->userData, efa, screen_co, index);
+ }
+ }
+}
+
+void mesh_foreachScreenFace(
+ ViewContext *vc,
+ void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index),
+ void *userData, const eV3DProjTest clip_flag)
+{
+ foreachScreenFace_userData data;
+ DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+
+ data.vc = *vc;
+ data.func = func;
+ data.userData = userData;
+ data.clip_flag = clip_flag;
+
+ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
+
+ EDBM_index_arrays_init(vc->em, 0, 0, 1);
+ dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data);
+ EDBM_index_arrays_free(vc->em);
+
+ dm->release(dm);
+}
+
+/* ------------------------------------------------------------------------ */
+
+void nurbs_foreachScreenVert(
+ ViewContext *vc,
+ void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co_b[2]),
+ void *userData, const eV3DProjTest clip_flag)
+{
+ Curve *cu = vc->obedit->data;
+ Nurb *nu;
+ int i;
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+
+ if (clip_flag & V3D_PROJ_TEST_CLIP_BB) {
+ ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
+ }
+
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER) {
+ for (i = 0; i < nu->pntsu; i++) {
+ BezTriple *bezt = &nu->bezt[i];
+
+ if (bezt->hide == 0) {
+ float screen_co[2];
+
+ if (cu->drawflag & CU_HIDE_HANDLES) {
+ if (ED_view3d_project_float_object(vc->ar, bezt->vec[1], screen_co,
+ V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
+ {
+ func(userData, nu, NULL, bezt, 1, screen_co);
+ }
+ }
+ else {
+ if (ED_view3d_project_float_object(vc->ar, bezt->vec[0], screen_co,
+ V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
+ {
+ func(userData, nu, NULL, bezt, 0, screen_co);
+ }
+ if (ED_view3d_project_float_object(vc->ar, bezt->vec[1], screen_co,
+ V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
+ {
+ func(userData, nu, NULL, bezt, 1, screen_co);
+ }
+ if (ED_view3d_project_float_object(vc->ar, bezt->vec[2], screen_co,
+ V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
+ {
+ func(userData, nu, NULL, bezt, 2, screen_co);
+ }
+ }
+ }
+ }
+ }
+ else {
+ for (i = 0; i < nu->pntsu * nu->pntsv; i++) {
+ BPoint *bp = &nu->bp[i];
+
+ if (bp->hide == 0) {
+ float screen_co[2];
+ if (ED_view3d_project_float_object(vc->ar, bp->vec, screen_co,
+ V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
+ {
+ func(userData, nu, bp, NULL, -1, screen_co);
+ }
+ }
+ }
+ }
+ }
+}
+
+/* ------------------------------------------------------------------------ */
+
+/* ED_view3d_init_mats_rv3d must be called first */
+void mball_foreachScreenElem(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct MetaElem *ml, const float screen_co_b[2]),
+ void *userData, const eV3DProjTest clip_flag)
+{
+ MetaBall *mb = (MetaBall *)vc->obedit->data;
+ MetaElem *ml;
+
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ float screen_co[2];
+ if (ED_view3d_project_float_object(vc->ar, &ml->x, screen_co, clip_flag) == V3D_PROJ_RET_OK) {
+ func(userData, ml, screen_co);
+ }
+ }
+}
+
+/* ------------------------------------------------------------------------ */
+
+void lattice_foreachScreenVert(
+ ViewContext *vc,
+ void (*func)(void *userData, BPoint *bp, const float screen_co[2]),
+ void *userData, const eV3DProjTest clip_flag)
+{
+ Object *obedit = vc->obedit;
+ Lattice *lt = obedit->data;
+ BPoint *bp = lt->editlatt->latt->def;
+ DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS);
+ float *co = dl ? dl->verts : NULL;
+ int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+
+ if (clip_flag & V3D_PROJ_TEST_CLIP_BB) {
+ ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */
+ }
+
+ for (i = 0; i < N; i++, bp++, co += 3) {
+ if (bp->hide == 0) {
+ float screen_co[2];
+ if (ED_view3d_project_float_object(vc->ar, dl ? co : bp->vec, screen_co, clip_flag) == V3D_PROJ_RET_OK) {
+ func(userData, bp, screen_co);
+ }
+ }
+ }
+}
+
+/* ------------------------------------------------------------------------ */
+
+/* ED_view3d_init_mats_rv3d must be called first */
+void armature_foreachScreenBone(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct EditBone *ebone, const float screen_co_a[2], const float screen_co_b[2]),
+ void *userData, const eV3DProjTest clip_flag)
+{
+ bArmature *arm = vc->obedit->data;
+ EditBone *ebone;
+
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_VISIBLE(arm, ebone)) {
+ float screen_co_a[2], screen_co_b[2];
+ int points_proj_tot = 0;
+
+ /* project head location to screenspace */
+ if (ED_view3d_project_float_object(vc->ar, ebone->head, screen_co_a, clip_flag) == V3D_PROJ_RET_OK) {
+ points_proj_tot++;
+ }
+ else {
+ screen_co_a[0] = IS_CLIPPED; /* weak */
+ /* screen_co_a[1]: intentionally dont set this so we get errors on misuse */
+ }
+
+ /* project tail location to screenspace */
+ if (ED_view3d_project_float_object(vc->ar, ebone->tail, screen_co_b, clip_flag) == V3D_PROJ_RET_OK) {
+ points_proj_tot++;
+ }
+ else {
+ screen_co_b[0] = IS_CLIPPED; /* weak */
+ /* screen_co_b[1]: intentionally dont set this so we get errors on misuse */
+ }
+
+ if (points_proj_tot) { /* at least one point's projection worked */
+ func(userData, ebone, screen_co_a, screen_co_b);
+ }
+ }
+ }
+}
+
+/* ------------------------------------------------------------------------ */
+
+/* ED_view3d_init_mats_rv3d must be called first */
+/* almost _exact_ copy of #armature_foreachScreenBone */
+void pose_foreachScreenBone(
+ struct ViewContext *vc,
+ void (*func)(void *userData, struct bPoseChannel *pchan, const float screen_co_a[2], const float screen_co_b[2]),
+ void *userData, const eV3DProjTest clip_flag)
+{
+ bArmature *arm = vc->obact->data;
+ bPose *pose = vc->obact->pose;
+ bPoseChannel *pchan;
+
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (PBONE_VISIBLE(arm, pchan->bone)) {
+ float screen_co_a[2], screen_co_b[2];
+ int points_proj_tot = 0;
+
+ /* project head location to screenspace */
+ if (ED_view3d_project_float_object(vc->ar, pchan->pose_head, screen_co_a, clip_flag) == V3D_PROJ_RET_OK) {
+ points_proj_tot++;
+ }
+ else {
+ screen_co_a[0] = IS_CLIPPED; /* weak */
+ /* screen_co_a[1]: intentionally dont set this so we get errors on misuse */
+ }
+
+ /* project tail location to screenspace */
+ if (ED_view3d_project_float_object(vc->ar, pchan->pose_tail, screen_co_b, clip_flag) == V3D_PROJ_RET_OK) {
+ points_proj_tot++;
+ }
+ else {
+ screen_co_b[0] = IS_CLIPPED; /* weak */
+ /* screen_co_b[1]: intentionally dont set this so we get errors on misuse */
+ }
+
+ if (points_proj_tot) { /* at least one point's projection worked */
+ func(userData, pchan, screen_co_a, screen_co_b);
+ }
+ }
+ }
+}
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 14c02c2357e..73f1563417c 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -83,6 +83,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_select_circle);
WM_operatortype_append(VIEW3D_OT_smoothview);
WM_operatortype_append(VIEW3D_OT_render_border);
+ WM_operatortype_append(VIEW3D_OT_clear_render_border);
WM_operatortype_append(VIEW3D_OT_zoom_border);
WM_operatortype_append(VIEW3D_OT_manipulator);
WM_operatortype_append(VIEW3D_OT_enable_manipulator);
@@ -136,8 +137,10 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
- WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, KM_CTRL, 0);
+ RNA_boolean_set(kmi->ptr, "use_all_regions", TRUE);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "use_all_regions", FALSE);
WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0);
@@ -169,6 +172,9 @@ void view3d_keymap(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "center", FALSE); /* only without camera view */
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_boolean_set(kmi->ptr, "use_all_regions", TRUE);
+ RNA_boolean_set(kmi->ptr, "center", FALSE); /* only without camera view */
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "center", TRUE);
@@ -340,7 +346,13 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
+
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "camera_only", TRUE);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_boolean_set(kmi->ptr, "camera_only", FALSE);
+
+ WM_keymap_add_item(keymap, "VIEW3D_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
new file mode 100644
index 00000000000..499f9e286ae
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -0,0 +1,493 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/view3d_project.c
+ * \ingroup spview3d
+ */
+
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BLO_sys_types.h" /* int64_t */
+
+#include "BIF_glutil.h" /* bglMats */
+
+#include "BLI_math_vector.h"
+
+#include "ED_view3d.h" /* own include */
+
+#include "GPU_compatibility.h"
+
+#define BL_NEAR_CLIP 0.001
+
+/* Non Clipping Projection Functions
+ * ********************************* */
+
+/**
+ * \note use #ED_view3d_ob_project_mat_get to get the projection matrix
+ */
+void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r_co[2], float mat[4][4])
+{
+ float vec4[4];
+
+ copy_v3_v3(vec4, co);
+ vec4[3] = 1.0;
+ /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
+
+ mul_m4_v4(mat, vec4);
+
+ if (vec4[3] > FLT_EPSILON) {
+ r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
+ r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ }
+ else {
+ zero_v2(r_co);
+ }
+}
+
+/**
+ * \note use #ED_view3d_ob_project_mat_get to get projecting mat
+ */
+void ED_view3d_project_float_v3_m4(ARegion *ar, const float vec[3], float r_co[3], float mat[4][4])
+{
+ float vec4[4];
+
+ copy_v3_v3(vec4, vec);
+ vec4[3] = 1.0;
+ /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
+
+ mul_m4_v4(mat, vec4);
+
+ if (vec4[3] > FLT_EPSILON) {
+ r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
+ r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ r_co[2] = vec4[2] / vec4[3];
+ }
+ else {
+ zero_v3(r_co);
+ }
+}
+
+
+/* Clipping Projection Functions
+ * ***************************** */
+
+eV3DProjStatus ED_view3d_project_base(struct ARegion *ar, struct Base *base)
+{
+ eV3DProjStatus ret = ED_view3d_project_short_global(ar, base->object->obmat[3], &base->sx, V3D_PROJ_TEST_CLIP_DEFAULT);
+
+ if (ret != V3D_PROJ_RET_OK) {
+ base->sx = IS_CLIPPED;
+ base->sy = 0;
+ }
+
+ return ret;
+}
+
+/* perspmat is typically...
+ * - 'rv3d->perspmat', is_local == FALSE
+ * - 'rv3d->perspmatob', is_local == TRUE
+ */
+static eV3DProjStatus ed_view3d_project__internal(ARegion *ar,
+ float perspmat[4][4], const int is_local, /* normally hidden */
+ const float co[3], float r_co[2], const eV3DProjTest flag)
+{
+ float fx, fy, vec4[4];
+
+ /* check for bad flags */
+ BLI_assert((flag & V3D_PROJ_TEST_ALL) == flag);
+
+ if (flag & V3D_PROJ_TEST_CLIP_BB) {
+ RegionView3D *rv3d = ar->regiondata;
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ if (ED_view3d_clipping_test(rv3d, co, is_local)) {
+ return V3D_PROJ_RET_CLIP_BB;
+ }
+ }
+ }
+
+ copy_v3_v3(vec4, co);
+ vec4[3] = 1.0;
+ mul_m4_v4(perspmat, vec4);
+
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
+ fx = ((float)ar->winx / 2.0f) * (1.0f + vec4[0] / vec4[3]);
+ if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fx > 0 && fx < ar->winx)) {
+ fy = ((float)ar->winy / 2.0f) * (1.0f + vec4[1] / vec4[3]);
+ if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fy > 0.0f && fy < (float)ar->winy)) {
+ r_co[0] = (short)floor(fx);
+ r_co[1] = (short)floor(fy);
+ }
+ else {
+ return V3D_PROJ_RET_CLIP_WIN;
+ }
+ }
+ else {
+ return V3D_PROJ_RET_CLIP_WIN;
+ }
+ }
+ else {
+ return V3D_PROJ_RET_CLIP_NEAR;
+ }
+
+ return V3D_PROJ_RET_OK;
+}
+
+eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], short r_co[2], const eV3DProjTest flag)
+{
+ float tvec[2];
+ eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
+ if (ret == V3D_PROJ_RET_OK) {
+ if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) &&
+ (tvec[1] > -32700.0f && tvec[1] < 32700.0f))
+ {
+ r_co[0] = (short)floor(tvec[0]);
+ r_co[1] = (short)floor(tvec[1]);
+ }
+ else {
+ ret = V3D_PROJ_RET_OVERFLOW;
+ }
+ }
+ return ret;
+}
+
+eV3DProjStatus ED_view3d_project_int_ex(ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], int r_co[2], const eV3DProjTest flag)
+{
+ float tvec[2];
+ eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
+ if (ret == V3D_PROJ_RET_OK) {
+ if ((tvec[0] > -2140000000.0f && tvec[0] < 2140000000.0f) &&
+ (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f))
+ {
+ r_co[0] = (int)floor(tvec[0]);
+ r_co[1] = (int)floor(tvec[1]);
+ }
+ else {
+ ret = V3D_PROJ_RET_OVERFLOW;
+ }
+ }
+ return ret;
+}
+
+eV3DProjStatus ED_view3d_project_float_ex(ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], float r_co[2], const eV3DProjTest flag)
+{
+ float tvec[2];
+ eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
+ if (ret == V3D_PROJ_RET_OK) {
+ if (finite(tvec[0]) &&
+ finite(tvec[1]))
+ {
+ copy_v2_v2(r_co, tvec);
+ }
+ else {
+ ret = V3D_PROJ_RET_OVERFLOW;
+ }
+ }
+ return ret;
+}
+
+/* --- short --- */
+eV3DProjStatus ED_view3d_project_short_global(ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_short_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
+}
+/* object space, use ED_view3d_init_mats_rv3d before calling */
+eV3DProjStatus ED_view3d_project_short_object(ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_short_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
+}
+
+/* --- int --- */
+eV3DProjStatus ED_view3d_project_int_global(ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_int_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
+}
+/* object space, use ED_view3d_init_mats_rv3d before calling */
+eV3DProjStatus ED_view3d_project_int_object(ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_int_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
+}
+
+/* --- float --- */
+eV3DProjStatus ED_view3d_project_float_global(ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_float_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
+}
+/* object space, use ED_view3d_init_mats_rv3d before calling */
+eV3DProjStatus ED_view3d_project_float_object(ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_float_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
+}
+
+
+
+/* More Generic Window/Ray/Vector projection functions
+ * *************************************************** */
+
+/* odd function, need to document better */
+int initgrabz(RegionView3D *rv3d, float x, float y, float z)
+{
+ int flip = FALSE;
+ if (rv3d == NULL) return flip;
+ rv3d->zfac = rv3d->persmat[0][3] * x + rv3d->persmat[1][3] * y + rv3d->persmat[2][3] * z + rv3d->persmat[3][3];
+ if (rv3d->zfac < 0.0f)
+ flip = TRUE;
+ /* if x,y,z is exactly the viewport offset, zfac is 0 and we don't want that
+ * (accounting for near zero values)
+ */
+ if (rv3d->zfac < 1.e-6f && rv3d->zfac > -1.e-6f) rv3d->zfac = 1.0f;
+
+ /* Negative zfac means x, y, z was behind the camera (in perspective).
+ * This gives flipped directions, so revert back to ok default case.
+ */
+ /* NOTE: I've changed this to flip zfac to be positive again for now so that GPencil draws ok
+ * Aligorith, 2009Aug31 */
+ //if (rv3d->zfac < 0.0f) rv3d->zfac = 1.0f;
+ if (rv3d->zfac < 0.0f) rv3d->zfac = -rv3d->zfac;
+
+ return flip;
+}
+
+/**
+ * Calculate a 3d viewpoint and direction vector from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_normal is the direction towards mval.
+ * ray_start is clipped by the view near limit so points in front of it are always in view.
+ * In orthographic view the resulting ray_normal will match the view vector.
+ * \param ar The region (used for the window width and height).
+ * \param v3d The 3d viewport (used for near clipping value).
+ * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * \param ray_start The world-space starting point of the segment.
+ * \param ray_normal The normalized world-space direction of towards mval.
+ */
+void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
+{
+ float ray_end[3];
+
+ ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
+ sub_v3_v3v3(ray_normal, ray_end, ray_start);
+ normalize_v3(ray_normal);
+}
+
+/**
+ * Calculate a normalized 3d direction vector from the viewpoint towards a global location.
+ * In orthographic view the resulting vector will match the view vector.
+ * \param rv3d The region (used for the window width and height).
+ * \param coord The world-space location.
+ * \param vec The resulting normalized vector.
+ */
+void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float vec[3])
+{
+ if (rv3d->is_persp) {
+ float p1[4], p2[4];
+
+ copy_v3_v3(p1, coord);
+ p1[3] = 1.0f;
+ copy_v3_v3(p2, p1);
+ p2[3] = 1.0f;
+ mul_m4_v4(rv3d->viewmat, p2);
+
+ mul_v3_fl(p2, 2.0f);
+
+ mul_m4_v4(rv3d->viewinv, p2);
+
+ sub_v3_v3v3(vec, p1, p2);
+ }
+ else {
+ copy_v3_v3(vec, rv3d->viewinv[2]);
+ }
+ normalize_v3(vec);
+}
+
+/**
+ * Calculate a 3d location from 2d window coordinates.
+ * \param ar The region (used for the window width and height).
+ * \param depth_pt The reference location used to calculate the Z depth.
+ * \param mval The area relative location (such as event->mval converted to floats).
+ * \param out The resulting world-space location.
+ */
+void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3])
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ float line_sta[3];
+ float line_end[3];
+
+ if (rv3d->is_persp) {
+ float mousevec[3];
+ copy_v3_v3(line_sta, rv3d->viewinv[3]);
+ ED_view3d_win_to_vector(ar, mval, mousevec);
+ add_v3_v3v3(line_end, line_sta, mousevec);
+
+ if (isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) {
+ /* highly unlikely to ever happen, mouse vec paralelle with view plane */
+ zero_v3(out);
+ }
+ }
+ else {
+ const float dx = (2.0f * mval[0] / (float)ar->winx) - 1.0f;
+ const float dy = (2.0f * mval[1] / (float)ar->winy) - 1.0f;
+ line_sta[0] = (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0];
+ line_sta[1] = (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1];
+ line_sta[2] = (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2];
+
+ add_v3_v3v3(line_end, line_sta, rv3d->viewinv[2]);
+ closest_to_line_v3(out, depth_pt, line_sta, line_end);
+ }
+}
+
+/**
+ * Calculate a 3d difference vector from 2d window offset.
+ * note that initgrabz() must be called first to determine
+ * the depth used to calculate the delta.
+ * \param ar The region (used for the window width and height).
+ * \param mval The area relative 2d difference (such as event->mval[0] - other_x).
+ * \param out The resulting world-space delta.
+ */
+void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3])
+{
+ RegionView3D *rv3d = ar->regiondata;
+ float dx, dy;
+
+ dx = 2.0f * mval[0] * rv3d->zfac / ar->winx;
+ dy = 2.0f * mval[1] * rv3d->zfac / ar->winy;
+
+ out[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy);
+ out[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy);
+ out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy);
+}
+
+/**
+ * Calculate a 3d direction vector from 2d window coordinates.
+ * This direction vector starts and the view in the direction of the 2d window coordinates.
+ * In orthographic view all window coordinates yield the same vector.
+ *
+ * \note doesn't rely on initgrabz
+ * for perspective view, get the vector direction to
+ * the mouse cursor as a normalized vector.
+ *
+ * \param ar The region (used for the window width and height).
+ * \param mval The area relative 2d location (such as event->mval converted to floats).
+ * \param out The resulting normalized world-space direction vector.
+ */
+void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3])
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ if (rv3d->is_persp) {
+ out[0] = 2.0f * (mval[0] / ar->winx) - 1.0f;
+ out[1] = 2.0f * (mval[1] / ar->winy) - 1.0f;
+ out[2] = -0.5f;
+ mul_project_m4_v3(rv3d->persinv, out);
+ sub_v3_v3(out, rv3d->viewinv[3]);
+ }
+ else {
+ copy_v3_v3(out, rv3d->viewinv[2]);
+ }
+ normalize_v3(out);
+}
+
+/**
+ * Calculate a 3d segment from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_end is a far point.
+ * ray_start and ray_end are clipped by the view near and far limits
+ * so points along this line are always in view.
+ * In orthographic view all resulting segments will be parallel.
+ * \param ar The region (used for the window width and height).
+ * \param v3d The 3d viewport (used for near and far clipping range).
+ * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * \param ray_start The world-space starting point of the segment.
+ * \param ray_end The world-space end point of the segment.
+ */
+void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ if (rv3d->is_persp) {
+ float vec[3];
+ ED_view3d_win_to_vector(ar, mval, vec);
+
+ copy_v3_v3(ray_start, rv3d->viewinv[3]);
+ madd_v3_v3v3fl(ray_start, rv3d->viewinv[3], vec, v3d->near);
+ madd_v3_v3v3fl(ray_end, rv3d->viewinv[3], vec, v3d->far);
+ }
+ else {
+ float vec[4];
+ vec[0] = 2.0f * mval[0] / ar->winx - 1;
+ vec[1] = 2.0f * mval[1] / ar->winy - 1;
+ vec[2] = 0.0f;
+ vec[3] = 1.0f;
+
+ mul_m4_v4(rv3d->persinv, vec);
+
+ madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f);
+ madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f);
+ }
+
+ /* clipping */
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ int a;
+ for (a = 0; a < 4; a++) {
+ clip_line_plane(ray_start, ray_end, rv3d->clip[a]);
+ }
+ }
+}
+
+
+/* Utility functions for projection
+ * ******************************** */
+
+void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][4])
+{
+ float vmat[4][4];
+
+ mult_m4_m4m4(vmat, rv3d->viewmat, ob->obmat);
+ mult_m4_m4m4(pmat, rv3d->winmat, vmat);
+}
+
+/**
+ * Uses window coordinates (x,y) and depth component z to find a point in
+ * modelspace */
+void ED_view3d_unproject(bglMats *mats, float out[3], const float x, const float y, const float z)
+{
+ float w[3];
+
+ w[0] = x;
+ w[1] = y;
+ w[2] = z;
+
+ gpuUnProject(w, mats->modelview, mats->projection, (GLint *)mats->viewport, out);
+}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 9cc657712bb..a9dcbdc1687 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -122,7 +122,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
- if (ret == V3D_PROJ_RET_SUCCESS) {
+ if (ret == V3D_PROJ_RET_OK) {
const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]),
(float)(mval_cpy[1] - mval[1])};
ED_view3d_win_to_delta(vc->ar, mval_f, dvec);
@@ -167,7 +167,7 @@ void view3d_get_transformation(const ARegion *ar, RegionView3D *rv3d, Object *ob
mats->viewport[0] = ar->winrct.xmin;
mats->viewport[1] = ar->winrct.ymin;
mats->viewport[2] = ar->winx;
- mats->viewport[3] = ar->winy;
+ mats->viewport[3] = ar->winy;
}
/* ********************** view3d_select: selection manipulations ********************* */
@@ -260,6 +260,8 @@ static void edbm_backbuf_check_and_select_tfaces(Mesh *me, int select)
typedef struct LassoSelectUserData {
ViewContext *vc;
const rcti *rect;
+ const rctf *rect_fl;
+ rctf _rect_fl;
const int (*mcords)[2];
int moves;
int select;
@@ -275,7 +277,11 @@ static void view3d_userdata_lassoselect_init(LassoSelectUserData *r_data,
const int moves, const int select)
{
r_data->vc = vc;
+
r_data->rect = rect;
+ r_data->rect_fl = &r_data->_rect_fl;
+ BLI_rctf_rcti_copy(&r_data->_rect_fl, rect);
+
r_data->mcords = mcords;
r_data->moves = moves;
r_data->select = select;
@@ -316,29 +322,29 @@ static int view3d_selectable_data(bContext *C)
/* helper also for borderselect */
-static int edge_fully_inside_rect(const rcti *rect, int x1, int y1, int x2, int y2)
+static int edge_fully_inside_rect(const rctf *rect, const float v1[2], const float v2[2])
{
- return BLI_rcti_isect_pt(rect, x1, y1) && BLI_rcti_isect_pt(rect, x2, y2);
+ return BLI_rctf_isect_pt_v(rect, v1) && BLI_rctf_isect_pt_v(rect, v2);
}
-static int edge_inside_rect(const rcti *rect, int x1, int y1, int x2, int y2)
+static int edge_inside_rect(const rctf *rect, const float v1[2], const float v2[2])
{
int d1, d2, d3, d4;
/* check points in rect */
- if (edge_fully_inside_rect(rect, x1, y1, x2, y2)) return 1;
+ if (edge_fully_inside_rect(rect, v1, v2)) return 1;
/* check points completely out rect */
- if (x1 < rect->xmin && x2 < rect->xmin) return 0;
- if (x1 > rect->xmax && x2 > rect->xmax) return 0;
- if (y1 < rect->ymin && y2 < rect->ymin) return 0;
- if (y1 > rect->ymax && y2 > 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 = (y1 - y2) * (x1 - rect->xmin) + (x2 - x1) * (y1 - rect->ymin);
- d2 = (y1 - y2) * (x1 - rect->xmin) + (x2 - x1) * (y1 - rect->ymax);
- d3 = (y1 - y2) * (x1 - rect->xmax) + (x2 - x1) * (y1 - rect->ymax);
- d4 = (y1 - y2) * (x1 - rect->xmax) + (x2 - x1) * (y1 - rect->ymin);
+ d1 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymin);
+ d2 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymax);
+ 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;
@@ -346,7 +352,7 @@ static int edge_inside_rect(const rcti *rect, int x1, int y1, int x2, int y2)
return 1;
}
-static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1)
+static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChannel *pchan, const float screen_co_a[2], const float screen_co_b[2])
{
LassoSelectUserData *data = userData;
bArmature *arm = data->vc->obact->data;
@@ -355,6 +361,11 @@ static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChann
int is_point_done = FALSE;
int points_proj_tot = 0;
+ const int x0 = screen_co_a[0];
+ const int y0 = screen_co_a[1];
+ const int x1 = screen_co_b[0];
+ const int y1 = screen_co_b[1];
+
/* project head location to screenspace */
if (x0 != IS_CLIPPED) {
points_proj_tot++;
@@ -389,6 +400,7 @@ static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChann
}
static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves, short select)
{
+ ViewContext vc_tmp;
LassoSelectUserData data;
rcti rect;
@@ -396,13 +408,16 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[]
return;
}
+ vc_tmp = *vc;
+ vc_tmp.obact = ob;
+
+ BLI_lasso_boundbox(&rect, mcords, moves);
+
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select);
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
- BLI_lasso_boundbox(&rect, mcords, moves);
-
- pose_foreachScreenBone(vc, do_lasso_select_pose__doSelectBone, &data);
+ pose_foreachScreenBone(&vc_tmp, do_lasso_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_change) {
bArmature *arm = ob->data;
@@ -447,23 +462,28 @@ static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], cons
}
}
-static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index))
+static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index))
{
LassoSelectUserData *data = userData;
- if (BLI_rcti_isect_pt(data->rect, x, y) &&
- BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED))
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co) &&
+ BLI_lasso_is_point_inside(data->mcords, data->moves, screen_co[0], screen_co[1], IS_CLIPPED))
{
BM_vert_select_set(data->vc->em->bm, eve, data->select);
}
}
-static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index)
+static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index)
{
LassoSelectUserData *data = userData;
if (EDBM_backbuf_check(bm_solidoffs + index)) {
+ const int x0 = screen_co_a[0];
+ const int y0 = screen_co_a[1];
+ const int x1 = screen_co_b[0];
+ const int y1 = screen_co_b[1];
+
if (data->pass == 0) {
- if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1) &&
+ if (edge_fully_inside_rect(data->rect_fl, screen_co_a, screen_co_b) &&
BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, IS_CLIPPED) &&
BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, IS_CLIPPED))
{
@@ -478,12 +498,12 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int
}
}
}
-static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
+static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, const float screen_co[2], int UNUSED(index))
{
LassoSelectUserData *data = userData;
- if (BLI_rcti_isect_pt(data->rect, x, y) &&
- BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED))
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co) &&
+ BLI_lasso_is_point_inside(data->mcords, data->moves, screen_co[0], screen_co[1], IS_CLIPPED))
{
BM_face_select_set(data->vc->em->bm, efa, data->select);
}
@@ -496,11 +516,11 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
rcti rect;
int bbsel;
- BLI_lasso_boundbox(&rect, mcords, moves);
-
/* set editmesh */
vc->em = BMEdit_FromObject(vc->obedit);
+ BLI_lasso_boundbox(&rect, mcords, moves);
+
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select);
if (extend == 0 && select)
@@ -517,17 +537,17 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
+ mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
- mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF);
+ mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_NOP);
if (data.is_done == 0) {
data.pass = 1;
- mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF);
+ mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_NOP);
}
}
@@ -536,7 +556,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data);
+ mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -544,13 +564,13 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
EDBM_selectmode_flush(vc->em);
}
-static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
+static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
{
LassoSelectUserData *data = userData;
Object *obedit = data->vc->obedit;
Curve *cu = (Curve *)obedit->data;
- if (BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) {
+ if (BLI_lasso_is_point_inside(data->mcords, data->moves, screen_co[0], screen_co[1], IS_CLIPPED)) {
if (bp) {
bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT);
if (bp == cu->lastsel && !(bp->f1 & SELECT)) cu->lastsel = NULL;
@@ -580,38 +600,45 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP
static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short moves, short extend, short select)
{
LassoSelectUserData data;
+ rcti rect;
+
+ BLI_lasso_boundbox(&rect, mcords, moves);
- view3d_userdata_lassoselect_init(&data, vc, NULL, mcords, moves, select);
+ view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select);
if (extend == 0 && select)
CU_deselect_all(vc->obedit);
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
- nurbs_foreachScreenVert(vc, do_lasso_select_curve__doSelect, &data);
+ nurbs_foreachScreenVert(vc, do_lasso_select_curve__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
-static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, int y)
+static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, const float screen_co[2])
{
LassoSelectUserData *data = userData;
- if (BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) {
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co) &&
+ BLI_lasso_is_point_inside(data->mcords, data->moves, screen_co[0], screen_co[1], IS_CLIPPED)) {
bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT);
}
}
static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], short moves, short extend, short select)
{
LassoSelectUserData data;
+ rcti rect;
- view3d_userdata_lassoselect_init(&data, vc, NULL, mcords, moves, select);
+ BLI_lasso_boundbox(&rect, mcords, moves);
+
+ view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select);
if (extend == 0 && select)
ED_setflagsLatt(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);
+ lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
-static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1)
+static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBone *ebone, const float screen_co_a[2], const float screen_co_b[2])
{
LassoSelectUserData *data = userData;
bArmature *arm = data->vc->obedit->data;
@@ -620,6 +647,11 @@ static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBo
int is_point_done = FALSE;
int points_proj_tot = 0;
+ const int x0 = screen_co_a[0];
+ const int y0 = screen_co_a[1];
+ const int x1 = screen_co_b[0];
+ const int y1 = screen_co_b[1];
+
/* project head location to screenspace */
if (x0 != IS_CLIPPED) {
points_proj_tot++;
@@ -662,16 +694,16 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho
LassoSelectUserData data;
rcti rect;
+ BLI_lasso_boundbox(&rect, mcords, moves);
+
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select);
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- BLI_lasso_boundbox(&rect, mcords, moves);
-
if (extend == 0 && select)
ED_armature_deselect_all_visible(vc->obedit);
- armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data);
+ armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_change) {
bArmature *arm = vc->obedit->data;
@@ -681,12 +713,12 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho
}
}
-static void do_lasso_select_mball__doSelectElem(void *userData, struct MetaElem *ml, int x, int y)
+static void do_lasso_select_mball__doSelectElem(void *userData, struct MetaElem *ml, const float screen_co[2])
{
LassoSelectUserData *data = userData;
- if (BLI_rcti_isect_pt(data->rect, x, y) &&
- BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, INT_MAX)) {
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co) &&
+ BLI_lasso_is_point_inside(data->mcords, data->moves, screen_co[0], screen_co[1], INT_MAX)) {
if (data->select) ml->flag |= SELECT;
else ml->flag &= ~SELECT;
data->is_change = TRUE;
@@ -702,13 +734,13 @@ static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short m
if (extend == 0 && select)
BKE_mball_deselect_all(mb);
+ BLI_lasso_boundbox(&rect, mcords, moves);
+
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select);
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- BLI_lasso_boundbox(&rect, mcords, moves);
-
- mball_foreachScreenElem(vc, do_lasso_select_mball__doSelectElem, &data);
+ mball_foreachScreenElem(vc, do_lasso_select_mball__doSelectElem, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
@@ -858,9 +890,10 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc,
do_lasso_select_paintface(vc, mcords, moves, extend, select);
else if (paint_vertsel_test(ob))
do_lasso_select_paintvert(vc, mcords, moves, extend, select);
- else if (ob && ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
- ;
- else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT)
+ 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, extend, select);
else {
do_lasso_select_objects(vc, mcords, moves, extend, select);
@@ -913,7 +946,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
select = !RNA_boolean_get(op->ptr, "deselect");
view3d_lasso_select(C, &vc, mcords, mcords_tot, extend, select);
- MEM_freeN(mcords);
+ MEM_freeN((void *)mcords);
return OPERATOR_FINISHED;
}
@@ -1389,9 +1422,12 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL;
- int temp, a, dist = 100;
+ int a;
+ float dist = 100.0f;
int retval = 0;
short hits;
+ const float mval_fl[2] = {(float)mval[0], (float)mval[1]};
+
/* setup view context for argument to callbacks */
view3d_set_viewcontext(C, &vc);
@@ -1412,13 +1448,16 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
base = startbase;
while (base) {
if (BASE_SELECTABLE(v3d, base)) {
- ED_view3d_project_base(ar, base);
- temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]);
- if (base == BASACT) temp += 10;
- if (temp < dist) {
-
- dist = temp;
- basact = base;
+ float screen_co[2];
+ if (ED_view3d_project_float_global(ar, base->object->obmat[3], screen_co,
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK)
+ {
+ float dist_temp = len_manhattan_v2v2(mval_fl, screen_co);
+ if (base == BASACT) dist_temp += 10.0f;
+ if (dist_temp < dist) {
+ dist = dist_temp;
+ basact = base;
+ }
}
}
base = base->next;
@@ -1508,7 +1547,8 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
}
}
}
- else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend, deselect, toggle) ) { /* then bone is found */
+ else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend, deselect, toggle) ) {
+ /* then bone is found */
/* we make the armature selected:
* not-selected active object in posemode won't work well for tools */
@@ -1584,6 +1624,8 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
typedef struct BoxSelectUserData {
ViewContext *vc;
const rcti *rect;
+ const rctf *rect_fl;
+ rctf _rect_fl;
int select;
/* runtime */
@@ -1596,7 +1638,11 @@ static void view3d_userdata_boxselect_init(BoxSelectUserData *r_data,
ViewContext *vc, const rcti *rect, const int select)
{
r_data->vc = vc;
+
r_data->rect = rect;
+ r_data->rect_fl = &r_data->_rect_fl;
+ BLI_rctf_rcti_copy(&r_data->_rect_fl, rect);
+
r_data->select = select;
/* runtime */
@@ -1605,23 +1651,20 @@ static void view3d_userdata_boxselect_init(BoxSelectUserData *r_data,
r_data->is_change = FALSE;
}
-int edge_inside_circle(int centx, int centy, int radius, int x1, int y1, int x2, int y2)
+int edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2])
{
int radius_squared = radius * radius;
/* check points in circle itself */
- if ((x1 - centx) * (x1 - centx) + (y1 - centy) * (y1 - centy) <= radius_squared) {
+ if (len_squared_v2v2(cent, screen_co_a) <= radius_squared) {
return TRUE;
}
- else if ((x2 - centx) * (x2 - centx) + (y2 - centy) * (y2 - centy) <= radius_squared) {
+ if (len_squared_v2v2(cent, screen_co_b) <= radius_squared) {
return TRUE;
}
else {
- const float cent[2] = {centx, centy};
- const float v1[2] = {x1, y1};
- const float v2[2] = {x2, y2};
/* pointdistline */
- if (dist_squared_to_line_segment_v2(cent, v1, v2) < (float)radius_squared) {
+ if (dist_squared_to_line_segment_v2(cent, screen_co_a, screen_co_b) < (float)radius_squared) {
return TRUE;
}
}
@@ -1629,13 +1672,13 @@ int edge_inside_circle(int centx, int centy, int radius, int x1, int y1, int x2,
return FALSE;
}
-static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
+static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
{
BoxSelectUserData *data = userData;
Object *obedit = data->vc->obedit;
Curve *cu = (Curve *)obedit->data;
- if (BLI_rcti_isect_pt(data->rect, x, y)) {
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co)) {
if (bp) {
bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT);
if (bp == cu->lastsel && !(bp->f1 & SELECT)) cu->lastsel = NULL;
@@ -1671,16 +1714,16 @@ static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int exte
CU_deselect_all(vc->obedit);
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
- nurbs_foreachScreenVert(vc, do_nurbs_box_select__doSelect, &data);
+ nurbs_foreachScreenVert(vc, do_nurbs_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
return OPERATOR_FINISHED;
}
-static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, int y)
+static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, const float screen_co[2])
{
BoxSelectUserData *data = userData;
- if (BLI_rcti_isect_pt(data->rect, x, y)) {
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co)) {
bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT);
}
}
@@ -1694,42 +1737,42 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int ex
ED_setflagsLatt(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);
+ lattice_foreachScreenVert(vc, do_lattice_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
return OPERATOR_FINISHED;
}
-static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index))
+static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index))
{
BoxSelectUserData *data = userData;
- if (BLI_rcti_isect_pt(data->rect, x, y)) {
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co)) {
BM_vert_select_set(data->vc->em->bm, eve, data->select);
}
}
-static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index)
+static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index)
{
BoxSelectUserData *data = userData;
if (EDBM_backbuf_check(bm_solidoffs + index)) {
if (data->pass == 0) {
- if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) {
+ if (edge_fully_inside_rect(data->rect_fl, screen_co_a, screen_co_b)) {
BM_edge_select_set(data->vc->em->bm, eed, data->select);
data->is_done = TRUE;
}
}
else {
- if (edge_inside_rect(data->rect, x0, y0, x1, y1)) {
+ if (edge_inside_rect(data->rect_fl, screen_co_a, screen_co_b)) {
BM_edge_select_set(data->vc->em->bm, eed, data->select);
}
}
}
}
-static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
+static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const float screen_co[2], int UNUSED(index))
{
BoxSelectUserData *data = userData;
- if (BLI_rcti_isect_pt(data->rect, x, y)) {
+ if (BLI_rctf_isect_pt_v(data->rect_fl, screen_co)) {
BM_face_select_set(data->vc->em->bm, efa, data->select);
}
}
@@ -1755,18 +1798,18 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
+ mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
- mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_CLIP_TEST_OFF);
+ mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_NOP);
if (data.is_done == 0) {
data.pass = 1;
- mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_CLIP_TEST_OFF);
+ mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_NOP);
}
}
@@ -1775,7 +1818,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data);
+ mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -1974,12 +2017,10 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
}
if (bone_selected) {
- Object *ob = base->object;
-
- if (ob && (ob->type == OB_ARMATURE)) {
- bArmature *arm = ob->data;
+ if (base->object && (base->object->type == OB_ARMATURE)) {
+ bArmature *arm = base->object->data;
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
if (arm && (arm->flag & ARM_HAS_VIZ_DEPS)) {
/* mask modifier ('armature' mode), etc. */
@@ -2217,7 +2258,8 @@ void VIEW3D_OT_select(wmOperatorType *ot)
typedef struct CircleSelectUserData {
ViewContext *vc;
short select;
- int mval[2];
+ int mval[2];
+ float mval_fl[2];
float radius;
float radius_squared;
@@ -2231,6 +2273,9 @@ static void view3d_userdata_circleselect_init(CircleSelectUserData *r_data,
r_data->vc = vc;
r_data->select = select;
copy_v2_v2_int(r_data->mval, mval);
+ r_data->mval_fl[0] = mval[0];
+ r_data->mval_fl[1] = mval[1];
+
r_data->radius = rad;
r_data->radius_squared = rad * rad;
@@ -2238,31 +2283,27 @@ static void view3d_userdata_circleselect_init(CircleSelectUserData *r_data,
r_data->is_change = FALSE;
}
-static void mesh_circle_doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index))
+static void mesh_circle_doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index))
{
CircleSelectUserData *data = userData;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
- if (len_squared_v2(delta) <= data->radius_squared) {
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
BM_vert_select_set(data->vc->em->bm, eve, data->select);
}
}
-static void mesh_circle_doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index))
+static void mesh_circle_doSelectEdge(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int UNUSED(index))
{
CircleSelectUserData *data = userData;
- if (edge_inside_circle(data->mval[0], data->mval[1], (int)data->radius, x0, y0, x1, y1)) {
+ if (edge_inside_circle(data->mval_fl, (int)data->radius, screen_co_a, screen_co_b)) {
BM_edge_select_set(data->vc->em->bm, eed, data->select);
}
}
-static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
+static void mesh_circle_doSelectFace(void *userData, BMFace *efa, const float screen_co[2], int UNUSED(index))
{
CircleSelectUserData *data = userData;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
- if (len_squared_v2(delta) <= data->radius_squared) {
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
BM_face_select_set(data->vc->em->bm, efa, data->select);
}
}
@@ -2285,7 +2326,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f
edbm_backbuf_check_and_select_verts(vc->em, select == LEFTMOUSE);
}
else {
- mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
+ mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -2294,7 +2335,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f
edbm_backbuf_check_and_select_edges(vc->em, select == LEFTMOUSE);
}
else {
- mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_CLIP_TEST_OFF);
+ mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_NOP);
}
}
@@ -2303,7 +2344,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f
edbm_backbuf_check_and_select_faces(vc->em, select == LEFTMOUSE);
}
else {
- mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data);
+ mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -2320,7 +2361,7 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, const int m
if (me) {
bm_vertoffs = me->totpoly + 1; /* max index array */
- /* bbsel= */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
+ /* bbsel = */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
edbm_backbuf_check_and_select_tfaces(me, select == LEFTMOUSE);
EDBM_backbuf_free();
paintface_flush_flags(ob);
@@ -2337,7 +2378,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m
if (me) {
bm_vertoffs = me->totvert + 1; /* max index array */
- /* bbsel= */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
+ /* bbsel = */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
edbm_backbuf_check_and_select_verts_obmode(me, select == LEFTMOUSE);
EDBM_backbuf_free();
@@ -2346,16 +2387,13 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m
}
-static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
+static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
{
CircleSelectUserData *data = userData;
Object *obedit = data->vc->obedit;
Curve *cu = (Curve *)obedit->data;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
-
- if (len_squared_v2(delta) <= data->radius_squared) {
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
if (bp) {
bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT);
@@ -2389,17 +2427,15 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
- nurbs_foreachScreenVert(vc, nurbscurve_circle_doSelect, &data);
+ nurbs_foreachScreenVert(vc, nurbscurve_circle_doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
-static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y)
+static void latticecurve_circle_doSelect(void *userData, BPoint *bp, const float screen_co[2])
{
CircleSelectUserData *data = userData;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
- if (len_squared_v2(delta) <= data->radius_squared) {
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT);
}
}
@@ -2410,18 +2446,16 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2]
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
- lattice_foreachScreenVert(vc, latticecurve_circle_doSelect, &data);
+ lattice_foreachScreenVert(vc, latticecurve_circle_doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
/* NOTE: pose-bone case is copied from editbone case... */
-static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y)
+static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, const float screen_co[2])
{
CircleSelectUserData *data = userData;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
- if (len_squared_v2(delta) <= data->radius_squared) {
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
if (data->select)
pchan->bone->flag |= BONE_SELECTED;
else
@@ -2430,7 +2464,7 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int
}
return 0;
}
-static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1)
+static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChannel *pchan, const float screen_co_a[2], const float screen_co_b[2])
{
CircleSelectUserData *data = userData;
bArmature *arm = data->vc->obact->data;
@@ -2440,17 +2474,17 @@ static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChan
int points_proj_tot = 0;
/* project head location to screenspace */
- if (x0 != IS_CLIPPED) {
+ if (screen_co_a[0] != IS_CLIPPED) {
points_proj_tot++;
- if (pchan_circle_doSelectJoint(data, pchan, x0, y0)) {
+ if (pchan_circle_doSelectJoint(data, pchan, screen_co_a)) {
is_point_done = TRUE;
}
}
/* project tail location to screenspace */
- if (x1 != IS_CLIPPED) {
+ if (screen_co_b[0] != IS_CLIPPED) {
points_proj_tot++;
- if (pchan_circle_doSelectJoint(data, pchan, x1, y1)) {
+ if (pchan_circle_doSelectJoint(data, pchan, screen_co_a)) {
is_point_done = TRUE;
}
}
@@ -2463,7 +2497,7 @@ static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChan
* It works nicer to only do this if the head or tail are not in the circle,
* otherwise there is no way to circle select joints alone */
if ((is_point_done == FALSE) && (points_proj_tot == 2) &&
- edge_inside_circle(data->mval[0], data->mval[1], data->radius, x0, y0, x1, y1))
+ 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;
@@ -2481,7 +2515,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */
- pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data);
+ pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_change) {
bArmature *arm = vc->obact->data;
@@ -2495,13 +2529,11 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f
}
}
-static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head)
+static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, const float screen_co[2], short head)
{
CircleSelectUserData *data = userData;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
-
- if (len_squared_v2(delta) <= data->radius_squared) {
+
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
if (head) {
if (data->select)
ebone->flag |= BONE_ROOTSEL;
@@ -2518,7 +2550,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int
}
return 0;
}
-static void do_circle_select_armature__doSelectBone(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1)
+static void do_circle_select_armature__doSelectBone(void *userData, struct EditBone *ebone, const float screen_co_a[2], const float screen_co_b[2])
{
CircleSelectUserData *data = userData;
bArmature *arm = data->vc->obedit->data;
@@ -2528,17 +2560,17 @@ static void do_circle_select_armature__doSelectBone(void *userData, struct EditB
int points_proj_tot = 0;
/* project head location to screenspace */
- if (x0 != IS_CLIPPED) {
+ if (screen_co_a[0] != IS_CLIPPED) {
points_proj_tot++;
- if (armature_circle_doSelectJoint(data, ebone, x0, y0, TRUE)) {
+ if (armature_circle_doSelectJoint(data, ebone, screen_co_a, TRUE)) {
is_point_done = TRUE;
}
}
/* project tail location to screenspace */
- if (x1 != IS_CLIPPED) {
+ if (screen_co_b[0] != IS_CLIPPED) {
points_proj_tot++;
- if (armature_circle_doSelectJoint(data, ebone, x1, y1, FALSE)) {
+ if (armature_circle_doSelectJoint(data, ebone, screen_co_b, FALSE)) {
is_point_done = TRUE;
}
}
@@ -2551,7 +2583,7 @@ static void do_circle_select_armature__doSelectBone(void *userData, struct EditB
* It works nicer to only do this if the head or tail are not in the circle,
* otherwise there is no way to circle select joints alone */
if ((is_point_done == FALSE) && (points_proj_tot == 2) &&
- edge_inside_circle(data->mval[0], data->mval[1], data->radius, x0, y0, x1, y1))
+ 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);
@@ -2570,7 +2602,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- armature_foreachScreenBone(vc, do_circle_select_armature__doSelectBone, &data);
+ armature_foreachScreenBone(vc, do_circle_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_change) {
ED_armature_sync_selection(arm->edbo);
@@ -2579,13 +2611,11 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2
}
}
-static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem *ml, int x, int y)
+static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem *ml, const float screen_co[2])
{
CircleSelectUserData *data = userData;
- const float delta[2] = {(float)(x - data->mval[0]),
- (float)(y - data->mval[1])};
- if (len_squared_v2(delta) <= data->radius_squared) {
+ if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
if (data->select) ml->flag |= SELECT;
else ml->flag &= ~SELECT;
data->is_change = TRUE;
@@ -2599,7 +2629,7 @@ static void mball_circle_select(ViewContext *vc, int select, const int mval[2],
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mball_foreachScreenElem(vc, do_circle_select_mball__doSelectElem, &data);
+ mball_foreachScreenElem(vc, do_circle_select_mball__doSelectElem, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
/** Callbacks for circle selection in Editmode */
@@ -2634,14 +2664,15 @@ static int object_circle_select(ViewContext *vc, int select, const int mval[2],
const float radius_squared = rad * rad;
const float mval_fl[2] = {mval[0], mval[1]};
int is_change = FALSE;
+ int select_flag = select ? SELECT : 0;
Base *base;
select = select ? BA_SELECT : BA_DESELECT;
for (base = FIRSTBASE; base; base = base->next) {
- if (((base->flag & SELECT) == 0) && BASE_SELECTABLE(vc->v3d, base)) {
+ if (BASE_SELECTABLE(vc->v3d, base) && ((base->flag & SELECT) != select_flag)) {
float screen_co[2];
if (ED_view3d_project_float_global(vc->ar, base->object->obmat[3], screen_co,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS)
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK)
{
if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) {
ED_base_object_select(base, select);
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index e55e97e501b..7f1bbb22f24 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -82,10 +82,9 @@ extern float originmat[3][3]; /* XXX object.c */
typedef struct TransVert {
float *loc;
- float oldloc[3], maploc[3], fac;
+ float oldloc[3], maploc[3];
float *val, oldval;
int flag;
- float *nor;
} TransVert;
/* SELECT == (1 << 0) */
@@ -193,6 +192,20 @@ static void special_transvert_update(Object *obedit)
}
}
+/* currently only used for bmesh index values */
+enum {
+ TM_INDEX_ON = 1, /* tag to make trans verts */
+ TM_INDEX_OFF = 0, /* don't make verts */
+ TM_INDEX_SKIP = -1 /* dont make verts (when the index values point to trans-verts) */
+};
+
+/* copied from editobject.c, needs to be replaced with new transform code still */
+/* mode flags: */
+enum {
+ TM_ALL_JOINTS = 1, /* all joints (for bones only) */
+ TM_SKIP_HANDLES = 2 /* skip handles when control point is selected (for curves only) */
+};
+
static void set_mapped_co(void *vuserdata, int index, const float co[3],
const float UNUSED(no[3]), const short UNUSED(no_s[3]))
{
@@ -201,16 +214,25 @@ static void set_mapped_co(void *vuserdata, int index, const float co[3],
TransVert *tv = userdata[1];
BMVert *eve = EDBM_vert_at_index(em, index);
- if (BM_elem_index_get(eve) != -1 && !(tv[BM_elem_index_get(eve)].flag & TX_VERT_USE_MAPLOC)) {
- copy_v3_v3(tv[BM_elem_index_get(eve)].maploc, co);
- tv[BM_elem_index_get(eve)].flag |= TX_VERT_USE_MAPLOC;
+ if (BM_elem_index_get(eve) != TM_INDEX_SKIP) {
+ tv = &tv[BM_elem_index_get(eve)];
+
+ /* be clever, get the closest vertex to the original,
+ * behaves most logically when the mirror modifier is used for eg [#33051]*/
+ if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) {
+ /* first time */
+ copy_v3_v3(tv->maploc, co);
+ tv->flag |= TX_VERT_USE_MAPLOC;
+ }
+ else {
+ /* find best location to use */
+ if (len_squared_v3v3(eve->co, co) < len_squared_v3v3(eve->co, tv->maploc)) {
+ copy_v3_v3(tv->maploc, co);
+ }
+ }
}
}
-/* copied from editobject.c, needs to be replaced with new transform code still */
-/* mode flags: */
-#define TM_ALL_JOINTS 1 /* all joints (for bones only) */
-#define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */
static void make_trans_verts(Object *obedit, float min[3], float max[3], int mode)
{
Nurb *nu;
@@ -233,7 +255,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
BMesh *bm = em->bm;
BMIter iter;
void *userdata[2] = {em, NULL};
- /*int proptrans= 0; */ /*UNUSED*/
+ /*int proptrans = 0; */ /*UNUSED*/
/* abuses vertex index all over, set, just set dirty here,
* perhaps this could use its own array instead? - campbell */
@@ -243,35 +265,37 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
if (em->selectmode & SCE_SELECT_VERTEX) {
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- BM_elem_index_set(eve, 1); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_ON); /* set_dirty! */
tottrans++;
}
- else BM_elem_index_set(eve, 0); /* set_dirty! */
+ else {
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
+ }
}
}
else if (em->selectmode & SCE_SELECT_EDGE) {
BMEdge *eed;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_index_set(eve, 0); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
}
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- BM_elem_index_set(eed->v1, 1); /* set_dirty! */
- BM_elem_index_set(eed->v2, 1); /* set_dirty! */
+ BM_elem_index_set(eed->v1, TM_INDEX_ON); /* set_dirty! */
+ BM_elem_index_set(eed->v2, TM_INDEX_ON); /* set_dirty! */
}
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve)) tottrans++;
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++;
}
}
else {
BMFace *efa;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_index_set(eve, 0); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
}
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -280,13 +304,13 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
BMLoop *l;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- BM_elem_index_set(l->v, 1); /* set_dirty! */
+ BM_elem_index_set(l->v, TM_INDEX_ON); /* set_dirty! */
}
}
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve)) tottrans++;
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++;
}
}
/* for any of the 3 loops above which all dirty the indices */
@@ -299,17 +323,15 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
a = 0;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_index_get(eve)) {
- BM_elem_index_set(eve, a); /* set_dirty! */
+ BM_elem_index_set(eve, a); /* set_dirty! */
copy_v3_v3(tv->oldloc, eve->co);
tv->loc = eve->co;
- if (eve->no[0] != 0.0f || eve->no[1] != 0.0f || eve->no[2] != 0.0f)
- tv->nor = eve->no; /* note this is a hackish signal (ton) */
- tv->flag = BM_elem_index_get(eve) & SELECT;
+ tv->flag = (BM_elem_index_get(eve) == TM_INDEX_ON) ? SELECT : 0;
tv++;
a++;
}
else {
- BM_elem_index_set(eve, -1); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_SKIP); /* set_dirty! */
}
}
/* set dirty already, above */
@@ -345,17 +367,15 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
if (rootok) {
copy_v3_v3(tv->oldloc, ebo->head);
tv->loc = ebo->head;
- tv->nor = NULL;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
- }
+ }
if ((mode & TM_ALL_JOINTS) && (tipsel)) {
copy_v3_v3(tv->oldloc, ebo->tail);
tv->loc = ebo->tail;
- tv->nor = NULL;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
@@ -363,8 +383,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
else if (tipsel) {
copy_v3_v3(tv->oldloc, ebo->tail);
tv->loc = ebo->tail;
- tv->nor = NULL;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
@@ -456,7 +475,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
copy_v3_v3(tv->oldloc, tv->loc);
tv->val = &(ml->rad);
tv->oldval = ml->rad;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index b40e880591a..d36b0085acb 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -173,7 +173,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
search[0] = 0;
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
/* fake button, it holds space for search items */
uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
@@ -182,7 +182,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL);
uiBoundsBlock(block, 6);
- uiBlockSetDirection(block, UI_DOWN);
+ uiBlockSetDirection(block, UI_DOWN);
uiEndBlock(C, block);
event = *(win->eventstate); /* XXX huh huh? make api call */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 61e7990f917..62615b82f8a 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -128,7 +128,7 @@ struct SmoothView3DStore {
/* will start timer if appropriate */
/* the arguments are the desired situation */
void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
- float *ofs, float *quat, float *dist, float *lens)
+ float *ofs, float *quat, float *dist, float *lens)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -143,7 +143,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
copy_qt_qt(sms.new_quat, rv3d->viewquat);
sms.new_dist = rv3d->dist;
sms.new_lens = v3d->lens;
- sms.to_camera = 0;
+ sms.to_camera = FALSE;
/* note on camera locking, this is a little confusing but works ok.
* we may be changing the view 'as if' there is no active camera, but in fact
@@ -164,23 +164,24 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
if (lens) sms.new_lens = *lens;
if (camera) {
+ sms.new_dist = ED_view3d_offset_distance(camera->obmat, ofs);
ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens);
- sms.to_camera = 1; /* restore view3d values in end */
+ sms.to_camera = TRUE; /* restore view3d values in end */
}
if (C && U.smooth_viewtx) {
- int changed = 0; /* zero means no difference */
+ int changed = FALSE; /* zero means no difference */
if (oldcamera != camera)
- changed = 1;
+ changed = TRUE;
else if (sms.new_dist != rv3d->dist)
- changed = 1;
+ changed = TRUE;
else if (sms.new_lens != v3d->lens)
- changed = 1;
+ changed = TRUE;
else if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
- changed = 1;
+ changed = TRUE;
else if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
- changed = 1;
+ changed = TRUE;
/* The new view is different from the old one
* so animate the view */
@@ -188,7 +189,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
/* original values */
if (oldcamera) {
- sms.orig_dist = rv3d->dist; /* below function does weird stuff with it... */
+ sms.orig_dist = ED_view3d_offset_distance(oldcamera->obmat, rv3d->ofs);
ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens);
}
else {
@@ -244,11 +245,13 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
/* if we get here nothing happens */
if (ok == FALSE) {
- if (sms.to_camera == 0) {
+ if (sms.to_camera == FALSE) {
copy_v3_v3(rv3d->ofs, sms.new_ofs);
copy_qt_qt(rv3d->viewquat, sms.new_quat);
rv3d->dist = sms.new_dist;
v3d->lens = sms.new_lens;
+
+ ED_view3d_camera_lock_sync(v3d, rv3d);
}
if (rv3d->viewlock & RV3D_BOXVIEW)
@@ -575,323 +578,27 @@ void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, co
}
}
-/**
- * Calculate a 3d segment from 2d window coordinates.
- * This ray_start is located at the viewpoint, ray_end is a far point.
- * ray_start and ray_end are clipped by the view near and far limits
- * so points along this line are always in view.
- * In orthographic view all resulting segments will be parallel.
- * \param ar The region (used for the window width and height).
- * \param v3d The 3d viewport (used for near and far clipping range).
- * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
- * \param ray_start The world-space starting point of the segment.
- * \param ray_end The world-space end point of the segment.
- */
-void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
-{
- RegionView3D *rv3d = ar->regiondata;
-
- if (rv3d->is_persp) {
- float vec[3];
- ED_view3d_win_to_vector(ar, mval, vec);
-
- copy_v3_v3(ray_start, rv3d->viewinv[3]);
- madd_v3_v3v3fl(ray_start, rv3d->viewinv[3], vec, v3d->near);
- madd_v3_v3v3fl(ray_end, rv3d->viewinv[3], vec, v3d->far);
- }
- else {
- float vec[4];
- vec[0] = 2.0f * mval[0] / ar->winx - 1;
- vec[1] = 2.0f * mval[1] / ar->winy - 1;
- vec[2] = 0.0f;
- vec[3] = 1.0f;
-
- mul_m4_v4(rv3d->persinv, vec);
-
- madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f);
- madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f);
- }
-
- /* clipping */
- if (rv3d->rflag & RV3D_CLIPPING) {
- int a;
- for (a = 0; a < 4; a++) {
- clip_line_plane(ray_start, ray_end, rv3d->clip[a]);
- }
- }
-}
-
-/**
- * Calculate a 3d viewpoint and direction vector from 2d window coordinates.
- * This ray_start is located at the viewpoint, ray_normal is the direction towards mval.
- * ray_start is clipped by the view near limit so points in front of it are always in view.
- * In orthographic view the resulting ray_normal will match the view vector.
- * \param ar The region (used for the window width and height).
- * \param v3d The 3d viewport (used for near clipping value).
- * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
- * \param ray_start The world-space starting point of the segment.
- * \param ray_normal The normalized world-space direction of towards mval.
- */
-void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
-{
- float ray_end[3];
-
- ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
- sub_v3_v3v3(ray_normal, ray_end, ray_start);
- normalize_v3(ray_normal);
-}
-
-/**
- * Calculate a normalized 3d direction vector from the viewpoint towards a global location.
- * In orthographic view the resulting vector will match the view vector.
- * \param rv3d The region (used for the window width and height).
- * \param coord The world-space location.
- * \param vec The resulting normalized vector.
- */
-void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float vec[3])
-{
- if (rv3d->is_persp) {
- float p1[4], p2[4];
-
- copy_v3_v3(p1, coord);
- p1[3] = 1.0f;
- copy_v3_v3(p2, p1);
- p2[3] = 1.0f;
- mul_m4_v4(rv3d->viewmat, p2);
-
- mul_v3_fl(p2, 2.0f);
-
- mul_m4_v4(rv3d->viewinv, p2);
-
- sub_v3_v3v3(vec, p1, p2);
- }
- else {
- copy_v3_v3(vec, rv3d->viewinv[2]);
- }
- normalize_v3(vec);
-}
-
-int initgrabz(RegionView3D *rv3d, float x, float y, float z)
-{
- int flip = FALSE;
- if (rv3d == NULL) return flip;
- rv3d->zfac = rv3d->persmat[0][3] * x + rv3d->persmat[1][3] * y + rv3d->persmat[2][3] * z + rv3d->persmat[3][3];
- if (rv3d->zfac < 0.0f)
- flip = TRUE;
- /* if x,y,z is exactly the viewport offset, zfac is 0 and we don't want that
- * (accounting for near zero values)
- */
- if (rv3d->zfac < 1.e-6f && rv3d->zfac > -1.e-6f) rv3d->zfac = 1.0f;
-
- /* Negative zfac means x, y, z was behind the camera (in perspective).
- * This gives flipped directions, so revert back to ok default case.
- */
- /* NOTE: I've changed this to flip zfac to be positive again for now so that GPencil draws ok
- * Aligorith, 2009Aug31 */
- //if (rv3d->zfac < 0.0f) rv3d->zfac = 1.0f;
- if (rv3d->zfac < 0.0f) rv3d->zfac = -rv3d->zfac;
-
- return flip;
-}
-
-/**
- * Calculate a 3d location from 2d window coordinates.
- * \param ar The region (used for the window width and height).
- * \param depth_pt The reference location used to calculate the Z depth.
- * \param mval The area relative location (such as event->mval converted to floats).
- * \param out The resulting world-space location.
- */
-void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3])
-{
- RegionView3D *rv3d = ar->regiondata;
-
- float line_sta[3];
- float line_end[3];
-
- if (rv3d->is_persp) {
- float mousevec[3];
- copy_v3_v3(line_sta, rv3d->viewinv[3]);
- ED_view3d_win_to_vector(ar, mval, mousevec);
- add_v3_v3v3(line_end, line_sta, mousevec);
-
- if (isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) {
- /* highly unlikely to ever happen, mouse vec paralelle with view plane */
- zero_v3(out);
- }
- }
- else {
- const float dx = (2.0f * mval[0] / (float)ar->winx) - 1.0f;
- const float dy = (2.0f * mval[1] / (float)ar->winy) - 1.0f;
- line_sta[0] = (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0];
- line_sta[1] = (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1];
- line_sta[2] = (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2];
-
- add_v3_v3v3(line_end, line_sta, rv3d->viewinv[2]);
- closest_to_line_v3(out, depth_pt, line_sta, line_end);
- }
-}
-
-/**
- * Calculate a 3d difference vector from 2d window offset.
- * note that initgrabz() must be called first to determine
- * the depth used to calculate the delta.
- * \param ar The region (used for the window width and height).
- * \param mval The area relative 2d difference (such as event->mval[0] - other_x).
- * \param out The resulting world-space delta.
- */
-void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3])
-{
- RegionView3D *rv3d = ar->regiondata;
- float dx, dy;
-
- dx = 2.0f * mval[0] * rv3d->zfac / ar->winx;
- dy = 2.0f * mval[1] * rv3d->zfac / ar->winy;
-
- out[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy);
- out[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy);
- out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy);
-}
-
-/**
- * Calculate a 3d direction vector from 2d window coordinates.
- * This direction vector starts and the view in the direction of the 2d window coordinates.
- * In orthographic view all window coordinates yield the same vector.
- *
- * \note doesn't rely on initgrabz
- * for perspective view, get the vector direction to
- * the mouse cursor as a normalized vector.
- *
- * \param ar The region (used for the window width and height).
- * \param mval The area relative 2d location (such as event->mval converted to floats).
- * \param out The resulting normalized world-space direction vector.
- */
-void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3])
-{
- RegionView3D *rv3d = ar->regiondata;
-
- if (rv3d->is_persp) {
- out[0] = 2.0f * (mval[0] / ar->winx) - 1.0f;
- out[1] = 2.0f * (mval[1] / ar->winy) - 1.0f;
- out[2] = -0.5f;
- mul_project_m4_v3(rv3d->persinv, out);
- sub_v3_v3(out, rv3d->viewinv[3]);
- }
- else {
- copy_v3_v3(out, rv3d->viewinv[2]);
- }
- normalize_v3(out);
-}
-
-float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y)
-{
- ViewDepths *vd = vc->rv3d->depths;
-
- x -= vc->ar->winrct.xmin;
- y -= vc->ar->winrct.ymin;
-
- if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
- return vd->depths[y * vd->w + x];
- else
- return 1;
-}
-
-void ED_view3d_depth_tag_update(RegionView3D *rv3d)
-{
- if (rv3d->depths)
- rv3d->depths->damaged = 1;
-}
-
-void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][4])
-{
- float vmat[4][4];
-
- mult_m4_m4m4(vmat, rv3d->viewmat, ob->obmat);
- mult_m4_m4m4(pmat, rv3d->winmat, vmat);
-}
-
-/* Uses window coordinates (x,y) and depth component z to find a point in
- * modelspace */
-void ED_view3d_unproject(bglMats *mats, float out[3], const float x, const float y, const float z)
-{
- float win[] = {x, y, z};
-
- gpuUnProject(win, mats->modelview, mats->projection, (GLint *)mats->viewport, out);
-}
-
-/* use #ED_view3d_ob_project_mat_get to get projecting mat */
-void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r_co[2], float mat[4][4])
-{
- float vec4[4];
-
- copy_v3_v3(vec4, co);
- vec4[3] = 1.0;
- /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
-
- mul_m4_v4(mat, vec4);
-
- if (vec4[3] > FLT_EPSILON) {
- r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
- }
- else {
- zero_v2(r_co);
- }
-}
-
-/* use #ED_view3d_ob_project_mat_get to get projecting mat */
-void ED_view3d_project_float_v3_m4(ARegion *ar, const float vec[3], float r_co[3], float mat[4][4])
-{
- float vec4[4];
-
- copy_v3_v3(vec4, vec);
- vec4[3] = 1.0;
- /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
-
- mul_m4_v4(mat, vec4);
-
- if (vec4[3] > FLT_EPSILON) {
- r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
- r_co[2] = vec4[2] / vec4[3];
- }
- else {
- zero_v3(r_co);
- }
-}
-
-eV3DProjStatus ED_view3d_project_base(struct ARegion *ar, struct Base *base)
-{
- eV3DProjStatus ret = ED_view3d_project_short_global(ar, base->object->obmat[3], &base->sx,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN);
-
- if (ret != V3D_PROJ_RET_SUCCESS) {
- base->sx = IS_CLIPPED;
- base->sy = 0;
- }
-
- return ret;
-}
int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
{
/* return 1: draw */
-
+
float mat[4][4];
float vec[4], min, max;
int a, flag = -1, fl;
-
+
if (bb == NULL) return 1;
if (bb->flag & OB_BB_DISABLED) return 1;
-
+
mult_m4_m4m4(mat, rv3d->persmat, obmat);
-
+
for (a = 0; a < 8; a++) {
copy_v3_v3(vec, bb->vec[a]);
vec[3] = 1.0;
mul_m4_v4(mat, vec);
max = vec[3];
min = -vec[3];
-
+
fl = 0;
if (vec[0] < min) fl += 1;
if (vec[0] > max) fl += 2;
@@ -899,153 +606,31 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
if (vec[1] > max) fl += 8;
if (vec[2] < min) fl += 16;
if (vec[2] > max) fl += 32;
-
+
flag &= fl;
if (flag == 0) return 1;
}
-
- return 0;
-}
-
-/* perspmat is typically...
- * - 'rv3d->perspmat', is_local == FALSE
- * - 'rv3d->perspmatob', is_local == TRUE
- */
-static eV3DProjStatus ed_view3d_project__internal(ARegion *ar,
- float perspmat[4][4], const int is_local, /* normally hidden */
- const float co[3], float r_co[2], eV3DProjTest flag)
-{
- float fx, fy, vec4[4];
-
- if (flag & V3D_PROJ_TEST_CLIP_BB) {
- RegionView3D *rv3d = ar->regiondata;
- if (rv3d->rflag & RV3D_CLIPPING) {
- if (ED_view3d_clipping_test(rv3d, co, is_local)) {
- return V3D_PROJ_RET_CLIP_BB;
- }
- }
- }
- copy_v3_v3(vec4, co);
- vec4[3] = 1.0;
- mul_m4_v4(perspmat, vec4);
-
- if (vec4[3] > (float)BL_NEAR_CLIP) {
- fx = ((float)ar->winx / 2.0f) * (1.0f + vec4[0] / vec4[3]);
- if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fx > 0 && fx < ar->winx)) {
- fy = ((float)ar->winy / 2.0f) * (1.0f + vec4[1] / vec4[3]);
- if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fy > 0.0f && fy < (float)ar->winy)) {
- r_co[0] = (short)floor(fx);
- r_co[1] = (short)floor(fy);
- }
- else {
- return V3D_PROJ_RET_CLIP_WIN;
- }
- }
- else {
- return V3D_PROJ_RET_CLIP_WIN;
- }
- }
- else {
- return V3D_PROJ_RET_CLIP_NEAR;
- }
-
- return V3D_PROJ_RET_SUCCESS;
-}
-
-eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], const int is_local,
- const float co[3], short r_co[2], eV3DProjTest flag)
-{
- float tvec[2];
- eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
- if (ret == V3D_PROJ_RET_SUCCESS) {
- if ((tvec[0] > -32700.0 && tvec[0] < 32700.0f) &&
- (tvec[1] > -32700.0 && tvec[1] < 32700.0f))
- {
- r_co[0] = (short)floor(tvec[0]);
- r_co[1] = (short)floor(tvec[1]);
- }
- else {
- ret = V3D_PROJ_RET_OVERFLOW;
- }
- }
- return ret;
-}
-
-eV3DProjStatus ED_view3d_project_int_ex(ARegion *ar, float perspmat[4][4], const int is_local,
- const float co[3], int r_co[2], eV3DProjTest flag)
-{
- float tvec[2];
- eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
- if (ret == V3D_PROJ_RET_SUCCESS) {
- if ((tvec[0] > -2140000000.0 && tvec[0] < 2140000000.0f) &&
- (tvec[1] > -2140000000.0 && tvec[1] < 2140000000.0f))
- {
- r_co[0] = (int)floor(tvec[0]);
- r_co[1] = (int)floor(tvec[1]);
- }
- else {
- ret = V3D_PROJ_RET_OVERFLOW;
- }
- }
- return ret;
-}
-
-eV3DProjStatus ED_view3d_project_float_ex(ARegion *ar, float perspmat[4][4], const int is_local,
- const float co[3], float r_co[2], eV3DProjTest flag)
-{
- float tvec[2];
- eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
- if (ret == V3D_PROJ_RET_SUCCESS) {
- if (finite(tvec[0]) &&
- finite(tvec[1]))
- {
- copy_v2_v2(r_co, tvec);
- }
- else {
- ret = V3D_PROJ_RET_OVERFLOW;
- }
- }
- return ret;
+ return 0;
}
-/* --- short --- */
-eV3DProjStatus ED_view3d_project_short_global(ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag)
-{
- RegionView3D *rv3d = ar->regiondata;
- return ED_view3d_project_short_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
-}
-/* object space, use ED_view3d_init_mats_rv3d before calling */
-eV3DProjStatus ED_view3d_project_short_object(ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag)
+float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y)
{
- RegionView3D *rv3d = ar->regiondata;
- return ED_view3d_project_short_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
-}
+ ViewDepths *vd = vc->rv3d->depths;
+
+ x -= vc->ar->winrct.xmin;
+ y -= vc->ar->winrct.ymin;
-/* --- int --- */
-eV3DProjStatus ED_view3d_project_int_global(ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag)
-{
- RegionView3D *rv3d = ar->regiondata;
- return ED_view3d_project_int_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
-}
-/* object space, use ED_view3d_init_mats_rv3d before calling */
-eV3DProjStatus ED_view3d_project_int_object(ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag)
-{
- RegionView3D *rv3d = ar->regiondata;
- return ED_view3d_project_int_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
+ if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
+ return vd->depths[y * vd->w + x];
+ else
+ return 1;
}
-/* --- float --- */
-eV3DProjStatus ED_view3d_project_float_global(ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag)
-{
- RegionView3D *rv3d = ar->regiondata;
- return ED_view3d_project_float_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
-}
-/* object space, use ED_view3d_init_mats_rv3d before calling */
-eV3DProjStatus ED_view3d_project_float_object(ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag)
+void ED_view3d_depth_tag_update(RegionView3D *rv3d)
{
- RegionView3D *rv3d = ar->regiondata;
- return ED_view3d_project_float_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
+ if (rv3d->depths)
+ rv3d->depths->damaged = 1;
}
/* copies logic of get_view3d_viewplane(), keep in sync */
@@ -1079,7 +664,10 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy,
return params.is_ortho;
}
-void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for picking */
+/*!
+ * \param rect for picking, NULL not to use.
+ */
+void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect)
{
RegionView3D *rv3d = ar->regiondata;
rctf viewplane;
@@ -1112,7 +700,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for
if (orth) wmOrtho(rect->xmin, rect->xmax, rect->ymin, rect->ymax, -clipend, clipend);
else wmFrustum(rect->xmin, rect->xmax, rect->ymin, rect->ymax, clipsta, clipend);
-
+
}
else {
if (orth) wmOrtho(x1, x2, y1, y2, clipsta, clipend);
@@ -1208,7 +796,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
{
if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */
if (v3d->camera) {
- BKE_object_where_is_calc(scene, v3d->camera);
+ BKE_object_where_is_calc(scene, v3d->camera);
obmat_to_viewmat(v3d, rv3d, v3d->camera, 0);
}
else {
@@ -1313,8 +901,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
glLoadName(code);
draw_object(scene, ar, v3d, base, DRAW_PICKING | DRAW_CONSTCOLOR);
- /* we draw group-duplicators for selection too */
- if ((base->object->transflag & OB_DUPLI) && base->object->dup_group) {
+ /* we draw duplicators for selection too */
+ if ((base->object->transflag & OB_DUPLI)) {
ListBase *lb;
DupliObject *dob;
Base tbase;
@@ -1341,7 +929,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
free_object_duplilist(lb);
}
code++;
- }
+ }
}
}
v3d->xray = FALSE; /* restore */
@@ -1459,7 +1047,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL
locallay = free_localbit(bmain);
if (locallay == 0) {
- BKE_reportf(reports, RPT_ERROR, "No more than 8 localviews");
+ BKE_report(reports, RPT_ERROR, "No more than 8 local views");
ok = FALSE;
}
else {
@@ -1614,7 +1202,7 @@ static int view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa)
DAG_on_visible_update(bmain, FALSE);
return TRUE;
- }
+ }
else {
return FALSE;
}
@@ -1648,7 +1236,6 @@ static int localview_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_localview(wmOperatorType *ot)
{
-
/* identifiers */
ot->name = "Local View";
ot->description = "Toggle display of selected object(s) separately and centered in view";
@@ -1688,12 +1275,12 @@ static void RestoreState(bContext *C, wmWindow *win)
GPU_paint_set_mipmap(0);
//XXX curarea->win_swap = 0;
- //XXX curarea->head_swap=0;
+ //XXX curarea->head_swap = 0;
//XXX allqueue(REDRAWVIEW3D, 1);
//XXX allqueue(REDRAWBUTSALL, 0);
//XXX reset_slowparents();
//XXX waitcursor(0);
- //XXX G.qual= 0;
+ //XXX G.qual = 0;
if (win) /* check because closing win can set to NULL */
win->queue = queue_back;
@@ -1818,7 +1405,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
WM_redraw_windows(C);
rv3d = CTX_wm_region_view3d(C);
- /* sa= CTX_wm_area(C); */ /* UNUSED */
+ /* sa = CTX_wm_area(C); */ /* UNUSED */
ar = CTX_wm_region(C);
view3d_operator_needs_opengl(C);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index fd10a153dc3..1c50e833c6d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -92,15 +92,12 @@
#include "BLI_linklist.h"
#include "BLI_smallhash.h"
#include "BLI_array.h"
-#include "PIL_time.h"
#include "UI_interface_icons.h"
#include "UI_resources.h"
#include "transform.h"
-#include <stdio.h> // XXX: duplicated???
-
static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg);
static int doEdgeSlide(TransInfo *t, float perc);
@@ -232,7 +229,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
if (t->spacetype == SPACE_VIEW3D) {
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- if (ED_view3d_project_int_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
adr[0] = (int)2140000000.0f; /* this is what was done in 2.64, perhaps we can be smarter? */
adr[1] = (int)2140000000.0f;
}
@@ -282,7 +279,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
//vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
/* same as below */
UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
- }
+ }
else
#endif
{
@@ -357,7 +354,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
case SPACE_VIEW3D:
{
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
/* XXX, 2.64 and prior did this, weak! */
adr[0] = t->ar->winx / 2.0f;
adr[1] = t->ar->winy / 2.0f;
@@ -474,11 +471,11 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_ACTION) {
- //SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+ //SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_IPO) {
- //SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+ //SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NLA) {
@@ -531,6 +528,10 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
/* if autokeying is enabled, send notifiers that keyframes were added */
if (IS_AUTOKEY_ON(t->scene))
WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+
+ /* redraw UV editor */
+ if (t->mode == TFM_EDGE_SLIDE && (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT))
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
/* XXX temp, first hack to get auto-render in compositor work (ton) */
WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM_DONE, CTX_data_scene(C));
@@ -1028,7 +1029,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
if (t->flag & T_PROP_EDIT) {
t->prop_size *= 1.1f;
if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
- t->prop_size = minf(t->prop_size, ((View3D *)t->view)->far);
+ t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far);
calculatePropRatio(t);
}
t->redraw |= TREDRAW_HARD;
@@ -1198,7 +1199,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
if (event->alt && t->flag & T_PROP_EDIT) {
t->prop_size *= 1.1f;
if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
- t->prop_size = minf(t->prop_size, ((View3D *)t->view)->far);
+ t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far);
calculatePropRatio(t);
}
t->redraw = 1;
@@ -1226,6 +1227,14 @@ int transformEvent(TransInfo *t, wmEvent *event)
else view_editmove(event->type);
t->redraw = 1;
break;
+ case LEFTALTKEY:
+ case RIGHTALTKEY:
+ if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
+ t->flag |= T_ALT_TRANSFORM;
+ t->redraw |= TREDRAW_HARD;
+ }
+
+ break;
default:
handled = 0;
break;
@@ -1259,6 +1268,14 @@ int transformEvent(TransInfo *t, wmEvent *event)
//// if (t->options & CTX_TWEAK)
// t->state = TRANS_CONFIRM;
// break;
+ case LEFTALTKEY:
+ case RIGHTALTKEY:
+ if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
+ t->flag &= ~T_ALT_TRANSFORM;
+ t->redraw |= TREDRAW_HARD;
+ }
+
+ break;
default:
handled = 0;
break;
@@ -1272,13 +1289,14 @@ int transformEvent(TransInfo *t, wmEvent *event)
}
}
}
+ else
+ handled = 0;
// Per transform event, if present
if (t->handleEvent)
t->redraw |= t->handleEvent(t, event);
if (handled || t->redraw) {
- t->last_update = PIL_check_seconds_timer();
return 0;
}
else {
@@ -1492,8 +1510,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
float angle = atan2f(dy, dx);
float dist = sqrtf(dx * dx + dy * dy);
- float delta_angle = minf(15.0f / dist, (float)M_PI / 4.0f);
- float spacing_angle = minf(5.0f / dist, (float)M_PI / 12.0f);
+ float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f);
+ float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f);
UI_ThemeColor(TH_WIRE);
setlinestyle(3);
@@ -1843,7 +1861,7 @@ static void drawNonPropEdge(const struct bContext *C, TransInfo *t)
float v1[3], v2[3];
float interp_v;
TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
- const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5;
+ const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
const float guide_size = ctrl_size - 0.5f;
const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
const int alpha_shade = -30;
@@ -1913,51 +1931,31 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi
}
/* just draw a little warning message in the top-right corner of the viewport to warn that autokeying is enabled */
-static void drawAutoKeyWarning(TransInfo *t, ARegion *ar)
+static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
{
- int show_warning;
-
- /* red border around the viewport */
- UI_ThemeColor(TH_REDALERT);
+ const char printable[] = "Auto Keying On";
+ float printable_size[2];
+ int xco, yco;
- gpuImmediateFormat_V2();
- gpuBegin(GL_LINE_LOOP);
- gpuVertex2f(1, 1);
- gpuVertex2f(1, ar->winy-1);
- gpuVertex2f(ar->winx-1, ar->winy-1);
- gpuVertex2f(ar->winx-1, 1);
- gpuEnd();
- gpuImmediateUnlock();
-
- /* Entire warning should "blink" to catch periphery attention without being overly distracting
- * much like how a traditional recording sign in the corner of a camcorder works
- *
- * - Blink frequency here is 0.5 secs (i.e. a compromise between epilepsy-inducing flicker + too slow to notice).
- * We multiply by two to speed up the odd/even time-in-seconds = on/off toggle.
- * - Always start with warning shown so that animators are more likely to notice when starting to transform
+ BLF_width_and_height_default(printable, &printable_size[0], &printable_size[1]);
+
+ xco = ar->winx - (int)printable_size[0] - 10;
+ yco = ar->winy - (int)printable_size[1] - 10;
+
+ /* warning text (to clarify meaning of overlays)
+ * - original color was red to match the icon, but that clashes badly with a less nasty border
*/
- show_warning = (int)(t->last_update * 2.0) & 1;
+ UI_ThemeColorShade(TH_TEXT_HI, -50);
+ BLF_draw_default_ascii(xco, ar->winy - 17, 0.0f, printable, sizeof(printable));
- if ((show_warning) || (t->state == TRANS_STARTING)) {
- const char printable[] = "Auto Keying On";
- int xco, yco;
-
- xco = ar->winx - BLF_width_default(printable) - 10;
- yco = ar->winy - BLF_height_default(printable) - 10;
-
- /* red warning text */
- UI_ThemeColor(TH_REDALERT);
- BLF_draw_default_ascii(xco, ar->winy - 17, 0.0f, printable, sizeof(printable));
-
- /* autokey recording icon... */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- xco -= (ICON_DEFAULT_WIDTH + 2);
- UI_icon_draw(xco, yco, ICON_REC);
-
- glDisable(GL_BLEND);
- }
+ /* autokey recording icon... */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+
+ xco -= (ICON_DEFAULT_WIDTH + 2);
+ UI_icon_draw(xco, yco, ICON_REC);
+
+ glDisable(GL_BLEND);
}
static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg)
@@ -1966,10 +1964,20 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo
Scene *scene = t->scene;
Object *ob = OBACT;
- /* draw autokeyframing hint in the corner */
- if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) {
- drawAutoKeyWarning(t, ar);
- }
+ /* draw autokeyframing hint in the corner
+ * - only draw if enabled (advanced users may be distracted/annoyed),
+ * for objects that will be autokeyframed (no point ohterwise),
+ * AND only for the active region (as showing all is too overwhelming)
+ */
+ if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) {
+ if (ar == t->ar) {
+ if (t->flag & (T_OBJECT | T_POSE)) {
+ if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) {
+ drawAutoKeyWarning(t, ar);
+ }
+ }
+ }
+ }
}
void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
@@ -3748,7 +3756,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* this function works on end result */
protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle);
}
- else {
+ else {
float eulmat[3][3];
mul_m3_m3m3(totmat, mat, td->ext->r_mtx);
@@ -4296,10 +4304,8 @@ void initShrinkFatten(TransInfo *t)
}
-
int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- float vec[3];
float distance;
int i;
char str[64];
@@ -4327,17 +4333,20 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
t->values[0] = -distance;
for (i = 0; i < t->total; i++, td++) {
+ float tdistance; /* temp dist */
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
- copy_v3_v3(vec, td->axismtx[2]);
- mul_v3_fl(vec, distance);
- mul_v3_fl(vec, td->factor);
+ /* get the final offset */
+ tdistance = distance * td->factor;
+ if (td->ext && (t->flag & T_ALT_TRANSFORM)) {
+ tdistance *= td->ext->isize[0]; /* shell factor */
+ }
- add_v3_v3v3(td->loc, td->iloc, vec);
+ madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance);
}
recalcData(t);
@@ -4388,12 +4397,15 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c);
- sprintf(str, "Tilt: %s %s", &c[0], t->proptext);
+ sprintf(str, "Tilt: %s° %s", &c[0], t->proptext);
final = DEG2RADF(final);
+
+ /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */
+ t->values[0] = final;
}
else {
- sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext);
+ sprintf(str, "Tilt: %.2f° %s", RAD2DEGF(final), t->proptext);
}
for (i = 0; i < t->total; i++, td++) {
@@ -5151,8 +5163,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
cross_v3_v3v3(a, f2, l->f->no);
mul_v3_fl(a, -1.0f);
- add_v3_v3(a, f3);
- mul_v3_fl(a, 0.5f);
+ mid_v3_v3v3(a, a, f3);
}
copy_v3_v3(vec, a);
@@ -5173,7 +5184,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
}
l = l->radial_next;
- } while (l != firstl);
+ } while (l != firstl);
if (i)
mul_v3_fl(a, 1.0f / (float)i);
@@ -5194,17 +5205,12 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo
float dist = 0;
float min_dist = FLT_MAX;
- float up_p[3];
- float dw_p[3];
-
for (i = 0; i < sld->totsv; i++, sv++) {
/* Set length */
- add_v3_v3v3(up_p, sv->origvert.co, sv->upvec);
- add_v3_v3v3(dw_p, sv->origvert.co, sv->downvec);
- sv->edge_len = len_v3v3(dw_p, up_p);
+ sv->edge_len = len_v3v3(sv->upvec, sv->downvec);
mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co);
- if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
dist = len_squared_v2v2(mval, v_proj);
if (dist < min_dist) {
min_dist = dist;
@@ -5222,10 +5228,9 @@ static int createSlideVerts(TransInfo *t)
{
BMEditMesh *em = BMEdit_FromObject(t->obedit);
BMesh *bm = em->bm;
- BMIter iter, iter2;
+ BMIter iter;
BMEdge *e, *e1;
BMVert *v, *v2, *first;
- BMLoop *l, *l1, *l2;
TransDataSlideVert *sv_array;
BMBVHTree *btree = BMBVH_NewBVH(em, BMBVH_RESPECT_HIDDEN, NULL, NULL);
SmallHash table;
@@ -5265,6 +5270,7 @@ static int createSlideVerts(TransInfo *t)
/*ensure valid selection*/
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ BMIter iter2;
numsel = 0;
BM_ITER_ELEM (e, &iter2, v, BM_EDGES_OF_VERT) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
@@ -5317,6 +5323,8 @@ static int createSlideVerts(TransInfo *t)
j = 0;
while (1) {
+ BMLoop *l, *l1, *l2;
+
v = NULL;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG))
@@ -5450,7 +5458,7 @@ static int createSlideVerts(TransInfo *t)
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
BMIter iter2;
BMEdge *e2;
- float vec1[3], mval[2] = {t->mval[0], t->mval[1]}, d;
+ float vec1[3], d;
/* search cross edges for visible edge to the mouse cursor,
* then use the shared vertex to calculate screen vector*/
@@ -5866,7 +5874,6 @@ static int doEdgeSlide(TransInfo *t, float perc)
{
SlideData *sld = t->customData;
TransDataSlideVert *svlist = sld->sv, *sv;
- float vec[3];
int i;
sld->perc = perc;
@@ -5874,6 +5881,7 @@ static int doEdgeSlide(TransInfo *t, float perc)
if (sld->is_proportional == TRUE) {
for (i = 0; i < sld->totsv; i++, sv++) {
+ float vec[3];
if (perc > 0.0f) {
copy_v3_v3(vec, sv->upvec);
mul_v3_fl(vec, perc);
@@ -5891,20 +5899,29 @@ static int doEdgeSlide(TransInfo *t, float perc)
* Implementation note, non proportional mode ignores the starting positions and uses only the
* up/down verts, this could be changed/improved so the distance is still met but the verts are moved along
* their original path (which may not be straight), however how it works now is OK and matches 2.4x - Campbell
+ *
+ * \note len_v3v3(curr_sv->upvec, curr_sv->downvec)
+ * is the same as the distance between the original vert locations, same goes for the lines below.
*/
TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
- const float curr_length_perc = len_v3v3(curr_sv->up->co, curr_sv->down->co) *
- (((sld->flipped_vtx ? perc : -perc) + 1.0f) / 2.0f);
+ const float curr_length_perc = curr_sv->edge_len * (((sld->flipped_vtx ? perc : -perc) + 1.0f) / 2.0f);
+
+ float down_co[3];
+ float up_co[3];
for (i = 0; i < sld->totsv; i++, sv++) {
- const float sv_length = len_v3v3(sv->up->co, sv->down->co);
- const float fac = minf(sv_length, curr_length_perc) / sv_length;
+ if (sv->edge_len > FLT_EPSILON) {
+ const float fac = min_ff(sv->edge_len, curr_length_perc) / sv->edge_len;
- if (sld->flipped_vtx) {
- interp_v3_v3v3(sv->v->co, sv->down->co, sv->up->co, fac);
- }
- else {
- interp_v3_v3v3(sv->v->co, sv->up->co, sv->down->co, fac);
+ add_v3_v3v3(up_co, sv->origvert.co, sv->upvec);
+ add_v3_v3v3(down_co, sv->origvert.co, sv->downvec);
+
+ if (sld->flipped_vtx) {
+ interp_v3_v3v3(sv->v->co, down_co, up_co, fac);
+ }
+ else {
+ interp_v3_v3v3(sv->v->co, up_co, down_co, fac);
+ }
}
}
}
@@ -6394,7 +6411,7 @@ static short getAnimEdit_DrawTime(TransInfo *t)
SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
drawtime = (sipo->flag & SIPO_DRAWTIME) ? 1 : 0;
- }
+ }
else {
drawtime = 0;
}
@@ -6875,5 +6892,5 @@ int TimeScale(TransInfo *t, const int UNUSED(mval[2]))
void BIF_TransformSetUndo(const char *UNUSED(str))
{
// TRANSFORM_FIX_ME
- //Trans.undostr= str;
+ //Trans.undostr = str;
}
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index c8fe963d94c..cca7917277e 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -197,6 +197,7 @@ typedef struct TransDataSlideVert {
float edge_len;
+ /* add origvert.co to get the original locations */
float upvec[3], downvec[3];
int loop_nr;
@@ -323,8 +324,6 @@ typedef struct TransInfo {
float axis[3];
float axis_orig[3]; /* TransCon can change 'axis', store the original value here */
- double last_update; /* Time of last update (in seconds) */
-
void *view;
struct bContext *context; /* Only valid (non null) during an operator called function. */
struct ScrArea *sa;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index cce8a388574..8e8b909270b 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -730,7 +730,7 @@ void startConstraint(TransInfo *t)
{
t->con.mode |= CON_APPLY;
*t->con.text = ' ';
- t->num.idx_max = MIN2(getConstraintSpaceDimension(t) - 1, t->idx_max);
+ t->num.idx_max = min_ii(getConstraintSpaceDimension(t) - 1, t->idx_max);
}
void stopConstraint(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 39a5da94798..9bbd3f59cbf 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -76,6 +76,7 @@
#include "BKE_gpencil.h"
#include "BKE_key.h"
#include "BKE_main.h"
+#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_movieclip.h"
#include "BKE_nla.h"
@@ -124,62 +125,46 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list);
/* ************************** Functions *************************** */
-static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, TransData *temp)
+static int trans_data_compare_dist(const void *A, const void *B)
{
- TransData *ihead = head;
- TransData *itail = tail;
- *temp = *head;
+ const TransData *td_A = (const TransData*)A;
+ const TransData *td_B = (const TransData*)B;
- while (head < tail) {
- if (t->flag & T_PROP_CONNECTED) {
- while ((tail->dist >= temp->dist) && (head < tail))
- tail--;
- }
- else {
- while ((tail->rdist >= temp->rdist) && (head < tail))
- tail--;
- }
-
- if (head != tail) {
- *head = *tail;
- head++;
- }
-
- if (t->flag & T_PROP_CONNECTED) {
- while ((head->dist <= temp->dist) && (head < tail))
- head++;
- }
- else {
- while ((head->rdist <= temp->rdist) && (head < tail))
- head++;
- }
+ if (td_A->dist < td_B->dist)
+ return -1;
+ else if (td_A->dist > td_B->dist)
+ return 1;
+
+ return 0;
+}
- if (head != tail) {
- *tail = *head;
- tail--;
- }
- }
+static int trans_data_compare_rdist(const void *A, const void *B)
+{
+ const TransData *td_A = (const TransData*)A;
+ const TransData *td_B = (const TransData*)B;
- *head = *temp;
- if (ihead < head) {
- qsort_trans_data(t, ihead, head - 1, temp);
- }
- if (itail > head) {
- qsort_trans_data(t, head + 1, itail, temp);
- }
+ if (td_A->rdist < td_B->rdist)
+ return -1;
+ else if (td_A->rdist > td_B->rdist)
+ return 1;
+
+ return 0;
}
void sort_trans_data_dist(TransInfo *t)
{
- TransData temp;
TransData *start = t->data;
- int i = 1;
+ int i;
- while (i < t->total && start->flag & TD_SELECTED) {
+ for (i = 0; i < t->total && start->flag & TD_SELECTED; i++)
start++;
- i++;
+
+ if (i < t->total) {
+ if (t->flag & T_PROP_CONNECTED)
+ qsort(start, t->total - i, sizeof(TransData), trans_data_compare_dist);
+ else
+ qsort(start, t->total - i, sizeof(TransData), trans_data_compare_rdist);
}
- qsort_trans_data(t, start, t->data + t->total - 1, &temp);
}
static void sort_trans_data(TransInfo *t)
@@ -332,13 +317,9 @@ static void createTransEdge(TransInfo *t)
invert_m3_m3(smtx, mtx);
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) {
- float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT);
- float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE);
-
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) {
/* need to set center for center calculations */
- add_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
- mul_v3_fl(td->center, 0.5f);
+ mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
td->loc = NULL;
if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
@@ -346,16 +327,18 @@ static void createTransEdge(TransInfo *t)
else
td->flag = 0;
-
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
td->ext = NULL;
if (t->mode == TFM_BWEIGHT) {
+ float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT);
td->val = bweight;
td->ival = bweight ? *bweight : 1.0f;
}
else {
+ float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE);
+ BLI_assert(t->mode == TFM_CREASE);
td->val = crease;
td->ival = crease ? *crease : 0.0f;
}
@@ -419,7 +402,7 @@ static short apply_targetless_ik(Object *ob)
float rmat[4][4] /*, tmat[4][4], imat[4][4]*/;
/* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */
- /* we put in channel the entire result of rmat= (channel * constraint * IK) */
+ /* we put in channel the entire result of rmat = (channel * constraint * IK) */
/* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat */
/* rmat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */
@@ -850,7 +833,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
data = con->data;
- if (targetless) {
+ if (targetless) {
/* if exists, use values from last targetless (but disabled) IK-constraint as base */
*data = *targetless;
}
@@ -973,7 +956,7 @@ static void createTransPose(TransInfo *t, Object *ob)
if (arm->flag & ARM_RESTPOS) {
if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE) == 0) {
// XXX use transform operator reports
- // BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled");
+ // BKE_report(op->reports, RPT_ERROR, "Cannot select linked when sync selection is enabled");
return;
}
}
@@ -1830,7 +1813,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
d2 = d + len_v3(vec);
if (dists[BM_elem_index_get(v3)] != FLT_MAX)
- dists[BM_elem_index_get(v3)] = minf(d2, dists[BM_elem_index_get(v3)]);
+ dists[BM_elem_index_get(v3)] = min_ff(d2, dists[BM_elem_index_get(v3)]);
else
dists[BM_elem_index_get(v3)] = d2;
@@ -1934,6 +1917,10 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
tx->size = vs->radius;
td->val = vs->radius;
}
+ else if (t->mode == TFM_SHRINKFATTEN) {
+ td->ext = tx;
+ tx->isize[0] = BM_vert_calc_shell_factor(eve);
+ }
}
static void createTransEditVerts(TransInfo *t)
@@ -2046,7 +2033,11 @@ static void createTransEditVerts(TransInfo *t)
else t->total = countsel;
tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)");
- if (t->mode == TFM_SKIN_RESIZE) {
+ if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) {
+ /* warning, this is overkill, we only need 2 extra floats,
+ * but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill
+ * since we may not use the 'alt' transform mode to maintain shell thickness,
+ * but with generic transform code its hard to lazy init vars */
tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension),
"TransObData ext");
}
@@ -2359,6 +2350,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = CTX_data_edit_image(C);
Scene *scene = t->scene;
+ ToolSettings *ts = CTX_data_tool_settings(C);
TransData *td = NULL;
TransData2D *td2d = NULL;
MTexPoly *tf;
@@ -2367,12 +2359,26 @@ static void createTransUVs(bContext *C, TransInfo *t)
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
- int count = 0, countsel = 0;
+ UvElementMap *elementmap;
+ char *island_enabled;
+ int count = 0, countsel = 0, count_rejected = 0;
int propmode = t->flag & T_PROP_EDIT;
+ int propconnected = t->flag & T_PROP_CONNECTED;
if (!ED_space_image_show_uvedit(sima, t->obedit)) return;
/* count */
+ if (propconnected) {
+ /* create element map with island information */
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ elementmap = EDBM_uv_element_map_create (em, FALSE, TRUE);
+ }
+ else {
+ elementmap = EDBM_uv_element_map_create (em, TRUE, TRUE);
+ }
+ island_enabled = MEM_callocN(sizeof(*island_enabled) * elementmap->totalIslands, "TransIslandData(UV Editing)");
+ }
+
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
@@ -2380,14 +2386,22 @@ static void createTransUVs(bContext *C, TransInfo *t)
BM_elem_flag_disable(efa, BM_ELEM_TAG);
continue;
}
-
+
BM_elem_flag_enable(efa, BM_ELEM_TAG);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(em, scene, l))
+ if (uvedit_uv_select_test(em, scene, l)) {
countsel++;
- if (propmode)
+ if (propconnected) {
+ UvElement *element = ED_uv_element_get(elementmap, efa, l);
+ island_enabled[element->island] = TRUE;
+ }
+
+ }
+
+ if (propmode) {
count++;
+ }
}
}
@@ -2413,12 +2427,26 @@ static void createTransUVs(bContext *C, TransInfo *t)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (!propmode && !uvedit_uv_select_test(em, scene, l))
continue;
+
+ if (propconnected) {
+ UvElement *element = ED_uv_element_get(elementmap, efa, l);
+ if (!island_enabled[element->island]) {
+ count_rejected++;
+ continue;
+ }
+ }
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
UVsToTransData(sima, td++, td2d++, luv->uv, uvedit_uv_select_test(em, scene, l));
}
}
+ if (propconnected) {
+ t->total -= count_rejected;
+ EDBM_uv_element_map_free(elementmap);
+ MEM_freeN(island_enabled);
+ }
+
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_begin(t->scene, t->obedit);
}
@@ -2510,8 +2538,8 @@ void clipUVData(TransInfo *t)
if ((td->flag & TD_SKIP) || (!td->loc))
continue;
- td->loc[0] = minf(maxf(0.0f, td->loc[0]), aspx);
- td->loc[1] = minf(maxf(0.0f, td->loc[1]), aspy);
+ td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), aspx);
+ td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), aspy);
}
}
@@ -3416,14 +3444,14 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, AnimData *adt, B
if (td->flag & TD_MOVEHANDLE1) {
td2d->h1 = bezt->vec[0];
copy_v2_v2(td2d->ih1, td2d->h1);
- }
- else
+ }
+ else
td2d->h1 = NULL;
if (td->flag & TD_MOVEHANDLE2) {
td2d->h2 = bezt->vec[2];
copy_v2_v2(td2d->ih2, td2d->h2);
- }
+ }
else
td2d->h2 = NULL;
@@ -3527,7 +3555,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (sel1) count++;
if (sel3) count++;
}
- }
+ }
else if (sipo->around == V3D_LOCAL) {
/* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't
* don't get moved wrong
@@ -3622,18 +3650,18 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (sel1) {
hdata = initTransDataCurveHandles(td, bezt);
bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx);
- }
+ }
else {
- /* h1= 0; */ /* UNUSED */
+ /* h1 = 0; */ /* UNUSED */
}
if (sel3) {
if (hdata == NULL)
hdata = initTransDataCurveHandles(td, bezt);
bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx);
- }
+ }
else {
- /* h2= 0; */ /* UNUSED */
+ /* h2 = 0; */ /* UNUSED */
}
}
@@ -3986,13 +4014,13 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
*flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
if (t->frame_side == 'R') {
- if (right <= cfra) *count = *flag = 0; /* ignore */
- else if (left > cfra) ; /* keep the selection */
+ if (right <= cfra) { *count = *flag = 0; } /* ignore */
+ else if (left > cfra) { } /* keep the selection */
else *flag |= SEQ_RIGHTSEL;
}
else {
- if (left >= cfra) *count = *flag = 0; /* ignore */
- else if (right < cfra) ; /* keep the selection */
+ if (left >= cfra) { *count = *flag = 0; } /* ignore */
+ else if (right < cfra) { } /* keep the selection */
else *flag |= SEQ_LEFTSEL;
}
}
@@ -4255,15 +4283,14 @@ static void freeSeqData(TransInfo *t)
}
}
-#if 1 /* (mango hack! - for Ian) this is truely bad - should _never_ be in a release :| */
- if (CTX_wm_window(t->context)->eventstate->alt) {
+ if (t->flag & T_ALT_TRANSFORM) {
int minframe = MAXFRAME;
td = t->data;
seq_prev = NULL;
for (a = 0; a < t->total; a++, td++) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
- minframe = mini(minframe, seq->startdisp);
+ minframe = min_ii(minframe, seq->startdisp);
}
}
@@ -4293,9 +4320,6 @@ static void freeSeqData(TransInfo *t)
else {
BKE_sequence_base_shuffle_time(seqbasep, t->scene);
}
-#else
- BKE_sequence_base_shuffle_time(seqbasep, t->scene);
-#endif
if (has_effect) {
/* update effects strips based on strips just moved in time */
@@ -4469,6 +4493,7 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list)
if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1;
if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1;
if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) return 1;
+ if (con->type == CONSTRAINT_TYPE_FOLLOWTRACK) return 1;
/* constraints that require this only under special conditions */
if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
@@ -4545,7 +4570,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->irotAngle = ob->rotAngle;
copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
- // td->ext->drotAngle= ob->drotAngle; // XXX, not implemented
+ // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented
// copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
}
else {
@@ -4603,7 +4628,7 @@ static void set_trans_object_base_flags(TransInfo *t)
/*
* if Base selected and has parent selected:
- * base->flag= BA_WAS_SEL
+ * base->flag = BA_WAS_SEL
*/
Base *base;
@@ -5012,9 +5037,10 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t)
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
- //if (nodeUpdateID(t->scene->nodetree, &mask->id)) {
+ //if (nodeUpdateID(t->scene->nodetree, &mask->id))
+ {
WM_event_add_notifier(C, NC_MASK | ND_DATA, &mask->id);
- //}
+ }
}
/* TODO - dont key all masks... */
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 84158fa51c7..37dacef4a96 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -702,7 +702,7 @@ static void recalcData_view3d(TransInfo *t)
BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
nu = nu->next;
}
- }
+ }
else {
/* Normal updating */
while (nu) {
@@ -961,9 +961,9 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
/* moving: is shown in drawobject() (transform color) */
// TRANSFORM_FIX_ME
-// if (obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT;
-// else if (G.f & G_PARTICLEEDIT) G.moving= G_TRANSFORM_PARTICLE;
-// else G.moving= G_TRANSFORM_OBJ;
+// if (obedit || (t->flag & T_POSE) ) G.moving = G_TRANSFORM_EDIT;
+// else if (G.f & G_PARTICLEEDIT) G.moving = G_TRANSFORM_PARTICLE;
+// else G.moving = G_TRANSFORM_OBJ;
t->scene = sce;
t->sa = sa;
@@ -1211,7 +1211,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
/* TRANSFORM_FIX_ME rna restrictions */
if (t->prop_size <= 0.00001f) {
- printf("Proportional size (%f) under 0.00001, reseting to 1!\n", t->prop_size);
+ printf("Proportional size (%f) under 0.00001, resetting to 1!\n", t->prop_size);
t->prop_size = 1.0f;
}
@@ -1527,9 +1527,8 @@ void calculateCenterBound(TransInfo *t)
copy_v3_v3(min, t->data[i].center);
}
}
- add_v3_v3v3(t->center, min, max);
- mul_v3_fl(t->center, 0.5);
-
+ mid_v3_v3v3(t->center, min, max);
+
calculateCenter2D(t);
}
@@ -1671,8 +1670,9 @@ void calculatePropRatio(TransInfo *t)
/*
* The elements are sorted according to their dist member in the array,
* that means we can stop when it finds one element outside of the propsize.
+ * do not set 'td->flag |= TD_NOACTION', the prop circle is being changed.
*/
- td->flag |= TD_NOACTION;
+
td->factor = 0.0f;
restoreElement(td);
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 70c5e058d31..757c99594cc 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -442,7 +442,7 @@ int calc_manipulator_stats(const bContext *C)
}
else if (obedit->type == OB_MBALL) {
MetaBall *mb = (MetaBall *)obedit->data;
- MetaElem *ml /* , *ml_sel=NULL */ /* UNUSED */;
+ MetaElem *ml /* , *ml_sel = NULL */ /* UNUSED */;
ml = mb->editelems->first;
while (ml) {
@@ -499,7 +499,7 @@ int calc_manipulator_stats(const bContext *C)
}
}
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
- ;
+ /* pass */
}
else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
PTCacheEdit *edit = PE_get_current(scene, ob);
@@ -745,7 +745,7 @@ static char axisBlendAngle(float angle)
return (char)(255.0f * (angle - 5) / 15.0f);
}
-/* three colors can be set;
+/* three colors can be set:
* gray for ghosting
* moving: in transform theme color
* else the red/green/blue
@@ -782,22 +782,16 @@ static void set_manipulator_color(View3D *v3d, char axis, int colcode, unsigned
}
break;
case 'X':
- col[0] = 220;
- col[1] = 0;
- col[2] = 0;
- col[3] = alpha;
+ UI_GetThemeColor3ubv(TH_AXIS_X, col);
+ col[3] = alpha;
break;
case 'Y':
- col[0] = 0;
- col[1] = 220;
- col[2] = 0;
- col[3] = alpha;
+ UI_GetThemeColor3ubv(TH_AXIS_Y, col);
+ col[3] = alpha;
break;
case 'Z':
- col[0] = 30;
- col[1] = 30;
- col[2] = 220;
- col[3] = alpha;
+ UI_GetThemeColor3ubv(TH_AXIS_Z, col);
+ col[3] = alpha;
break;
default:
BLI_assert(!"invalid axis arg");
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 81a4c082dcc..916cf540589 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -284,7 +284,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
if (use && !CTX_wm_view3d(C)) {
- BKE_report(op->reports, RPT_ERROR, "Create Orientation \"use\" parameter only valid in a 3dView context");
+ BKE_report(op->reports, RPT_ERROR, "Create Orientation's 'use' parameter only valid in a 3DView context");
return OPERATOR_CANCELLED;
}
@@ -605,8 +605,10 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
- ot->name = "Rotate";
+ ot->name = "Rotate";
ot->description = "Rotate selected items";
ot->idname = OP_ROTATION;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
@@ -618,19 +620,22 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
+ prop = RNA_def_float(ot->srna, "value", 0.0f, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
+ RNA_def_property_subtype(prop, PROP_ANGLE);
Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP);
}
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
- ot->name = "Tilt";
+ ot->name = "Tilt";
/* optionals -
* "Tilt selected vertices"
- * "Specify an extra axis rotation for selected vertices of 3d curve" */
- ot->description = "Tilt selected control vertices of 3d curve";
+ * "Specify an extra axis rotation for selected vertices of 3D curve" */
+ ot->description = "Tilt selected control vertices of 3D curve";
ot->idname = OP_TILT;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
@@ -641,9 +646,10 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_editcurve_3d;
- RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
+ prop = RNA_def_float(ot->srna, "value", 0.0, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
+ RNA_def_property_subtype(prop, PROP_ANGLE);
- Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 0e25739c34a..70e4d4cd027 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -142,7 +142,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports)
strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
}
- return addMatrixSpace(C, mat, name, overwrite);
+ return addMatrixSpace(C, mat, name, overwrite);
}
TransformOrientation *createBoneSpace(bContext *C, ReportList *reports, char *name, int overwrite)
@@ -631,7 +631,6 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
/* if there's an edge available, use that for the tangent */
if (em->bm->totedgesel >= 1) {
BMEdge *eed = NULL;
- BMIter iter;
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
@@ -746,14 +745,14 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
MetaBall *mb = obedit->data;
if (mb->lastelem) {
- float mat[4][4];
+ float qmat[3][3];
/* Rotation of MetaElem is stored in quat */
- quat_to_mat4(mat, mb->lastelem->quat);
+ quat_to_mat3(qmat, mb->lastelem->quat);
- copy_v3_v3(normal, mat[2]);
+ copy_v3_v3(normal, qmat[2]);
- negate_v3_v3(plane, mat[1]);
+ negate_v3_v3(plane, qmat[1]);
result = ORIENTATION_FACE;
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index a206e17d32b..2908df41aa3 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -78,8 +78,6 @@
#include "transform.h"
-#define USE_BVH_FACE_SNAP
-
#define TRANSFORM_DIST_MAX_PX 1000
/********************* PROTOTYPES ***********************/
@@ -189,7 +187,7 @@ void applyProject(TransInfo *t)
copy_v3_v3(iloc, td->ob->obmat[3]);
}
- if (ED_view3d_project_float_global(t->ar, iloc, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_float_global(t->ar, iloc, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) {
// if (t->flag & (T_EDIT|T_POSE)) {
// mul_m4_v3(imat, loc);
@@ -475,7 +473,7 @@ int updateSelectedSnapPoint(TransInfo *t)
int dx, dy;
int dist;
- if (ED_view3d_project_int_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
continue;
}
@@ -595,14 +593,14 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3])
{
float angle, start[3], end[3], center[3];
- copy_v3_v3(center, t->center);
+ copy_v3_v3(center, t->center);
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, center);
}
sub_v3_v3v3(start, p1, center);
- sub_v3_v3v3(end, p2, center);
+ sub_v3_v3v3(end, p2, center);
// Angle around a constraint axis (error prone, will need debug)
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
@@ -651,7 +649,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
{
float d1[3], d2[3], center[3], len_d1;
- copy_v3_v3(center, t->center);
+ copy_v3_v3(center, t->center);
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, center);
@@ -718,7 +716,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
p2 = NULL;
p1->flag = 1;
- /* if peeling objects, take the first and last from each object */
+ /* if peeling objects, take the first and last from each object */
if (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) {
DepthPeel *peel;
for (peel = p1->next; peel; peel = peel->next) {
@@ -854,7 +852,7 @@ static void TargetSnapCenter(TransInfo *t)
{
/* Only need to calculate once */
if ((t->tsnap.status & TARGET_INIT) == 0) {
- copy_v3_v3(t->tsnap.snapTarget, t->center);
+ copy_v3_v3(t->tsnap.snapTarget, t->center);
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
@@ -863,7 +861,7 @@ static void TargetSnapCenter(TransInfo *t)
TargetSnapOffset(t, NULL);
- t->tsnap.status |= TARGET_INIT;
+ t->tsnap.status |= TARGET_INIT;
}
}
@@ -899,7 +897,7 @@ static void TargetSnapActive(TransInfo *t)
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
t->tsnap.targetSnap = TargetSnapMedian;
TargetSnapMedian(t);
- }
+ }
}
}
@@ -927,7 +925,7 @@ static void TargetSnapMedian(TransInfo *t)
TargetSnapOffset(t, NULL);
- t->tsnap.status |= TARGET_INIT;
+ t->tsnap.status |= TARGET_INIT;
}
}
@@ -1008,58 +1006,6 @@ static void TargetSnapClosest(TransInfo *t)
t->tsnap.status |= TARGET_INIT;
}
}
-/*================================================================*/
-#ifndef USE_BVH_FACE_SNAP
-static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4co, float mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float loc[3], float no[3], int *dist, float *depth)
-{
- float lambda;
- int result;
- int retval = 0;
-
- result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, v1co, v2co, v3co, &lambda, NULL, 0.001);
-
- if (result) {
- float location[3], normal[3];
- float intersect[3];
- float new_depth;
- int screen_loc[2];
- int new_dist;
-
- copy_v3_v3(intersect, ray_normal_local);
- mul_v3_fl(intersect, lambda);
- add_v3_v3(intersect, ray_start_local);
-
- copy_v3_v3(location, intersect);
-
- if (v4co)
- normal_quad_v3(normal, v1co, v2co, v3co, v4co);
- else
- normal_tri_v3(normal, v1co, v2co, v3co);
-
- mul_m4_v3(obmat, location);
-
- new_depth = len_v3v3(location, ray_start);
-
- ED_view3d_project_int(ar, location, screen_loc);
- new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
-
- if (new_dist <= *dist && new_depth < *depth) {
- *depth = new_depth;
- retval = 1;
-
- copy_v3_v3(loc, location);
- copy_v3_v3(no, normal);
-
- mul_m3_v3(timat, no);
- normalize_v3(no);
-
- *dist = new_dist;
- }
- }
-
- return retval;
-}
-#endif
static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float obmat[][4], float timat[][3],
const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
@@ -1106,9 +1052,9 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
mul_m4_v3(obmat, location);
- new_depth = len_v3v3(location, ray_start);
+ new_depth = len_v3v3(location, ray_start);
- if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
}
else {
@@ -1131,17 +1077,17 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc);
if (r_no) {
- normal_short_to_float_v3(n1, v1no);
+ normal_short_to_float_v3(n1, v1no);
normal_short_to_float_v3(n2, v2no);
interp_v3_v3v3(r_no, n2, n1, mul);
mul_m3_v3(timat, r_no);
normalize_v3(r_no);
- }
+ }
copy_v3_v3(r_loc, location);
*r_dist = new_dist;
- }
+ }
}
}
@@ -1169,7 +1115,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
new_depth = len_v3v3(location, ray_start);
- if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
}
else {
@@ -1190,7 +1136,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
}
*r_dist = new_dist;
- }
+ }
}
return retval;
@@ -1297,8 +1243,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
switch (snap_mode) {
case SCE_SNAP_MODE_FACE:
- {
-#ifdef USE_BVH_FACE_SNAP // Added for durian
+ {
BVHTreeRayHit hit;
BVHTreeFromMesh treeData;
@@ -1328,80 +1273,6 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
}
}
break;
-
-#else
- MVert *verts = dm->getVertArray(dm);
- MFace *faces = dm->getTessFaceArray(dm);
- int *index_array = NULL;
- int index = 0;
- int i;
-
- if (em != NULL) {
- index_array = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- EDBM_index_arrays_init(em, 0, 0, 1);
- }
-
- for (i = 0; i < totface; i++) {
- BMFace *efa = NULL;
- MFace *f = faces + i;
-
- test = 1; /* reset for every face */
-
- if (em != NULL) {
- if (index_array) {
- index = index_array[i];
- }
- else {
- index = i;
- }
-
- if (index == ORIGINDEX_NONE) {
- test = 0;
- }
- else {
- efa = EDBM_face_at_index(em, index);
-
- if (efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- test = 0;
- }
- else if (efa) {
- BMIter iter;
- BMLoop *l;
-
- l = BM_iter_new(&iter, em->bm, BM_LOOPS_OF_FACE, efa);
- for (; l; l = BM_iter_step(&iter)) {
- if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) {
- test = 0;
- break;
- }
- }
- }
- }
- }
-
-
- if (test) {
- int result;
- float *v4co = NULL;
-
- if (f->v4) {
- v4co = verts[f->v4].co;
- }
-
- result = snapFace(ar, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, v4co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
- retval |= result;
-
- if (f->v4 && result == 0) {
- retval |= snapFace(ar, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, verts[f->v2].co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
- }
- }
- }
-
- if (em != NULL) {
- EDBM_index_arrays_free(em);
- }
-#endif
- break;
}
case SCE_SNAP_MODE_VERTEX:
{
@@ -1730,7 +1601,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4],
mul_m4_v3(obmat, location);
- new_depth = len_v3v3(location, ray_start);
+ new_depth = len_v3v3(location, ray_start);
mul_m3_v3(timat, normal);
normalize_v3(normal);
@@ -1765,7 +1636,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4],
normalize_v3(normal);
addDepthPeel(depth_peels, new_depth, location, normal, ob);
- }
+ }
}
}
}
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c
index b0edc702e48..e953aa2f0ed 100644
--- a/source/blender/editors/util/crazyspace.c
+++ b/source/blender/editors/util/crazyspace.c
@@ -409,7 +409,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3
MEM_freeN(quats);
}
- if (!*deformmats) {
+ if (*deformmats == NULL) {
int a, numVerts;
Mesh *me = (Mesh *)ob->data;
diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c
index 9a3b0476205..c8c26ed771d 100644
--- a/source/blender/editors/util/editmode_undo.c
+++ b/source/blender/editors/util/editmode_undo.c
@@ -104,7 +104,7 @@ static UndoElem *curundo = NULL;
static void undo_restore(UndoElem *undo, void *editdata, void *obdata)
{
if (undo) {
- undo->to_editmode(undo->undodata, editdata, obdata);
+ undo->to_editmode(undo->undodata, editdata, obdata);
}
}
@@ -233,7 +233,7 @@ static void undo_clean_stack(bContext *C)
if (curundo == NULL) curundo = undobase.last;
}
-/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
+/* 1 = an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
void undo_editmode_step(bContext *C, int step)
{
Object *obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 5eafc3e65a9..1753a564a3c 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -505,7 +505,7 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
MEM_freeN(item);
uiPupMenuEnd(C, pup);
- }
+ }
}
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 7b9aebde25a..a5a8b85b0b5 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -462,8 +462,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
int drawfaces, interpedges;
Image *ima = sima->image;
- StitchPreviewer *stitch_preview = uv_get_stitch_previewer();
-
gpuImmediateFormat_C4_V2();
activetf = EDBM_mtexpoly_active_get(em, &efa_act, FALSE, FALSE); /* will be set to NULL if hidden */
@@ -546,7 +544,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY);
- if (uvedit_face_visible_test(scene, ima, efa, tf)) {
+ if (uvedit_face_visible_test(scene, ima, efa, tf)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
}
else {
@@ -831,56 +829,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
gpuEndSprites();
}
- /* finally draw stitch preview */
- if (stitch_preview) {
- int i, index = 0;
- GPUarrays arrays = GPU_ARRAYS_V2F;
-
- glEnable(GL_BLEND);
-
- gpuImmediateFormat_V2();
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- UI_ThemeColor4(TH_STITCH_PREVIEW_ACTIVE);
- arrays.vertexPointer = stitch_preview->static_tris;
- gpuDrawClientArrays(GL_TRIANGLES, &arrays, 0, 3 * stitch_preview->num_static_tris);
-
- for (i = 0; i < stitch_preview->num_polys; i++) {
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- UI_ThemeColor4(TH_STITCH_PREVIEW_FACE);
- arrays.vertexPointer = stitch_preview->preview_polys;
- gpuDrawClientArrays(GL_TRIANGLE_FAN, &arrays, index, stitch_preview->uvs_per_polygon[i]);
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- UI_ThemeColor4(TH_STITCH_PREVIEW_EDGE);
- gpuRepeat();
-
- index += stitch_preview->uvs_per_polygon[i];
- }
- glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
-#if 0
- UI_ThemeColor4(TH_STITCH_PREVIEW_VERT);
- gpuDrawClientArrays_V3F(GL_TRIANGLES, stitch_preview->preview_polys, 0, 0, 3 * stitch_preview->num_tris);
-#endif
- glDisable(GL_BLEND);
-
- /* draw vert preview */
-
- glPointSize(pointsize * 2.0f);
-
- UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
- arrays.vertexPointer = stitch_preview->preview_stitchable;
- gpuDrawClientArrays(GL_POINTS, &arrays, 0, stitch_preview->num_stitchable);
-
- UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
- arrays.vertexPointer = stitch_preview->preview_unstitchable;
- gpuDrawClientArrays(GL_POINTS, &arrays, 0, stitch_preview->num_unstitchable);
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- gpuImmediateUnformat();
- }
-
glPointSize(1.0);
gpuImmediateUnformat();
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index f0ff79ae25e..b42875f20c2 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -72,33 +72,8 @@ void uv_find_nearest_edge(struct Scene *scene, struct Image *ima, struct BMEditM
/* utility tool functions */
-struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l);
void uvedit_live_unwrap_update(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit);
-/* smart stitch */
-
-/* object that stores display data for previewing before accepting stitching */
-typedef struct StitchPreviewer {
- /* here we'll store the preview triangle indices of the mesh */
- float *preview_polys;
- /* uvs per polygon. */
- unsigned int *uvs_per_polygon;
- /*number of preview polygons */
- unsigned int num_polys;
- /* preview data. These will be either the previewed vertices or edges depending on stitch mode settings */
- float *preview_stitchable;
- float *preview_unstitchable;
- /* here we'll store the number of elements to be drawn */
- unsigned int num_stitchable;
- unsigned int num_unstitchable;
- unsigned int preview_uvs;
- /* ...and here we'll store the triangles*/
- float *static_tris;
- unsigned int num_static_tris;
-} StitchPreviewer;
-
-StitchPreviewer *uv_get_stitch_previewer(void);
-
/* operators */
void UV_OT_average_islands_scale(struct wmOperatorType *ot);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 8abcfd95a64..d3d85c19487 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -170,7 +170,6 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i
void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *ima, Image *previma)
{
BMEditMesh *em;
- BMFace *efa;
BMIter iter;
MTexPoly *tf;
int update = 0;
@@ -198,6 +197,8 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im
ED_object_assign_active_image(bmain, obedit, efa->mat_nr + 1, ima);
}
else {
+ BMFace *efa;
+
/* old shading system, assign image to selected faces */
#ifdef USE_SWITCH_ASPECT
float prev_aspect[2], fprev_aspect;
@@ -214,6 +215,8 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im
if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY);
BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV);
+ /* make UVs all nice 0-1 */
+ ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer_index(&em->bm->pdata, CD_MTEXPOLY));
update = 1;
}
@@ -771,13 +774,15 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i
BM_ITER_ELEM (l, &iter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if (i == id1)
+ if (i == id1) {
uv1 = luv->uv;
- else if (i == id)
- ; /* uv2 = luv->uv; */ /* UNUSED */
- else if (i == id2)
+ }
+ else if (i == id) {
+ /* uv2 = luv->uv; */ /* UNUSED */
+ }
+ else if (i == id2) {
uv3 = luv->uv;
-
+ }
i++;
}
@@ -892,19 +897,6 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float c
return found;
}
-UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l)
-{
- UvElement *element;
-
- element = map->vert[BM_elem_index_get(l->v)];
-
- for (; element; element = element->next)
- if (element->face == efa)
- return element;
-
- return NULL;
-}
-
/*********************** loop select ***********************/
static void select_edgeloop_uv_vertex_loop_flag(UvMapVert *first)
@@ -1310,9 +1302,7 @@ static void weld_align_uv(bContext *C, int tool)
Object *obedit;
Image *ima;
BMEditMesh *em;
- BMIter iter, liter;
MTexPoly *tf;
- MLoopUV *luv;
float cent[2], min[2], max[2];
scene = CTX_data_scene(C);
@@ -1324,6 +1314,7 @@ static void weld_align_uv(bContext *C, int tool)
INIT_MINMAX2(min, max);
if (tool == 'a') {
+ BMIter iter, liter;
BMFace *efa;
BMLoop *l;
@@ -1335,7 +1326,7 @@ static void weld_align_uv(bContext *C, int tool)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(em, scene, l)) {
- luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
+ MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
DO_MINMAX2(luv->uv, min, max);
}
}
@@ -1347,6 +1338,7 @@ static void weld_align_uv(bContext *C, int tool)
uvedit_center(scene, ima, obedit, cent, 0);
if (tool == 'x' || tool == 'w') {
+ BMIter iter, liter;
BMFace *efa;
BMLoop *l;
@@ -1357,7 +1349,7 @@ static void weld_align_uv(bContext *C, int tool)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(em, scene, l)) {
- luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
+ MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
luv->uv[0] = cent[0];
}
@@ -1366,6 +1358,7 @@ static void weld_align_uv(bContext *C, int tool)
}
if (tool == 'y' || tool == 'w') {
+ BMIter iter, liter;
BMFace *efa;
BMLoop *l;
@@ -1376,7 +1369,7 @@ static void weld_align_uv(bContext *C, int tool)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(em, scene, l)) {
- luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
+ MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
luv->uv[1] = cent[1];
}
@@ -1949,7 +1942,7 @@ static int mouse_select(bContext *C, const float co[2], int extend, int loop)
}
flush = 1;
- }
+ }
}
}
else {
@@ -2131,7 +2124,7 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i
NearestHit hit, *hit_p = NULL;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled");
+ BKE_report(op->reports, RPT_ERROR, "Cannot select linked when sync selection is enabled");
return OPERATOR_CANCELLED;
}
@@ -2238,7 +2231,7 @@ static int select_split_exec(bContext *C, wmOperator *op)
short change = FALSE;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- BKE_report(op->reports, RPT_ERROR, "Can't split selection when sync selection is enabled");
+ BKE_report(op->reports, RPT_ERROR, "Cannot split selection when sync selection is enabled");
return OPERATOR_CANCELLED;
}
@@ -2279,6 +2272,7 @@ static int select_split_exec(bContext *C, wmOperator *op)
}
if (change) {
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
return OPERATOR_FINISHED;
}
else {
@@ -2316,7 +2310,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op)
MLoopUV *luv;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- BKE_report(op->reports, RPT_ERROR, "Can't unlink selection when sync selection is enabled");
+ BKE_report(op->reports, RPT_ERROR, "Cannot unlink selection when sync selection is enabled");
return OPERATOR_CANCELLED;
}
@@ -2487,13 +2481,16 @@ static void uv_faces_do_sticky(SpaceImage *sima, Scene *scene, Object *obedit, s
break;
if (efa_index != vlist_iter->f) {
+ BMLoop *l_other;
efa_vlist = EDBM_face_at_index(em, vlist_iter->f);
/* tf_vlist = CustomData_bmesh_get(&em->bm->pdata, efa_vlist->head.data, CD_MTEXPOLY); */ /* UNUSED */
+ l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex);
+
if (select)
- uvedit_uv_select_enable(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex), FALSE);
+ uvedit_uv_select_enable(em, scene, l_other, FALSE);
else
- uvedit_uv_select_disable(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex));
+ uvedit_uv_select_disable(em, scene, l_other);
}
vlist_iter = vlist_iter->next;
}
@@ -2827,7 +2824,7 @@ static int uv_lasso_select_exec(bContext *C, wmOperator *op)
select = !RNA_boolean_get(op->ptr, "deselect");
change = do_lasso_select_mesh_uv(C, mcords, mcords_tot, select);
- MEM_freeN(mcords);
+ MEM_freeN((void *)mcords);
return change ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index f017394356e..5b6125b558b 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -1566,7 +1566,7 @@ static void p_vert_harmonic_insert(PVert *v)
e = v->edge;
do {
- npoints++;
+ npoints++;
e = p_wheel_edge_next(e);
} while (e && (e != v->edge));
@@ -3306,7 +3306,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
trusted_radius /= 2 * nedges;
- random_angle = rng_getFloat(rng) * 2.0f * (float)M_PI;
+ random_angle = BLI_rng_get_float(rng) * 2.0f * (float)M_PI;
dir[0] = trusted_radius * cosf(random_angle);
dir[1] = trusted_radius * sinf(random_angle);
@@ -3988,7 +3988,7 @@ static void p_smooth(PChart *chart)
diff[1] = p[1] - oldp[1];
length = sqrt(diff[0] * diff[0] + diff[1] * diff[1]);
- d = MAX2(d, length);
+ d = max_ff(d, length);
moved += length;
}
}
@@ -4285,7 +4285,7 @@ void param_stretch_begin(ParamHandle *handle)
param_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED);
phandle->state = PHANDLE_STATE_STRETCH;
- phandle->rng = rng_new(31415926);
+ phandle->rng = BLI_rng_new(31415926);
phandle->blend = 0.0f;
for (i = 0; i < phandle->ncharts; i++) {
@@ -4332,7 +4332,7 @@ void param_stretch_end(ParamHandle *handle)
param_assert(phandle->state == PHANDLE_STATE_STRETCH);
phandle->state = PHANDLE_STATE_CONSTRUCTED;
- rng_free(phandle->rng);
+ BLI_rng_free(phandle->rng);
phandle->rng = NULL;
}
@@ -4400,7 +4400,7 @@ void param_pack(ParamHandle *handle, float margin)
if (margin > 0.0f)
area += sqrt(box->w * box->h);
- }
+ }
if (margin > 0.0f) {
/* multiply the margin by the area to give predictable results not dependent on UV scale,
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 4e0e7944e84..4f6aa224586 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -55,6 +55,7 @@
#include "ED_mesh.h"
#include "ED_uvedit.h"
#include "ED_screen.h"
+#include "ED_space_api.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -63,11 +64,34 @@
#include "WM_types.h"
#include "UI_view2d.h"
+#include "UI_resources.h"
+
+#include "GPU_compatibility.h"
#include "uvedit_intern.h"
/* ********************** smart stitch operator *********************** */
+/* object that stores display data for previewing before accepting stitching */
+typedef struct StitchPreviewer {
+ /* here we'll store the preview triangle indices of the mesh */
+ float *preview_polys;
+ /* uvs per polygon. */
+ unsigned int *uvs_per_polygon;
+ /*number of preview polygons */
+ unsigned int num_polys;
+ /* preview data. These will be either the previewed vertices or edges depending on stitch mode settings */
+ float *preview_stitchable;
+ float *preview_unstitchable;
+ /* here we'll store the number of elements to be drawn */
+ unsigned int num_stitchable;
+ unsigned int num_unstitchable;
+ unsigned int preview_uvs;
+ /* ...and here we'll store the triangles*/
+ float *static_tris;
+ unsigned int num_static_tris;
+} StitchPreviewer;
+
struct IslandStitchData;
@@ -143,6 +167,8 @@ typedef struct StitchState {
int static_island;
/* store number of primitives per face so that we can allocate the active island buffer later */
unsigned int *tris_per_island;
+
+ void *draw_handle;
} StitchState;
typedef struct PreviewPosition {
@@ -216,7 +242,7 @@ static void stitch_preview_delete(void)
/* "getter method" */
-StitchPreviewer *uv_get_stitch_previewer(void)
+static StitchPreviewer *uv_get_stitch_previewer(void)
{
return _stitch_preview;
}
@@ -406,8 +432,8 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta
edgesin = uv1[0] * uv2[1] - uv2[0] * uv1[1];
rotation = (edgesin > 0.0f) ?
- +acosf(maxf(-1.0f, minf(1.0f, edgecos))) :
- -acosf(maxf(-1.0f, minf(1.0f, edgecos)));
+ +acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))) :
+ -acosf(max_ff(-1.0f, min_ff(1.0f, edgecos)));
island_stitch_data[element1->island].num_rot_elements++;
island_stitch_data[element1->island].rotation += rotation;
@@ -981,6 +1007,55 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no
normalize_v2(normal);
}
+static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *UNUSED(arg))
+{
+ int i, index = 0;
+ float pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
+ StitchPreviewer *stitch_preview = uv_get_stitch_previewer();
+
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glEnable(GL_BLEND);
+
+ UI_ThemeColor4(TH_STITCH_PREVIEW_ACTIVE);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glVertexPointer(2, GL_FLOAT, 0, stitch_preview->static_tris);
+ glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_static_tris * 3);
+
+ glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_polys);
+ for (i = 0; i < stitch_preview->num_polys; i++) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ UI_ThemeColor4(TH_STITCH_PREVIEW_FACE);
+ glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ UI_ThemeColor4(TH_STITCH_PREVIEW_EDGE);
+ glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]);
+
+ index += stitch_preview->uvs_per_polygon[i];
+ }
+ glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+#if 0
+ UI_ThemeColor4(TH_STITCH_PREVIEW_VERT);
+ glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_tris * 3);
+#endif
+ glDisable(GL_BLEND);
+
+ /* draw vert preview */
+ glPointSize(pointsize * 2.0f);
+ UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
+ glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_stitchable);
+ glDrawArrays(GL_POINTS, 0, stitch_preview->num_stitchable);
+
+ UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
+ glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_unstitchable);
+ glDrawArrays(GL_POINTS, 0, stitch_preview->num_unstitchable);
+
+ glPopClientAttrib();
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+}
+
static int stitch_init(bContext *C, wmOperator *op)
{
/* for fast edge lookup... */
@@ -1016,6 +1091,7 @@ static int stitch_init(bContext *C, wmOperator *op)
state->static_island = RNA_int_get(op->ptr, "static_island");
state->midpoints = RNA_boolean_get(op->ptr, "midpoint_snap");
state->clear_seams = RNA_boolean_get(op->ptr, "clear_seams");
+ state->draw_handle = ED_region_draw_cb_activate(CTX_wm_region(C)->type, stitch_draw, NULL, REGION_DRAW_POST_VIEW);
/* in uv synch selection, all uv's are visible */
if (ts->uv_flag & UV_SYNC_SELECTION) {
state->element_map = EDBM_uv_element_map_create(state->em, 0, 1);
@@ -1282,6 +1358,8 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
if (sa)
ED_area_headerprint(sa, NULL);
+ ED_region_draw_cb_exit(CTX_wm_region(C)->type, stitch_state->draw_handle);
+
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 7c06fbd2a9d..f615902eedf 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -60,6 +60,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_tessmesh.h"
#include "BLI_math.h"
@@ -177,7 +178,33 @@ static int uvedit_have_selection(Scene *scene, BMEditMesh *em, short implicit)
return 0;
}
-static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
+static void ED_uvedit_get_aspect(Scene *scene, Object *ob, BMEditMesh *em, float *aspx, float *aspy)
+{
+ int sloppy = TRUE;
+ int selected = FALSE;
+ BMFace *efa;
+ Image *ima;
+
+ efa = BM_active_face_get(em->bm, sloppy, selected);
+
+ if (efa) {
+ if (BKE_scene_use_new_shading_nodes(scene)) {
+ ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, NULL, NULL);
+ }
+ else {
+ MTexPoly *tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+ ima = tf->tpage;
+ }
+
+ ED_image_get_uv_aspect(ima, NULL, aspx, aspy);
+ }
+ else {
+ *aspx = 1.0f;
+ *aspy = 1.0f;
+ }
+}
+
+static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMEditMesh *em,
short implicit, short fill, short sel,
short correct_aspect)
{
@@ -187,27 +214,16 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
- MTexPoly *tf;
handle = param_construct_begin();
if (correct_aspect) {
- int sloppy = TRUE;
- int selected = FALSE;
-
- efa = BM_active_face_get(em->bm, sloppy, selected);
+ float aspx, aspy;
- if (efa) {
- float aspx, aspy;
- tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+ ED_uvedit_get_aspect(scene, ob, em, &aspx, &aspy);
- ED_image_get_uv_aspect(tf->tpage, NULL, &aspx, &aspy);
-
- if (aspx != aspy)
- param_aspect_ratio(handle, aspx, aspy);
- else
- param_aspect_ratio(handle, 1.0, 1.0);
- }
+ if (aspx != aspy)
+ param_aspect_ratio(handle, aspx, aspy);
}
/* we need the vert indices */
@@ -223,7 +239,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BMLoop *ls[3];
float *co[4];
float *uv[4];
- int i, lsel;
+ int lsel;
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0))
continue;
@@ -245,6 +261,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
// tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); // UNUSED
if (efa->len == 3 || efa->len == 4) {
+ int i;
/* for quads let parametrize split, it can make better decisions
* about which split is best for unwrapping than scanfill */
i = 0;
@@ -291,6 +308,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BLI_scanfill_calc_ex(&sf_ctx, TRUE, efa->no);
for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) {
+ int i;
ls[0] = sf_tri->v1->tmp.p;
ls[1] = sf_tri->v2->tmp.p;
ls[2] = sf_tri->v3->tmp.p;
@@ -353,13 +371,12 @@ static void texface_from_original_index(BMFace *efa, int index, float **uv, Para
/* unwrap handle initialization for subsurf aware-unwrapper. The many modifications required to make the original function(see above)
* work justified the existence of a new function. */
-static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *em, short fill, short sel, short correct_aspect)
+static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, BMEditMesh *em, short fill, short sel, short correct_aspect)
{
ParamHandle *handle;
/* index pointers */
MFace *face;
MEdge *edge;
- BMFace *editFace;
int i;
/* modifier initialization data, will control what type of subdivision will happen*/
@@ -367,7 +384,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
/* Used to hold subsurfed Mesh */
DerivedMesh *derivedMesh, *initialDerived;
/* holds original indices for subsurfed mesh */
- int *origVertIndices, *origFaceIndices, *origEdgeIndices;
+ int *origVertIndices, *origEdgeIndices, *origFaceIndices, *origPolyIndices;
/* Holds vertices of subsurfed mesh */
MVert *subsurfedVerts;
MEdge *subsurfedEdges;
@@ -383,30 +400,19 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
handle = param_construct_begin();
if (correct_aspect) {
- int sloppy = TRUE;
- int selected = FALSE;
-
- editFace = BM_active_face_get(em->bm, sloppy, selected);
-
- if (editFace) {
- MTexPoly *tf;
- float aspx, aspy;
- tf = CustomData_bmesh_get(&em->bm->pdata, editFace->head.data, CD_MTEXPOLY);
+ float aspx, aspy;
- ED_image_get_uv_aspect(tf->tpage, NULL, &aspx, &aspy);
+ ED_uvedit_get_aspect(scene, ob, em, &aspx, &aspy);
- if (aspx != aspy)
- param_aspect_ratio(handle, aspx, aspy);
- else
- param_aspect_ratio(handle, 1.0, 1.0);
- }
+ if (aspx != aspy)
+ param_aspect_ratio(handle, aspx, aspy);
}
/* number of subdivisions to perform */
smd.levels = scene->toolsettings->uv_subsurf_level;
smd.subdivType = ME_CC_SUBSURF;
- initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0);
+ initialDerived = CDDM_from_editbmesh(em, FALSE, FALSE);
derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd,
NULL, SUBSURF_IN_EDIT_MODE);
@@ -420,6 +426,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
origVertIndices = derivedMesh->getVertDataArray(derivedMesh, CD_ORIGINDEX);
origEdgeIndices = derivedMesh->getEdgeDataArray(derivedMesh, CD_ORIGINDEX);
origFaceIndices = derivedMesh->getTessFaceDataArray(derivedMesh, CD_ORIGINDEX);
+ origPolyIndices = derivedMesh->getPolyDataArray(derivedMesh, CD_ORIGINDEX);
numOfEdges = derivedMesh->getNumEdges(derivedMesh);
numOfFaces = derivedMesh->getNumTessFaces(derivedMesh);
@@ -431,7 +438,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
/* map subsurfed faces to original editFaces */
for (i = 0; i < numOfFaces; i++)
- faceMap[i] = EDBM_face_at_index(em, origFaceIndices[i]);
+ faceMap[i] = EDBM_face_at_index(em, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i));
edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map");
@@ -538,7 +545,7 @@ static int minimize_stretch_init(bContext *C, wmOperator *op)
ms->blend = RNA_float_get(op->ptr, "blend");
ms->iterations = RNA_int_get(op->ptr, "iterations");
ms->i = 0;
- ms->handle = construct_param_handle(scene, em, implicit, fill_holes, 1, 1);
+ ms->handle = construct_param_handle(scene, obedit, em, implicit, fill_holes, 1, 1);
ms->lasttime = PIL_check_seconds_timer();
param_stretch_begin(ms->handle);
@@ -727,14 +734,12 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (RNA_struct_property_is_set(op->ptr, "margin")) {
+ if (RNA_struct_property_is_set(op->ptr, "margin"))
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- }
- else {
+ else
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
- }
- handle = construct_param_handle(scene, em, implicit, 0, 1, 1);
+ handle = construct_param_handle(scene, obedit, em, implicit, 0, 1, 1);
param_pack(handle, scene->toolsettings->uvcalc_margin);
param_flush(handle);
param_delete(handle);
@@ -759,7 +764,7 @@ void UV_OT_pack_islands(wmOperatorType *ot)
ot->poll = ED_operator_uvedit;
/* properties */
- RNA_def_float_factor(ot->srna, "margin", 0.0f, 0.0f, 1.0f, "Margin", "Space between islands", 0.0f, 1.0f);
+ RNA_def_float_factor(ot->srna, "margin", 0.001f, 0.0f, 1.0f, "Margin", "Space between islands", 0.0f, 1.0f);
}
/* ******************** Average Islands Scale operator **************** */
@@ -776,7 +781,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- handle = construct_param_handle(scene, em, implicit, 0, 1, 1);
+ handle = construct_param_handle(scene, obedit, em, implicit, 0, 1, 1);
param_average(handle);
param_flush(handle);
param_delete(handle);
@@ -817,9 +822,9 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
}
if (use_subsurf)
- liveHandle = construct_param_handle_subsurfed(scene, em, fillholes, 0, 1);
+ liveHandle = construct_param_handle_subsurfed(scene, obedit, em, fillholes, 0, 1);
else
- liveHandle = construct_param_handle(scene, em, 0, fillholes, 0, 1);
+ liveHandle = construct_param_handle(scene, obedit, em, 0, fillholes, 0, 1);
param_lscm_begin(liveHandle, PARAM_TRUE, abf);
}
@@ -1007,22 +1012,15 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
"Radius of the sphere or cylinder", 0.0001f, 100.0f);
}
-static void correct_uv_aspect(BMEditMesh *em)
+static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
{
- int sloppy = TRUE;
- int selected = FALSE;
- BMFace *efa = BM_active_face_get(em->bm, sloppy, selected);
BMLoop *l;
BMIter iter, liter;
MLoopUV *luv;
- float scale, aspx = 1.0f, aspy = 1.0f;
+ BMFace *efa;
+ float scale, aspx, aspy;
- if (efa) {
- MTexPoly *tf;
-
- tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- ED_image_get_uv_aspect(tf->tpage, NULL, &aspx, &aspy);
- }
+ ED_uvedit_get_aspect(scene, ob, em, &aspx, &aspy);
if (aspx == aspy)
return;
@@ -1067,7 +1065,7 @@ static void uv_map_clip_correct_properties(wmOperatorType *ot)
"Scale UV coordinates to bounds after unwrapping");
}
-static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
+static void uv_map_clip_correct(Scene *scene, Object *ob, BMEditMesh *em, wmOperator *op)
{
BMFace *efa;
BMLoop *l;
@@ -1080,7 +1078,7 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
/* correct for image aspect ratio */
if (correct_aspect)
- correct_uv_aspect(em);
+ correct_uv_aspect(scene, ob, em);
if (scale_to_bounds) {
INIT_MINMAX2(min, max);
@@ -1144,9 +1142,9 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
const short use_subsurf = scene->toolsettings->uvcalc_flag & UVCALC_USESUBSURF;
if (use_subsurf)
- handle = construct_param_handle_subsurfed(scene, em, fill_holes, sel, correct_aspect);
+ handle = construct_param_handle_subsurfed(scene, obedit, em, fill_holes, sel, correct_aspect);
else
- handle = construct_param_handle(scene, em, 0, fill_holes, sel, correct_aspect);
+ handle = construct_param_handle(scene, obedit, em, 0, fill_holes, sel, correct_aspect);
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
@@ -1170,7 +1168,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
int correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect");
int use_subsurf = RNA_boolean_get(op->ptr, "use_subsurf_data");
int subsurf_level = RNA_int_get(op->ptr, "uv_subsurf_level");
- float obsize[3], unitsize[3] = {1.0f, 1.0f, 1.0f};
+ float obsize[3];
short implicit = 0;
if (!uvedit_have_selection(scene, em, implicit)) {
@@ -1183,8 +1181,9 @@ static int unwrap_exec(bContext *C, wmOperator *op)
}
mat4_to_size(obsize, obedit->obmat);
- if (!compare_v3v3(obsize, unitsize, 1e-4f))
- BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh.");
+ if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f))
+ BKE_report(op->reports, RPT_INFO,
+ "Object has non-uniform scale, unwrap will operate on a non-scaled version of the mesh");
/* remember last method for live unwrap */
if (RNA_struct_property_is_set(op->ptr, "method"))
@@ -1192,6 +1191,12 @@ static int unwrap_exec(bContext *C, wmOperator *op)
else
RNA_enum_set(op->ptr, "method", scene->toolsettings->unwrapper);
+ /* remember packing marging */
+ if (RNA_struct_property_is_set(op->ptr, "margin"))
+ scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
+ else
+ RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+
scene->toolsettings->uv_subsurf_level = subsurf_level;
if (fill_holes) scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES;
@@ -1239,8 +1244,9 @@ void UV_OT_unwrap(wmOperatorType *ot)
"Map UVs taking image aspect ratio into account");
RNA_def_boolean(ot->srna, "use_subsurf_data", 0, "Use Subsurf Data",
"Map UVs taking vertex position after subsurf into account");
- RNA_def_int(ot->srna, "uv_subsurf_level", 1, 1, 6, "SubSurf Target",
+ RNA_def_int(ot->srna, "uv_subsurf_level", 1, 1, 6, "Subsurf Target",
"Number of times to subdivide before calculating UVs", 1, 6);
+ RNA_def_float_factor(ot->srna, "margin", 0.001f, 0.0f, 1.0f, "Margin", "Space between islands", 0.0f, 1.0f);
}
/**************** Project From View operator **************/
@@ -1313,7 +1319,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
}
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -1428,8 +1434,8 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf))
if (i != mi) {
dx = uvs[mi][0] - uvs[i][0];
if (dx > 0.5f) uvs[i][0] += 1.0f;
- }
- }
+ }
+ }
BLI_array_fixedstack_free(uvs);
}
@@ -1467,7 +1473,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
uv_map_mirror(em, efa, tf);
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -1542,7 +1548,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
uv_map_mirror(em, efa, tf);
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -1622,7 +1628,7 @@ static int cube_project_exec(bContext *C, wmOperator *op)
}
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 1729ac06f5a..36fbd818f11 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -123,37 +123,36 @@ void GPU_global_buffer_pool_free(void);
GPUBuffer *GPU_buffer_alloc(int size);
void GPU_buffer_free(GPUBuffer *buffer);
-GPUDrawObject *GPU_drawobject_new(struct DerivedMesh *dm );
-void GPU_drawobject_free(struct DerivedMesh *dm );
+GPUDrawObject *GPU_drawobject_new(struct DerivedMesh *dm);
+void GPU_drawobject_free(struct DerivedMesh *dm);
/* called before drawing */
-void GPU_vertex_setup(struct DerivedMesh *dm );
-void GPU_normal_setup(struct DerivedMesh *dm );
-void GPU_uv_setup(struct DerivedMesh *dm );
-void GPU_color_setup(struct DerivedMesh *dm );
-void GPU_edge_setup(struct DerivedMesh *dm ); /* does not mix with other data */
-void GPU_uvedge_setup(struct DerivedMesh *dm );
-int GPU_attrib_element_size( GPUAttrib data[], int numdata );
-void GPU_interleaved_attrib_setup( GPUBuffer *buffer, GPUAttrib data[], int numdata );
+void GPU_vertex_setup(struct DerivedMesh *dm);
+void GPU_normal_setup(struct DerivedMesh *dm);
+void GPU_uv_setup(struct DerivedMesh *dm);
+/* colType is the cddata MCol type to use! */
+void GPU_color_setup(struct DerivedMesh *dm, int colType);
+void GPU_edge_setup(struct DerivedMesh *dm); /* does not mix with other data */
+void GPU_uvedge_setup(struct DerivedMesh *dm);
+int GPU_attrib_element_size(GPUAttrib data[], int numdata);
+void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata);
/* can't lock more than one buffer at once */
-void *GPU_buffer_lock( GPUBuffer *buffer );
-void *GPU_buffer_lock_stream( GPUBuffer *buffer );
-void GPU_buffer_unlock( GPUBuffer *buffer );
+void *GPU_buffer_lock(GPUBuffer *buffer);
+void *GPU_buffer_lock_stream(GPUBuffer *buffer);
+void GPU_buffer_unlock(GPUBuffer *buffer);
-/* upload three unsigned chars, representing RGB colors, for each vertex. Resets dm->drawObject->colType to -1 */
-void GPU_color3_upload(struct DerivedMesh *dm, unsigned char *data );
/* switch color rendering on=1/off=0 */
-void GPU_color_switch( int mode );
+void GPU_color_switch(int mode);
/* used for drawing edges */
-void GPU_buffer_draw_elements( GPUBuffer *elements, unsigned int mode, int start, int count );
+void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count);
/* called after drawing */
void GPU_buffer_unbind(void);
/* used to check whether to use the old (without buffers) code */
-int GPU_buffer_legacy(struct DerivedMesh *dm );
+int GPU_buffer_legacy(struct DerivedMesh *dm);
/* Buffers for non-DerivedMesh drawing */
typedef struct GPU_Buffers GPU_Buffers;
@@ -162,18 +161,22 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
struct MFace *mface, struct MVert *mvert,
int *face_indices, int totface);
-void GPU_update_mesh_buffers(GPU_Buffers *buffers, struct MVert *mvert,
- int *vert_indices, int totvert, const float *vmask);
+void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
+ int *vert_indices, int totvert, const float *vmask,
+ int (*face_vert_indices)[4], int show_diffuse_color);
GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
unsigned int **grid_hidden, int gridsize);
void GPU_update_grid_buffers(GPU_Buffers *buffers, struct CCGElem **grids,
const struct DMFlagMat *grid_flag_mats,
- int *grid_indices, int totgrid, const struct CCGKey *key);
+ int *grid_indices, int totgrid, const struct CCGKey *key,
+ int show_diffuse_color);
void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial);
+int GPU_buffers_diffuse_changed(GPU_Buffers *buffers, int show_diffuse_color);
+
void GPU_free_buffers(GPU_Buffers *buffers);
#endif
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 285acb6bdde..b26c25558c3 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -75,6 +75,8 @@ void GPU_end_object_materials(void);
int GPU_enable_material(int nr, void *attribs);
void GPU_disable_material(void);
+void GPU_material_diffuse_get(int nr, float diff[4]);
+
void GPU_set_material_alpha_blend(int alphablend);
int GPU_get_material_alpha_blend(void);
@@ -122,7 +124,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap);
void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h);
void GPU_update_images_framechange(void);
int GPU_update_image_time(struct Image *ima, double time);
-int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int ncd);
+int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int isdata);
void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int rectw, int recth, int mipmap, int use_hight_bit_depth, struct Image *ima);
void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf);
int GPU_upload_dxt_texture(struct ImBuf *ibuf);
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 0bfa331f957..6cbec4f632e 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -139,11 +139,11 @@ int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver);
GPUTexture *GPU_texture_create_1D(int w, float *pixels, char err_out[256]);
GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels);
+GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float *fpixels);
GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]);
GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]);
GPUTexture *GPU_texture_from_blender(struct Image *ima,
- struct ImageUser *iuser, int ncd, double time, int mipmap);
+ struct ImageUser *iuser, int isdata, double time, int mipmap);
void GPU_texture_free(GPUTexture *tex);
void GPU_texture_ref(GPUTexture *tex);
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index baa557c3484..c46230de8bf 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -107,10 +107,9 @@ typedef struct GPUNodeStack {
GPUNodeLink *GPU_attribute(int type, const char *name);
GPUNodeLink *GPU_uniform(float *num);
GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data);
-GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int ncd);
+GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int isdata);
GPUNodeLink *GPU_texture(int size, float *pixels);
GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, int dynamictype, void *data);
-GPUNodeLink *GPU_socket(GPUNodeStack *sock);
GPUNodeLink *GPU_builtin(GPUBuiltin builtin);
int GPU_link(GPUMaterial *mat, const char *name, ...);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 8b5b8f491da..1aae8ed2271 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -53,6 +53,7 @@
#include "GPU_buffers.h"
#include "GPU_compatibility.h"
+#include "GPU_draw.h"
typedef enum {
GPU_BUFFER_VERTEX_STATE = 1,
@@ -706,34 +707,6 @@ static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int *
}
}
-
-static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index, int *mat_orig_to_new, void *user)
-{
- int i, totface;
- char *varray = (char *)varray_;
- char *mcol = (char *)user;
- MFace *f = dm->getTessFaceArray(dm);
-
- totface = dm->getNumTessFaces(dm);
- for (i = 0; i < totface; i++, f++) {
- int start = index[mat_orig_to_new[f->mat_nr]];
-
- /* v1 v2 v3 */
- copy_v3_v3_char(&varray[start], &mcol[i * 12]);
- copy_v3_v3_char(&varray[start + 3], &mcol[i * 12 + 3]);
- copy_v3_v3_char(&varray[start + 6], &mcol[i * 12 + 6]);
- index[mat_orig_to_new[f->mat_nr]] += 9;
-
- if (f->v4) {
- /* v3 v4 v1 */
- copy_v3_v3_char(&varray[start + 9], &mcol[i * 12 + 6]);
- copy_v3_v3_char(&varray[start + 12], &mcol[i * 12 + 9]);
- copy_v3_v3_char(&varray[start + 15], &mcol[i * 12]);
- index[mat_orig_to_new[f->mat_nr]] += 9;
- }
- }
-}
-
static void copy_mcol_uc3(unsigned char *v, unsigned char *col)
{
v[0] = col[3];
@@ -818,28 +791,6 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i
}
}
-/* get the DerivedMesh's MCols; choose (in decreasing order of
- * preference) from CD_ID_MCOL, CD_PREVIEW_MCOL, or CD_MCOL */
-static MCol *gpu_buffer_color_type(DerivedMesh *dm)
-{
- MCol *c;
- int type;
-
- type = CD_ID_MCOL;
- c = DM_get_tessface_data_layer(dm, type);
- if (!c) {
- type = CD_PREVIEW_MCOL;
- c = DM_get_tessface_data_layer(dm, type);
- if (!c) {
- type = CD_MCOL;
- c = DM_get_tessface_data_layer(dm, type);
- }
- }
-
- dm->drawObject->colType = type;
- return c;
-}
-
typedef enum {
GPU_BUFFER_VERTEX = 0,
GPU_BUFFER_NORMAL,
@@ -922,7 +873,7 @@ static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type)
/* special handling for MCol and UV buffers */
if (type == GPU_BUFFER_COLOR) {
- if (!(user_data = gpu_buffer_color_type(dm)))
+ if (!(user_data = DM_get_tessface_data_layer(dm, dm->drawObject->colType)))
return NULL;
}
else if (type == GPU_BUFFER_UV) {
@@ -942,7 +893,7 @@ static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type)
static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type)
{
GPUBuffer **buf;
-
+
if (!dm->drawObject)
dm->drawObject = GPU_drawobject_new(dm);
@@ -1004,8 +955,28 @@ void GPU_uv_setup(DerivedMesh *dm)
GLStates |= GPU_BUFFER_TEXCOORD_STATE;
}
-void GPU_color_setup(DerivedMesh *dm)
+void GPU_color_setup(DerivedMesh *dm, int colType)
{
+ if (!dm->drawObject) {
+ /* XXX Not really nice, but we need a valid gpu draw object to set the colType...
+ * Else we would have to add a new param to gpu_buffer_setup_common. */
+ dm->drawObject = GPU_drawobject_new(dm);
+ dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
+ dm->drawObject->colType = colType;
+ }
+ /* In paint mode, dm may stay the same during stroke, however we still want to update colors!
+ * Also check in case we changed color type (i.e. which MCol cdlayer we use). */
+ else if ((dm->dirty & DM_DIRTY_MCOL_UPDATE_DRAW) || (colType != dm->drawObject->colType)) {
+ GPUBuffer **buf = gpu_drawobject_buffer_from_type(dm->drawObject, GPU_BUFFER_COLOR);
+ /* XXX Freeing this buffer is a bit stupid, as geometry has not changed, size should remain the same.
+ * Not sure though it would be worth defining a sort of gpu_buffer_update func - nor whether
+ * it is even possible ! */
+ GPU_buffer_free(*buf);
+ *buf = NULL;
+ dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
+ dm->drawObject->colType = colType;
+ }
+
if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR))
return;
@@ -1166,20 +1137,6 @@ void GPU_buffer_unbind(void)
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
-/* confusion: code in cdderivedmesh calls both GPU_color_setup and
- * GPU_color3_upload; both of these set the `colors' buffer, so seems
- * like it will just needlessly overwrite? --nicholas */
-void GPU_color3_upload(DerivedMesh *dm, unsigned char *data)
-{
- if (dm->drawObject == 0)
- dm->drawObject = GPU_drawobject_new(dm);
- GPU_buffer_free(dm->drawObject->colors);
-
- dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3,
- sizeof(char) * 3 * dm->drawObject->tot_triangle_point,
- GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3);
-}
-
void GPU_color_switch(int mode)
{
if (mode) {
@@ -1270,11 +1227,11 @@ void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start,
* drawing and doesn't interact at all with the buffer code above */
/* Return false if VBO is either unavailable or disabled by the user,
- true otherwise */
+ * true otherwise */
static int gpu_vbo_enabled(void)
{
return (GLEW_ARB_vertex_buffer_object &&
- !(U.gameflags & USER_DISABLE_VBO));
+ !(U.gameflags & USER_DISABLE_VBO));
}
/* Convenience struct for building the VBO. */
@@ -1316,6 +1273,9 @@ struct GPU_Buffers {
/* The PBVH ensures that either all faces in the node are
smooth-shaded or all faces are flat-shaded */
int smooth;
+
+ int show_diffuse_color;
+ float diffuse_color[4];
};
typedef enum {
VBO_ENABLED,
@@ -1339,23 +1299,24 @@ static void gpu_colors_disable(VBO_State vbo_state)
static float gpu_color_from_mask(float mask)
{
- return (1.0f - mask) * 0.5f + 0.25f;
+ return 1.0f - mask * 0.75f;
}
-static void gpu_color_from_mask_copy(float mask, unsigned char out[3])
+static void gpu_color_from_mask_copy(float mask, const float diffuse_color[4], unsigned char out[3])
{
- unsigned char color;
-
- color = gpu_color_from_mask(mask) * 255.0f;
+ float mask_color;
+
+ mask_color = gpu_color_from_mask(mask) * 255.0f;
- out[0] = color;
- out[1] = color;
- out[2] = color;
+ out[0] = diffuse_color[0] * mask_color;
+ out[1] = diffuse_color[1] * mask_color;
+ out[2] = diffuse_color[2] * mask_color;
}
-static void gpu_color_from_mask_set(float mask)
+static void gpu_color_from_mask_set(float mask, float diffuse_color[4])
{
- gpuGray3f(gpu_color_from_mask(mask));
+ float color = gpu_color_from_mask(mask);
+ gpuColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color);
}
static float gpu_color_from_mask_quad(const CCGKey *key,
@@ -1371,36 +1332,50 @@ static float gpu_color_from_mask_quad(const CCGKey *key,
static void gpu_color_from_mask_quad_copy(const CCGKey *key,
CCGElem *a, CCGElem *b,
CCGElem *c, CCGElem *d,
+ const float *diffuse_color,
unsigned char out[3])
{
- unsigned char color =
+ float mask_color =
gpu_color_from_mask((*CCG_elem_mask(key, a) +
*CCG_elem_mask(key, b) +
*CCG_elem_mask(key, c) +
*CCG_elem_mask(key, d)) * 0.25f) * 255.0f;
- out[0] = color;
- out[1] = color;
- out[2] = color;
+ out[0] = diffuse_color[0] * mask_color;
+ out[1] = diffuse_color[1] * mask_color;
+ out[2] = diffuse_color[2] * mask_color;
}
static void gpu_color_from_mask_quad_set(const CCGKey *key,
CCGElem *a, CCGElem *b,
- CCGElem *c, CCGElem *d)
+ CCGElem *c, CCGElem *d,
+ float diffuse_color[4])
{
- gpuGray3f(gpu_color_from_mask_quad(key, a, b, c, d));
+ float color = gpu_color_from_mask_quad(key, a, b, c, d);
+ gpuColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color);
}
void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
- int *vert_indices, int totvert, const float *vmask)
+ int *vert_indices, int totvert, const float *vmask,
+ int (*face_vert_indices)[4], int show_diffuse_color)
{
VertexBufferFormat *vert_data;
int i, j, k;
buffers->vmask = vmask;
+ buffers->show_diffuse_color = show_diffuse_color;
if (buffers->vert_buf) {
int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3));
+ float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
+
+ if (buffers->show_diffuse_color) {
+ MFace *f = buffers->mface + buffers->face_indices[0];
+
+ GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+ }
+
+ copy_v4_v4(buffers->diffuse_color, diffuse_color);
/* Build VBO */
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
@@ -1421,11 +1396,27 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
copy_v3_v3(out->co, v->co);
memcpy(out->no, v->no, sizeof(short) * 3);
- if (vmask) {
- gpu_color_from_mask_copy(vmask[vert_indices[i]],
- out->color);
- }
}
+
+#define UPDATE_VERTEX(face, vertex, index, diffuse_color) \
+ { \
+ VertexBufferFormat *out = vert_data + face_vert_indices[face][index]; \
+ if (vmask) \
+ gpu_color_from_mask_copy(vmask[vertex], diffuse_color, out->color); \
+ else \
+ rgb_float_to_uchar(out->color, diffuse_color); \
+ } (void)0
+
+ for (i = 0; i < buffers->totface; i++) {
+ MFace *f = buffers->mface + buffers->face_indices[i];
+
+ UPDATE_VERTEX(i, f->v1, 0, diffuse_color);
+ UPDATE_VERTEX(i, f->v2, 1, diffuse_color);
+ UPDATE_VERTEX(i, f->v3, 2, diffuse_color);
+ if (f->v4)
+ UPDATE_VERTEX(i, f->v4, 3, diffuse_color);
+ }
+#undef UPDATE_VERTEX
}
else {
for (i = 0; i < buffers->totface; ++i) {
@@ -1437,6 +1428,9 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
float fmask;
+ if (paint_is_face_hidden(f, mvert))
+ continue;
+
/* Face normal and mask */
if (f->v4) {
normal_quad_v3(fno,
@@ -1448,7 +1442,7 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
fmask = (vmask[fv[0]] +
vmask[fv[1]] +
vmask[fv[2]] +
- vmask[fv[3]]) * 0.25;
+ vmask[fv[3]]) * 0.25f;
}
}
else {
@@ -1471,8 +1465,11 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
copy_v3_v3(out->co, v->co);
memcpy(out->no, no, sizeof(short) * 3);
+
if (vmask)
- gpu_color_from_mask_copy(fmask, out->color);
+ gpu_color_from_mask_copy(fmask, diffuse_color, out->color);
+ else
+ rgb_float_to_uchar(out->color, diffuse_color);
vert_data++;
}
@@ -1506,6 +1503,8 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
buffers->index_type = GL_UNSIGNED_SHORT;
buffers->smooth = mface[face_indices[0]].flag & ME_SMOOTH;
+ buffers->show_diffuse_color = FALSE;
+
/* Count the number of visible triangles */
for (i = 0, tottri = 0; i < totface; ++i) {
const MFace *f = &mface[face_indices[i]];
@@ -1560,7 +1559,7 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
}
- if (buffers->index_buf || !buffers->smooth)
+ if (gpu_vbo_enabled() && (buffers->index_buf || !buffers->smooth))
glGenBuffersARB(1, &buffers->vert_buf);
buffers->tot_tri = tottri;
@@ -1574,16 +1573,27 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
const DMFlagMat *grid_flag_mats, int *grid_indices,
- int totgrid, const CCGKey *key)
+ int totgrid, const CCGKey *key, int show_diffuse_color)
{
VertexBufferFormat *vert_data;
int i, j, k, x, y;
+ buffers->show_diffuse_color = show_diffuse_color;
+
/* Build VBO */
if (buffers->vert_buf) {
int totvert = key->grid_area * totgrid;
int smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH;
const int has_mask = key->has_mask;
+ float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
+
+ if (buffers->show_diffuse_color) {
+ const DMFlagMat *flags = &grid_flag_mats[grid_indices[0]];
+
+ GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
+ }
+
+ copy_v4_v4(buffers->diffuse_color, diffuse_color);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
@@ -1601,12 +1611,11 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
copy_v3_v3(vd->co, CCG_elem_co(key, elem));
if (smooth) {
- normal_float_to_short_v3(vd->no,
- CCG_elem_no(key, elem));
+ normal_float_to_short_v3(vd->no, CCG_elem_no(key, elem));
if (has_mask) {
gpu_color_from_mask_copy(*CCG_elem_mask(key, elem),
- vd->color);
+ diffuse_color, vd->color);
}
}
vd++;
@@ -1642,6 +1651,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
elems[1],
elems[2],
elems[3],
+ diffuse_color,
vd->color);
}
}
@@ -1761,7 +1771,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
/* VBO is disabled; delete the previous buffer (if it exists) and
* return an invalid handle */
- if (gpu_vbo_enabled()) {
+ if (!gpu_vbo_enabled()) {
if (buffer)
glDeleteBuffersARB(1, &buffer);
return 0;
@@ -1810,6 +1820,8 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
buffers->grid_hidden = grid_hidden;
buffers->totgrid = totgrid;
+ buffers->show_diffuse_color = FALSE;
+
/* Count the number of quads */
totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize);
@@ -1854,6 +1866,11 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers)
const MVert *mvert = buffers->mvert;
int i, j;
const int has_mask = (buffers->vmask != NULL);
+ const MFace *face = &buffers->mface[buffers->face_indices[0]];
+ float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
+
+ if (buffers->show_diffuse_color)
+ GPU_material_diffuse_get(face->mat_nr + 1, diffuse_color);
if (has_mask) {
gpu_colors_enable(VBO_DISABLED);
@@ -1874,7 +1891,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers)
if (buffers->smooth) {
for (j = 0; j < S; j++) {
if (has_mask) {
- gpu_color_from_mask_set(buffers->vmask[fv[j]]);
+ gpu_color_from_mask_set(buffers->vmask[fv[j]], diffuse_color);
}
gpuNormal3sv(mvert[fv[j]].no);
gpuVertex3fv(mvert[fv[j]].co);
@@ -1900,10 +1917,10 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers)
buffers->vmask[fv[1]] +
buffers->vmask[fv[2]]);
if (f->v4)
- fmask = (fmask + buffers->vmask[fv[3]]) * 0.25;
+ fmask = (fmask + buffers->vmask[fv[3]]) * 0.25f;
else
fmask /= 3.0f;
- gpu_color_from_mask_set(fmask);
+ gpu_color_from_mask_set(fmask, diffuse_color);
}
for (j = 0; j < S; j++)
@@ -1925,6 +1942,11 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
const CCGKey *key = &buffers->gridkey;
int i, j, x, y, gridsize = buffers->gridkey.grid_size;
const int has_mask = key->has_mask;
+ const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]];
+ float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
+
+ if (buffers->show_diffuse_color)
+ GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
if (has_mask) {
gpu_colors_enable(VBO_DISABLED);
@@ -1958,7 +1980,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
if (buffers->smooth) {
for (j = 0; j < 4; j++) {
if (has_mask) {
- gpu_color_from_mask_set(*CCG_elem_mask(key, e[j]));
+ gpu_color_from_mask_set(*CCG_elem_mask(key, e[j]), diffuse_color);
}
gpuNormal3fv(CCG_elem_no(key, e[j]));
@@ -1975,7 +1997,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
gpuNormal3fv(fno);
if (has_mask) {
- gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3]);
+ gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3], diffuse_color);
}
for (j = 0; j < 4; j++)
@@ -1994,13 +2016,13 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
CCGElem *b = CCG_grid_elem(key, grid, x, y + 1);
if (has_mask) {
- gpu_color_from_mask_set(*CCG_elem_mask(key, a));
+ gpu_color_from_mask_set(*CCG_elem_mask(key, a), diffuse_color);
}
gpuNormal3fv(CCG_elem_no(key, a));
gpuVertex3fv(CCG_elem_co(key, a));
if (has_mask) {
- gpu_color_from_mask_set(*CCG_elem_mask(key, b));
+ gpu_color_from_mask_set(*CCG_elem_mask(key, b), diffuse_color);
}
gpuNormal3fv(CCG_elem_no(key, b));
@@ -2029,7 +2051,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
gpuNormal3fv(fno);
if (has_mask) {
- gpu_color_from_mask_quad_set(key, a, b, c, d);
+ gpu_color_from_mask_quad_set(key, a, b, c, d, diffuse_color);
}
}
@@ -2050,8 +2072,6 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
{
- const int has_mask = (buffers->vmask || buffers->gridkey.has_mask);
-
if (buffers->totface) {
const MFace *f = &buffers->mface[buffers->face_indices[0]];
if (!setMaterial(f->mat_nr + 1, NULL))
@@ -2068,13 +2088,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
if (buffers->vert_buf) {
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- if (has_mask) {
- gpu_colors_enable(VBO_ENABLED);
- }
- else {
- gpu_colors_enable(VBO_DISABLED);
- gpuCurrentColor4ub(0xff, 0xff, 0xff, 0xff);
- }
+ gpu_colors_enable(VBO_ENABLED);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
@@ -2091,10 +2105,8 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
offset + offsetof(VertexBufferFormat, co));
glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
offset + offsetof(VertexBufferFormat, no));
- if (has_mask) {
- glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
- offset + offsetof(VertexBufferFormat, color));
- }
+ glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
+ offset + offsetof(VertexBufferFormat, color));
glDrawElements(GL_QUADS, buffers->tot_quad * 4, buffers->index_type, 0);
@@ -2108,10 +2120,8 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
(void *)offsetof(VertexBufferFormat, co));
glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
(void *)offsetof(VertexBufferFormat, no));
- if (has_mask) {
- glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
- (void *)offsetof(VertexBufferFormat, color));
- }
+ glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
+ (void *)offsetof(VertexBufferFormat, color));
if (buffers->index_buf)
glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, 0);
@@ -2125,12 +2135,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
- if (has_mask) {
- gpu_colors_disable(VBO_ENABLED);
- }
- else {
- gpu_colors_disable(VBO_DISABLED);
- }
+ gpu_colors_disable(VBO_ENABLED);
}
/* fallbacks if we are out of memory or VBO is disabled */
else if (buffers->totface) {
@@ -2141,6 +2146,32 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
}
}
+int GPU_buffers_diffuse_changed(GPU_Buffers *buffers, int show_diffuse_color)
+{
+ float diffuse_color[4];
+
+ if (buffers->show_diffuse_color != show_diffuse_color)
+ return TRUE;
+
+ if (buffers->show_diffuse_color == FALSE)
+ return FALSE;
+
+ if (buffers->mface) {
+ MFace *f = buffers->mface + buffers->face_indices[0];
+
+ GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+ }
+ else {
+ const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]];
+
+ GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
+ }
+
+ return diffuse_color[0] != buffers->diffuse_color[0] ||
+ diffuse_color[1] != buffers->diffuse_color[1] ||
+ diffuse_color[2] != buffers->diffuse_color[2];
+}
+
void GPU_free_buffers(GPU_Buffers *buffers)
{
if (buffers) {
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 235bb74a65c..cfac515e306 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -794,7 +794,7 @@ void GPU_pass_bind(GPUPass *pass, double time, int mipmap)
/* now bind the textures */
for (input=inputs->first; input; input=input->next) {
if (input->ima)
- input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->imagencd, time, mipmap);
+ input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->image_isdata, time, mipmap);
if (input->tex && input->bindtex) {
GPU_texture_bind(input->tex, input->texid);
@@ -950,7 +950,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type)
input->ima = link->ptr1;
input->iuser = link->ptr2;
- input->imagencd = link->imagencd;
+ input->image_isdata = link->image_isdata;
input->textarget = GL_TEXTURE_2D;
input->textype = GPU_TEX2D;
MEM_freeN(link);
@@ -1079,17 +1079,20 @@ static void gpu_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *a
}
}
- if (a == attribs->totlayer && a < GPU_MAX_ATTRIB) {
- input->attribid = attribs->totlayer++;
- input->attribfirst = 1;
+ if (a < GPU_MAX_ATTRIB) {
+ if (a == attribs->totlayer) {
+ input->attribid = attribs->totlayer++;
+ input->attribfirst = 1;
- attribs->layer[a].type = input->attribtype;
- attribs->layer[a].attribid = input->attribid;
- BLI_strncpy(attribs->layer[a].name, input->attribname,
- sizeof(attribs->layer[a].name));
+ attribs->layer[a].type = input->attribtype;
+ attribs->layer[a].attribid = input->attribid;
+ BLI_strncpy(attribs->layer[a].name, input->attribname,
+ sizeof(attribs->layer[a].name));
+ }
+ else {
+ input->attribid = attribs->layer[a].attribid;
+ }
}
- else
- input->attribid = attribs->layer[a].attribid;
}
}
}
@@ -1143,14 +1146,14 @@ GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data)
return link;
}
-GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, int ncd)
+GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, int isdata)
{
GPUNodeLink *link = GPU_node_link_create(0);
link->image= 1;
link->ptr1= ima;
link->ptr2= iuser;
- link->imagencd= ncd;
+ link->image_isdata= isdata;
return link;
}
@@ -1178,15 +1181,6 @@ GPUNodeLink *GPU_dynamic_texture(GPUTexture *tex, int dynamictype, void *data)
return link;
}
-GPUNodeLink *GPU_socket(GPUNodeStack *sock)
-{
- GPUNodeLink *link = GPU_node_link_create(0);
-
- link->socket= sock;
-
- return link;
-}
-
GPUNodeLink *GPU_builtin(GPUBuiltin builtin)
{
GPUNodeLink *link = GPU_node_link_create(0);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index b4e9f6d996c..a412d0eb4c6 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -92,7 +92,7 @@ struct GPUNodeLink {
const char *attribname;
int image;
- int imagencd;
+ int image_isdata;
int texture;
int texturesize;
@@ -100,7 +100,7 @@ struct GPUNodeLink {
void *ptr1, *ptr2;
int dynamic;
- int dynamictype;
+ int dynamictype;
int type;
int users;
@@ -139,7 +139,7 @@ typedef struct GPUInput {
struct Image *ima; /* image */
struct ImageUser *iuser;/* image user */
- int imagencd; /* image does not contain color data */
+ int image_isdata; /* image does not contain color data */
float *dynamicvec; /* vector data in case it is dynamic */
int dynamictype; /* origin of the dynamic uniform (GPUDynamicType) */
void *dynamicdata; /* data source of the dynamic uniform */
diff --git a/source/blender/gpu/intern/gpu_deprecated.h b/source/blender/gpu/intern/gpu_deprecated.h
index 403e0ec87c9..016cb3d10e4 100644
--- a/source/blender/gpu/intern/gpu_deprecated.h
+++ b/source/blender/gpu/intern/gpu_deprecated.h
@@ -536,6 +536,9 @@
#undef glNewList
#define glNewList DO_NOT_USE_glNewList
-/* GLU Quadrics */
+/* GLU */
+#undef gluUnProject
+#define gluUnProject DO_NOT_USE_gluUnProject
+
#endif /* _GPU_DEPRECATED_H_ */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index ab8a7389887..53a51c9c9fd 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -529,7 +529,7 @@ static void GenerateMipmapRGBA(int high_bit, int w, int h, void * data)
}
#endif
-int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap, int ncd)
+int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap, int is_data)
{
ImBuf *ibuf = NULL;
unsigned int *bind = NULL;
@@ -599,7 +599,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
}
/* TODO unneeded when float images are correctly treated as linear always */
- if (!ncd)
+ if (!is_data)
do_color_management = TRUE;
if (ibuf->rect==NULL)
@@ -719,12 +719,21 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
rect= tilerect;
}
}
+
#ifdef WITH_DDS
if (ibuf->ftype & DDS)
GPU_create_gl_tex_compressed(bind, rect, rectw, recth, mipmap, ima, ibuf);
else
#endif
GPU_create_gl_tex(bind, rect, frect, rectw, recth, mipmap, use_high_bit_depth, ima);
+
+ /* mark as non-color data texture */
+ if (*bind) {
+ if (is_data)
+ ima->tpageflag |= IMA_GLBIND_IS_DATA;
+ else
+ ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
+ }
/* clean up */
if (tilerect)
@@ -831,12 +840,17 @@ int GPU_upload_dxt_texture(ImBuf *ibuf)
return FALSE;
}
+ if (!is_power_of_2_i(width) || !is_power_of_2_i(height)) {
+ printf("Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n");
+ return FALSE;
+ }
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- blocksize = (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16;
+ blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16;
for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) {
if (width == 0)
width = 1;
@@ -999,7 +1013,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
/* if color correction is needed, we must update the part that needs updating. */
if (ibuf->rect_float) {
float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf");
- IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h);
+ int is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA);
+ IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data);
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
@@ -1030,12 +1045,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
if (y != 0)
glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
- if (ibuf->rect_float)
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
- GL_FLOAT, ibuf->rect_float);
- else
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
- GL_UNSIGNED_BYTE, ibuf->rect);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
+ GL_UNSIGNED_BYTE, ibuf->rect);
if (ibuf->x != 0)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); /* restore default value */
@@ -1127,21 +1138,53 @@ void GPU_free_smoke(SmokeModifierData *smd)
if (smd->domain->tex_shadow)
GPU_texture_free(smd->domain->tex_shadow);
smd->domain->tex_shadow = NULL;
+
+ if (smd->domain->tex_flame)
+ GPU_texture_free(smd->domain->tex_flame);
+ smd->domain->tex_flame = NULL;
}
}
void GPU_create_smoke(SmokeModifierData *smd, int highres)
{
#ifdef WITH_SMOKE
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && !highres)
- smd->domain->tex = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smoke_get_density(smd->domain->fluid));
- else if (smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && highres)
- smd->domain->tex = GPU_texture_create_3D(smd->domain->res_wt[0], smd->domain->res_wt[1], smd->domain->res_wt[2], smoke_turbulence_get_density(smd->domain->wt));
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
+ SmokeDomainSettings *sds = smd->domain;
+ if (!sds->tex && !highres) {
+ /* rgba texture for color + density */
+ if (smoke_has_colors(sds->fluid)) {
+ float *data = MEM_callocN(sizeof(float)*sds->total_cells*4, "smokeColorTexture");
+ smoke_get_rgba(sds->fluid, data, 0);
+ sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], 4, data);
+ MEM_freeN(data);
+ }
+ /* density only */
+ else {
+ sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], 1, smoke_get_density(sds->fluid));
+ }
+ sds->tex_flame = (smoke_has_fuel(sds->fluid)) ? GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], 1, smoke_get_flame(sds->fluid)) : NULL;
+ }
+ else if (!sds->tex && highres) {
+ /* rgba texture for color + density */
+ if (smoke_turbulence_has_colors(sds->wt)) {
+ float *data = MEM_callocN(sizeof(float)*smoke_turbulence_get_cells(sds->wt)*4, "smokeColorTexture");
+ smoke_turbulence_get_rgba(sds->wt, data, 0);
+ sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 4, data);
+ MEM_freeN(data);
+ }
+ /* density only */
+ else {
+ sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1, smoke_turbulence_get_density(sds->wt));
+ }
+ sds->tex_flame = (smoke_turbulence_has_fuel(sds->wt)) ? GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1, smoke_turbulence_get_flame(sds->wt)) : NULL;
+ }
- smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->shadow);
+ sds->tex_shadow = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], 1, sds->shadow);
+ }
#else // WITH_SMOKE
(void)highres;
smd->domain->tex= NULL;
+ smd->domain->tex_flame= NULL;
smd->domain->tex_shadow= NULL;
#endif // WITH_SMOKE
}
@@ -1206,7 +1249,7 @@ void GPU_free_image(Image *ima)
ima->repbind= NULL;
}
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+ ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE|IMA_GLBIND_IS_DATA);
}
void GPU_free_images(void)
@@ -1392,7 +1435,7 @@ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat,
if (gamma) {
linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
linearrgb_to_srgb_v3_v3(smat->spec, smat->spec);
- }
+ }
}
}
@@ -1656,6 +1699,21 @@ void GPU_disable_material(void)
reset_default_alphablend_state();
}
+void GPU_material_diffuse_get(int nr, float diff[4])
+{
+ /* prevent index to use un-initialized array items */
+ if (nr >= GMS.totmat)
+ nr = 0;
+
+ /* no GPU_begin_object_materials, use default material */
+ if (!GMS.matbuf) {
+ mul_v3_v3fl(diff, &defmaterial.r, defmaterial.ref + defmaterial.emit);
+ }
+ else {
+ copy_v4_v4(diff, GMS.matbuf[nr].diff);
+ }
+}
+
void GPU_end_object_materials(void)
{
GPU_disable_material();
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 7de3729f9b5..57a35eac3e2 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -474,7 +474,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
}
-GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
+GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float *fpixels)
{
GPUTexture *tex;
GLenum type, format, internalformat;
@@ -512,9 +512,15 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
GPU_print_error("3D glBindTexture");
- type = GL_FLOAT; // GL_UNSIGNED_BYTE
- format = GL_RED;
- internalformat = GL_INTENSITY;
+ type = GL_FLOAT;
+ if (channels == 4) {
+ format = GL_RGBA;
+ internalformat = GL_RGBA;
+ }
+ else {
+ format = GL_RED;
+ internalformat = GL_INTENSITY;
+ }
//if (fpixels)
// pixels = GPU_texture_convert_pixels(w*h*depth, fpixels);
@@ -554,7 +560,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
return tex;
}
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int ncd, double time, int mipmap)
+GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int isdata, double time, int mipmap)
{
GPUTexture *tex;
GLint w, h, border, lastbindcode, bindcode;
@@ -562,7 +568,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int ncd, doub
glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode);
GPU_update_image_time(ima, time);
- bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap, ncd);
+ bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap, isdata);
if (ima->gputexture) {
ima->gputexture->bindcode = bindcode;
@@ -1319,7 +1325,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
return retval;
}
-void GPU_shader_free_builtin_shaders()
+void GPU_shader_free_builtin_shaders(void)
{
if (GG.shaders.vsm_store) {
MEM_freeN(GG.shaders.vsm_store);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index b60c178cf3c..1005a60d8b1 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -802,7 +802,9 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
}
}
- if (mat->scene->gm.flag & GAME_GLSL_NO_SHADERS);
+ if (mat->scene->gm.flag & GAME_GLSL_NO_SHADERS) {
+ /* pass */
+ }
else if (!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) &&
(GPU_link_changed(shi->spec) || ma->spec != 0.0f))
{
@@ -1149,7 +1151,7 @@ static void do_material_tex(GPUShadeInput *shi)
newnor = tnor;
}
- norfac = minf(fabsf(mtex->norfac), 1.0f);
+ norfac = min_ff(fabsf(mtex->norfac), 1.0f);
if (norfac == 1.0f && !GPU_link_changed(stencil)) {
shi->vn = newnor;
@@ -1609,8 +1611,8 @@ void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float a
void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend)
{
- lamp->spotsi= cos(M_PI*spotsize/360.0);
- lamp->spotbl= (1.0f - lamp->spotsi)*spotblend;
+ lamp->spotsi= cosf((float)M_PI * spotsize / 360.0f);
+ lamp->spotbl= (1.0f - lamp->spotsi) * spotblend;
}
static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
@@ -1901,7 +1903,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
GPUBuiltin gputype;
GPUDynamicType dynamictype;
GPUDataType datatype;
- } builtins[] = {
+ } builtins[] = {
{ GPU_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWMAT, GPU_DATA_16F },
{ GPU_INVERSE_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWIMAT, GPU_DATA_16F },
{ GPU_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_MAT, GPU_DATA_16F },
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 4c5018dc173..e7becd9d449 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -4,6 +4,21 @@ float exp_blender(float f)
return pow(2.71828182846, f);
}
+float compatible_pow(float x, float y)
+{
+ /* glsl pow doesn't accept negative x */
+ if(x < 0.0) {
+ if(mod(-y, 2.0) == 0.0)
+ return pow(-x, y);
+ else
+ return -pow(-x, y);
+ }
+ else if(x == 0.0)
+ return 0.0;
+
+ return pow(x, y);
+}
+
void rgb_to_hsv(vec4 rgb, out vec4 outcol)
{
float cmax, cmin, h, s, v, cdelta;
@@ -212,10 +227,17 @@ void math_atan(float val, out float outval)
void math_pow(float val1, float val2, out float outval)
{
- if (val1 >= 0.0)
- outval = pow(val1, val2);
- else
- outval = 0.0;
+ if (val1 >= 0.0) {
+ outval = compatible_pow(val1, val2);
+ }
+ else {
+ float val2_mod_1 = mod(abs(val2), 1.0);
+
+ if (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)
+ outval = compatible_pow(val1, floor(val2 + 0.5));
+ else
+ outval = 0.0;
+ }
}
void math_log(float val1, float val2, out float outval)
@@ -1907,7 +1929,7 @@ void test_shadowbuf_vsm(vec3 rco, sampler2D shadowmap, mat4 shadowpersmat, float
}
else {
result = 1.0;
- }
+ }
}
}
@@ -2008,7 +2030,7 @@ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out vec4 result)
result = vec4(L*color.rgb, 1.0);
}
-void node_bsdf_glossy(vec4 color, float roughness, vec3 N, vec3 I, out vec4 result)
+void node_bsdf_glossy(vec4 color, float roughness, vec3 N, out vec4 result)
{
/* ambient light */
vec3 L = vec3(0.2);
@@ -2029,12 +2051,12 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, vec3 I, out vec4 resu
result = vec4(L*color.rgb, 1.0);
}
-void node_bsdf_anisotropic(vec4 color, float roughnessU, float roughnessV, vec3 N, vec3 I, out vec4 result)
+void node_bsdf_anisotropic(vec4 color, float roughness, float anisotropy, float rotation, vec3 N, vec3 T, out vec4 result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
-void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, vec3 I, out vec4 result)
+void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, out vec4 result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
@@ -2213,7 +2235,8 @@ void node_light_path(
out float is_glossy_ray,
out float is_singular_ray,
out float is_reflection_ray,
- out float is_transmission_ray)
+ out float is_transmission_ray,
+ out float ray_length)
{
is_camera_ray = 1.0;
is_shadow_ray = 0.0;
@@ -2222,6 +2245,7 @@ void node_light_path(
is_singular_ray = 0.0;
is_reflection_ray = 0.0;
is_transmission_ray = 0.0;
+ ray_length = 1.0;
}
void node_light_falloff(float strength, float tsmooth, out float quadratic, out float linear, out float constant)
@@ -2239,6 +2263,10 @@ void node_object_info(out vec3 location, out float object_index, out float mater
random = 0.0;
}
+void node_bump(float strength, float height, vec3 N, out vec3 result)
+{
+ result = N;
+}
/* output */
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index e1d5f50edfb..95b1dafd129 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -58,7 +58,7 @@ struct BIK_ParamValue {
float f[8];
int i[8];
char s[32];
- } value;
+ } value;
};
typedef struct BIK_ParamValue BIK_ParamValue;
@@ -92,5 +92,4 @@ void BIK_test_constraint(struct Object *ob, struct bConstraint *cons);
}
#endif
-#endif // __BIK_API_H__
-
+#endif /* __BIK_API_H__ */
diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt
index 903267c5618..0a0e0e664b4 100644
--- a/source/blender/ikplugin/CMakeLists.txt
+++ b/source/blender/ikplugin/CMakeLists.txt
@@ -56,9 +56,11 @@ endif()
if(WITH_IK_ITASC)
add_definitions(-DWITH_IK_ITASC)
list(APPEND INC
- ../../../extern/Eigen3
../../../intern/itasc
)
+ list(APPEND INC_SYS
+ ../../../extern/Eigen3
+ )
list(APPEND SRC
intern/itasc_plugin.cpp
intern/itasc_plugin.h
diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c
index 08d2789451c..9a0878f24ce 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.c
+++ b/source/blender/ikplugin/intern/ikplugin_api.c
@@ -80,6 +80,8 @@ static IKPlugin ikplugin_tab[] = {
itasc_test_constraint,
},
#endif
+
+ { NULL }
};
static IKPlugin *get_plugin(bPose *pose)
diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h
index 77c962269dc..53d9da8e614 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.h
+++ b/source/blender/ikplugin/intern/ikplugin_api.h
@@ -60,5 +60,4 @@ typedef struct IKPlugin IKPlugin;
}
#endif
-#endif // __IKPLUGIN_API_H__
-
+#endif /* __IKPLUGIN_API_H__ */
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h
index dd00c5f4add..c2ae4f937e7 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.h
+++ b/source/blender/ikplugin/intern/iksolver_plugin.h
@@ -47,5 +47,4 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose
}
#endif
-#endif // __IKSOLVER_PLUGIN_H__
-
+#endif /* __IKSOLVER_PLUGIN_H__ */
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index c929c97a040..5cf762af3e8 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -1253,7 +1253,7 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan)
ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof - 1]);
const float ikstretch = pchan->ikstretch * pchan->ikstretch;
/* why invert twice here? */
- weight[1] = (1.0 - minf(1.0 - ikstretch, 1.0f - 0.001f));
+ weight[1] = (1.0 - min_ff(1.0 - ikstretch, 1.0f - 0.001f));
weights.push_back(weight[1]);
}
if (!ret)
diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h
index 0d5fde0bec0..0500125b4c7 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.h
+++ b/source/blender/ikplugin/intern/itasc_plugin.h
@@ -52,5 +52,4 @@ void itasc_test_constraint(struct Object *ob, struct bConstraint *cons);
}
#endif
-#endif // __ITASC_PLUGIN_H__
-
+#endif /* __ITASC_PLUGIN_H__ */
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index bbe70a7d73f..29ed8c95fc6 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -25,7 +25,6 @@
set(INC
.
- ../avi
../blenkernel
../blenlib
../blenloader
@@ -82,25 +81,6 @@ set(SRC
intern/IMB_indexer.h
intern/IMB_metadata.h
intern/imbuf.h
- intern/cineon/cin_debug_stuff.h
- intern/cineon/cineonfile.h
- intern/cineon/cineonlib.h
- intern/cineon/dpxfile.h
- intern/cineon/dpxlib.h
- intern/cineon/logImageCore.h
- intern/cineon/logImageLib.h
- intern/cineon/logmemfile.h
- intern/dds/BlockDXT.h
- intern/dds/Color.h
- intern/dds/ColorBlock.h
- intern/dds/Common.h
- intern/dds/DirectDrawSurface.h
- intern/dds/Image.h
- intern/dds/PixelFormat.h
- intern/dds/Stream.h
- intern/dds/dds_api.h
- intern/openexr/openexr_api.h
- intern/openexr/openexr_multi.h
# orphan include
../../../intern/ffmpeg/ffmpeg_compat.h
@@ -143,6 +123,13 @@ if(WITH_IMAGE_REDCODE)
add_definitions(-DWITH_REDCODE)
endif()
+if(WITH_CODEC_AVI)
+ list(APPEND INC
+ ../avi
+ )
+ add_definitions(-DWITH_AVI)
+endif()
+
if(WITH_CODEC_QUICKTIME)
list(APPEND INC
../quicktime
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index e2604241caf..0653956e113 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -130,7 +130,8 @@ void IMB_colormanagement_colorspace_items_add(struct EnumPropertyItem **items, i
void IMB_partial_display_buffer_update(struct ImBuf *ibuf, const float *linear_buffer, const unsigned char *buffer_byte,
int stride, int offset_x, int offset_y, const struct ColorManagedViewSettings *view_settings,
const struct ColorManagedDisplaySettings *display_settings,
- int xmin, int ymin, int xmax, int ymax);
+ int xmin, int ymin, int xmax, int ymax,
+ int update_orig_byte_buffer);
/* ** Pixel processor functions ** */
struct ColormanageProcessor *IMB_colormanagement_display_processor_new(const struct ColorManagedViewSettings *view_settings,
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 28dbe110528..d0ac71a7131 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -103,7 +103,7 @@ struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags,
*
* \attention Defined in readimage.c
*/
-struct ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
+struct ImBuf *IMB_testiffname(const char *filepath, int flags);
/**
*
@@ -371,7 +371,7 @@ void IMB_interlace(struct ImBuf *ibuf);
void IMB_rect_from_float(struct ImBuf *ibuf);
/* Create char buffer for part of the image, color corrected if necessary,
* Changed part will be stored in buffer. This is expected to be used for texture painting updates */
-void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h);
+void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data);
void IMB_float_from_rect(struct ImBuf *ibuf);
void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */
/* note, check that the conversion exists, only some are supported */
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index f03f709f13f..28e62d496b2 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -93,7 +93,7 @@ typedef struct ImBuf {
/* tiled pixel storage */
int tilex, tiley;
int xtiles, ytiles;
- unsigned int **tiles;
+ unsigned int **tiles;
/* zbuffer */
int *zbuf; /* z buffer data, original zbuffer */
@@ -200,6 +200,10 @@ typedef struct ImBuf {
#ifdef WITH_CINEON
#define CINEON (1 << 21)
#define DPX (1 << 20)
+#define CINEON_LOG (1 << 8)
+#define CINEON_16BIT (1 << 7)
+#define CINEON_12BIT (1 << 6)
+#define CINEON_10BIT (1 << 5)
#endif
#ifdef WITH_DDS
@@ -242,7 +246,7 @@ typedef struct ImBuf {
((unsigned long)(unsigned char)(ch1) << 8) | \
((unsigned long)(unsigned char)(ch2) << 16) | \
((unsigned long)(unsigned char)(ch3) << 24))
-#endif //MAKEFOURCC
+#endif /* MAKEFOURCC */
/*
* FOURCC codes for DX compressed-texture pixel formats
@@ -255,7 +259,7 @@ typedef struct ImBuf {
#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))
-#endif // DDS
+#endif /* DDS */
extern const char *imb_ext_image[];
extern const char *imb_ext_image_qt[];
extern const char *imb_ext_movie[];
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index d5cc4929aed..ed349e8f7eb 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -62,7 +62,9 @@
#include "imbuf.h"
-#include "AVI_avi.h"
+#ifdef WITH_AVI
+# include "AVI_avi.h"
+#endif
#ifdef WITH_QUICKTIME
# if defined(_WIN32) || defined(__APPLE__)
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index 56a03121409..68ad4808c80 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -97,13 +97,13 @@ struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags, cha
short imb_cocoaSaveImage(struct ImBuf *ibuf, const char *name, int flags);
/* cineon */
-int imb_savecineon(struct ImBuf *buf, const char *name, int flags);
-struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_save_cineon(struct ImBuf *buf, const char *name, int flags);
+struct ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_is_cineon(unsigned char *buf);
/* dpx */
int imb_save_dpx(struct ImBuf *buf, const char *name, int flags);
-struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+struct ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_is_dpx(unsigned char *buf);
/* hdr */
diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h
index 18816924a9b..9c95531e90d 100644
--- a/source/blender/imbuf/intern/IMB_indexer.h
+++ b/source/blender/imbuf/intern/IMB_indexer.h
@@ -72,7 +72,7 @@ typedef struct anim_index_builder {
char name[FILE_MAX];
char temp_name[FILE_MAX];
- void * private_data;
+ void *private_data;
void (*delete_priv_data)(struct anim_index_builder * idx);
void (*proc_frame)(struct anim_index_builder * idx,
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 69048274104..1b3a6d4a4cd 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -357,7 +357,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
ibuf->planes = planes;
ibuf->ftype = TGA;
ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */
- ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; /* IMB_DPI_DEFAULT -> pixels-per-meter */
+ ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f; /* IMB_DPI_DEFAULT -> pixels-per-meter */
if (flags & IB_rect) {
if (imb_addrectImBuf(ibuf) == FALSE) {
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 394f5169046..5b64416c309 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -78,7 +78,9 @@
#include "imbuf.h"
-#include "AVI_avi.h"
+#ifdef WITH_AVI
+# include "AVI_avi.h"
+#endif
#ifdef WITH_QUICKTIME
#if defined(_WIN32) || defined(__APPLE__)
@@ -185,6 +187,7 @@ static void an_stringenc(char *string, const char *head, const char *tail, unsig
BLI_stringenc(string, head, tail, numlen, pic);
}
+#ifdef WITH_AVI
static void free_anim_avi(struct anim *anim)
{
#if defined(_WIN32) && !defined(FREE_WINDOWS)
@@ -219,6 +222,7 @@ static void free_anim_avi(struct anim *anim)
anim->duration = 0;
}
+#endif /* WITH_AVI */
#ifdef WITH_FFMPEG
static void free_anim_ffmpeg(struct anim *anim);
@@ -235,7 +239,10 @@ void IMB_free_anim(struct anim *anim)
}
free_anim_movie(anim);
+
+#ifdef WITH_AVI
free_anim_avi(anim);
+#endif
#ifdef WITH_QUICKTIME
free_anim_quicktime(anim);
@@ -287,7 +294,7 @@ struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char
return(anim);
}
-
+#ifdef WITH_AVI
static int startavi(struct anim *anim)
{
@@ -397,7 +404,9 @@ static int startavi(struct anim *anim)
return 0;
}
+#endif /* WITH_AVI */
+#ifdef WITH_AVI
static ImBuf *avi_fetchibuf(struct anim *anim, int position)
{
ImBuf *ibuf = NULL;
@@ -447,6 +456,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
return ibuf;
}
+#endif /* WITH_AVI */
#ifdef WITH_FFMPEG
@@ -1206,7 +1216,11 @@ static ImBuf *anim_getnew(struct anim *anim)
if (anim == NULL) return(NULL);
free_anim_movie(anim);
+
+#ifdef WITH_AVI
free_anim_avi(anim);
+#endif
+
#ifdef WITH_QUICKTIME
free_anim_quicktime(anim);
#endif
@@ -1219,7 +1233,7 @@ static ImBuf *anim_getnew(struct anim *anim)
if (anim->curtype != 0) return (NULL);
- anim->curtype = imb_get_anim_type(anim->name);
+ anim->curtype = imb_get_anim_type(anim->name);
switch (anim->curtype) {
case ANIM_SEQUENCE:
@@ -1233,6 +1247,7 @@ static ImBuf *anim_getnew(struct anim *anim)
if (startmovie(anim)) return (NULL);
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
break;
+#ifdef WITH_AVI
case ANIM_AVI:
if (startavi(anim)) {
printf("couldnt start avi\n");
@@ -1240,6 +1255,7 @@ static ImBuf *anim_getnew(struct anim *anim)
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
+#endif
#ifdef WITH_QUICKTIME
case ANIM_QTIME:
if (startquicktime(anim)) return (0);
@@ -1331,11 +1347,13 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
IMB_convert_rgba_to_abgr(ibuf);
}
break;
+#ifdef WITH_AVI
case ANIM_AVI:
ibuf = avi_fetchibuf(anim, position);
if (ibuf)
anim->curposition = position;
break;
+#endif
#ifdef WITH_QUICKTIME
case ANIM_QTIME:
ibuf = qtime_fetchibuf(anim, position);
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index df12f0b703e..32733668052 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -184,7 +184,7 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char co
rect += 4; bmp += 3;
}
/* for 24-bit images, rows are padded to multiples of 4 */
- bmp += x % 4;
+ bmp += x % 4;
}
}
else if (depth == 32) {
diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt
index fdf4f5409a5..b94cfd22058 100644
--- a/source/blender/imbuf/intern/cineon/CMakeLists.txt
+++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt
@@ -39,12 +39,24 @@ set(INC_SYS
)
set(SRC
+ cin_debug_stuff.h
+ cineonfile.h
+ cineonlib.h
+ dpxfile.h
+ dpxlib.h
+ logImageCore.h
+ logImageLib.h
+ logmemfile.h
+
cineon_dpx.c
cineonlib.c
dpxlib.c
logImageCore.c
- logImageLib.c
logmemfile.c
)
+if(WITH_IMAGE_CINEON)
+ add_definitions(-DWITH_CINEON)
+endif()
+
blender_add_lib(bf_imbuf_cineon "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/imbuf/intern/cineon/SConscript b/source/blender/imbuf/intern/cineon/SConscript
index e1afb5ebd2d..a07334632d7 100644
--- a/source/blender/imbuf/intern/cineon/SConscript
+++ b/source/blender/imbuf/intern/cineon/SConscript
@@ -15,4 +15,7 @@ incs = ['.',
defs = []
+if env['WITH_BF_CINEON']:
+ defs.append('WITH_CINEON')
+
env.BlenderLib ('bf_imbuf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [220,175])
diff --git a/source/blender/imbuf/intern/cineon/cin_debug_stuff.h b/source/blender/imbuf/intern/cineon/cin_debug_stuff.h
index a97499fb1ae..e69de29bb2d 100644
--- a/source/blender/imbuf/intern/cineon/cin_debug_stuff.h
+++ b/source/blender/imbuf/intern/cineon/cin_debug_stuff.h
@@ -1,4 +0,0 @@
-/** \file blender/imbuf/intern/cineon/cin_debug_stuff.h
- * \ingroup imbcineon
- */
-#define d_printf printf
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 7705af13b1e..d20c6dec9d3 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -4,11 +4,11 @@
* 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.
+ * 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
+ * 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
@@ -20,25 +20,24 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Julien Enche.
*
* ***** END GPL LICENSE BLOCK *****
* cineon.c
- * contributors: joeedh
+ * contributors: joeedh, Julien Enche
* I hearby donate this code and all rights to the Blender Foundation.
+ * $Id$
*/
/** \file blender/imbuf/intern/cineon/cineon_dpx.c
* \ingroup imbcineon
*/
-
-#include <stdio.h>
-#include <string.h> /*for memcpy*/
-#include "logImageLib.h"
-#include "cineonlib.h"
-#include "dpxlib.h"
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "logImageCore.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -51,167 +50,142 @@
#include "MEM_guardedalloc.h"
-#if 0
-static void cineon_conversion_parameters(LogImageByteConversionParameters *params)
-{
-// params->blackPoint = scene?scene->r.cineonblack:95;
-// params->whitePoint = scene?scene->r.cineonwhite:685;
-// params->gamma = scene?scene->r.cineongamma:1.7f;
-// params->doLogarithm = scene?scene->r.subimtype & R_CINEON_LOG:0;
-
- params->blackPoint = 95;
- params->whitePoint = 685;
- params->gamma = 1.0f;
- params->doLogarithm = 0;
-}
-#endif
-
-static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags, char colorspace[IM_MAX_SPACE])
+static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags,
+ char colorspace[IM_MAX_SPACE])
{
ImBuf *ibuf;
LogImageFile *image;
- int x, y;
- unsigned short *row, *upix;
int width, height, depth;
- float *frow;
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
- logImageSetVerbose((G.debug & G_DEBUG) ? 1:0);
-
- image = logImageOpenFromMem(mem, size, use_cineon);
-
- if (!image) {
- printf("no image!\n");
- return NULL;
+ logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);
+
+ image = logImageOpenFromMemory(mem, size);
+
+ if (image == 0) {
+ printf("DPX/Cineon: error opening image.\n");
+ return 0;
}
-
+
logImageGetSize(image, &width, &height, &depth);
-
- if (depth != 3) { /*need to do grayscale loading eventually.*/
+
+ if (width == 0 || height == 0) {
logImageClose(image);
- return NULL;
+ return 0;
}
-
- if (width == 0 && height == 0) {
+
+ ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
+ if (ibuf == 0) {
logImageClose(image);
- return NULL;
+ return 0;
}
-
- ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
- row = MEM_mallocN(sizeof(unsigned short)*width*depth, "row in cineon_dpx.c");
- frow = ibuf->rect_float+width*height*4;
-
- for (y = 0; y < height; y++) {
- logImageGetRowBytes(image, row, y); /* checks image->params.doLogarithm and convert */
- upix = row;
- frow -= width*4;
-
- for (x=0; x<width; x++) {
- *(frow++) = ((float)*(upix++)) / 65535.0f;
- *(frow++) = ((float)*(upix++)) / 65535.0f;
- *(frow++) = ((float)*(upix++)) / 65535.0f;
- *(frow++) = 1.0f;
- }
- frow -= width*4;
+ if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) {
+ /* Conversion not possible (probably because the format is unsupported) */
+ logImageClose(image);
+ MEM_freeN(ibuf);
+ return 0;
}
- MEM_freeN(row);
logImageClose(image);
-
- if (flags & IB_rect) {
+ ibuf->ftype = use_cineon ? CINEON : DPX;
+ IMB_flipy(ibuf);
+
+ if (flags & IB_rect)
IMB_rect_from_float(ibuf);
- }
+
return ibuf;
}
static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon, int flags)
{
- LogImageByteConversionParameters conversion;
- const int width= ibuf->x;
- const int height= ibuf->y;
- const int depth= 3;
- LogImageFile* logImage;
- unsigned short* line, *pixel;
- int i, j;
- float *fline;
+ LogImageFile *logImage;
float *fbuf;
- int is_alloc= 0;
+ float *fbuf_ptr;
+ unsigned char *rect_ptr;
+ int x, y, depth, bitspersample, rvalue;
+
+ if (flags & IB_mem) {
+ printf("DPX/Cineon: saving in memory is not supported.\n");
+ return 0;
+ }
- (void)flags; /* unused */
+ logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);
- // cineon_conversion_parameters(&conversion);
- logImageGetByteConversionDefaults(&conversion);
+ depth = (ibuf->planes + 7) >> 3;
+ if (depth > 4 || depth < 3) {
+ printf("DPX/Cineon: unsupported depth: %d for file: '%s'\n", depth, filename);
+ return 0;
+ }
- /*
- * Get the drawable for the current image...
- */
+ if (ibuf->ftype & CINEON_10BIT)
+ bitspersample = 10;
+ else if (ibuf->ftype & CINEON_12BIT)
+ bitspersample = 12;
+ else if (ibuf->ftype & CINEON_16BIT)
+ bitspersample = 16;
+ else
+ bitspersample = 8;
- fbuf= IMB_float_profile_ensure(ibuf, conversion.doLogarithm ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE, &is_alloc);
+ logImage = logImageCreate(filename, use_cineon, ibuf->x, ibuf->y, bitspersample, (depth == 4),
+ (ibuf->ftype & CINEON_LOG), -1, -1, -1, "Blender");
- if (fbuf == NULL) { /* in the unlikely event that converting to a float buffer fails */
+ if (logImage == 0) {
+ printf("DPX/Cineon: error creating file.\n");
return 0;
}
-
- logImageSetVerbose((G.debug & G_DEBUG) ? 1:0);
- logImage = logImageCreate(filename, use_cineon, width, height, depth);
- if (!logImage) return 0;
-
- if (logImageSetByteConversion(logImage, &conversion)==0) {
- printf("error setting args\n");
+ if (ibuf->rect_float != 0 && bitspersample != 8) {
+ /* don't use the float buffer to save 8 bpp picture to prevent color banding
+ (there's no dithering algorithm behing the logImageSetDataRGBA function) */
+ IMB_flipy(ibuf);
+ rvalue = (logImageSetDataRGBA(logImage, ibuf->rect_float, 1) == 0);
+ IMB_flipy(ibuf);
}
-
- line = MEM_mallocN(sizeof(unsigned short)*depth*width, "line");
-
- /*note that image is flipped when sent to logImageSetRowBytes (see last passed parameter).*/
- for (j = 0; j < height; ++j) {
- fline = &fbuf[width*j*4];
- for (i=0; i<width; i++) {
- float *fpix, fpix2[3];
- /*we have to convert to cinepaint's 16-bit-per-channel here*/
- pixel = &line[i*depth];
- fpix = &fline[i*4];
- memcpy(fpix2, fpix, sizeof(float)*3);
-
- if (fpix2[0]>=1.0f) fpix2[0] = 1.0f; else if (fpix2[0]<0.0f) fpix2[0]= 0.0f;
- if (fpix2[1]>=1.0f) fpix2[1] = 1.0f; else if (fpix2[1]<0.0f) fpix2[1]= 0.0f;
- if (fpix2[2]>=1.0f) fpix2[2] = 1.0f; else if (fpix2[2]<0.0f) fpix2[2]= 0.0f;
-
- pixel[0] = (unsigned short)(fpix2[0] * 65535.0f); /*float-float math is faster*/
- pixel[1] = (unsigned short)(fpix2[1] * 65535.0f);
- pixel[2] = (unsigned short)(fpix2[2] * 65535.0f);
+ else {
+ if (ibuf->rect == 0)
+ IMB_rect_from_float(ibuf);
+
+ fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon");
+ if (fbuf == 0) {
+ printf("DPX/Cineon: error allocating memory.\n");
+ logImageClose(logImage);
+ return 0;
}
- logImageSetRowBytes(logImage, (const unsigned short*)line, height-1-j);
- }
- logImageClose(logImage);
-
- MEM_freeN(line);
-
- if (is_alloc) {
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ fbuf_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x + x);
+ rect_ptr = (unsigned char *)ibuf->rect + 4 * (y * ibuf->x + x);
+ fbuf_ptr[0] = (float)rect_ptr[0] / 255.0f;
+ fbuf_ptr[1] = (float)rect_ptr[1] / 255.0f;
+ fbuf_ptr[2] = (float)rect_ptr[2] / 255.0f;
+ fbuf_ptr[3] = (depth == 4) ? ((float)rect_ptr[3] / 255.0f) : 1.0f;
+ }
+ }
+ rvalue = (logImageSetDataRGBA(logImage, fbuf, 0) == 0);
MEM_freeN(fbuf);
}
-
- return 1;
+
+ logImageClose(logImage);
+ return rvalue;
}
-int imb_savecineon(struct ImBuf *buf, const char *myfile, int flags)
+int imb_save_cineon(struct ImBuf *buf, const char *myfile, int flags)
{
return imb_save_dpx_cineon(buf, myfile, 1, flags);
}
-
int imb_is_cineon(unsigned char *buf)
{
- return cineonIsMemFileCineon(buf);
+ return logImageIsCineon(buf);
}
-ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
if (imb_is_cineon(mem))
- return imb_load_dpx_cineon(mem, 1, size, flags, colorspace);
- return NULL;
+ return imb_load_dpx_cineon(mem, size, 1, flags, colorspace);
+ return 0;
}
int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags)
@@ -221,12 +195,12 @@ int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags)
int imb_is_dpx(unsigned char *buf)
{
- return dpxIsMemFileCineon(buf);
+ return logImageIsDpx(buf);
}
-ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
if (imb_is_dpx(mem))
- return imb_load_dpx_cineon(mem, 0, size, flags, colorspace);
- return NULL;
+ return imb_load_dpx_cineon(mem, size, 0, flags, colorspace);
+ return 0;
}
diff --git a/source/blender/imbuf/intern/cineon/cineonfile.h b/source/blender/imbuf/intern/cineon/cineonfile.h
index e681153aa6e..e69de29bb2d 100644
--- a/source/blender/imbuf/intern/cineon/cineonfile.h
+++ b/source/blender/imbuf/intern/cineon/cineonfile.h
@@ -1,134 +0,0 @@
-/*
- * Cineon image file format library definitions.
- * Cineon file format structures.
- *
- * This header file contains private details.
- * User code should generally use cineonlib.h only.
- *
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
- *
- * 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.
- *
- */
-
-#ifndef __CINEONFILE_H__
-#define __CINEONFILE_H__
-
-/** \file blender/imbuf/intern/cineon/cineonfile.h
- * \ingroup imbcineon
- */
-
-#include "logImageCore.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- U32 magic_num; /* magic number */
- U32 image_offset; /* offset to image data in bytes */
- U32 gen_hdr_size; /* generic header length in bytes */
- U32 ind_hdr_size; /* industry header length in bytes */
- U32 user_data_size; /* user-defined data length in bytes */
- U32 file_size; /* file size in bytes */
- ASCII vers[8]; /* which header format version is being used (v4.5) */
- ASCII file_name[100]; /* image file name */
- ASCII create_date[12]; /* file creation date */
- ASCII create_time[12]; /* file creation time */
- ASCII Reserved[36]; /* reserved field TBD (need to pad) */
-} CineonFileInformation;
-
-typedef struct {
- U8 designator1;
- U8 designator2;
- U8 bits_per_pixel;
- U8 filler;
- U32 pixels_per_line;
- U32 lines_per_image;
- U32 ref_low_data; /* reference low data code value */
- R32 ref_low_quantity; /* reference low quantity represented */
- U32 ref_high_data; /* reference high data code value */
- R32 ref_high_quantity;/* reference high quantity represented */
-} CineonChannelInformation;
-
-typedef struct {
- U8 orientation; /* image orientation */
- U8 channels_per_image;
- U16 filler;
- CineonChannelInformation channel[8];
- R32 white_point_x;
- R32 white_point_y;
- R32 red_primary_x;
- R32 red_primary_y;
- R32 green_primary_x;
- R32 green_primary_y;
- R32 blue_primary_x;
- R32 blue_primary_y;
- ASCII label[200];
- ASCII reserved[28];
-} CineonImageInformation;
-
-typedef struct {
- U8 interleave;
- U8 packing;
- U8 signage;
- U8 sense;
- U32 line_padding;
- U32 channel_padding;
- ASCII reserved[20];
-} CineonFormatInformation;
-
-typedef struct {
- S32 x_offset;
- S32 y_offset;
- ASCII file_name[100];
- ASCII create_date[12]; /* file creation date */
- ASCII create_time[12]; /* file creation time */
- ASCII input_device[64];
- ASCII model_number[32];
- ASCII serial_number[32];
- R32 x_input_samples_per_mm;
- R32 y_input_samples_per_mm;
- R32 input_device_gamma;
- ASCII reserved[40];
-} CineonOriginationInformation;
-
-typedef struct {
- CineonFileInformation fileInfo;
- CineonImageInformation imageInfo;
- CineonFormatInformation formatInfo;
- CineonOriginationInformation originInfo;
-} CineonGenericHeader;
-
-typedef struct {
- U8 filmCode;
- U8 filmType;
- U8 perfOffset;
- U8 filler;
- U32 keycodePrefix;
- U32 keycodeCount;
- ASCII format[32];
- U32 framePosition; /* in sequence */
- R32 frameRate; /* frames per second */
- ASCII attribute[32];
- ASCII slate[200];
- ASCII reserved[740];
-} CineonMPISpecificInformation;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CINEONFILE_H__ */
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index a9001303679..9926d8c8562 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -1,21 +1,23 @@
/*
- * Cineon image file format library routines.
+ * Cineon image file format library routines.
*
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
+ * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
@@ -23,800 +25,355 @@
* \ingroup imbcineon
*/
+
#include "cineonlib.h"
-#include "cineonfile.h"
+#include "logmemfile.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
-#include <time.h> /* strftime() */
+#include <time.h>
#include <sys/types.h>
-#ifdef WIN32
-#include <winsock.h>
-#else
-#include <netinet/in.h> /* htonl() */
-#endif
-#include <string.h> /* memset */
+#include <string.h>
-#include "BLI_utildefines.h"
#include "BLI_fileops.h"
+#include "BLI_math_base.h"
+#include "BLI_utildefines.h"
-#include "cin_debug_stuff.h"
-#include "logmemfile.h"
-
-static void
-fillCineonFileInfo(CineonFile* cineon, CineonFileInformation* fileInfo, const char* filename) {
-
- time_t fileClock;
- struct tm* fileTime;
-
- fileInfo->magic_num = htonl(CINEON_FILE_MAGIC);
- fileInfo->image_offset = htonl(cineon->imageOffset);
- fileInfo->gen_hdr_size = htonl(
- sizeof(CineonFileInformation) +
- sizeof(CineonImageInformation) +
- sizeof(CineonFormatInformation) +
- sizeof(CineonOriginationInformation));
- fileInfo->ind_hdr_size = 0;
- fileInfo->user_data_size = 0;
- fileInfo->file_size = htonl(cineon->imageOffset + cineon->height * cineon->lineBufferLength);
- strcpy(fileInfo->vers, "V4.5");
- strncpy(fileInfo->file_name, filename, 99);
- fileInfo->file_name[99] = 0;
-
- fileClock = time(0);
- fileTime = localtime(&fileClock);
- strftime(fileInfo->create_date, 12, "%Y:%m:%d", fileTime);
- /* Question: is %Z in strftime guaranteed to return 3 chars? */
- strftime(fileInfo->create_time, 12, "%H:%M:%S%Z", fileTime);
- fileInfo->create_time[11] = 0;
-}
-
-static void
-dumpCineonFileInfo(CineonFileInformation* fileInfo) {
- d_printf("\n--File Information--\n");
- d_printf("Magic: %8.8lX\n", (uintptr_t)ntohl(fileInfo->magic_num));
- d_printf("Image Offset %ld\n", (intptr_t)ntohl(fileInfo->image_offset));
- d_printf("Generic Header size %ld\n", (intptr_t)ntohl(fileInfo->gen_hdr_size));
- d_printf("Industry Header size %ld\n", (intptr_t)ntohl(fileInfo->ind_hdr_size));
- d_printf("User Data size %ld\n", (intptr_t)ntohl(fileInfo->user_data_size));
- d_printf("File size %ld\n", (intptr_t)ntohl(fileInfo->file_size));
- d_printf("Version \"%s\"\n", fileInfo->vers);
- d_printf("File name \"%s\"\n", fileInfo->file_name);
- d_printf("Creation date \"%s\"\n", fileInfo->create_date);
- d_printf("Creation time \"%s\"\n", fileInfo->create_time);
-}
-
-static void
-fillCineonChannelInfo(CineonFile* cineon, CineonChannelInformation* chan, int des) {
-
- chan->designator1 = 0;
- chan->designator2 = des;
- chan->bits_per_pixel = 10;
- chan->pixels_per_line = htonl(cineon->width);
- chan->lines_per_image = htonl(cineon->height);
- chan->ref_low_data = htonl(0);
- chan->ref_low_quantity = htonf(0.0);
- chan->ref_high_data = htonl(1023);
- chan->ref_high_quantity = htonf(2.046);
-}
-
-static void
-dumpCineonChannelInfo(CineonChannelInformation* chan) {
- d_printf(" Metric selector: %d", chan->designator1);
- switch (chan->designator1) {
- case 0: d_printf(" (Universal)\n"); break;
- default: d_printf(" (Vendor specific)\n"); break;
- }
- d_printf(" Metric: %d,", chan->designator2);
- switch (chan->designator2) {
- case 0: d_printf(" B&W (printing density?)\n"); break;
- case 1: d_printf(" Red printing density\n"); break;
- case 2: d_printf(" Green printing density\n"); break;
- case 3: d_printf(" Blue printing density\n"); break;
- case 4: d_printf(" Red CCIR XA/11\n"); break;
- case 5: d_printf(" Green CCIR XA/11\n"); break;
- case 6: d_printf(" Blue CCIR XA/11\n"); break;
- default: d_printf(" (unknown)\n"); break;
- }
- d_printf(" Bits per pixel %d\n", chan->bits_per_pixel);
- d_printf(" Pixels per line %ld\n", (intptr_t)ntohl(chan->pixels_per_line));
- d_printf(" Lines per image %ld\n", (intptr_t)ntohl(chan->lines_per_image));
- d_printf(" Ref low data %ld\n", (intptr_t)ntohl(chan->ref_low_data));
- d_printf(" Ref low quantity %f\n", ntohf(chan->ref_low_quantity));
- d_printf(" Ref high data %ld\n", (intptr_t)ntohl(chan->ref_high_data));
- d_printf(" Ref high quantity %f\n", ntohf(chan->ref_high_quantity));
-}
-
-static void
-fillCineonImageInfo(CineonFile* cineon, CineonImageInformation* imageInfo) {
-
- imageInfo->orientation = 0;
- imageInfo->channels_per_image = cineon->depth;
-
- if (cineon->depth == 1) {
- fillCineonChannelInfo(cineon, &imageInfo->channel[0], 0);
-
- }
- else if (cineon->depth == 3) {
- fillCineonChannelInfo(cineon, &imageInfo->channel[0], 1);
- fillCineonChannelInfo(cineon, &imageInfo->channel[1], 2);
- fillCineonChannelInfo(cineon, &imageInfo->channel[2], 3);
- }
-
- imageInfo->white_point_x = htonf(undefined());
- imageInfo->white_point_y = htonf(undefined());
- imageInfo->red_primary_x = htonf(undefined());
- imageInfo->red_primary_y = htonf(undefined());
- imageInfo->green_primary_x = htonf(undefined());
- imageInfo->green_primary_y = htonf(undefined());
- imageInfo->blue_primary_x = htonf(undefined());
- imageInfo->blue_primary_y = htonf(undefined());
-
- strcpy(imageInfo->label, "David's Cineon writer.");
-
-}
-
-static void
-dumpCineonImageInfo(CineonImageInformation* imageInfo) {
-
- int i;
- d_printf("\n--Image Information--\n");
- d_printf("Image orientation %d,", imageInfo->orientation);
- switch (imageInfo->orientation) {
- case 0: d_printf(" LRTB\n"); break;
- case 1: d_printf(" LRBT\n"); break;
- case 2: d_printf(" RLTB\n"); break;
- case 3: d_printf(" RLBT\n"); break;
- case 4: d_printf(" TBLR\n"); break;
- case 5: d_printf(" TBRL\n"); break;
- case 6: d_printf(" BTLR\n"); break;
- case 7: d_printf(" BTRL\n"); break;
- default: d_printf(" (unknown)\n"); break;
- }
- d_printf("Channels %d\n", imageInfo->channels_per_image);
- for (i = 0; i < imageInfo->channels_per_image; ++i) {
- d_printf(" --Channel %d--\n", i);
- dumpCineonChannelInfo(&imageInfo->channel[i]);
- }
-
- d_printf("White point x %f\n", ntohf(imageInfo->white_point_x));
- d_printf("White point y %f\n", ntohf(imageInfo->white_point_y));
- d_printf("Red primary x %f\n", ntohf(imageInfo->red_primary_x));
- d_printf("Red primary y %f\n", ntohf(imageInfo->red_primary_y));
- d_printf("Green primary x %f\n", ntohf(imageInfo->green_primary_x));
- d_printf("Green primary y %f\n", ntohf(imageInfo->green_primary_y));
- d_printf("Blue primary x %f\n", ntohf(imageInfo->blue_primary_x));
- d_printf("Blue primary y %f\n", ntohf(imageInfo->blue_primary_y));
- d_printf("Label \"%s\"\n", imageInfo->label);
-}
-
-static void
-fillCineonFormatInfo(CineonFile* cineon, CineonFormatInformation* formatInfo) {
-
- (void)cineon; /* unused */
-
- formatInfo->interleave = 0;
- formatInfo->packing = 5;
- formatInfo->signage = 0;
- formatInfo->sense = 0;
- formatInfo->line_padding = htonl(0);
- formatInfo->channel_padding = htonl(0);
-}
-
-static void
-dumpCineonFormatInfo(CineonFormatInformation* formatInfo) {
- d_printf("\n--Format Information--\n");
- d_printf("Interleave %d,", formatInfo->interleave);
- switch (formatInfo->interleave) {
- case 0: d_printf(" pixel interleave\n"); break;
- case 1: d_printf(" line interleave\n"); break;
- case 2: d_printf(" channel interleave\n"); break;
- default: d_printf(" (unknown)\n"); break;
- }
- d_printf("Packing %d,", formatInfo->packing);
- if (formatInfo->packing & 0x80) {
- d_printf(" multi pixel,");
- }
- else {
- d_printf(" single pixel,");
- }
- switch (formatInfo->packing & 0x7F) {
- case 0: d_printf(" tight\n"); break;
- case 1: d_printf(" byte packed left\n"); break;
- case 2: d_printf(" byte packed right\n"); break;
- case 3: d_printf(" word packed left\n"); break;
- case 4: d_printf(" word packed right\n"); break;
- case 5: d_printf(" long packed left\n"); break;
- case 6: d_printf(" long packed right\n"); break;
- default: d_printf(" (unknown)\n"); break;
- }
- d_printf("Sign %d,", formatInfo->signage);
- if (formatInfo->signage) {
- d_printf(" signed\n");
- }
- else {
- d_printf(" unsigned\n");
- }
- d_printf("Sense %d,", formatInfo->signage);
- if (formatInfo->signage) {
- d_printf(" negative\n");
- }
- else {
- d_printf(" positive\n");
- }
- d_printf("End of line padding %ld\n", (intptr_t)ntohl(formatInfo->line_padding));
- d_printf("End of channel padding %ld\n", (intptr_t)ntohl(formatInfo->channel_padding));
-}
-
-static void
-fillCineonOriginationInfo(CineonFile* cineon,
- CineonOriginationInformation* originInfo, CineonFileInformation* fileInfo) {
-
- (void)cineon; /* unused */
-
- originInfo->x_offset = htonl(0);
- originInfo->y_offset = htonl(0);
- strcpy(originInfo->file_name, fileInfo->file_name);
- strcpy(originInfo->create_date, fileInfo->create_date);
- strcpy(originInfo->create_time, fileInfo->create_time);
- strncpy(originInfo->input_device, "David's Cineon writer", 64);
- strncpy(originInfo->model_number, "Software", 32);
- strncpy(originInfo->serial_number, "001", 32);
- originInfo->x_input_samples_per_mm = htonf(undefined());
- originInfo->y_input_samples_per_mm = htonf(undefined());
- /* this should probably be undefined, too */
- originInfo->input_device_gamma = htonf(1.0);
-}
-
-static void
-dumpCineonOriginationInfo(CineonOriginationInformation* originInfo) {
- d_printf("\n--Origination Information--\n");
- d_printf("X offset %ld\n", (intptr_t)ntohl(originInfo->x_offset));
- d_printf("Y offset %ld\n", (intptr_t)ntohl(originInfo->y_offset));
- d_printf("File name \"%s\"\n", originInfo->file_name);
- d_printf("Creation date \"%s\"\n", originInfo->create_date);
- d_printf("Creation time \"%s\"\n", originInfo->create_time);
- d_printf("Input device \"%s\"\n", originInfo->input_device);
- d_printf("Model number \"%s\"\n", originInfo->model_number);
- d_printf("Serial number \"%s\"\n", originInfo->serial_number);
- d_printf("Samples per mm in x %f\n", ntohf(originInfo->x_input_samples_per_mm));
- d_printf("Samples per mm in y %f\n", ntohf(originInfo->y_input_samples_per_mm));
- d_printf("Input device gamma %f\n", ntohf(originInfo->input_device_gamma));
-}
-
-static int
-initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const char* imagename) {
-
- fillCineonFileInfo(cineon, &header->fileInfo, imagename);
- fillCineonImageInfo(cineon, &header->imageInfo);
- fillCineonFormatInfo(cineon, &header->formatInfo);
- fillCineonOriginationInfo(cineon, &header->originInfo, &header->fileInfo);
+#include "logImageLib.h"
- return 0;
-}
+#include "MEM_guardedalloc.h"
-static void
-UNUSED_FUNCTION(dumpCineonGenericHeader)(CineonGenericHeader* header) {
- dumpCineonFileInfo(&header->fileInfo);
- dumpCineonImageInfo(&header->imageInfo);
- dumpCineonFormatInfo(&header->formatInfo);
- dumpCineonOriginationInfo(&header->originInfo);
-}
+/*
+ * For debug purpose
+ */
static int verbose = 0;
-void
-cineonSetVerbose(int verbosity) {
- verbose = verbosity;
-}
-
-static void
-verboseMe(CineonFile* cineon) {
-
- d_printf("size %d x %d x %d\n", cineon->width, cineon->height, cineon->depth);
- d_printf("ImageStart %d, lineBufferLength %d, implied length %d\n",
- cineon->imageOffset, cineon->lineBufferLength * 4,
- cineon->imageOffset + cineon->lineBufferLength * 4 * cineon->height);
-}
-
-int
-cineonGetRowBytes(CineonFile* cineon, unsigned short* row, int y) {
-
- int longsRead;
- int pixelIndex;
- int longIndex;
- int numPixels = cineon->width * cineon->depth;
-
-
- /* only seek if not reading consecutive lines */
- if (y != cineon->fileYPos) {
- int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4;
- if (verbose) d_printf("Seek in getRowBytes\n");
- if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset);
- return 1;
- }
- cineon->fileYPos = y;
- }
-
- longsRead = logimage_fread(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon);
- if (longsRead != cineon->lineBufferLength) {
- if (verbose) {
- d_printf("Couldn't read line %d length %d\n", y, cineon->lineBufferLength * 4);
- perror("cineonGetRowBytes");
- }
-
- return 1;
- }
- /* remember where we left the car, honey */
- ++cineon->fileYPos;
-
- /* convert longwords to pixels */
- pixelIndex = 0;
- for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) {
- unsigned int t = ntohl(cineon->lineBuffer[longIndex]);
- t = t >> 2;
- cineon->pixelBuffer[pixelIndex+2] = (unsigned short) t & 0x3ff;
- t = t >> 10;
- cineon->pixelBuffer[pixelIndex+1] = (unsigned short) t & 0x3ff;
- t = t >> 10;
- cineon->pixelBuffer[pixelIndex] = (unsigned short) t & 0x3ff;
- pixelIndex += 3;
- }
-
- /* extract required pixels */
- for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
- if (cineon->params.doLogarithm)
- row[pixelIndex] = cineon->lut10_16[cineon->pixelBuffer[pixelIndex]];
- else
- row[pixelIndex] = cineon->pixelBuffer[pixelIndex] << 6;
- }
-
- return 0;
+void cineonSetVerbose(int verbosity) {
+ verbose = verbosity;
}
-int
-cineonSetRowBytes(CineonFile* cineon, const unsigned short* row, int y) {
-
- int pixelIndex;
- int numPixels = cineon->width * cineon->depth;
- int longIndex;
- int longsWritten;
-
- /* put new pixels into pixelBuffer */
- for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
- if (cineon->params.doLogarithm)
- cineon->pixelBuffer[pixelIndex] = cineon->lut16_16[row[pixelIndex]];
- else
- cineon->pixelBuffer[pixelIndex] = row[pixelIndex] >> 6;
- }
-
- /* pack into longwords */
- pixelIndex = 0;
- for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) {
- unsigned int t =
- (cineon->pixelBuffer[pixelIndex] << 22) |
- (cineon->pixelBuffer[pixelIndex+1] << 12) |
- (cineon->pixelBuffer[pixelIndex+2] << 2);
- cineon->lineBuffer[longIndex] = htonl(t);
- pixelIndex += 3;
- }
-
- /* only seek if not reading consecutive lines */
- if (y != cineon->fileYPos) {
- int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4;
- if (verbose) d_printf("Seek in setRowBytes\n");
- if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset);
- return 1;
- }
- cineon->fileYPos = y;
- }
-
- longsWritten = fwrite(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon->file);
- if (longsWritten != cineon->lineBufferLength) {
- if (verbose) d_printf("Couldn't write line %d length %d\n", y, cineon->lineBufferLength * 4);
- return 1;
- }
-
- ++cineon->fileYPos;
+static void fillCineonMainHeader(LogImageFile *cineon, CineonMainHeader *header,
+ const char *filename, const char *creator)
+{
+ time_t fileClock;
+ struct tm *fileTime;
+ int i;
- return 0;
+ memset(header, 0, sizeof(CineonMainHeader));
+
+ /* --- File header --- */
+ header->fileHeader.magic_num = swap_uint(CINEON_FILE_MAGIC, cineon->isMSB);
+ header->fileHeader.offset = swap_uint(cineon->element[0].dataOffset, cineon->isMSB);
+ header->fileHeader.gen_hdr_size = swap_uint(sizeof(CineonFileHeader) + sizeof(CineonImageHeader) +
+ sizeof(CineonOriginationHeader), cineon->isMSB);
+ header->fileHeader.ind_hdr_size = 0;
+ header->fileHeader.user_data_size = 0;
+ header->fileHeader.file_size = swap_uint(cineon->element[0].dataOffset + cineon->height * getRowLength(cineon->width, cineon->element[0]), cineon->isMSB);
+ strcpy(header->fileHeader.version, "v4.5");
+ strncpy(header->fileHeader.file_name, filename, 99);
+ header->fileHeader.file_name[99] = 0;
+ fileClock = time(0);
+ fileTime = localtime(&fileClock);
+ strftime(header->fileHeader.creation_date, 12, "%Y:%m:%d", fileTime);
+ strftime(header->fileHeader.creation_time, 12, "%H:%M:%S%Z", fileTime);
+ header->fileHeader.creation_time[11] = 0;
+
+ /* --- Image header --- */
+ header->imageHeader.orientation = 0;
+ header->imageHeader.elements_per_image = cineon->depth;
+
+ for (i = 0; i < 3; i++) {
+ header->imageHeader.element[i].descriptor1 = 0;
+ header->imageHeader.element[i].descriptor2 = i;
+ header->imageHeader.element[i].bits_per_sample = cineon->element[0].bitsPerSample;
+ header->imageHeader.element[i].pixels_per_line = swap_uint(cineon->width, cineon->isMSB);
+ header->imageHeader.element[i].lines_per_image = swap_uint(cineon->height, cineon->isMSB);
+ header->imageHeader.element[i].ref_low_data = swap_uint(cineon->element[0].refLowData, cineon->isMSB);
+ header->imageHeader.element[i].ref_low_quantity = swap_float(cineon->element[0].refLowQuantity, cineon->isMSB);
+ header->imageHeader.element[i].ref_high_data = swap_uint(cineon->element[0].refHighData, cineon->isMSB);
+ header->imageHeader.element[i].ref_high_quantity = swap_float(cineon->element[0].refHighQuantity, cineon->isMSB);
+ }
+
+ header->imageHeader.white_point_x = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.white_point_y = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.red_primary_x = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.red_primary_y = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.green_primary_x = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.green_primary_y = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.blue_primary_x = swap_float(0.0f, cineon->isMSB);
+ header->imageHeader.blue_primary_y = swap_float(0.0f, cineon->isMSB);
+ strncpy(header->imageHeader.label, creator, 199);
+ header->imageHeader.label[199] = 0;
+ header->imageHeader.interleave = 0;
+ header->imageHeader.data_sign = 0;
+ header->imageHeader.sense = 0;
+ header->imageHeader.line_padding = swap_uint(0, cineon->isMSB);
+ header->imageHeader.element_padding = swap_uint(0, cineon->isMSB);
+
+ switch (cineon->element[0].packing) {
+ case 0:
+ header->imageHeader.packing = 0;
+ break;
+
+ case 1:
+ header->imageHeader.packing = 5;
+ break;
+
+ case 2:
+ header->imageHeader.packing = 6;
+ break;
+ }
+
+ /* --- Origination header --- */
+ /* we leave it blank */
+
+ /* --- Film header --- */
+ /* we leave it blank */
}
-int
-cineonGetRow(CineonFile* cineon, unsigned short* row, int y) {
-
- int longsRead;
- int pixelIndex;
- int longIndex;
-/* int numPixels = cineon->width * cineon->depth;
-*/
- /* only seek if not reading consecutive lines */
- if (y != cineon->fileYPos) {
- int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4;
- if (verbose) d_printf("Seek in getRow\n");
- if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset);
- return 1;
- }
- cineon->fileYPos = y;
- }
-
- longsRead = logimage_fread(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon);
- if (longsRead != cineon->lineBufferLength) {
- if (verbose) d_printf("Couldn't read line %d length %d\n", y, cineon->lineBufferLength * 4);
- return 1;
- }
+LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize)
+{
+ CineonMainHeader header;
+ LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
+ char *filename = (char *)byteStuff;
+ int i;
+ unsigned int dataOffset;
- /* remember where we left the car, honey */
- ++cineon->fileYPos;
-
- /* convert longwords to pixels */
- pixelIndex = 0;
- for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) {
- unsigned int t = ntohl(cineon->lineBuffer[longIndex]);
- t = t >> 2;
- row[pixelIndex+2] = (unsigned short) t & 0x3ff;
- t = t >> 10;
- row[pixelIndex+1] = (unsigned short) t & 0x3ff;
- t = t >> 10;
- row[pixelIndex] = (unsigned short) t & 0x3ff;
- pixelIndex += 3;
+ if (cineon == 0) {
+ if (verbose) printf("Cineon: Failed to malloc cineon file structure.\n");
+ return 0;
}
- return 0;
-}
+ /* zero the header */
+ memset(&header, 0, sizeof(CineonMainHeader));
-int
-cineonSetRow(CineonFile* cineon, const unsigned short* row, int y) {
-
- int pixelIndex;
-/* int numPixels = cineon->width * cineon->depth;
-*/ int longIndex;
- int longsWritten;
-
- /* pack into longwords */
- pixelIndex = 0;
- for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) {
- unsigned int t =
- (row[pixelIndex] << 22) |
- (row[pixelIndex+1] << 12) |
- (row[pixelIndex+2] << 2);
- cineon->lineBuffer[longIndex] = htonl(t);
- pixelIndex += 3;
- }
+ /* for close routine */
+ cineon->file = 0;
- /* only seek if not reading consecutive lines */
- if (y != cineon->fileYPos) {
- int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4;
- if (verbose) d_printf("Seek in setRowBytes\n");
- if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset);
- return 1;
+ if (fromMemory == 0) {
+ /* byteStuff is then the filename */
+ cineon->file = BLI_fopen(filename, "rb");
+ if (cineon->file == 0) {
+ if (verbose) printf("Cineon: Failed to open file \"%s\".\n", filename);
+ logImageClose(cineon);
+ return 0;
}
- cineon->fileYPos = y;
+ /* not used in this case */
+ cineon->memBuffer = 0;
+ cineon->memCursor = 0;
+ cineon->memBufferSize = 0;
}
-
- longsWritten = fwrite(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon->file);
- if (longsWritten != cineon->lineBufferLength) {
- if (verbose) d_printf("Couldn't write line %d length %d\n", y, cineon->lineBufferLength * 4);
- return 1;
+ else {
+ cineon->memBuffer = (unsigned char *)byteStuff;
+ cineon->memCursor = (unsigned char *)byteStuff;
+ cineon->memBufferSize = bufferSize;
}
- ++cineon->fileYPos;
-
- return 0;
-}
-
-CineonFile*
-cineonOpen(const char* filename) {
-
- CineonGenericHeader header;
-
- CineonFile* cineon = (CineonFile* )malloc(sizeof(CineonFile));
- if (cineon == 0) {
- if (verbose) d_printf("Failed to malloc cineon file structure.\n");
+ if (logimage_fread(&header, sizeof(header), 1, cineon) == 0) {
+ if (verbose) printf("Cineon: Not enough data for header in \"%s\".\n", byteStuff);
+ logImageClose(cineon);
return 0;
}
- /* for close routine */
- cineon->file = 0;
- cineon->lineBuffer = 0;
- cineon->pixelBuffer = 0;
- cineon->membuffer = 0;
- cineon->memcursor = 0;
- cineon->membuffersize = 0;
-
- cineon->file = BLI_fopen(filename, "rb");
- if (cineon->file == 0) {
- if (verbose) d_printf("Failed to open file \"%s\".\n", filename);
- cineonClose(cineon);
- return 0;
+ /* endianness determination */
+ if (header.fileHeader.magic_num == swap_uint(CINEON_FILE_MAGIC, 1)) {
+ cineon->isMSB = 1;
+ if (verbose) printf("Cineon: File is MSB.\n");
}
- cineon->reading = 1;
-
- if (logimage_fread(&header, sizeof(CineonGenericHeader), 1, cineon) == 0) {
- if (verbose) d_printf("Not enough data for header in \"%s\".\n", filename);
- cineonClose(cineon);
- return 0;
+ else if (header.fileHeader.magic_num == CINEON_FILE_MAGIC) {
+ cineon->isMSB = 0;
+ if (verbose) printf("Cineon: File is LSB.\n");
}
-
- /* let's assume cineon files are always network order */
- if (header.fileInfo.magic_num != ntohl(CINEON_FILE_MAGIC)) {
- if (verbose) d_printf("Bad magic number %8.8lX in \"%s\".\n",
- (uintptr_t)ntohl(header.fileInfo.magic_num), filename);
- cineonClose(cineon);
+ else {
+ if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n",
+ (uintptr_t)header.fileHeader.magic_num, byteStuff);
+ logImageClose(cineon);
return 0;
}
- if (header.formatInfo.packing != 5) {
- if (verbose) d_printf("Can't understand packing %d\n", header.formatInfo.packing);
- cineonClose(cineon);
- return 0;
- }
+ cineon->width = swap_uint(header.imageHeader.element[0].pixels_per_line, cineon->isMSB);
+ cineon->height = swap_uint(header.imageHeader.element[0].lines_per_image, cineon->isMSB);
+ cineon->depth = header.imageHeader.elements_per_image;
+ cineon->srcFormat = format_Cineon;
- cineon->width = ntohl(header.imageInfo.channel[0].pixels_per_line);
- cineon->height = ntohl(header.imageInfo.channel[0].lines_per_image);
- cineon->depth = header.imageInfo.channels_per_image;
- /* cineon->bitsPerPixel = 10; */
- cineon->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel;
- cineon->imageOffset = ntohl(header.fileInfo.image_offset);
-
- cineon->lineBufferLength = pixelsToLongs(cineon->width * cineon->depth);
- cineon->lineBuffer = malloc(cineon->lineBufferLength * 4);
- if (cineon->lineBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", cineon->lineBufferLength * 4);
- cineonClose(cineon);
+ if (header.imageHeader.interleave == 0)
+ cineon->numElements = 1;
+ else if (header.imageHeader.interleave == 2)
+ cineon->numElements = header.imageHeader.elements_per_image;
+ else {
+ if (verbose) printf("Cineon: Data interleave not supported: %d\n", header.imageHeader.interleave);
return 0;
}
- cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short));
- if (cineon->pixelBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (cineon->width * cineon->depth) * (int)sizeof(unsigned short));
- cineonClose(cineon);
- return 0;
+ if (cineon->depth == 1) {
+ /* Grayscale image */
+ cineon->element[0].descriptor = descriptor_Luminance;
+ cineon->element[0].transfer = transfer_Linear;
+ cineon->element[0].depth = 1;
}
- cineon->pixelBufferUsed = 0;
-
- if (logimage_fseek(cineon, cineon->imageOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to image data at %d\n", cineon->imageOffset);
- cineonClose(cineon);
- return 0;
+ else if (cineon->depth == 3) {
+ /* RGB image */
+ if (cineon->numElements == 1) {
+ cineon->element[0].descriptor = descriptor_RGB;
+ cineon->element[0].transfer = transfer_PrintingDensity;
+ cineon->element[0].depth = 3;
+ }
+ else if (cineon->numElements == 3) {
+ cineon->element[0].descriptor = descriptor_Red;
+ cineon->element[0].transfer = transfer_PrintingDensity;
+ cineon->element[0].depth = 1;
+ cineon->element[1].descriptor = descriptor_Green;
+ cineon->element[1].transfer = transfer_PrintingDensity;
+ cineon->element[1].depth = 1;
+ cineon->element[2].descriptor = descriptor_Blue;
+ cineon->element[2].transfer = transfer_PrintingDensity;
+ cineon->element[2].depth = 1;
+ }
}
- cineon->fileYPos = 0;
-
- logImageGetByteConversionDefaults(&cineon->params);
- setupLut(cineon);
-
- cineon->getRow = &cineonGetRowBytes;
- cineon->setRow = 0;
- cineon->close = &cineonClose;
-
- if (verbose) {
- verboseMe(cineon);
+ else {
+ if (verbose) printf("Cineon: Cineon image depth unsupported: %d\n", cineon->depth);
+ return 0;
}
- return cineon;
-}
+ dataOffset = swap_uint(header.fileHeader.offset, cineon->isMSB);
-int cineonIsMemFileCineon(unsigned char *mem)
-{
- unsigned int num;
- memcpy(&num, mem, sizeof(unsigned int));
-
- if (num != ntohl(CINEON_FILE_MAGIC)) {
- return 0;
- }
- else return 1;
-}
+ for (i = 0; i < cineon->numElements; i++) {
+ cineon->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample;
+ cineon->element[i].maxValue = powf(2, cineon->element[i].bitsPerSample) - 1.0f;
+ cineon->element[i].refLowData = swap_uint(header.imageHeader.element[i].ref_low_data, cineon->isMSB);
+ cineon->element[i].refLowQuantity = swap_float(header.imageHeader.element[i].ref_low_quantity, cineon->isMSB);
+ cineon->element[i].refHighData = swap_uint(header.imageHeader.element[i].ref_high_data, cineon->isMSB);
+ cineon->element[i].refHighQuantity = swap_float(header.imageHeader.element[i].ref_high_quantity, cineon->isMSB);
-CineonFile*
-cineonOpenFromMem(unsigned char *mem, unsigned int size) {
+ switch (header.imageHeader.packing) {
+ case 0:
+ cineon->element[i].packing = 0;
+ break;
- CineonGenericHeader header;
-
- CineonFile* cineon = (CineonFile* )malloc(sizeof(CineonFile));
- if (cineon == 0) {
- if (verbose) d_printf("Failed to malloc cineon file structure.\n");
- return 0;
- }
+ case 5:
+ cineon->element[i].packing = 1;
+ break;
- /* for close routine */
- cineon->file = 0;
- cineon->lineBuffer = 0;
- cineon->pixelBuffer = 0;
- cineon->membuffer = mem;
- cineon->membuffersize = size;
- cineon->memcursor = mem;
-
- cineon->file = 0;
- cineon->reading = 1;
- verbose = 0;
- if (size < sizeof(CineonGenericHeader)) {
- if (verbose) d_printf("Not enough data for header!\n");
- cineonClose(cineon);
- return 0;
- }
+ case 6:
+ cineon->element[i].packing = 2;
+ break;
- logimage_fread(&header, sizeof(CineonGenericHeader), 1, cineon);
+ default:
+ /* Not supported */
+ if (verbose) printf("Cineon: packing unsupported: %d\n", header.imageHeader.packing);
+ return 0;
+ }
- /* let's assume cineon files are always network order */
- if (header.fileInfo.magic_num != ntohl(CINEON_FILE_MAGIC)) {
- if (verbose) d_printf("Bad magic number %8.8lX in\n", (uintptr_t)ntohl(header.fileInfo.magic_num));
+ if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refLowData))
+ cineon->element[i].refLowData = 0;
- cineonClose(cineon);
- return 0;
- }
+ if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refHighData))
+ cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue;
- if (header.formatInfo.packing != 5) {
- if (verbose) d_printf("Can't understand packing %d\n", header.formatInfo.packing);
- cineonClose(cineon);
- return 0;
- }
+ if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refLowQuantity))
+ cineon->element[i].refLowQuantity = 0.0f;
- cineon->width = ntohl(header.imageInfo.channel[0].pixels_per_line);
- cineon->height = ntohl(header.imageInfo.channel[0].lines_per_image);
- cineon->depth = header.imageInfo.channels_per_image;
- /* cineon->bitsPerPixel = 10; */
- cineon->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel;
- cineon->imageOffset = ntohl(header.fileInfo.image_offset);
-
- cineon->lineBufferLength = pixelsToLongs(cineon->width * cineon->depth);
- cineon->lineBuffer = malloc(cineon->lineBufferLength * 4);
- if (cineon->lineBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", cineon->lineBufferLength * 4);
- cineonClose(cineon);
- return 0;
- }
+ if (cineon->element[i].refHighQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refHighQuantity)) {
+ if (cineon->element[i].transfer == transfer_PrintingDensity)
+ cineon->element[i].refHighQuantity = 2.048f;
+ else
+ cineon->element[i].refHighQuantity = cineon->element[i].maxValue;
+ }
- cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short));
- if (cineon->pixelBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (cineon->width * cineon->depth) * (int)sizeof(unsigned short));
- cineonClose(cineon);
- return 0;
- }
- cineon->pixelBufferUsed = 0;
-
- if (logimage_fseek(cineon, cineon->imageOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to image data at %d\n", cineon->imageOffset);
- cineonClose(cineon);
- return 0;
+ cineon->element[i].dataOffset = dataOffset;
+ dataOffset += cineon->height * getRowLength(cineon->width, cineon->element[i]);
}
-
- cineon->fileYPos = 0;
-
- logImageGetByteConversionDefaults(&cineon->params);
- setupLut(cineon);
- cineon->getRow = &cineonGetRowBytes;
- cineon->setRow = 0;
- cineon->close = &cineonClose;
+ cineon->referenceBlack = 95.0f / 1023.0f * cineon->element[0].maxValue;
+ cineon->referenceWhite = 685.0f / 1023.0f * cineon->element[0].maxValue;
+ cineon->gamma = 1.7f;
if (verbose) {
- verboseMe(cineon);
- }
+ printf("size %d x %d x %d elements\n", cineon->width, cineon->height, cineon->numElements);
+ for (i = 0; i < cineon->numElements; i++) {
+ printf(" Element %d:\n", i);
+ printf(" Bits per sample: %d\n", cineon->element[i].bitsPerSample);
+ printf(" Depth: %d\n", cineon->element[i].depth);
+ printf(" Transfer characteristics: %d\n", cineon->element[i].transfer);
+ printf(" Packing: %d\n", cineon->element[i].packing);
+ printf(" Descriptor: %d\n", cineon->element[i].descriptor);
+ printf(" Data offset: %u\n", cineon->element[i].dataOffset);
+ printf(" Reference low data: %u\n", cineon->element[i].refLowData);
+ printf(" Reference low quantity: %f\n", cineon->element[i].refLowQuantity);
+ printf(" Reference high data: %u\n", cineon->element[i].refHighData);
+ printf(" Reference high quantity: %f\n", cineon->element[i].refHighQuantity);
+ printf("\n");
+ }
+ printf("Gamma: %f\n", cineon->gamma);
+ printf("Reference black: %f\n", cineon->referenceBlack);
+ printf("Reference white: %f\n", cineon->referenceWhite);
+ printf("----------------------------\n");
+ }
return cineon;
}
+LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator)
+{
+ CineonMainHeader header;
+ const char *shortFilename = 0;
+ /* unsigned char pad[6044]; */
-int
-cineonGetSize(const CineonFile* cineon, int* width, int* height, int* depth) {
- *width = cineon->width;
- *height = cineon->height;
- *depth = cineon->depth;
- return 0;
-}
-
-CineonFile*
-cineonCreate(const char* filename, int width, int height, int depth) {
-
- /* Note: always write files in network order */
- /* By the spec, it shouldn't matter, but ... */
-
- CineonGenericHeader header;
- const char* shortFilename = 0;
-
- CineonFile* cineon = (CineonFile*)malloc(sizeof(CineonFile));
+ LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
if (cineon == 0) {
- if (verbose) d_printf("Failed to malloc cineon file structure.\n");
+ if (verbose) printf("cineon: Failed to malloc cineon file structure.\n");
return 0;
}
- memset(&header, 0, sizeof(header));
-
- /* for close routine */
- cineon->file = 0;
- cineon->lineBuffer = 0;
- cineon->pixelBuffer = 0;
-
- cineon->file = BLI_fopen(filename, "wb");
- if (cineon->file == 0) {
- if (verbose) d_printf("Couldn't open file %s\n", filename);
- cineonClose(cineon);
+ /* Only 10 bits Cineon are supported */
+ if (bitsPerSample != 10) {
+ if (verbose) printf("cineon: Only 10 bits Cineon are supported.\n");
+ logImageClose(cineon);
return 0;
}
- cineon->reading = 0;
cineon->width = width;
cineon->height = height;
- cineon->depth = depth;
- cineon->bitsPerPixel = 10;
- cineon->imageOffset = sizeof(CineonGenericHeader);
-
- cineon->lineBufferLength = pixelsToLongs(cineon->width * cineon->depth);
- cineon->lineBuffer = malloc(cineon->lineBufferLength * 4);
- if (cineon->lineBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", cineon->lineBufferLength * 4);
- cineonClose(cineon);
- return 0;
- }
+ cineon->element[0].bitsPerSample = 10;
+ cineon->element[0].dataOffset = sizeof(CineonMainHeader);
+ cineon->element[0].maxValue = 1023;
+ cineon->isMSB = 1;
+ cineon->numElements = 1;
+ cineon->element[0].packing = 1;
+ cineon->depth = 3;
+ cineon->element[0].depth = 3;
+ cineon->element[0].descriptor = descriptor_RGB;
+ cineon->element[0].transfer = transfer_PrintingDensity;
+ cineon->element[0].refHighQuantity = 2.048f;
+ cineon->element[0].refLowQuantity = 0;
+ cineon->element[0].refLowData = 0;
+ cineon->element[0].refHighData = cineon->element[0].maxValue;
+ cineon->referenceWhite = 685.0f;
+ cineon->referenceBlack = 95.0f;
+ cineon->gamma = 1.7f;
- cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short));
- if (cineon->pixelBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (cineon->width * cineon->depth) * (int)sizeof(unsigned short));
- cineonClose(cineon);
- return 0;
- }
- cineon->pixelBufferUsed = 0;
-
- /* find trailing part of filename */
shortFilename = strrchr(filename, '/');
- if (shortFilename == 0) {
+ if (shortFilename == 0)
shortFilename = filename;
- }
- else {
- ++shortFilename;
- }
+ else
+ shortFilename++;
- if (initCineonGenericHeader(cineon, &header, shortFilename) != 0) {
- cineonClose(cineon);
+ cineon->file = BLI_fopen(filename, "wb");
+ if (cineon->file == 0) {
+ if (verbose) printf("cineon: Couldn't open file %s\n", filename);
+ logImageClose(cineon);
return 0;
}
+ fillCineonMainHeader(cineon, &header, shortFilename, creator);
+
if (fwrite(&header, sizeof(header), 1, cineon->file) == 0) {
- if (verbose) d_printf("Couldn't write image header\n");
- cineonClose(cineon);
+ if (verbose) printf("cineon: Couldn't write image header\n");
+ logImageClose(cineon);
return 0;
}
- cineon->fileYPos = 0;
-
- logImageGetByteConversionDefaults(&cineon->params);
- setupLut(cineon);
-
- cineon->getRow = 0;
- cineon->setRow = &cineonSetRowBytes;
- cineon->close = &cineonClose;
return cineon;
}
-
-void
-cineonClose(CineonFile* cineon) {
-
- if (cineon == 0) {
- return;
- }
-
- if (cineon->file) {
- fclose(cineon->file);
- cineon->file = 0;
- }
-
- if (cineon->lineBuffer) {
- free(cineon->lineBuffer);
- cineon->lineBuffer = 0;
- }
-
- if (cineon->pixelBuffer) {
- free(cineon->pixelBuffer);
- cineon->pixelBuffer = 0;
- }
-
- free(cineon);
-}
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.h b/source/blender/imbuf/intern/cineon/cineonlib.h
index ef992c527b0..9333743a1bf 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.h
+++ b/source/blender/imbuf/intern/cineon/cineonlib.h
@@ -1,68 +1,142 @@
/*
- * Cineon image file format library definitions.
- * Also handles DPX files (almost)
+ * Cineon image file format library definitions.
+ * Also handles DPX files (almost)
*
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
+ * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
-#ifndef __CINEONLIB_H__
-#define __CINEONLIB_H__
-
/** \file blender/imbuf/intern/cineon/cineonlib.h
* \ingroup imbcineon
*/
-#include "logImageCore.h"
+
+#ifndef __CINEON_LIB_H__
+#define __CINEON_LIB_H__
#ifdef __cplusplus
extern "C" {
#endif
-/*
- * Cineon image structure. You don't care what this is.
- */
+#include "logImageCore.h"
-typedef struct _Log_Image_File_t_ CineonFile;
+#define CINEON_FILE_MAGIC 0x802A5FD7
+#define CINEON_UNDEFINED_U8 0xFF
+#define CINEON_UNDEFINED_U16 0xFFFF
+#define CINEON_UNDEFINED_U32 0xFFFFFFFF
+#define CINEON_UNDEFINED_R32 0x7F800000
+#define CINEON_UNDEFINED_CHAR 0
-/* int functions return 0 for OK */
+typedef struct {
+ unsigned int magic_num;
+ unsigned int offset;
+ unsigned int gen_hdr_size;
+ unsigned int ind_hdr_size;
+ unsigned int user_data_size;
+ unsigned int file_size;
+ char version[8];
+ char file_name[100];
+ char creation_date[12];
+ char creation_time[12];
+ char reserved[36];
+} CineonFileHeader;
-void cineonSetVerbose(int);
+typedef struct {
+ unsigned char descriptor1;
+ unsigned char descriptor2;
+ unsigned char bits_per_sample;
+ unsigned char filler;
+ unsigned int pixels_per_line;
+ unsigned int lines_per_image;
+ unsigned int ref_low_data;
+ float ref_low_quantity;
+ unsigned int ref_high_data;
+ float ref_high_quantity;
+} CineonElementHeader;
-CineonFile* cineonOpenFromMem(unsigned char *mem, unsigned int size);
+typedef struct {
+ unsigned char orientation;
+ unsigned char elements_per_image;
+ unsigned short filler;
+ CineonElementHeader element[8];
+ float white_point_x;
+ float white_point_y;
+ float red_primary_x;
+ float red_primary_y;
+ float green_primary_x;
+ float green_primary_y;
+ float blue_primary_x;
+ float blue_primary_y;
+ char label[200];
+ char reserved[28];
+ unsigned char interleave;
+ unsigned char packing;
+ unsigned char data_sign;
+ unsigned char sense;
+ unsigned int line_padding;
+ unsigned int element_padding;
+ char reserved2[20];
+} CineonImageHeader;
-CineonFile* cineonOpen(const char* filename);
-int cineonGetSize(const CineonFile* cineon, int* xsize, int* ysize, int* channels);
-CineonFile* cineonCreate(const char* filename, int xsize, int ysize, int channels);
-int cineonIsMemFileCineon(unsigned char *mem);
+typedef struct {
+ int x_offset;
+ int y_offset;
+ char file_name[100];
+ char creation_date[12];
+ char creation_time[12];
+ char input_device[64];
+ char model_number[32];
+ char input_serial_number[32];
+ float x_input_samples_per_mm;
+ float y_input_samples_per_mm;
+ float input_device_gamma;
+ char reserved[40];
+} CineonOriginationHeader;
-/* get/set scanline of converted bytes */
-int cineonGetRowBytes(CineonFile* cineon, unsigned short* row, int y);
-int cineonSetRowBytes(CineonFile* cineon, const unsigned short* row, int y);
+typedef struct {
+ unsigned char film_code;
+ unsigned char film_type;
+ unsigned char edge_code_perforation_offset;
+ unsigned char filler;
+ unsigned int prefix;
+ unsigned int count;
+ char format[32];
+ unsigned int frame_position;
+ float frame_rate;
+ char attribute[32];
+ char slate[200];
+ char reserved[740];
+} CineonFilmHeader;
-/* get/set scanline of unconverted shorts */
-int cineonGetRow(CineonFile* cineon, unsigned short* row, int y);
-int cineonSetRow(CineonFile* cineon, const unsigned short* row, int y);
+typedef struct {
+ CineonFileHeader fileHeader;
+ CineonImageHeader imageHeader;
+ CineonOriginationHeader originationHeader;
+ CineonFilmHeader filmHeader;
+} CineonMainHeader;
-/* closes file and deletes data */
-void cineonClose(CineonFile* cineon);
+void cineonSetVerbose(int);
+LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize);
+LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator);
#ifdef __cplusplus
}
#endif
-#endif /* __CINEONLIB_H__ */
+#endif /* __CINEON_LIB_H__ */
diff --git a/source/blender/imbuf/intern/cineon/dpxfile.h b/source/blender/imbuf/intern/cineon/dpxfile.h
index e1d95268a80..e69de29bb2d 100644
--- a/source/blender/imbuf/intern/cineon/dpxfile.h
+++ b/source/blender/imbuf/intern/cineon/dpxfile.h
@@ -1,128 +0,0 @@
-/*
- * Cineon image file format library definitions.
- * Dpx file format structures.
- *
- * This header file contains private details.
- * User code should generally use cineonlib.h only.
- *
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
- *
- * 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.
- *
- */
-
-#ifndef __DPXFILE_H__
-#define __DPXFILE_H__
-
-/** \file blender/imbuf/intern/cineon/dpxfile.h
- * \ingroup imbcineon
- */
-
-#include "logImageCore.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- U32 magic_num; /* magic number */
- U32 offset; /* offset to image data in bytes */
- ASCII vers[8]; /* which header format version is being used (v1.0) */
- U32 file_size; /* file size in bytes */
- U32 ditto_key; /* I bet some people use this */
- U32 gen_hdr_size; /* generic header length in bytes */
- U32 ind_hdr_size; /* industry header length in bytes */
- U32 user_data_size; /* user-defined data length in bytes */
- ASCII file_name[100]; /* image file name */
- ASCII create_date[24]; /* file creation date, yyyy:mm:dd:hh:mm:ss:LTZ */
- ASCII creator[100];
- ASCII project[200];
- ASCII copyright[200];
- U32 key; /* encryption key, FFFFFFF = unencrypted */
- ASCII Reserved[104]; /* reserved field TBD (need to pad) */
-} DpxFileInformation;
-
-typedef struct {
- U32 signage;
- U32 ref_low_data; /* reference low data code value */
- R32 ref_low_quantity; /* reference low quantity represented */
- U32 ref_high_data; /* reference high data code value */
- R32 ref_high_quantity;/* reference high quantity represented */
- U8 designator1;
- U8 transfer_characteristics;
- U8 colorimetry;
- U8 bits_per_pixel;
- U16 packing;
- U16 encoding;
- U32 data_offset;
- U32 line_padding;
- U32 channel_padding;
- ASCII description[32];
-} DpxChannelInformation;
-
-typedef struct {
- U16 orientation;
- U16 channels_per_image;
- U32 pixels_per_line;
- U32 lines_per_image;
- DpxChannelInformation channel[8];
- ASCII reserved[52];
-} DpxImageInformation;
-
-typedef struct {
- U32 x_offset;
- U32 y_offset;
- R32 x_centre;
- R32 y_centre;
- U32 x_original_size;
- U32 y_original_size;
- ASCII file_name[100];
- ASCII creation_time[24];
- ASCII input_device[32];
- ASCII input_serial_number[32];
- U16 border_validity[4];
- U32 pixel_aspect_ratio[2]; /* h:v */
- ASCII reserved[28];
-} DpxOriginationInformation;
-
-typedef struct {
- ASCII film_manufacturer_id[2];
- ASCII film_type[2];
- ASCII edge_code_perforation_offset[2];
- ASCII edge_code_prefix[6];
- ASCII edge_code_count[4];
- ASCII film_format[32];
- U32 frame_position;
- U32 sequence_length;
- U32 held_count;
- R32 frame_rate;
- R32 shutter_angle;
- ASCII frame_identification[32];
- ASCII slate_info[100];
- ASCII reserved[56];
-} DpxMPIInformation;
-
-typedef struct {
- DpxFileInformation fileInfo;
- DpxImageInformation imageInfo;
- DpxOriginationInformation originInfo;
- DpxMPIInformation filmHeader;
-} DpxMainHeader;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __DPXFILE_H__ */
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index c1138225e93..aedce52a7bf 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -1,21 +1,23 @@
/*
- * Dpx image file format library routines.
+ * Dpx image file format library routines.
*
- * Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
+ * Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
@@ -23,689 +25,445 @@
* \ingroup imbcineon
*/
-#include "dpxfile.h"
+
#include "dpxlib.h"
+#include "logmemfile.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
-#include <time.h> /* strftime() */
+#include <time.h>
#include <sys/types.h>
-#ifdef WIN32
-#include <winsock.h>
-#else
-#include <netinet/in.h> /* htonl() */
-#endif
-#include <string.h> /* memset */
-#include "cin_debug_stuff.h"
-#include "logmemfile.h"
-#include "BLI_fileops.h"
-
-static void
-fillDpxChannelInfo(DpxFile* dpx, DpxChannelInformation* chan, int des) {
-
- (void)dpx; /* unused */
-
- chan->signage = 0;
- chan->ref_low_data = htonl(0);
- chan->ref_low_quantity = htonf(0.0);
- chan->ref_high_data = htonl(1023);
- chan->ref_high_quantity = htonf(2.046);
- chan->designator1 = des;
- chan->transfer_characteristics = 0;
- chan->colorimetry = 0;
- chan->bits_per_pixel = 10;
- chan->packing = htons(1);
- chan->encoding = 0;
- chan->data_offset = 0;
- chan->line_padding = htonl(0);
- chan->channel_padding = htonl(0);
- chan->description[0] = 0;
-}
-
-static void
-dumpDpxChannelInfo(DpxChannelInformation* chan) {
- d_printf(" Signage %ld", (intptr_t)ntohl(chan->signage));
- d_printf(" Ref low data %ld\n", (intptr_t)ntohl(chan->ref_low_data));
- d_printf(" Ref low quantity %f\n", ntohf(chan->ref_low_quantity));
- d_printf(" Ref high data %ld\n", (intptr_t)ntohl(chan->ref_high_data));
- d_printf(" Ref high quantity %f\n", ntohf(chan->ref_high_quantity));
- d_printf(" Designator1: %d,", chan->designator1);
- d_printf(" Bits per pixel %d\n", chan->bits_per_pixel);
- d_printf(" Packing: %d,", ntohs(chan->packing));
- d_printf(" Data Offset: %ld,", (intptr_t)ntohl(chan->data_offset));
-}
-
-static void
-fillDpxFileInfo(
- DpxFile* dpx, DpxFileInformation* fileInfo, const char* filename) {
-
- time_t fileClock;
- struct tm* fileTime;
-
- /* Note: always write files in network order */
- /* By the spec, it shouldn't matter, but ... */
-
- fileInfo->magic_num = htonl(DPX_FILE_MAGIC);
- fileInfo->offset = htonl(dpx->imageOffset);
- strcpy(fileInfo->vers, "v1.0");
- fileInfo->file_size = htonl(dpx->imageOffset +
- pixelsToLongs(dpx->height * dpx->width * dpx->depth) * 4);
- fileInfo->ditto_key = 0;
- fileInfo->gen_hdr_size = htonl(
- sizeof(DpxFileInformation) +
- sizeof(DpxImageInformation) +
- sizeof(DpxOriginationInformation));
- fileInfo->ind_hdr_size = htonl(sizeof(DpxMPIInformation));
- fileInfo->user_data_size = 0;
- strncpy(fileInfo->file_name, filename, 99);
- fileInfo->file_name[99] = 0;
+#include <string.h>
- fileClock = time(0);
- fileTime = localtime(&fileClock);
- strftime(fileInfo->create_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime);
- /* Question: is %Z in strftime guaranteed to return 3 chars? */
- fileInfo->create_date[23] = 0;
-
- strcpy(fileInfo->creator, "David's DPX writer");
- fileInfo->project[0] = 0;
- fileInfo->copyright[0] = 0;
- fileInfo->key = 0xFFFFFFFF; /* same in any byte order */
-}
+#include "BLI_fileops.h"
+#include "BLI_math_base.h"
+#include "BLI_utildefines.h"
-static void
-dumpDpxFileInfo(DpxFileInformation* fileInfo) {
- d_printf("\n--File Information--\n");
- d_printf("Magic: %8.8lX\n", (unsigned long)ntohl(fileInfo->magic_num));
- d_printf("Image Offset %ld\n", (intptr_t)ntohl(fileInfo->offset));
- d_printf("Version \"%s\"\n", fileInfo->vers);
- d_printf("File size %ld\n", (intptr_t)ntohl(fileInfo->file_size));
- d_printf("Ditto key %ld\n", (intptr_t)ntohl(fileInfo->ditto_key));
- d_printf("Generic Header size %ld\n", (intptr_t)ntohl(fileInfo->gen_hdr_size));
- d_printf("Industry Header size %ld\n", (intptr_t)ntohl(fileInfo->ind_hdr_size));
- d_printf("User Data size %ld\n", (intptr_t)ntohl(fileInfo->user_data_size));
- d_printf("File name \"%s\"\n", fileInfo->file_name);
- d_printf("Creation date \"%s\"\n", fileInfo->create_date);
- d_printf("Creator \"%s\"\n", fileInfo->creator);
- d_printf("Project \"%s\"\n", fileInfo->project);
- d_printf("Copyright \"%s\"\n", fileInfo->copyright);
- d_printf("Key %ld\n", (intptr_t)ntohl(fileInfo->key));
-}
+#include "MEM_guardedalloc.h"
-static void
-fillDpxImageInfo(
- DpxFile* dpx, DpxImageInformation* imageInfo) {
- imageInfo->orientation = 0;
- imageInfo->channels_per_image = htons(1);
- imageInfo->pixels_per_line = htonl(dpx->width);
- imageInfo->lines_per_image = htonl(dpx->height);
+/*
+ * For debug purpose
+ */
- if (dpx->depth == 1) {
- fillDpxChannelInfo(dpx, &imageInfo->channel[0], 0);
+static int verbose = 0;
- }
- else if (dpx->depth == 3) {
- fillDpxChannelInfo(dpx, &imageInfo->channel[0], 50);
- }
+void dpxSetVerbose(int verbosity) {
+ verbose = verbosity;
}
-static void
-dumpDpxImageInfo(DpxImageInformation* imageInfo) {
- int n;
- int i;
- d_printf("\n--Image Information--\n");
- d_printf("Image orientation %d,", ntohs(imageInfo->orientation));
- n = ntohs(imageInfo->channels_per_image);
- d_printf("Channels %d\n", n);
- d_printf("Pixels per line %ld\n", (intptr_t)ntohl(imageInfo->pixels_per_line));
- d_printf("Lines per image %ld\n", (intptr_t)ntohl(imageInfo->lines_per_image));
- for (i = 0; i < n; ++i) {
- d_printf(" --Channel %d--\n", i);
- dumpDpxChannelInfo(&imageInfo->channel[i]);
- }
-}
+/*
+ * Headers
+ */
-static void
-fillDpxOriginationInfo(
- DpxFile* dpx, DpxOriginationInformation* originInfo, DpxFileInformation* fileInfo)
+static void fillDpxMainHeader(LogImageFile *dpx, DpxMainHeader *header, const char *filename, const char *creator)
{
- /* unused */
- (void)dpx;
- (void)originInfo;
- (void)fileInfo;
-}
-
-static void
-dumpDpxOriginationInfo(DpxOriginationInformation* originInfo) {
- d_printf("\n--Origination Information--\n");
- d_printf("X offset %ld\n", (intptr_t)ntohl(originInfo->x_offset));
- d_printf("Y offset %ld\n", (intptr_t)ntohl(originInfo->y_offset));
- d_printf("X centre %f\n", ntohf(originInfo->x_centre));
- d_printf("Y centre %f\n", ntohf(originInfo->y_centre));
- d_printf("Original X %ld\n", (intptr_t)ntohl(originInfo->x_original_size));
- d_printf("Original Y %ld\n", (intptr_t)ntohl(originInfo->y_original_size));
- d_printf("File name \"%s\"\n", originInfo->file_name);
- d_printf("Creation time \"%s\"\n", originInfo->creation_time);
- d_printf("Input device \"%s\"\n", originInfo->input_device);
- d_printf("Serial number \"%s\"\n", originInfo->input_serial_number);
-}
+ time_t fileClock;
+ struct tm *fileTime;
-static void
-initDpxMainHeader(DpxFile* dpx, DpxMainHeader* header, const char* shortFilename) {
memset(header, 0, sizeof(DpxMainHeader));
- fillDpxFileInfo(dpx, &header->fileInfo, shortFilename);
- fillDpxImageInfo(dpx, &header->imageInfo);
- fillDpxOriginationInfo(dpx, &header->originInfo, &header->fileInfo);
-#if 0
- fillDpxMPIInfo(dpx, &header->filmHeader);
-#endif
-}
-
-static void
-dumpDpxMainHeader(DpxMainHeader* header) {
- dumpDpxFileInfo(&header->fileInfo);
- dumpDpxImageInfo(&header->imageInfo);
- dumpDpxOriginationInfo(&header->originInfo);
-#if 0
- dumpDpxMPIInformation(&header->filmHeader);
-#endif
-}
-
-static int verbose = 0;
-void
-dpxSetVerbose(int verbosity) {
- verbose = verbosity;
-}
-
-static void
-verboseMe(DpxFile* dpx) {
-
- d_printf("size %d x %d x %d\n", dpx->width, dpx->height, dpx->depth);
- d_printf("ImageStart %d, lineBufferLength %d, implied length %d\n",
- dpx->imageOffset, dpx->lineBufferLength * 4,
- dpx->imageOffset + pixelsToLongs(dpx->width * dpx->depth * dpx->height) * 4);
-}
-
-int
-dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y) {
-
- /* Note: this code is bizarre because DPX files can wrap */
- /* packed longwords across line boundaries!!!! */
-
- size_t readLongs;
- unsigned int longIndex;
- int numPixels = dpx->width * dpx->depth;
- int pixelIndex;
-
- /* only seek if not reading consecutive lines */
- /* this is not quite right yet, need to account for leftovers */
- if (y != dpx->fileYPos) {
- int lineOffset = pixelsToLongs(y * dpx->width * dpx->depth) * 4;
- if (verbose) d_printf("Seek in getRowBytes\n");
- if (logimage_fseek(dpx, dpx->imageOffset + lineOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, dpx->imageOffset + lineOffset);
- return 1;
- }
- dpx->fileYPos = y;
- }
-
- /* read enough longwords */
- readLongs = pixelsToLongs(numPixels - dpx->pixelBufferUsed);
- if (logimage_fread(dpx->lineBuffer, 4, readLongs, dpx) != readLongs) {
- if (verbose) d_printf("Couldn't read line %d length %d\n", y, (int)readLongs * 4);
- return 1;
- }
- ++dpx->fileYPos;
-
- /* convert longwords to pixels */
- pixelIndex = dpx->pixelBufferUsed;
-
- /* this is just strange */
- if (dpx->depth == 1) {
- for (longIndex = 0; longIndex < readLongs; ++longIndex) {
- unsigned int t = ntohl(dpx->lineBuffer[longIndex]);
- dpx->pixelBuffer[pixelIndex] = t & 0x3ff;
- t = t >> 10;
- dpx->pixelBuffer[pixelIndex+1] = t & 0x3ff;
- t = t >> 10;
- dpx->pixelBuffer[pixelIndex+2] = t & 0x3ff;
- pixelIndex += 3;
- }
- }
- else /* if (dpx->depth == 3) */ {
- for (longIndex = 0; longIndex < readLongs; ++longIndex) {
- unsigned int t = ntohl(dpx->lineBuffer[longIndex]);
- t = t >> 2;
- dpx->pixelBuffer[pixelIndex+2] = t & 0x3ff;
- t = t >> 10;
- dpx->pixelBuffer[pixelIndex+1] = t & 0x3ff;
- t = t >> 10;
- dpx->pixelBuffer[pixelIndex] = t & 0x3ff;
- pixelIndex += 3;
- }
- }
- dpx->pixelBufferUsed = pixelIndex;
-
- /* extract required pixels */
- for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
- if (dpx->params.doLogarithm)
- row[pixelIndex] = dpx->lut10_16[dpx->pixelBuffer[pixelIndex]];
- else
- row[pixelIndex] = dpx->pixelBuffer[pixelIndex] << 6;
- }
-
- /* save remaining pixels */
- while (pixelIndex < dpx->pixelBufferUsed) {
- dpx->pixelBuffer[pixelIndex - numPixels] = dpx->pixelBuffer[pixelIndex];
- ++pixelIndex;
- }
- dpx->pixelBufferUsed -= numPixels;
- /* done! */
- return 0;
-}
-
-int
-dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y) {
-
- /* Note: this code is bizarre because DPX files can wrap */
- /* packed longwords across line boundaries!!!! */
-
- size_t writeLongs;
- int longIndex;
- int numPixels = dpx->width * dpx->depth;
- int pixelIndex;
- int pixelIndex2;
-
- /* only seek if not reading consecutive lines */
- /* this is not quite right yet */
- if (y != dpx->fileYPos) {
- int lineOffset = pixelsToLongs(y * dpx->width * dpx->depth) * 4;
- if (verbose) d_printf("Seek in getRowBytes\n");
- if (logimage_fseek(dpx, dpx->imageOffset + lineOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, dpx->imageOffset + lineOffset);
- return 1;
- }
- dpx->fileYPos = y;
- }
-
- /* put new pixels into pixelBuffer */
- for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
- if (dpx->params.doLogarithm)
- dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = dpx->lut16_16[row[pixelIndex]];
- else
- dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = row[pixelIndex] >> 6;
- }
- dpx->pixelBufferUsed += numPixels;
-
- /* pack into longwords */
- writeLongs = dpx->pixelBufferUsed / 3;
- /* process whole line at image end */
- if (dpx->fileYPos == (dpx->height - 1)) {
- writeLongs = pixelsToLongs(dpx->pixelBufferUsed);
- }
- pixelIndex = 0;
- if (dpx->depth == 1) {
- for (longIndex = 0; longIndex < writeLongs; ++longIndex) {
- unsigned int t = dpx->pixelBuffer[pixelIndex] |
- (dpx->pixelBuffer[pixelIndex+1] << 10) |
- (dpx->pixelBuffer[pixelIndex+2] << 20);
- dpx->lineBuffer[longIndex] = htonl(t);
- pixelIndex += 3;
- }
- }
- else {
- for (longIndex = 0; longIndex < writeLongs; ++longIndex) {
- unsigned int t = dpx->pixelBuffer[pixelIndex+2] << 2 |
- (dpx->pixelBuffer[pixelIndex+1] << 12) |
- (dpx->pixelBuffer[pixelIndex] << 22);
- dpx->lineBuffer[longIndex] = htonl(t);
- pixelIndex += 3;
- }
- }
-
- /* write them */
- if (fwrite(dpx->lineBuffer, 4, writeLongs, dpx->file) != writeLongs) {
- if (verbose) d_printf("Couldn't write line %d length %d\n", y, (int)writeLongs * 4);
- return 1;
- }
- ++dpx->fileYPos;
-
- /* save remaining pixels */
- pixelIndex2 = 0;
- while (pixelIndex < dpx->pixelBufferUsed) {
- dpx->pixelBuffer[pixelIndex2] = dpx->pixelBuffer[pixelIndex];
- ++pixelIndex;
- ++pixelIndex2;
- }
- dpx->pixelBufferUsed = pixelIndex2;
-
- return 0;
+ /* --- File header --- */
+ header->fileHeader.magic_num = swap_uint(DPX_FILE_MAGIC, dpx->isMSB);
+ header->fileHeader.offset = swap_uint(dpx->element[0].dataOffset, dpx->isMSB);
+ strcpy(header->fileHeader.version, "v2.0");
+ header->fileHeader.file_size = swap_uint(dpx->element[0].dataOffset + dpx->height * getRowLength(dpx->width, dpx->element[0]), dpx->isMSB);
+ header->fileHeader.ditto_key = 0;
+ header->fileHeader.gen_hdr_size = swap_uint(sizeof(DpxFileHeader) + sizeof(DpxImageHeader) + sizeof(DpxOrientationHeader), dpx->isMSB);
+ header->fileHeader.ind_hdr_size = swap_uint(sizeof(DpxFilmHeader) + sizeof(DpxTelevisionHeader), dpx->isMSB);
+ header->fileHeader.user_data_size = DPX_UNDEFINED_U32;
+ strncpy(header->fileHeader.file_name, filename, 99);
+ header->fileHeader.file_name[99] = 0;
+ fileClock = time(0);
+ fileTime = localtime(&fileClock);
+ strftime(header->fileHeader.creation_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime);
+ header->fileHeader.creation_date[23] = 0;
+ strncpy(header->fileHeader.creator, creator, 99);
+ header->fileHeader.creator[99] = 0;
+ header->fileHeader.project[0] = 0;
+ header->fileHeader.copyright[0] = 0;
+ header->fileHeader.key = 0xFFFFFFFF;
+
+ /* --- Image header --- */
+ header->imageHeader.orientation = 0;
+ header->imageHeader.elements_per_image = swap_ushort(1, dpx->isMSB);
+ header->imageHeader.pixels_per_line = swap_uint(dpx->width, dpx->isMSB);
+ header->imageHeader.lines_per_element = swap_uint(dpx->height, dpx->isMSB);
+
+ /* Fills element */
+ header->imageHeader.element[0].data_sign = 0;
+ header->imageHeader.element[0].ref_low_data = swap_uint(dpx->element[0].refLowData, dpx->isMSB);
+ header->imageHeader.element[0].ref_low_quantity = swap_float(dpx->element[0].refLowQuantity, dpx->isMSB);
+ header->imageHeader.element[0].ref_high_data = swap_uint(dpx->element[0].refHighData, dpx->isMSB);
+ header->imageHeader.element[0].ref_high_quantity = swap_float(dpx->element[0].refHighQuantity, dpx->isMSB);
+ header->imageHeader.element[0].descriptor = dpx->element[0].descriptor;
+ header->imageHeader.element[0].transfer = dpx->element[0].transfer;
+ header->imageHeader.element[0].colorimetric = 0;
+ header->imageHeader.element[0].bits_per_sample = dpx->element[0].bitsPerSample;
+ header->imageHeader.element[0].packing = swap_ushort(dpx->element[0].packing, dpx->isMSB);
+ header->imageHeader.element[0].encoding = 0;
+ header->imageHeader.element[0].data_offset = swap_uint(dpx->element[0].dataOffset, dpx->isMSB);
+ header->imageHeader.element[0].line_padding = 0;
+ header->imageHeader.element[0].element_padding = 0;
+ header->imageHeader.element[0].description[0] = 0;
+
+ /* --- Orientation header --- */
+ /* we leave it blank */
+
+ /* --- Television header --- */
+ header->televisionHeader.time_code = DPX_UNDEFINED_U32;
+ header->televisionHeader.user_bits = DPX_UNDEFINED_U32;
+ header->televisionHeader.interlace = DPX_UNDEFINED_U8;
+ header->televisionHeader.field_number = DPX_UNDEFINED_U8;
+ header->televisionHeader.video_signal = DPX_UNDEFINED_U8;
+ header->televisionHeader.padding = DPX_UNDEFINED_U8;
+ header->televisionHeader.horizontal_sample_rate = DPX_UNDEFINED_R32;
+ header->televisionHeader.vertical_sample_rate = DPX_UNDEFINED_R32;
+ header->televisionHeader.frame_rate = DPX_UNDEFINED_R32;
+ header->televisionHeader.time_offset = DPX_UNDEFINED_R32;
+ header->televisionHeader.gamma = swap_float(dpx->gamma, dpx->isMSB);
+ header->televisionHeader.black_level = swap_float(dpx->referenceBlack, dpx->isMSB);
+ header->televisionHeader.black_gain = DPX_UNDEFINED_R32;
+ header->televisionHeader.breakpoint = DPX_UNDEFINED_R32;
+ header->televisionHeader.white_level = swap_float(dpx->referenceWhite, dpx->isMSB);
+ header->televisionHeader.integration_times = DPX_UNDEFINED_R32;
}
-#define LFMEMFILE 0
-#define LFREALFILE 1
-
-static DpxFile*
-intern_dpxOpen(int mode, const char* bytestuff, int bufsize) {
-
+LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize)
+{
DpxMainHeader header;
- const char *filename = bytestuff;
- DpxFile* dpx = (DpxFile*)malloc(sizeof(DpxFile));
-
+ LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
+ char *filename = (char *)byteStuff;
+ int i;
+
if (dpx == 0) {
- if (verbose) d_printf("Failed to malloc dpx file structure.\n");
+ if (verbose) printf("DPX: Failed to malloc dpx file structure.\n");
return 0;
}
+ /* zero the header */
+ memset(&header, 0, sizeof(DpxMainHeader));
+
/* for close routine */
dpx->file = 0;
- dpx->lineBuffer = 0;
- dpx->pixelBuffer = 0;
- if (mode == LFREALFILE) {
- filename = bytestuff;
+ if (fromMemory == 0) {
+ /* byteStuff is then the filename */
dpx->file = BLI_fopen(filename, "rb");
- if (dpx->file == 0) {
- if (verbose) d_printf("Failed to open file \"%s\".\n", filename);
- dpxClose(dpx);
+ if (dpx->file == 0) {
+ if (verbose) printf("DPX: Failed to open file \"%s\".\n", filename);
+ logImageClose(dpx);
return 0;
}
- dpx->membuffer = 0;
- dpx->memcursor = 0;
- dpx->membuffersize = 0;
+ /* not used in this case */
+ dpx->memBuffer = 0;
+ dpx->memCursor = 0;
+ dpx->memBufferSize = 0;
}
- else if (mode == LFMEMFILE) {
- dpx->membuffer = (unsigned char *)bytestuff;
- dpx->memcursor = (unsigned char *)bytestuff;
- dpx->membuffersize = bufsize;
+ else {
+ dpx->memBuffer = (unsigned char *)byteStuff;
+ dpx->memCursor = (unsigned char *)byteStuff;
+ dpx->memBufferSize = bufferSize;
}
-
- dpx->reading = 1;
if (logimage_fread(&header, sizeof(header), 1, dpx) == 0) {
- if (verbose) d_printf("Not enough data for header in \"%s\".\n", filename);
- dpxClose(dpx);
+ if (verbose) printf("DPX: Not enough data for header in \"%s\".\n", byteStuff);
+ logImageClose(dpx);
return 0;
}
- /* let's assume dpx files are always network order */
- if (header.fileInfo.magic_num != ntohl(DPX_FILE_MAGIC)) {
- if (verbose) d_printf("Bad magic number %8.8lX in \"%s\".\n",
- (uintptr_t)ntohl(header.fileInfo.magic_num), filename);
- dpxClose(dpx);
- return 0;
+ /* endianness determination */
+ if (header.fileHeader.magic_num == swap_uint(DPX_FILE_MAGIC, 1)) {
+ dpx->isMSB = 1;
+ if (verbose) printf("DPX: File is MSB.\n");
}
-
- if (ntohs(header.imageInfo.channel[0].packing) != 1) {
- if (verbose) d_printf("Unknown packing %d\n", header.imageInfo.channel[0].packing);
- dpxClose(dpx);
+ else if (header.fileHeader.magic_num == DPX_FILE_MAGIC) {
+ dpx->isMSB = 0;
+ if (verbose) printf("DPX: File is LSB.\n");
+ }
+ else {
+ if (verbose) printf("DPX: Bad magic number %lu in \"%s\".\n",
+ (uintptr_t)header.fileHeader.magic_num, byteStuff);
+ logImageClose(dpx);
return 0;
}
+ dpx->srcFormat = format_DPX;
+ dpx->numElements = swap_ushort(header.imageHeader.elements_per_image, dpx->isMSB);
+ dpx->width = swap_uint(header.imageHeader.pixels_per_line, dpx->isMSB);
+ dpx->height = swap_uint(header.imageHeader.lines_per_element, dpx->isMSB);
+ dpx->depth = 0;
+
+ for (i = 0; i < dpx->numElements; i++) {
+ dpx->element[i].descriptor = header.imageHeader.element[i].descriptor;
+
+ switch (dpx->element[i].descriptor) {
+ case descriptor_Red:
+ case descriptor_Green:
+ case descriptor_Blue:
+ case descriptor_Alpha:
+ case descriptor_Luminance:
+ case descriptor_Chrominance:
+ dpx->depth++;
+ dpx->element[i].depth = 1;
+ break;
+
+ case descriptor_CbYCrY:
+ dpx->depth += 2;
+ dpx->element[i].depth = 2;
+ break;
+
+ case descriptor_RGB:
+ case descriptor_CbYCr:
+ case descriptor_CbYACrYA:
+ dpx->depth += 3;
+ dpx->element[i].depth = 3;
+ break;
+
+ case descriptor_RGBA:
+ case descriptor_ABGR:
+ case descriptor_CbYCrA:
+ dpx->depth += 4;
+ dpx->element[i].depth = 4;
+ break;
+
+ case descriptor_Depth:
+ case descriptor_Composite:
+ /* unsupported */
+ break;
+ }
- dpx->width = ntohl(header.imageInfo.pixels_per_line);
- dpx->height = ntohl(header.imageInfo.lines_per_image);
- dpx->depth = ntohs(header.imageInfo.channels_per_image);
- /* Another DPX vs Cineon wierdness */
- if (dpx->depth == 1) {
- switch (header.imageInfo.channel[0].designator1) {
- case 50: dpx->depth = 3; break;
- case 51: dpx->depth = 4; break;
- case 52: dpx->depth = 4; break;
- default: break;
+ if (dpx->depth == 0 || dpx->depth > 4) {
+ if (verbose) printf("DPX: Unsupported image depth: %d\n", dpx->depth);
+ logImageClose(dpx);
+ return 0;
}
- }
- /* dpx->bitsPerPixel = 10; */
- dpx->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel;
- if (dpx->bitsPerPixel != 10) {
- if (verbose) d_printf("Don't support depth: %d\n", dpx->bitsPerPixel);
- dpxClose(dpx);
- return 0;
- }
- dpx->imageOffset = ntohl(header.fileInfo.offset);
- dpx->lineBufferLength = pixelsToLongs(dpx->width * dpx->depth);
- dpx->lineBuffer = malloc(dpx->lineBufferLength * 4);
- if (dpx->lineBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", dpx->lineBufferLength * 4);
- dpxClose(dpx);
- return 0;
- }
+ dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample;
+ dpx->element[i].maxValue = powf(2, dpx->element[i].bitsPerSample) - 1.0f;
+ dpx->element[i].packing = swap_ushort(header.imageHeader.element[i].packing, dpx->isMSB);
- /* could have 2 pixels left over */
- dpx->pixelBuffer = malloc((dpx->lineBufferLength * 3 + 2) * sizeof(unsigned short));
- if (dpx->pixelBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (dpx->width * dpx->depth + 2 + 2) * (int)sizeof(unsigned short));
- dpxClose(dpx);
- return 0;
- }
- dpx->pixelBufferUsed = 0;
+ /* Sometimes, the offset is not set correctly in the header */
+ dpx->element[i].dataOffset = swap_uint(header.imageHeader.element[i].data_offset, dpx->isMSB);
+ if (dpx->element[i].dataOffset == 0 && dpx->numElements == 1)
+ dpx->element[i].dataOffset = swap_uint(header.fileHeader.offset, dpx->isMSB);
- if (logimage_fseek(dpx, dpx->imageOffset, SEEK_SET) != 0) {
- if (verbose) d_printf("Couldn't seek to image data start at %d\n", dpx->imageOffset);
- dpxClose(dpx);
- return 0;
- }
- dpx->fileYPos = 0;
-
- logImageGetByteConversionDefaults(&dpx->params);
- /* The SMPTE define this code:
- * 0 - User-defined
- * 1 - Printing density
- * 2 - Linear
- * 3 - Logarithmic
- * 4 - Unspecified video
- * 5 - SMPTE 240M
- * 6 - CCIR 709-1
- * 7 - CCIR 601-2 system B or G
- * 8 - CCIR 601-2 system M
- * 9 - NTSC composite video
- * 10 - PAL composite video
- * 11 - Z linear
- * 12 - homogeneous
- *
- * Note that transfer_characteristics is U8, don't need
- * check the byte order.
- */
-
- switch (header.imageInfo.channel[0].transfer_characteristics) {
- case 1:
- case 2: /* linear */
- dpx->params.doLogarithm= 0;
- break;
-
- case 3:
- dpx->params.doLogarithm= 1;
- break;
-
- /* TODO - Unsupported, but for now just load them,
- * colors may look wrong, but can solve color conversion later
- */
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- if (verbose) d_printf("Un-supported Transfer Characteristics: %d using linear color conversion\n", header.imageInfo.channel[0].transfer_characteristics);
- dpx->params.doLogarithm= 0;
- break;
- default:
- if (verbose) d_printf("Un-supported Transfer Characteristics: %d\n", header.imageInfo.channel[0].transfer_characteristics);
- dpxClose(dpx);
+ if (dpx->element[i].dataOffset == 0) {
+ if (verbose) printf("DPX: Image header is corrupted.\n");
+ logImageClose(dpx);
return 0;
- break;
- }
- setupLut(dpx);
-
- dpx->getRow = &dpxGetRowBytes;
- dpx->setRow = 0;
- dpx->close = &dpxClose;
+ }
- if (verbose) {
- verboseMe(dpx);
+ dpx->element[i].transfer = header.imageHeader.element[i].transfer;
+
+ /* if undefined, assign default */
+ dpx->element[i].refLowData = swap_uint(header.imageHeader.element[i].ref_low_data, dpx->isMSB);
+ dpx->element[i].refLowQuantity = swap_float(header.imageHeader.element[i].ref_low_quantity, dpx->isMSB);
+ dpx->element[i].refHighData = swap_uint(header.imageHeader.element[i].ref_high_data, dpx->isMSB);
+ dpx->element[i].refHighQuantity = swap_float(header.imageHeader.element[i].ref_high_quantity, dpx->isMSB);
+
+ switch (dpx->element[i].descriptor) {
+ case descriptor_Red:
+ case descriptor_Green:
+ case descriptor_Blue:
+ case descriptor_Alpha:
+ case descriptor_RGB:
+ case descriptor_RGBA:
+ case descriptor_ABGR:
+ if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData))
+ dpx->element[i].refLowData = 0;
+
+ if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData))
+ dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue;
+
+ if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
+ dpx->element[i].refLowQuantity = 0.0f;
+
+ if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity)) {
+ if (dpx->element[i].transfer == transfer_PrintingDensity || dpx->element[i].transfer == transfer_Logarithmic)
+ dpx->element[i].refHighQuantity = 2.048f;
+ else
+ dpx->element[i].refHighQuantity = dpx->element[i].maxValue;
+ }
+
+ break;
+
+ case descriptor_Luminance:
+ case descriptor_Chrominance:
+ case descriptor_CbYCrY:
+ case descriptor_CbYCr:
+ case descriptor_CbYACrYA:
+ case descriptor_CbYCrA:
+ if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData))
+ dpx->element[i].refLowData = 16.0f / 255.0f * dpx->element[i].maxValue;
+
+ if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData))
+ dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue;
+
+ if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
+ dpx->element[i].refLowQuantity = 0.0f;
+
+ if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity))
+ dpx->element[i].refHighQuantity = 0.7f;
+
+ break;
+
+ default:
+ break;
+ }
}
- return dpx;
-}
-
-DpxFile*
-dpxOpen(const char *filename) {
- return intern_dpxOpen(LFREALFILE, filename, 0);
-}
+ dpx->referenceBlack = swap_float(header.televisionHeader.black_level, dpx->isMSB);
+ dpx->referenceWhite = swap_float(header.televisionHeader.white_level, dpx->isMSB);
+ dpx->gamma = swap_float(header.televisionHeader.gamma, dpx->isMSB);
-DpxFile*
-dpxOpenFromMem(unsigned char *buffer, unsigned int size) {
- return intern_dpxOpen(LFMEMFILE, (const char *) buffer, size);
-}
+ if ((dpx->referenceBlack == DPX_UNDEFINED_R32 || isnan(dpx->referenceBlack)) ||
+ (dpx->referenceWhite == DPX_UNDEFINED_R32 || dpx->referenceWhite <= dpx->referenceBlack || isnan(dpx->referenceWhite)) ||
+ (dpx->gamma == DPX_UNDEFINED_R32 || dpx->gamma <= 0 || isnan(dpx->gamma)))
+ {
-int
-dpxIsMemFileCineon(void *buffer) {
- int magicnum = 0;
- magicnum = *((int*)buffer);
- if (magicnum == ntohl(DPX_FILE_MAGIC)) return 1;
- else return 0;
-}
+ dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue;
+ dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue;
+ dpx->gamma = 1.7f;
+ }
-DpxFile*
-dpxCreate(const char* filename, int width, int height, int depth) {
+ if (verbose) {
+ printf("size %d x %d x %d elements\n", dpx->width, dpx->height, dpx->numElements);
+ for (i = 0; i < dpx->numElements; i++) {
+ printf(" Element %d:\n", i);
+ printf(" Bits per sample: %d\n", dpx->element[i].bitsPerSample);
+ printf(" Depth: %d\n", dpx->element[i].depth);
+ printf(" Transfer characteristics: %d\n", dpx->element[i].transfer);
+ printf(" Packing: %d\n", dpx->element[i].packing);
+ printf(" Descriptor: %d\n", dpx->element[i].descriptor);
+ printf(" Data offset: %u\n", dpx->element[i].dataOffset);
+ printf(" Reference low data: %u\n", dpx->element[i].refLowData);
+ printf(" Reference low quantity: %f\n", dpx->element[i].refLowQuantity);
+ printf(" Reference high data: %u\n", dpx->element[i].refHighData);
+ printf(" Reference high quantity: %f\n", dpx->element[i].refHighQuantity);
+ printf("\n");
+ }
- /* Note: always write files in network order */
- /* By the spec, it shouldn't matter, but ... */
+ printf("Gamma: %f\n", dpx->gamma);
+ printf("Reference black: %f\n", dpx->referenceBlack);
+ printf("Reference white: %f\n", dpx->referenceWhite);
+ printf("----------------------------\n");
+ }
+ return dpx;
+}
+LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPerSample, int hasAlpha,
+ int isLogarithmic, int referenceWhite, int referenceBlack, float gamma,
+ const char *creator)
+{
DpxMainHeader header;
- const char* shortFilename = 0;
+ const char *shortFilename = 0;
+ unsigned char pad[6044];
- DpxFile* dpx = (DpxFile*)malloc(sizeof(DpxFile));
+ LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
if (dpx == 0) {
- if (verbose) d_printf("Failed to malloc dpx file structure.\n");
- return 0;
- }
-
- memset(&header, 0, sizeof(header));
-
- /* for close routine */
- dpx->file = 0;
- dpx->lineBuffer = 0;
- dpx->pixelBuffer = 0;
-
- dpx->file = BLI_fopen(filename, "wb");
- if (dpx->file == 0) {
- if (verbose) d_printf("Couldn't open file %s\n", filename);
- dpxClose(dpx);
+ if (verbose) printf("DPX: Failed to malloc dpx file structure.\n");
return 0;
}
- dpx->reading = 0;
dpx->width = width;
dpx->height = height;
- dpx->depth = depth;
- dpx->bitsPerPixel = 10;
- dpx->imageOffset = sizeof(DpxMainHeader);
-
- dpx->lineBufferLength = pixelsToLongs(dpx->width * dpx->depth);
- dpx->lineBuffer = malloc(dpx->lineBufferLength * 4);
- if (dpx->lineBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", dpx->lineBufferLength * 4);
- dpxClose(dpx);
- return 0;
- }
+ dpx->element[0].bitsPerSample = bitsPerSample;
+ dpx->element[0].dataOffset = 8092;
+ dpx->element[0].maxValue = powf(2, dpx->element[0].bitsPerSample) - 1.0f;
+ dpx->isMSB = 1;
+ dpx->numElements = 1;
- dpx->pixelBuffer = malloc((dpx->lineBufferLength * 3 + 2) * sizeof(unsigned short));
- if (dpx->pixelBuffer == 0) {
- if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (dpx->width * dpx->depth + 2 + 2) * (int)sizeof(unsigned short));
- dpxClose(dpx);
- return 0;
+ switch (bitsPerSample) {
+ case 8:
+ case 16:
+ dpx->element[0].packing = 0;
+ break;
+
+ case 10:
+ case 12:
+ /* Packed Type A padding is the most common 10/12 bits format */
+ dpx->element[0].packing = 1;
+ break;
+
+ default:
+ if (verbose) printf("DPX: bitsPerSample not supported: %d\n", bitsPerSample);
+ logImageClose(dpx);
+ return 0;
}
- dpx->pixelBufferUsed = 0;
- /* find trailing part of filename */
- shortFilename = strrchr(filename, '/');
- if (shortFilename == 0) {
- shortFilename = filename;
+ if (hasAlpha == 0) {
+ dpx->depth = 3;
+ dpx->element[0].depth = 3;
+ dpx->element[0].descriptor = descriptor_RGB;
}
else {
- ++shortFilename;
+ dpx->depth = 4;
+ dpx->element[0].depth = 4;
+ dpx->element[0].descriptor = descriptor_RGBA;
}
- initDpxMainHeader(dpx, &header, shortFilename);
- logImageGetByteConversionDefaults(&dpx->params);
- /* Need set the file type before write the header!
- * 2 - Linear
- * 3 - Logarithmic
- *
- * Note that transfer characteristics is U8, don't need
- * check the byte order.
- */
- if (dpx->params.doLogarithm == 0)
- header.imageInfo.channel[0].transfer_characteristics= 2;
- else
- header.imageInfo.channel[0].transfer_characteristics= 3;
- if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) {
- if (verbose) d_printf("Couldn't write image header\n");
- dpxClose(dpx);
- return 0;
+ if (isLogarithmic == 0) {
+ dpx->element[0].transfer = transfer_Linear;
+ dpx->element[0].refHighQuantity = dpx->element[0].maxValue;
}
- dpx->fileYPos = 0;
- setupLut(dpx);
+ else {
+ dpx->element[0].transfer = transfer_PrintingDensity;
+ dpx->element[0].refHighQuantity = 2.048f;
- dpx->getRow = 0;
- dpx->setRow = &dpxSetRowBytes;
- dpx->close = &dpxClose;
+ }
- return dpx;
-}
+ dpx->element[0].refLowQuantity = 0;
+ dpx->element[0].refLowData = 0;
+ dpx->element[0].refHighData = dpx->element[0].maxValue;
-void
-dpxClose(DpxFile* dpx) {
+ if (referenceWhite > 0)
+ dpx->referenceWhite = referenceWhite;
+ else
+ dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue;
- if (dpx == 0) {
- return;
- }
+ if (referenceBlack > 0)
+ dpx->referenceBlack = referenceBlack;
+ else
+ dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue;
- if (dpx->file) {
- fclose(dpx->file);
- dpx->file = 0;
- }
+ if (gamma > 0.0f)
+ dpx->gamma = gamma;
+ else
+ dpx->gamma = 1.7f;
- if (dpx->lineBuffer) {
- free(dpx->lineBuffer);
- dpx->lineBuffer = 0;
- }
- if (dpx->pixelBuffer) {
- free(dpx->pixelBuffer);
- dpx->pixelBuffer = 0;
- }
+ shortFilename = strrchr(filename, '/');
+ if (shortFilename == 0)
+ shortFilename = filename;
+ else
+ shortFilename++;
- free(dpx);
-}
+ dpx->file = BLI_fopen(filename, "wb");
-void
-dpxDump(const char* filename) {
+ if (dpx->file == 0) {
+ if (verbose) printf("DPX: Couldn't open file %s\n", filename);
+ logImageClose(dpx);
+ return 0;
+ }
- DpxMainHeader header;
- FILE* file;
+ fillDpxMainHeader(dpx, &header, shortFilename, creator);
- file = BLI_fopen(filename, "rb");
- if (file == 0) {
- d_printf("Failed to open file \"%s\".\n", filename);
- return;
+ if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) {
+ if (verbose) printf("DPX: Couldn't write image header\n");
+ logImageClose(dpx);
+ return 0;
}
- if (fread(&header, sizeof(header), 1, file) == 0) {
- d_printf("Not enough data for header in \"%s\".\n", filename);
- fclose(file);
- return;
+ /* Header should be rounded to next 8k block
+ 6044 = 8092 - sizeof(DpxMainHeader) */
+ memset(&pad, 0, 6044);
+ if (fwrite(&pad, 6044, 1, dpx->file) == 0) {
+ if (verbose) printf("DPX: Couldn't write image header\n");
+ logImageClose(dpx);
+ return 0;
}
- fclose(file);
- dumpDpxMainHeader(&header);
+ return dpx;
}
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h
index eb3937f2bf7..e910aaa61e1 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.h
+++ b/source/blender/imbuf/intern/cineon/dpxlib.h
@@ -1,60 +1,160 @@
/*
- * DPX image file format library definitions.
+ * DPX image file format library definitions.
*
- * Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
+ * Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
-#ifndef __DPXLIB_H__
-#define __DPXLIB_H__
-
/** \file blender/imbuf/intern/cineon/dpxlib.h
* \ingroup imbcineon
*/
+
+#ifndef __DPX_LIB_H__
+#define __DPX_LIB_H__
+
#ifdef __cplusplus
extern "C" {
#endif
#include "logImageCore.h"
-typedef struct _Log_Image_File_t_ DpxFile;
+#define DPX_FILE_MAGIC 0x53445058
+#define DPX_UNDEFINED_U8 0xFF
+#define DPX_UNDEFINED_U16 0xFFFF
+#define DPX_UNDEFINED_U32 0xFFFFFFFF
+#define DPX_UNDEFINED_R32 0xFFFFFFFF
+#define DPX_UNDEFINED_CHAR 0
-/* int functions return 0 for OK */
+typedef struct {
+ unsigned int magic_num;
+ unsigned int offset;
+ char version[8];
+ unsigned int file_size;
+ unsigned int ditto_key;
+ unsigned int gen_hdr_size;
+ unsigned int ind_hdr_size;
+ unsigned int user_data_size;
+ char file_name[100];
+ char creation_date[24];
+ char creator[100];
+ char project[200];
+ char copyright[200];
+ unsigned int key;
+ char reserved[104];
+} DpxFileHeader;
-void dpxSetVerbose(int);
+typedef struct {
+ unsigned int data_sign;
+ unsigned int ref_low_data;
+ float ref_low_quantity;
+ unsigned int ref_high_data;
+ float ref_high_quantity;
+ unsigned char descriptor;
+ unsigned char transfer;
+ unsigned char colorimetric;
+ unsigned char bits_per_sample;
+ unsigned short packing;
+ unsigned short encoding;
+ unsigned int data_offset;
+ unsigned int line_padding;
+ unsigned int element_padding;
+ char description[32];
+} DpxElementHeader;
-DpxFile* dpxOpen(const char* filename);
-DpxFile* dpxCreate(const char* filename, int xsize, int ysize, int channels);
-DpxFile* dpxOpenFromMem(unsigned char *buffer, unsigned int size);
-int dpxIsMemFileCineon(void *buffer);
+typedef struct {
+ unsigned short orientation;
+ unsigned short elements_per_image;
+ unsigned int pixels_per_line;
+ unsigned int lines_per_element;
+ DpxElementHeader element[8];
+ char reserved[52];
+} DpxImageHeader;
-/* get/set scanline of converted bytes */
-int dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y);
-int dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y);
+typedef struct {
+ unsigned int x_offset;
+ unsigned int y_offset;
+ float x_center;
+ float y_center;
+ unsigned int x_original_size;
+ unsigned int y_original_size;
+ char file_name[100];
+ char creation_time[24];
+ char input_device[32];
+ char input_serial_number[32];
+ unsigned short border_validity[4];
+ unsigned int pixel_aspect_ratio[2];
+ char reserved[28];
+} DpxOrientationHeader;
-/* closes file and deletes data */
-void dpxClose(DpxFile* dpx);
+typedef struct {
+ char film_manufacturer_id[2];
+ char film_type[2];
+ char edge_code_perforation_offset[2];
+ char edge_code_prefix[6];
+ char edge_code_count[4];
+ char film_format[32];
+ unsigned int frame_position;
+ unsigned int sequence_length;
+ unsigned int held_count;
+ float frame_rate;
+ float shutter_angle;
+ char frame_identification[32];
+ char slate_info[100];
+ char reserved[56];
+} DpxFilmHeader;
-/* dumps file to stdout */
-void dpxDump(const char* filename);
+typedef struct {
+ unsigned int time_code;
+ unsigned int user_bits;
+ unsigned char interlace;
+ unsigned char field_number;
+ unsigned char video_signal;
+ unsigned char padding;
+ float horizontal_sample_rate;
+ float vertical_sample_rate;
+ float frame_rate;
+ float time_offset;
+ float gamma;
+ float black_level;
+ float black_gain;
+ float breakpoint;
+ float white_level;
+ float integration_times;
+ unsigned char reserved[76];
+} DpxTelevisionHeader;
+
+
+typedef struct {
+ DpxFileHeader fileHeader;
+ DpxImageHeader imageHeader;
+ DpxOrientationHeader orientationHeader;
+ DpxFilmHeader filmHeader;
+ DpxTelevisionHeader televisionHeader;
+} DpxMainHeader;
+
+void dpxSetVerbose(int verbosity);
+LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize);
+LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPerSample, int hasAlpha, int isLogarithmic, int referenceWhite, int referenceBlack, float gamma, const char *creator);
#ifdef __cplusplus
}
#endif
-#endif /* __DPXLIB_H__ */
+#endif
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index f772cc7d477..3911e5c2ef3 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -1,21 +1,23 @@
/*
- * Cineon image file format library routines.
+ * Cineon image file format library routines.
*
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
+ * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
@@ -23,223 +25,1407 @@
* \ingroup imbcineon
*/
+
+#include "logmemfile.h"
#include "logImageCore.h"
+#include "dpxlib.h"
+#include "cineonlib.h"
-#include <time.h> /* strftime() */
+#include <stdlib.h>
+#include <string.h>
#include <math.h>
-/* Makes rint consistent in Windows and Linux: */
-#define rint(x) floor(x+0.5)
-#ifdef WIN32
-#include <winsock.h>
-#else
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/param.h>
-#endif
+#include "BLI_fileops.h"
+#include "BLI_utildefines.h"
+
+#include "MEM_guardedalloc.h"
+
+/*
+ * Declaration of static functions
+ */
+
+static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data);
+static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data);
+static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data);
+static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data);
+static int logImageElementGetData(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData1(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData8(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData10(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData10Packed(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData12(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData12Packed(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int logImageElementGetData16(LogImageFile *dpx, LogImageElement logElement, float *data);
+static int convertLogElementToRGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int dstIsLinearRGB);
+static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int srcIsLinearRGB);
+
+
+/*
+ * For debug purpose
+ */
+
+static int verbose = 0;
+
+void logImageSetVerbose(int verbosity)
+{
+ verbose = verbosity;
+ cineonSetVerbose(verbosity);
+ dpxSetVerbose(verbosity);
+}
+
+
+/*
+ * IO stuff
+ */
+
+int logImageIsDpx(const void *buffer)
+{
+ unsigned int magicNum = *(unsigned int *)buffer;
+ return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1));
+}
-#if defined(__hpux)
-/* These are macros in hpux */
-#ifdef htonl
-#undef htonl
-#undef htons
-#undef ntohl
-#undef ntohs
-#endif
-unsigned int htonl(h) unsigned int h; { return(h); }
-unsigned short htons(h) unsigned short h; { return(h); }
-unsigned int ntohl(n) unsigned int n; { return(n); }
-unsigned short ntohs(n) unsigned short n; { return(n); }
-#endif
-
-
-/* obscure LogImage conversion */
-/* from 10 bit int to 0.0 - 1.0 */
-/* magic numbers left intact */
-static double
-convertTo(int inp, int white, float gamma) {
- /* return pow(pow(10.0, ((inp - white) * 0.002 / 0.6)), gamma); */
- return pow(10.0, (inp - white) * gamma * 0.002 / 0.6);
+int logImageIsCineon(const void *buffer)
+{
+ unsigned int magicNum = *(unsigned int *)buffer;
+ return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1));
}
-static double
-convertFrom(double inp, int white, float gamma) {
- return white + log10(inp) / (gamma * 0.002 / 0.6);
+LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
+{
+ unsigned int magicNum;
+ FILE *f = BLI_fopen(filename, "rb");
+
+ (void)cineon;
+
+ if (f == 0)
+ return 0;
+
+ if (fread(&magicNum, sizeof(unsigned int), 1, f) != 1) {
+ fclose(f);
+ return 0;
+ }
+
+ fclose(f);
+
+ if (logImageIsDpx(&magicNum))
+ return dpxOpen((const unsigned char *)filename, 0, 0);
+ else if (logImageIsCineon(&magicNum))
+ return cineonOpen((const unsigned char *)filename, 0, 0);
+
+ return 0;
}
-/* set up the 10 bit to 8 bit and 8 bit to 10 bit tables */
-void
-setupLut(LogImageFile *logImage) {
+LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
+{
+ if (logImageIsDpx(buffer))
+ return dpxOpen(buffer, 1, size);
+ else if (logImageIsCineon(buffer))
+ return cineonOpen(buffer, 1, size);
- int i;
- double f_black;
- double scale;
+ return 0;
+}
+
+LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample,
+ int isLogarithmic, int hasAlpha, int referenceWhite, int referenceBlack,
+ float gamma, const char *creator)
+{
+ /* referenceWhite, referenceBlack and gamma values are only supported for DPX file */
+ if (cineon)
+ return cineonCreate(filename, width, height, bitsPerSample, creator);
+ else
+ return dpxCreate(filename, width, height, bitsPerSample, isLogarithmic, hasAlpha,
+ referenceWhite, referenceBlack, gamma, creator);
- f_black = convertTo(logImage->params.blackPoint, logImage->params.whitePoint, logImage->params.gamma);
- scale = 255.0 / (1.0 - f_black);
+ return 0;
+}
- for (i = 0; i <= logImage->params.blackPoint; ++i) {
- logImage->lut10[i] = 0;
+void logImageClose(LogImageFile *logImage)
+{
+ if (logImage != 0) {
+ if (logImage->file) {
+ fclose(logImage->file);
+ logImage->file = 0;
+ }
+ MEM_freeN(logImage);
}
- for (; i < logImage->params.whitePoint; ++i) {
- double f_i;
- f_i = convertTo(i, logImage->params.whitePoint, logImage->params.gamma);
- logImage->lut10[i] = (int)rint(scale * (f_i - f_black));
+}
+
+void logImageGetSize(LogImageFile *logImage, int *width, int *height, int *depth)
+{
+ *width = logImage->width;
+ *height = logImage->height;
+ *depth = logImage->depth;
+}
+
+
+/*
+ * Helper
+ */
+
+unsigned int getRowLength(int width, LogImageElement logElement)
+{
+ /* return the row length in bytes according to width and packing method */
+ switch (logElement.bitsPerSample) {
+ case 1:
+ return ((width * logElement.depth - 1) / 32 + 1) * 4;
+
+ case 8:
+ return ((width * logElement.depth - 1) / 4 + 1) * 4;
+
+ case 10:
+ if (logElement.packing == 0)
+ return ((width * logElement.depth * 10 - 1) / 32 + 1) * 4;
+ else if (logElement.packing == 1 || logElement.packing == 2)
+ return ((width * logElement.depth - 1) / 3 + 1) * 4;
+
+ case 12:
+ if (logElement.packing == 0)
+ return ((width * logElement.depth * 12 - 1) / 32 + 1) * 4;
+ else if (logElement.packing == 1 || logElement.packing == 2)
+ return width * logElement.depth * 2;
+
+ case 16:
+ return width * logElement.depth * 2;
+
+ default:
+ return 0;
}
- for (; i < 1024; ++i) {
- logImage->lut10[i] = 255;
+}
+
+
+/*
+ * Data writing
+ */
+
+int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB)
+{
+ float *elementData;
+ int returnValue;
+
+ elementData = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->depth * sizeof(float), __func__);
+ if (elementData == 0)
+ return 1;
+
+ if (convertRGBAToLogElement(data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) {
+ MEM_freeN(elementData);
+ return 1;
}
- for (i = 0; i < 256; ++i) {
- double f_i = f_black + (i / 255.0) * (1.0 - f_black);
- logImage->lut8[i] = convertFrom(f_i, logImage->params.whitePoint, logImage->params.gamma);
- }
-}
-
-/* set up the 10 bit to 16 bit and 16 bit to 10 bit tables */
-void
-setupLut16(LogImageFile *logImage) {
+ switch (logImage->element[0].bitsPerSample) {
+ case 8:
+ returnValue = logImageSetData8(logImage, logImage->element[0], elementData);
+ break;
+
+ case 10:
+ returnValue = logImageSetData10(logImage, logImage->element[0], elementData);
+ break;
- int i;
- double f_black;
- double scale;
+ case 12:
+ returnValue = logImageSetData12(logImage, logImage->element[0], elementData);
+ break;
- f_black = convertTo(logImage->params.blackPoint, logImage->params.whitePoint, logImage->params.gamma);
- scale = 65535.0 / (1.0 - f_black);
-
- for (i = 0; i <= logImage->params.blackPoint; ++i) {
- logImage->lut10_16[i] = 0;
- }
- for (; i < logImage->params.whitePoint; ++i) {
- double f_i;
- f_i = convertTo(i, logImage->params.whitePoint, logImage->params.gamma);
- logImage->lut10_16[i] = (int)rint(scale * (f_i - f_black));
- }
- for (; i < 1024; ++i) {
- logImage->lut10_16[i] = 65535;
- }
-
- for (i = 0; i < 65536; ++i) {
- double f_i = f_black + (i / 65535.0) * (1.0 - f_black);
- logImage->lut16_16[i] = convertFrom(f_i, logImage->params.whitePoint, logImage->params.gamma);
- }
-}
-
-/* how many longwords to hold this many pixels? */
-int
-pixelsToLongs(int numPixels) {
- return (numPixels + 2) / 3;
-}
-
-/* byte reversed float */
+ case 16:
+ returnValue = logImageSetData16(logImage, logImage->element[0], elementData);
+ break;
-typedef union {
- U32 i;
- R32 f;
-} Hack;
+ default:
+ returnValue = 1;
+ break;
+ }
-R32
-htonf(R32 f) {
- Hack hack;
- hack.f = f;
- hack.i = htonl(hack.i);
- return hack.f;
+ MEM_freeN(elementData);
+ return returnValue;
}
-R32
-ntohf(R32 f) {
- Hack hack;
- hack.f = f;
- hack.i = ntohl(hack.i);
- return hack.f;
+static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned char *row;
+ int x, y;
+
+ row = (unsigned char *)MEM_mallocN(rowLength, __func__);
+ if (row == 0) {
+ if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
+ return 1;
+ }
+ memset(row, 0, rowLength);
+
+ for (y = 0; y < logImage->height; y++) {
+ for (x = 0; x < logImage->width * logImage->depth; x++)
+ row[x] = (unsigned char)float_uint(data[y * logImage->width * logImage->depth + x], 255);
+
+ if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
+ if (verbose) printf("DPX/Cineon: Error while writing file.\n");
+ MEM_freeN(row);
+ return 1;
+ }
+ }
+ MEM_freeN(row);
+ return 0;
}
-#define UNDEF_FLOAT 0x7F800000
+static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned int pixel, index;
+ unsigned int *row;
+ int x, y, offset;
-R32
-undefined(void) {
- Hack hack;
- hack.i = UNDEF_FLOAT;
- return hack.f;
+ row = (unsigned int *)MEM_mallocN(rowLength, __func__);
+ if (row == 0) {
+ if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
+ return 1;
+ }
+
+ for (y = 0; y < logImage->height; y++) {
+ offset = 22;
+ index = 0;
+ pixel = 0;
+
+ for (x = 0; x < logImage->width * logImage->depth; x++) {
+ pixel |= (unsigned int)float_uint(data[y * logImage->width * logImage->depth + x], 1023) << offset;
+ offset -= 10;
+ if (offset < 0) {
+ row[index] = swap_uint(pixel, logImage->isMSB);
+ index++;
+ pixel = 0;
+ offset = 22;
+ }
+ }
+ if (pixel != 0)
+ row[index] = swap_uint(pixel, logImage->isMSB);
+
+ if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
+ if (verbose) printf("DPX/Cineon: Error while writing file.\n"); {
+ MEM_freeN(row);
+ return 1;
+ }
+ }
+ }
+ MEM_freeN(row);
+ return 0;
}
-/* reverse an endian-swapped U16 */
-U16
-reverseU16(U16 value) {
+static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned short *row;
+ int x, y;
- union {
- U16 whole;
- char part[2];
- } buff;
- char temp;
- buff.whole = value;
- temp = buff.part[0];
- buff.part[0] = buff.part[1];
- buff.part[1] = temp;
- return buff.whole;
+ row = (unsigned short *)MEM_mallocN(rowLength, __func__);
+ if (row == 0) {
+ if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
+ return 1;
+ }
+
+ for (y = 0; y < logImage->height; y++) {
+ for (x = 0; x < logImage->width * logImage->depth; x++)
+ row[x] = swap_ushort(((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4, logImage->isMSB);
+
+ if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
+ if (verbose) printf("DPX/Cineon: Error while writing file.\n");
+ MEM_freeN(row);
+ return 1;
+ }
+ }
+ MEM_freeN(row);
+ return 0;
}
-/* reverse an endian-swapped U32 */
-U32
-reverseU32(U32 value) {
+static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned short *row;
+ int x, y;
- union {
- U32 whole;
- char part[4];
- } buff;
- char temp;
- buff.whole = value;
- temp = buff.part[0];
- buff.part[0] = buff.part[3];
- buff.part[3] = temp;
- temp = buff.part[1];
- buff.part[1] = buff.part[2];
- buff.part[2] = temp;
- return buff.whole;
+ row = (unsigned short *)MEM_mallocN(rowLength, __func__);
+ if (row == 0) {
+ if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
+ return 1;
+ }
+
+ for (y = 0; y < logImage->height; y++) {
+ for (x = 0; x < logImage->width * logImage->depth; x++)
+ row[x] = swap_ushort((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 65535), logImage->isMSB);
+
+ if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
+ if (verbose) printf("DPX/Cineon: Error while writing file.\n");
+ MEM_freeN(row);
+ return 1;
+ }
+ }
+ MEM_freeN(row);
+ return 0;
}
-/* reverse an endian-swapped R32 */
-R32
-reverseR32(R32 value) {
- union {
- R32 whole;
- char part[4];
- } buff;
- char temp;
- buff.whole = value;
- temp = buff.part[0];
- buff.part[0] = buff.part[3];
- buff.part[3] = temp;
- temp = buff.part[1];
- buff.part[1] = buff.part[2];
- buff.part[2] = temp;
- return buff.whole;
+/*
+ * Data reading
+ */
+
+int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB)
+{
+ /* Fills data with 32 bits float RGBA values */
+ int i, j, returnValue, sortedElementData[8], hasAlpha;
+ float *elementData[8];
+ float *elementData_ptr[8];
+ float *mergedData;
+ unsigned int sampleIndex;
+ LogImageElement mergedElement;
+
+ /* Determine the depth of the picture and if there's a separate alpha element.
+ If the element is supported, load it into an unsigned ints array. */
+ memset(&elementData, 0, 8 * sizeof(float *));
+ hasAlpha = 0;
+
+ for (i = 0; i < logImage->numElements; i++) {
+ /* descriptor_Depth and descriptor_Composite are not supported */
+ if (logImage->element[i].descriptor != descriptor_Depth && logImage->element[i].descriptor != descriptor_Composite) {
+ /* Allocate memory */
+ elementData[i] = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->element[i].depth * sizeof(float), __func__);
+ if (elementData[i] == 0) {
+ if (verbose) printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i);
+ for (j = 0; j < i; j++)
+ if (elementData[j] != 0)
+ MEM_freeN(elementData[j]);
+ return 1;
+ }
+ elementData_ptr[i] = elementData[i];
+
+ /* Load data */
+ if (logImageElementGetData(logImage, logImage->element[i], elementData[i]) != 0) {
+ if (verbose) printf("DPX/Cineon: Cannot read elementData[%d]\n.", i);
+ for (j = 0; j < i; j++)
+ if (elementData[j] != 0)
+ MEM_freeN(elementData[j]);
+ return 1;
+ }
+ }
+
+ if (logImage->element[i].descriptor == descriptor_Alpha)
+ hasAlpha = 1;
+ }
+
+ /* only one element, easy case, no need to do anything */
+ if (logImage->numElements == 1) {
+ returnValue = convertLogElementToRGBA(elementData[0], data, logImage, logImage->element[0], dataIsLinearRGB);
+ MEM_freeN(elementData[0]);
+ }
+ else {
+ /* The goal here is to merge every elements into only one
+ * to recreate a classic 16 bits RGB, RGBA or YCbCr element.
+ * Unsupported elements are skipped (depth, composite) */
+
+ memcpy(&mergedElement, &logImage->element[0], sizeof(LogImageElement));
+ mergedElement.descriptor = -1;
+ mergedElement.depth = logImage->depth;
+ memset(&sortedElementData, -1, 8 * sizeof(int));
+
+ /* Try to know how to assemble the elements */
+ for (i = 0; i < logImage->numElements; i++) {
+ switch (logImage->element[i].descriptor) {
+ case descriptor_Red:
+ case descriptor_RGB:
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_RGB;
+ else
+ mergedElement.descriptor = descriptor_RGBA;
+
+ sortedElementData[0] = i;
+ break;
+
+ case descriptor_Green:
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_RGB;
+ else
+ mergedElement.descriptor = descriptor_RGBA;
+
+ sortedElementData[1] = i;
+ break;
+
+ case descriptor_Blue:
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_RGB;
+ else
+ mergedElement.descriptor = descriptor_RGBA;
+
+ sortedElementData[2] = i;
+ break;
+
+ case descriptor_Alpha:
+ /* Alpha component is always the last one */
+ sortedElementData[mergedElement.depth - 1] = i;
+ break;
+
+ case descriptor_Luminance:
+ if (mergedElement.descriptor == -1)
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_Luminance;
+ else
+ mergedElement.descriptor = descriptor_YA;
+ else if (mergedElement.descriptor == descriptor_Chrominance) {
+ if (mergedElement.depth == 2)
+ mergedElement.descriptor = descriptor_CbYCrY;
+ else if (mergedElement.depth == 3)
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_CbYCr;
+ else
+ mergedElement.descriptor = descriptor_CbYACrYA;
+ else if (mergedElement.depth == 4)
+ mergedElement.descriptor = descriptor_CbYCrA;
+ }
+
+ /* Y component always in 1 except if it's alone or with alpha */
+ if (mergedElement.depth == 1 || (mergedElement.depth == 2 && hasAlpha == 1))
+ sortedElementData[0] = i;
+ else
+ sortedElementData[1] = i;
+ break;
+
+ case descriptor_Chrominance:
+ if (mergedElement.descriptor == -1)
+ mergedElement.descriptor = descriptor_Chrominance;
+ else if (mergedElement.descriptor == descriptor_Luminance) {
+ if (mergedElement.depth == 2)
+ mergedElement.descriptor = descriptor_CbYCrY;
+ else if (mergedElement.depth == 3)
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_CbYCr;
+ else
+ mergedElement.descriptor = descriptor_CbYACrYA;
+ else if (mergedElement.depth == 4)
+ mergedElement.descriptor = descriptor_CbYCrA;
+ }
+
+ /* Cb and Cr always in 0 or 2 */
+ if (sortedElementData[0] == -1)
+ sortedElementData[0] = i;
+ else
+ sortedElementData[2] = i;
+ break;
+
+ case descriptor_CbYCr:
+ if (hasAlpha == 0)
+ mergedElement.descriptor = descriptor_CbYCr;
+ else
+ mergedElement.descriptor = descriptor_CbYCrA;
+
+ sortedElementData[0] = i;
+ break;
+
+ case descriptor_RGBA:
+ case descriptor_ABGR:
+ case descriptor_CbYACrYA:
+ case descriptor_CbYCrY:
+ case descriptor_CbYCrA:
+ /* I don't think these ones can be seen in a planar image */
+ mergedElement.descriptor = logImage->element[i].descriptor;
+ sortedElementData[0] = i;
+ break;
+
+ case descriptor_Depth:
+ case descriptor_Composite:
+ /* Not supported */
+ break;
+ }
+ }
+
+ mergedData = (float *)MEM_mallocN(logImage->width * logImage->height * mergedElement.depth * sizeof(float), __func__);
+ if (mergedData == 0) {
+ if (verbose) printf("DPX/Cineon: Cannot allocate mergedData.\n");
+ for (i = 0; i < logImage->numElements; i++)
+ if (elementData[i] != 0)
+ MEM_freeN(elementData[i]);
+ return 1;
+ }
+
+ sampleIndex = 0;
+ while (sampleIndex < logImage->width * logImage->height * mergedElement.depth) {
+ for (i = 0; i < logImage->numElements; i++)
+ for (j = 0; j < logImage->element[sortedElementData[i]].depth; j++)
+ mergedData[sampleIndex++] = *(elementData_ptr[sortedElementData[i]]++);
+ }
+
+ /* Done with elements data, clean-up */
+ for (i = 0; i < logImage->numElements; i++)
+ if (elementData[i] != 0)
+ MEM_freeN(elementData[i]);
+
+ returnValue = convertLogElementToRGBA(mergedData, data, logImage, mergedElement, dataIsLinearRGB);
+ MEM_freeN(mergedData);
+ }
+ return returnValue;
}
-#if 0
-/* bytes per line for images packed 3 10 bit pixels to 32 bits, 32 bit aligned */
-int
-bytesPerLine_10_4(int numPixels) {
- return ((numPixels + 2) / 3) * 4;
+static int logImageElementGetData(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ switch (logElement.bitsPerSample) {
+ case 1:
+ return logImageElementGetData1(logImage, logElement, data);
+
+ case 8:
+ return logImageElementGetData8(logImage, logElement, data);
+
+ case 10:
+ if (logElement.packing == 0)
+ return logImageElementGetData10Packed(logImage, logElement, data);
+ else if (logElement.packing == 1 || logElement.packing == 2)
+ return logImageElementGetData10(logImage, logElement, data);
+
+ case 12:
+ if (logElement.packing == 0)
+ return logImageElementGetData12Packed(logImage, logElement, data);
+ else if (logElement.packing == 1 || logElement.packing == 2)
+ return logImageElementGetData12(logImage, logElement, data);
+
+ case 16:
+ return logImageElementGetData16(logImage, logElement, data);
+
+ default:
+ /* format not supported */
+ return 1;
+ }
}
-void
-seekLine_noPadding(LogImageFile* logImage, int lineNumber) {
- int fileOffset = bytesPerLine_10_4(lineNumber * logImage->width * logImage->depth);
- int filePos = logImage->imageOffset + fileOffset;
- if (fseek(logImage->file, filePos, SEEK_SET) != 0) {
- /* complain? */
- }
-}
-
-void
-seekLine_padding(LogImageFile* logImage, int lineNumber) {
- int fileOffset = lineNumber * bytesPerLine_10_4(logImage->width * logImage->depth);
- int filePos = logImage->imageOffset + fileOffset;
- if (fseek(logImage->file, filePos, SEEK_SET) != 0) {
- /* complain? */
- }
-}
-#endif
+static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int pixel;
+ int x, y, offset;
+
+ /* seek at the right place */
+ if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ return 1;
+ }
+
+ /* read 1 bit data padded to 32 bits */
+ for (y = 0; y < logImage->height; y++) {
+ for (x = 0; x < logImage->width * logElement.depth; x += 32) {
+ if (logimage_read_uint(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_uint(pixel, logImage->isMSB);
+ for (offset = 0; offset < 32 && x + offset < logImage->width; offset++)
+ data[y * logImage->width * logElement.depth + x + offset] = (float)((pixel >> offset) & 0x01);
+ }
+ }
+ return 0;
+}
+
+static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned char pixel;
+ int x, y;
+
+ /* extract required pixels */
+ for (y = 0; y < logImage->height; y++) {
+ /* 8 bits are 32-bits padded so we need to seek at each row */
+ if (logimage_fseek(logImage, logElement.dataOffset + y * rowLength, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset + y * rowLength);
+ return 1;
+ }
+
+ for (x = 0; x < logImage->width * logElement.depth; x++) {
+ if (logimage_read_uchar(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ data[y * logImage->width * logElement.depth + x] = (float)pixel / 255.0f;
+ }
+ }
+ return 0;
+}
+
+static int logImageElementGetData10(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int pixel;
+ int x, y, offset;
+
+ /* seek to data */
+ if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ return 1;
+ }
+
+ if (logImage->depth == 1 && logImage->srcFormat == format_DPX) {
+ for (y = 0; y < logImage->height; y++) {
+ offset = 32;
+ for (x = 0; x < logImage->width * logElement.depth; x++) {
+ /* we need to read the next long */
+ if (offset >= 30) {
+ if (logElement.packing == 1)
+ offset = 2;
+ else if (logElement.packing == 2)
+ offset = 0;
+
+ if (logimage_read_uint(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_uint(pixel, logImage->isMSB);
+ }
+ data[y * logImage->width * logElement.depth + x] = (float)((pixel >> offset) & 0x3ff) / 1023.0f;
+ offset += 10;
+ }
+ }
+ }
+ else {
+ for (y = 0; y < logImage->height; y++) {
+ offset = -1;
+ for (x = 0; x < logImage->width * logElement.depth; x++) {
+ /* we need to read the next long */
+ if (offset < 0) {
+ if (logElement.packing == 1)
+ offset = 22;
+ else if (logElement.packing == 2)
+ offset = 20;
+
+ if (logimage_read_uint(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_uint(pixel, logImage->isMSB);
+ }
+ data[y * logImage->width * logElement.depth + x] = (float)((pixel >> offset) & 0x3ff) / 1023.0f;
+ offset -= 10;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int logImageElementGetData10Packed(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned int pixel, oldPixel;
+ int offset, offset2, x, y;
+
+ /* converting bytes to pixels */
+ for (y = 0; y < logImage->height; y++) {
+ /* seek to data */
+ if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %u\n", y * rowLength + logElement.dataOffset);
+ return 1;
+ }
+
+ oldPixel = 0;
+ offset = 0;
+ offset2 = 0;
+
+ for (x = 0; x < logImage->width * logElement.depth; x++) {
+ if (offset2 != 0) {
+ offset = 10 - offset2;
+ offset2 = 0;
+ oldPixel = 0;
+ }
+ else if (offset == 32) {
+ offset = 0;
+ }
+ else if (offset + 10 > 32) {
+ /* next pixel is on two different longs */
+ oldPixel = (pixel >> offset);
+ offset2 = 32 - offset;
+ offset = 0;
+ }
+
+ if (offset == 0) {
+ /* we need to read the next long */
+ if (logimage_read_uint(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_uint(pixel, logImage->isMSB);
+ }
+ data[y * logImage->width * logElement.depth + x] = (float)((((pixel << offset2) >> offset) & 0x3ff) | oldPixel) / 1023.0f;
+ offset += 10;
+ }
+ }
+ return 0;
+}
+
+static int logImageElementGetData12(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int sampleIndex;
+ unsigned int numSamples = logImage->width * logImage->height * logElement.depth;
+ unsigned short pixel;
+
+ /* seek to data */
+ if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ return 1;
+ }
+
+ /* convert bytes to pixels */
+ sampleIndex = 0;
+
+ for (sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) {
+ if (logimage_read_ushort(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_ushort(pixel, logImage->isMSB);
+
+ if (logElement.packing == 1) /* padded to the right */
+ data[sampleIndex] = (float)(pixel >> 4) / 4095.0f;
+ else if (logElement.packing == 2) /* padded to the left */
+ data[sampleIndex] = (float)pixel / 4095.0f;
+ }
+ return 0;
+}
+
+static int logImageElementGetData12Packed(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int rowLength = getRowLength(logImage->width, logElement);
+ unsigned int pixel, oldPixel;
+ int offset, offset2, x, y;
+
+ /* converting bytes to pixels */
+ for (y = 0; y < logImage->height; y++) {
+ /* seek to data */
+ if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %u\n", y * rowLength + logElement.dataOffset);
+ return 1;
+ }
+
+ oldPixel = 0;
+ offset = 0;
+ offset2 = 0;
+
+ for (x = 0; x < logImage->width * logElement.depth; x++) {
+ if (offset2 != 0) {
+ offset = 12 - offset2;
+ offset2 = 0;
+ oldPixel = 0;
+ }
+ else if (offset == 32) {
+ offset = 0;
+ }
+ else if (offset + 12 > 32) {
+ /* next pixel is on two different longs */
+ oldPixel = (pixel >> offset);
+ offset2 = 32 - offset;
+ offset = 0;
+ }
+
+ if (offset == 0) {
+ /* we need to read the next long */
+ if (logimage_read_uint(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_uint(pixel, logImage->isMSB);
+ }
+ data[y * logImage->width * logElement.depth + x] = (float)((((pixel << offset2) >> offset) & 0xfff) | oldPixel) / 4095.0f;
+ offset += 12;
+ }
+ }
+ return 0;
+}
+
+static int logImageElementGetData16(LogImageFile *logImage, LogImageElement logElement, float *data)
+{
+ unsigned int numSamples = logImage->width * logImage->height * logElement.depth;
+ unsigned int sampleIndex;
+ unsigned short pixel;
+
+ /* seek to data */
+ if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
+ if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ return 1;
+ }
+
+ for (sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) {
+ if (logimage_read_ushort(&pixel, logImage) != 0) {
+ if (verbose) printf("DPX/Cineon: EOF reached\n");
+ return 1;
+ }
+ pixel = swap_ushort(pixel, logImage->isMSB);
+ data[sampleIndex] = (float)pixel / 65535.0f;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Color conversion
+ */
+
+static int getYUVtoRGBMatrix(float *matrix, LogImageElement logElement)
+{
+ float scaleY, scaleCbCr;
+ float refHighData = (float)logElement.refHighData / logElement.maxValue;
+ float refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ scaleY = 1.0f / (refHighData - refLowData);
+ scaleCbCr = scaleY * ((940.0f - 64.0f) / (960.0f - 64.0f));
+
+ switch (logElement.transfer) {
+ case 2: /* linear */
+ matrix[0] = 1.0f * scaleY;
+ matrix[1] = 1.0f * scaleCbCr;
+ matrix[2] = 1.0f * scaleCbCr;
+ matrix[3] = 1.0f * scaleY;
+ matrix[4] = 1.0f * scaleCbCr;
+ matrix[5] = 1.0f * scaleCbCr;
+ matrix[6] = 1.0f * scaleY;
+ matrix[7] = 1.0f * scaleCbCr;
+ matrix[8] = 1.0f * scaleCbCr;
+ return 0;
+
+ case 5: /* SMPTE 240M */
+ matrix[0] = 1.0000f * scaleY;
+ matrix[1] = 0.0000f * scaleCbCr;
+ matrix[2] = 1.5756f * scaleCbCr;
+ matrix[3] = 1.0000f * scaleY;
+ matrix[4] = -0.2253f * scaleCbCr;
+ matrix[5] = -0.5000f * scaleCbCr;
+ matrix[6] = 1.0000f * scaleY;
+ matrix[7] = 1.8270f * scaleCbCr;
+ matrix[8] = 0.0000f * scaleCbCr;
+ return 0;
+
+ case 6: /* CCIR 709-1 */
+ matrix[0] = 1.000000f * scaleY;
+ matrix[1] = 0.000000f * scaleCbCr;
+ matrix[2] = 1.574800f * scaleCbCr;
+ matrix[3] = 1.000000f * scaleY;
+ matrix[4] = -0.187324f * scaleCbCr;
+ matrix[5] = -0.468124f * scaleCbCr;
+ matrix[6] = 1.000000f * scaleY;
+ matrix[7] = 1.855600f * scaleCbCr;
+ matrix[8] = 0.000000f * scaleCbCr;
+ return 0;
+
+ case 7: /* CCIR 601 */
+ case 8: /* I'm not sure 7 and 8 should share the same matrix */
+ matrix[0] = 1.000000f * scaleY;
+ matrix[1] = 0.000000f * scaleCbCr;
+ matrix[2] = 1.402000f * scaleCbCr;
+ matrix[3] = 1.000000f * scaleY;
+ matrix[4] = -0.344136f * scaleCbCr;
+ matrix[5] = -0.714136f * scaleCbCr;
+ matrix[6] = 1.000000f * scaleY;
+ matrix[7] = 1.772000f * scaleCbCr;
+ matrix[8] = 0.000000f * scaleCbCr;
+ return 0;
+
+ default:
+ return 1;
+ }
+}
+
+static void getLinToLogLut(float *lut, LogImageFile *logImage, LogImageElement logElement)
+{
+ float gain, negativeFilmGamma, offset, step;
+ unsigned int i;
+
+ negativeFilmGamma = 0.6;
+ step = logElement.refHighQuantity / logElement.maxValue;
+ gain = logElement.maxValue / (1.0f - powf(10, (logImage->referenceBlack - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f));
+ offset = gain - logElement.maxValue;
+
+ for (i = 0; i < (int)(logElement.maxValue + 1); i++)
+ lut[i] = (logImage->referenceWhite + log10f(powf((i + offset) / gain, 1.7f / logImage->gamma)) / (step / negativeFilmGamma)) / logElement.maxValue;
+}
+
+static void getLogToLinLut(float *lut, LogImageFile *logImage, LogImageElement logElement)
+{
+ float breakPoint, gain, kneeGain, kneeOffset, negativeFilmGamma, offset, step, softClip;
+ /* float filmGamma; unused */
+ unsigned int i;
+
+ /* Building the Log -> Lin LUT */
+ step = logElement.refHighQuantity / logElement.maxValue;
+ negativeFilmGamma = 0.6;
+
+ /* these are default values */
+ /* filmGamma = 2.2f; unused */
+ softClip = 0;
+
+ breakPoint = logImage->referenceWhite - softClip;
+ gain = logElement.maxValue / (1.0f - powf(10, (logImage->referenceBlack - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f));
+ offset = gain - logElement.maxValue;
+ kneeOffset = powf(10, (breakPoint - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f) * gain - offset;
+ kneeGain = (logElement.maxValue - kneeOffset) / powf(5 * softClip, softClip / 100);
+
+ for (i = 0; i < (int)(logElement.maxValue + 1); i++) {
+ if (i < logImage->referenceBlack)
+ lut[i] = 0.0f;
+ else if (i > breakPoint)
+ lut[i] = (powf(i - breakPoint, softClip / 100) * kneeGain + kneeOffset) / logElement.maxValue;
+ else
+ lut[i] = (powf(10, ((float)i - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f) * gain - offset) / logElement.maxValue;
+ }
+}
+
+static void getLinToSrgbLut(float *lut, LogImageElement logElement)
+{
+ unsigned int i;
+ float col;
+
+ for (i = 0; i < (int)(logElement.maxValue + 1); i++) {
+ col = (float)i / logElement.maxValue;
+ if (col < 0.0031308f)
+ lut[i] = (col < 0.0f) ? 0.0f : col * 12.92f;
+ else
+ lut[i] = 1.055f * powf(col, 1.0f / 2.4f) - 0.055f;
+ }
+}
+
+static void getSrgbToLinLut(float *lut, LogImageElement logElement)
+{
+ unsigned int i;
+ float col;
+
+ for (i = 0; i < (int)(logElement.maxValue + 1); i++) {
+ col = (float)i / logElement.maxValue;
+ if (col < 0.04045f)
+ lut[i] = (col < 0.0f) ? 0.0f : col * (1.0f / 12.92f);
+ else
+ lut[i] = powf((col + 0.055f) * (1.0f / 1.055f), 2.4f);
+ }
+}
+
+static int convertRGBA_RGB(float *src, float *dst, LogImageFile *logImage,
+ LogImageElement logElement, int elementIsSource)
+{
+ unsigned int i;
+ float lut[65536];
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ switch (logElement.transfer) {
+ case transfer_UserDefined:
+ case transfer_Linear:
+ case transfer_Logarithmic:
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(dst_ptr++) = *(src_ptr++);
+ *(dst_ptr++) = *(src_ptr++);
+ *(dst_ptr++) = *(src_ptr++);
+ src_ptr++;
+ }
+ return 0;
+
+ case transfer_PrintingDensity:
+ if (elementIsSource == 1)
+ getLogToLinLut((float *)&lut, logImage, logElement);
+ else
+ getLinToLogLut((float *)&lut, logImage, logElement);
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ src_ptr++;
+ }
+ return 0;
+
+ default:
+ return 1;
+ }
+}
+
+static int convertRGB_RGBA(float *src, float *dst, LogImageFile *logImage,
+ LogImageElement logElement, int elementIsSource)
+{
+ unsigned int i;
+ float lut[65536];
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ switch (logElement.transfer) {
+ case transfer_UserDefined:
+ case transfer_Linear:
+ case transfer_Logarithmic:
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(dst_ptr++) = *(src_ptr++);
+ *(dst_ptr++) = *(src_ptr++);
+ *(dst_ptr++) = *(src_ptr++);
+ *(dst_ptr++) = 1.0f;
+ }
+ return 0;
+
+ case transfer_PrintingDensity:
+ if (elementIsSource == 1)
+ getLogToLinLut((float *)&lut, logImage, logElement);
+ else
+ getLinToLogLut((float *)&lut, logImage, logElement);
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = 1.0f;
+ }
+ return 0;
+
+ default:
+ return 1;
+ }
+}
+
+static int convertRGBA_RGBA(float *src, float *dst, LogImageFile *logImage,
+ LogImageElement logElement, int elementIsSource)
+{
+ unsigned int i;
+ float lut[65536];
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ switch (logElement.transfer) {
+ case transfer_UserDefined:
+ case transfer_Linear:
+ case transfer_Logarithmic:
+ memcpy(dst, src, 4 * logImage->width * logImage->height * sizeof(float));
+ return 0;
+
+ case transfer_PrintingDensity:
+ if (elementIsSource == 1)
+ getLogToLinLut((float *)&lut, logImage, logElement);
+ else
+ getLinToLogLut((float *)&lut, logImage, logElement);
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = *(src_ptr++);
+ }
+ return 0;
+
+ default:
+ return 1;
+ }
+}
+
+static int convertABGR_RGBA(float *src, float *dst, LogImageFile *logImage,
+ LogImageElement logElement, int elementIsSource)
+{
+ unsigned int i;
+ float lut[65536];
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ switch (logElement.transfer) {
+ case transfer_UserDefined:
+ case transfer_Linear:
+ case transfer_Logarithmic:
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ src_ptr += 4;
+ *(dst_ptr++) = *(src_ptr--);
+ *(dst_ptr++) = *(src_ptr--);
+ *(dst_ptr++) = *(src_ptr--);
+ *(dst_ptr++) = *(src_ptr--);
+ src_ptr += 4;
+ }
+ return 0;
+
+ case transfer_PrintingDensity:
+ if (elementIsSource == 1)
+ getLogToLinLut((float *)&lut, logImage, logElement);
+ else
+ getLinToLogLut((float *)&lut, logImage, logElement);
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ src_ptr += 4;
+ *(dst_ptr++) = lut[float_uint(*(src_ptr--), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr--), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr--), logElement.maxValue)];
+ *(dst_ptr++) = *(src_ptr--);
+ src_ptr += 4;
+ }
+ return 0;
+
+ default:
+ return 1;
+ }
+}
+
+static int convertCbYCr_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement)
+{
+ unsigned int i;
+ float conversionMatrix[9], refLowData, y, cb, cr;
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ return 1;
+
+ refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ cb = *(src_ptr++) - 0.5f;
+ y = *(src_ptr++) - refLowData;
+ cr = *(src_ptr++) - 0.5f;
+
+ *(dst_ptr++) = clamp_float(y * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f);
+ *(dst_ptr++) = 1.0f;
+ }
+ return 0;
+}
+
+static int convertCbYCrA_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement)
+{
+ unsigned int i;
+ float conversionMatrix[9], refLowData, y, cb, cr, a;
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ return 1;
+
+ refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ cb = *(src_ptr++) - 0.5f;
+ y = *(src_ptr++) - refLowData;
+ cr = *(src_ptr++) - 0.5f;
+ a = *(src_ptr++);
+
+ *(dst_ptr++) = clamp_float(y * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f);
+ *(dst_ptr++) = a;
+ }
+ return 0;
+}
+
+static int convertCbYCrY_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement)
+{
+ unsigned int i;
+ float conversionMatrix[9], refLowData, y1, y2, cb, cr;
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ return 1;
+
+ refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ for (i = 0; i < logImage->width * logImage->height / 2; i++) {
+ cb = *(src_ptr++) - 0.5f;
+ y1 = *(src_ptr++) - refLowData;
+ cr = *(src_ptr++) - 0.5f;
+ y2 = *(src_ptr++) - refLowData;
+
+ *(dst_ptr++) = clamp_float(y1 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y1 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y1 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f);
+ *(dst_ptr++) = 1.0f;
+ *(dst_ptr++) = clamp_float(y2 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y2 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y2 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f);
+ *(dst_ptr++) = 1.0f;
+ }
+ return 0;
+}
+
+static int convertCbYACrYA_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement)
+{
+ unsigned int i;
+ float conversionMatrix[9], refLowData, y1, y2, cb, cr, a1, a2;
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ return 1;
+
+ refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ for (i = 0; i < logImage->width * logImage->height / 2; i++) {
+ cb = *(src_ptr++) - 0.5f;
+ y1 = *(src_ptr++) - refLowData;
+ a1 = *(src_ptr++);
+ cr = *(src_ptr++) - 0.5f;
+ y2 = *(src_ptr++) - refLowData;
+ a2 = *(src_ptr++);
+
+ *(dst_ptr++) = clamp_float(y1 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y1 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y1 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f);
+ *(dst_ptr++) = a1;
+ *(dst_ptr++) = clamp_float(y2 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y2 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f);
+ *(dst_ptr++) = clamp_float(y2 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f);
+ *(dst_ptr++) = a2;
+ }
+ return 0;
+}
+
+static int convertLuminance_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement)
+{
+ unsigned int i;
+ float conversionMatrix[9], value, refLowData;
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ return 1;
+
+ refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ value = clamp_float((*(src_ptr++) - refLowData) * conversionMatrix[0], 0.0f, 1.0f);
+ *(dst_ptr++) = value;
+ *(dst_ptr++) = value;
+ *(dst_ptr++) = value;
+ *(dst_ptr++) = 1.0f;
+ }
+ return 0;
+}
+
+static int convertYA_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement)
+{
+ unsigned int i;
+ float conversionMatrix[9], value, refLowData;
+ float *src_ptr = src;
+ float *dst_ptr = dst;
+
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ return 1;
+
+ refLowData = (float)logElement.refLowData / logElement.maxValue;
+
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ value = clamp_float((*(src_ptr++) - refLowData) * conversionMatrix[0], 0.0f, 1.0f);
+ *(dst_ptr++) = value;
+ *(dst_ptr++) = value;
+ *(dst_ptr++) = value;
+ *(dst_ptr++) = *(src_ptr++);
+ }
+ return 0;
+}
+
+static int convertLogElementToRGBA(float *src, float *dst, LogImageFile *logImage,
+ LogImageElement logElement, int dstIsLinearRGB)
+{
+ int rvalue;
+ unsigned int i;
+ float *src_ptr;
+ float *dst_ptr;
+ float lut[65536];
+
+ /* Convert data in src to linear RGBA in dst */
+ switch (logElement.descriptor) {
+ case descriptor_RGB:
+ rvalue = convertRGB_RGBA(src, dst, logImage, logElement, 1);
+ break;
+
+ case descriptor_RGBA:
+ rvalue = convertRGBA_RGBA(src, dst, logImage, logElement, 1);
+ break;
+
+ case descriptor_ABGR:
+ rvalue = convertABGR_RGBA(src, dst, logImage, logElement, 1);
+ break;
+
+ case descriptor_Luminance:
+ rvalue = convertLuminance_RGBA(src, dst, logImage, logElement);
+ break;
+
+ case descriptor_CbYCr:
+ rvalue = convertCbYCr_RGBA(src, dst, logImage, logElement);
+ break;
+
+ case descriptor_CbYCrY:
+ rvalue = convertCbYCrY_RGBA(src, dst, logImage, logElement);
+ break;
+
+ case descriptor_CbYACrYA:
+ rvalue = convertCbYACrYA_RGBA(src, dst, logImage, logElement);
+ break;
+
+ case descriptor_CbYCrA:
+ rvalue = convertCbYCrA_RGBA(src, dst, logImage, logElement);
+ break;
+
+ case descriptor_YA: /* this descriptor is for internal use only */
+ rvalue = convertYA_RGBA(src, dst, logImage, logElement);
+ break;
+
+ default:
+ return 1;
+ }
+
+ if (rvalue == 1)
+ return 1;
+ else if (dstIsLinearRGB) {
+ /* convert data from sRGB to Linear RGB via lut */
+ getSrgbToLinLut((float *)&lut, logElement);
+ src_ptr = dst; // no error here
+ dst_ptr = dst;
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ dst_ptr++; src_ptr++;
+ }
+ }
+ return 0;
+}
+
+static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImage,
+ LogImageElement logElement, int srcIsLinearRGB)
+{
+ unsigned int i;
+ int rvalue;
+ float *srgbSrc;
+ float *srgbSrc_ptr;
+ float *src_ptr = src;
+ float lut[65536];
+
+ if (srcIsLinearRGB != 0) {
+ /* we need to convert src to sRGB */
+ srgbSrc = (float *)MEM_mallocN(4 * logImage->width * logImage->height * sizeof(float), __func__);
+ if (srgbSrc == 0)
+ return 1;
+
+ memcpy(srgbSrc, src, 4 * logImage->width * logImage->height * sizeof(float));
+ srgbSrc_ptr = srgbSrc;
+
+ /* convert data from Linear RGB to sRGB via lut */
+ getLinToSrgbLut((float *)&lut, logElement);
+ for (i = 0; i < logImage->width * logImage->height; i++) {
+ *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
+ srgbSrc_ptr++; src_ptr++;
+ }
+ }
+ else
+ srgbSrc = src;
+
+ /* Convert linear RGBA data in src to format described by logElement in dst */
+ switch (logElement.descriptor) {
+ case descriptor_RGB:
+ rvalue = convertRGBA_RGB(srgbSrc, dst, logImage, logElement, 0);
+ break;
+
+ case descriptor_RGBA:
+ rvalue = convertRGBA_RGBA(srgbSrc, dst, logImage, logElement, 0);
+ break;
+
+ /* these ones are not supported for the moment */
+ case descriptor_ABGR:
+ case descriptor_Luminance:
+ case descriptor_CbYCr:
+ case descriptor_CbYCrY:
+ case descriptor_CbYACrYA:
+ case descriptor_CbYCrA:
+ case descriptor_YA: /* this descriptor is for internal use only */
+ default:
+ rvalue = 1;
+ }
+
+ if (srcIsLinearRGB != 0) {
+ MEM_freeN(srgbSrc);
+ }
+
+ return rvalue;
+}
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h
index 7d88c10c2d6..7c75f8b730b 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.h
+++ b/source/blender/imbuf/intern/cineon/logImageCore.h
@@ -1,123 +1,283 @@
/*
- * Cineon image file format library definitions.
- * Cineon and DPX common structures.
+ * Cineon image file format library definitions.
+ * Cineon and DPX common structures.
*
- * This header file contains private details.
- * User code should generally use cineonlib.h and dpxlib.h only.
- * Hmm. I thought the two formats would have more in common!
+ * This header file contains private details.
+ * User code should generally use cineonlib.h and dpxlib.h only.
+ * Hmm. I thought the two formats would have more in common!
*
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
+ * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
-#ifndef __LOGIMAGECORE_H__
-#define __LOGIMAGECORE_H__
-
/** \file blender/imbuf/intern/cineon/logImageCore.h
* \ingroup imbcineon
*/
+#ifndef __LOG_IMAGE_CORE_H__
+#define __LOG_IMAGE_CORE_H__
+
#include <stdio.h>
-#include "logImageLib.h"
+
+#include "BLO_sys_types.h"
+#include "BLI_utildefines.h"
#ifdef __cplusplus
extern "C" {
#endif
-#include "BLO_sys_types.h" // for intptr_t support
+/*
+ * Image structure
+ */
-#ifdef _MSC_VER
-#undef ntohl
-#undef htonl
-#endif
+/* There are some differences between DPX and Cineon so we need to know from what type of file the datas come from */
+enum format {
+ format_DPX,
+ format_Cineon
+};
-typedef int (GetRowFn)(LogImageFile* logImage, unsigned short* row, int lineNum);
-typedef int (SetRowFn)(LogImageFile* logImage, const unsigned short* row, int lineNum);
-typedef void (CloseFn)(LogImageFile* logImage);
+typedef struct LogImageElement
+{
+ int depth;
+ int bitsPerSample;
+ int dataOffset;
+ int packing;
+ int transfer;
+ int descriptor;
+ unsigned int refLowData;
+ unsigned int refHighData;
+ float refLowQuantity;
+ float refHighQuantity;
+ float maxValue; /* = 2^bitsPerSample - 1 (used internally, doesn't come from the file header) */
+} LogImageElement;
-struct _Log_Image_File_t_
+typedef struct LogImageFile
{
/* specified in header */
int width;
int height;
+ int numElements;
int depth;
- int bitsPerPixel;
- int imageOffset;
+ LogImageElement element[8];
- /* file buffer, measured in longwords (4 byte) */
- int lineBufferLength;
- unsigned int* lineBuffer;
-
- /* pixel buffer, holds 10 bit pixel values */
- unsigned short* pixelBuffer;
- int pixelBufferUsed;
+ /* used for log <-> lin conversion */
+ float referenceBlack;
+ float referenceWhite;
+ float gamma;
/* io stuff */
- FILE* file;
- int reading;
- int fileYPos;
+ FILE *file;
+ unsigned char *memBuffer;
+ uintptr_t memBufferSize;
+ unsigned char *memCursor;
- /* byte conversion stuff */
- LogImageByteConversionParameters params;
-#if 0
- float gamma;
- int blackPoint;
- int whitePoint;
-#endif
- unsigned char lut10[1024];
- unsigned short lut8[256];
-
- unsigned short lut10_16[1024];
- unsigned short lut16_16[65536];
-
- /* pixel access functions */
- GetRowFn* getRow;
- SetRowFn* setRow;
- CloseFn* close;
-
- unsigned char *membuffer;
- uintptr_t membuffersize;
- unsigned char *memcursor;
+ /* is the file LSB or MSB ? */
+ int isMSB;
+
+ /* DPX or Cineon ? */
+ int srcFormat;
+} LogImageFile;
+
+
+/* The SMPTE defines this code:
+ * 0 - User-defined
+ * 1 - Printing density
+ * 2 - Linear
+ * 3 - Logarithmic
+ * 4 - Unspecified video
+ * 5 - SMPTE 240M
+ * 6 - CCIR 709-1
+ * 7 - CCIR 601-2 system B or G
+ * 8 - CCIR 601-2 system M
+ * 9 - NTSC composite video
+ * 10 - PAL composite video
+ * 11 - Z linear
+ * 12 - homogeneous
+ *
+ * Note that transfer_characteristics is U8, don't need
+ * check the byte order.
+ */
+
+enum transfer {
+ transfer_UserDefined,
+ transfer_PrintingDensity,
+ transfer_Linear,
+ transfer_Logarithmic,
+ transfer_Unspecified,
+ transfer_Smpte240M,
+ transfer_Ccir7091,
+ transfer_Ccir6012BG,
+ transfer_Ccir6012M,
+ transfer_NTSC,
+ transfer_PAL,
+ transfer_ZLinear,
+ transfer_Homogeneous
+};
+
+/* The SMPTE defines this code:
+ * 0 - User-defined
+ * 1 - Red
+ * 2 - Green
+ * 3 - Blue
+ * 4 - Alpha
+ * 6 - Luminance
+ * 7 - Chrominance
+ * 8 - Depth
+ * 9 - Composite video
+ * 50 - RGB
+ * 51 - RGBA
+ * 52 - ABGR
+ * 100 - CbYCrY
+ * 101 - CbYACrYA
+ * 102 - CbYCr
+ * 103 - CbYCrA
+ * 150 - User-defined 2-component element
+ * 151 - User-defined 3-component element
+ * 152 - User-defined 4-component element
+ * 153 - User-defined 5-component element
+ * 154 - User-defined 6-component element
+ * 155 - User-defined 7-component element
+ * 156 - User-defined 8-component element
+ */
+
+enum descriptor {
+ descriptor_UserDefined,
+ descriptor_Red,
+ descriptor_Green,
+ descriptor_Blue,
+ descriptor_Alpha,
+ descriptor_Luminance = 6, /* don't ask me why there's no 5 */
+ descriptor_Chrominance,
+ descriptor_Depth,
+ descriptor_Composite,
+ descriptor_RGB = 50,
+ descriptor_RGBA,
+ descriptor_ABGR,
+ descriptor_CbYCrY = 100,
+ descriptor_CbYACrYA,
+ descriptor_CbYCr,
+ descriptor_CbYCrA,
+ descriptor_UserDefined2Elt = 150,
+ descriptor_UserDefined3Elt,
+ descriptor_UserDefined4Elt,
+ descriptor_UserDefined5Elt,
+ descriptor_UserDefined6Elt,
+ descriptor_UserDefined7Elt,
+ descriptor_UserDefined8Elt,
+ /* following descriptors are for internal use only */
+ descriptor_YA
};
-void setupLut(LogImageFile*);
-void setupLut16(LogImageFile*);
+/* int functions return 0 for OK */
-int pixelsToLongs(int numPixels);
+void logImageSetVerbose(int verbosity);
+int logImageIsDpx(const void *buffer);
+int logImageIsCineon(const void *buffer);
+LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size);
+LogImageFile *logImageOpenFromFile(const char *filename, int cineon);
+void logImageGetSize(LogImageFile *logImage, int *width, int *height, int *depth);
+LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample,
+ int isLogarithmic, int hasAlpha, int referenceWhite, int referenceBlack,
+ float gamma, const char *creator);
+void logImageClose(LogImageFile *logImage);
-/* typedefs used in original docs */
-/* note size assumptions! */
+/* Data handling */
+unsigned int getRowLength(int width, LogImageElement logElement);
+int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
+int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
-typedef unsigned int U32;
-typedef unsigned short U16;
-typedef unsigned char U8;
-typedef signed int S32;
-typedef float R32;
-typedef char ASCII;
+/*
+ * Inline routines
+ */
+
+/* Endianness swapping */
+
+BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap)
+{
+ if (swap != 0)
+ return (x >> 8) | (x << 8);
+ else
+ return x;
+}
+
+BLI_INLINE unsigned int swap_uint(unsigned int x, int swap)
+{
+ if (swap != 0)
+ return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
+ else
+ return x;
+}
+
+BLI_INLINE float swap_float(float x, int swap)
+{
+ if (swap != 0) {
+ union {
+ float f;
+ unsigned char b[4];
+ } dat1, dat2;
+
+ dat1.f = x;
+ dat2.b[0] = dat1.b[3];
+ dat2.b[1] = dat1.b[2];
+ dat2.b[2] = dat1.b[1];
+ dat2.b[3] = dat1.b[0];
+ return dat2.f;
+ }
+ else
+ return x;
+}
+
+/* Other */
+
+BLI_INLINE unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high)
+{
+ if (x > high)
+ return high;
+ else if (x < low)
+ return low;
+ else
+ return x;
+}
+
+BLI_INLINE float clamp_float(float x, float low, float high)
+{
+ if (x > high)
+ return high;
+ else if (x < low)
+ return low;
+ else
+ return x;
+}
+
+BLI_INLINE unsigned int float_uint(float value, unsigned int max)
+{
+ if (value < 0.0f)
+ return 0;
+ else if (value > (1.0f - 0.5f / (float)max))
+ return max;
+ else
+ return (unsigned int)(((float)max * value) + 0.5f);
+}
-R32 htonf(R32 f);
-R32 ntohf(R32 f);
-R32 undefined(void);
-U16 reverseU16(U16 value);
-U32 reverseU32(U32 value);
-R32 reverseR32(R32 value);
#ifdef __cplusplus
}
#endif
-#endif /* __LOGIMAGECORE_H__ */
+#endif /* __LOG_IMAGE_CORE_H__ */
diff --git a/source/blender/imbuf/intern/cineon/logImageLib.c b/source/blender/imbuf/intern/cineon/logImageLib.c
deleted file mode 100644
index ccc6045e6e5..00000000000
--- a/source/blender/imbuf/intern/cineon/logImageLib.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Cineon and DPX image file format library routines.
- *
- * Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
- *
- * 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 blender/imbuf/intern/cineon/logImageLib.c
- * \ingroup imbcineon
- */
-
-#include "cineonlib.h"
-#include "dpxlib.h"
-
-#include <stdio.h>
-#include <math.h>
-#include <stdlib.h>
-#include <time.h> /* strftime() */
-#include <sys/types.h>
-#ifdef WIN32
-#include <winsock.h>
-#else
-#include <netinet/in.h> /* htonl() */
-#endif
-#include <string.h> /* memset */
-#include "BLI_fileops.h"
-
-#define MIN_GAMMA 0.01
-#define MAX_GAMMA 99.9
-#define DEFAULT_GAMMA 1.0
-#define DEFAULT_BLACK_POINT 95
-#define DEFAULT_WHITE_POINT 685
-
-void
-logImageSetVerbose(int verbosity)
-{
- cineonSetVerbose(verbosity);
- dpxSetVerbose(verbosity);
-}
-
-LogImageFile*
-logImageOpen(const char* filename, int cineon)
-{
- if (cineon) {
- return cineonOpen(filename);
- }
- else {
- return dpxOpen(filename);
- }
- return 0;
-}
-
-LogImageFile*
-logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon)
-{
- if (cineon) {
- return cineonOpenFromMem(buffer, size);
- }
- else {
- return dpxOpenFromMem(buffer, size);
- }
- return 0;
-}
-
-LogImageFile*
-logImageCreate(const char* filename, int cineon, int width, int height, int depth)
-{
- if (cineon) {
- return cineonCreate(filename, width, height, depth);
- }
- else {
- return dpxCreate(filename, width, height, depth);
- }
- return 0;
-}
-
-int
-logImageGetSize(const LogImageFile* logImage, int* width, int* height, int* depth)
-{
- *width = logImage->width;
- *height = logImage->height;
- *depth = logImage->depth;
- return 0;
-}
-
-int
-logImageGetByteConversionDefaults(LogImageByteConversionParameters* params)
-{
- params->gamma = DEFAULT_GAMMA;
- params->blackPoint = DEFAULT_BLACK_POINT;
- params->whitePoint = DEFAULT_WHITE_POINT;
- params->doLogarithm = 0;
- return 0;
-}
-
-int
-logImageGetByteConversion(const LogImageFile* logImage, LogImageByteConversionParameters* params)
-{
- params->gamma = logImage->params.gamma;
- params->blackPoint = logImage->params.blackPoint;
- params->whitePoint = logImage->params.whitePoint;
- params->doLogarithm = 0;
- return 0;
-}
-
-int
-logImageSetByteConversion(LogImageFile* logImage, const LogImageByteConversionParameters* params)
-{
- if ((params->gamma >= MIN_GAMMA) &&
- (params->gamma <= MAX_GAMMA) &&
- (params->blackPoint >= 0) &&
- (params->blackPoint < params->whitePoint) &&
- (params->whitePoint <= 1023))
- {
- logImage->params.gamma = params->gamma;
- logImage->params.blackPoint = params->blackPoint;
- logImage->params.whitePoint = params->whitePoint;
- logImage->params.doLogarithm = params->doLogarithm;
- setupLut16(logImage);
- return 0;
- }
- return 1;
-}
-
-int
-logImageGetRowBytes(LogImageFile* logImage, unsigned short* row, int y)
-{
- return logImage->getRow(logImage, row, y);
-}
-
-int
-logImageSetRowBytes(LogImageFile* logImage, const unsigned short* row, int y)
-{
- return logImage->setRow(logImage, row, y);
-}
-
-void
-logImageClose(LogImageFile* logImage)
-{
- logImage->close(logImage);
-}
-
-void
-logImageDump(const char* filename)
-{
-
- U32 magic;
-
- FILE* foo = BLI_fopen(filename, "rb");
- if (foo == 0) {
- return;
- }
-
- if (fread(&magic, sizeof(magic), 1, foo) == 0) {
- fclose(foo);
- return;
- }
-
- fclose(foo);
-
- if (magic == ntohl(CINEON_FILE_MAGIC)) {
-#if 0
- cineonDump(filename);
-#endif
- }
- else if (magic == ntohl(DPX_FILE_MAGIC)) {
- dpxDump(filename);
- }
-}
diff --git a/source/blender/imbuf/intern/cineon/logImageLib.h b/source/blender/imbuf/intern/cineon/logImageLib.h
index 1c24358e4ef..e69de29bb2d 100644
--- a/source/blender/imbuf/intern/cineon/logImageLib.h
+++ b/source/blender/imbuf/intern/cineon/logImageLib.h
@@ -1,87 +0,0 @@
-/*
- * Common library definitions for Cineon and DPX image files.
- *
- * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org>
- *
- * 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.
- *
- */
-
-#ifndef __LOGIMAGELIB_H__
-#define __LOGIMAGELIB_H__
-
-/** \file blender/imbuf/intern/cineon/logImageLib.h
- * \ingroup imbcineon
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Image structure. You don't care what this is.
- */
-
-typedef struct _Log_Image_File_t_ LogImageFile;
-
-/*
- * Magic numbers for normal and byte-swapped Cineon and Dpx files
- */
-
-#define CINEON_FILE_MAGIC 0x802A5FD7
-#define DPX_FILE_MAGIC 0x53445058
-
-/*
- * Image 8 bit <-> 10 bit conversion parameters.
- */
-
-typedef struct {
- float gamma;
- int blackPoint;
- int whitePoint;
- int doLogarithm;
-} LogImageByteConversionParameters;
-
-/* int functions return 0 for OK */
-
-void logImageSetVerbose(int);
-
-LogImageFile* logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon);
-LogImageFile* logImageOpen(const char* filename, int cineon);
-int logImageGetSize(const LogImageFile* logImage, int* xsize, int* ysize, int* channels);
-LogImageFile* logImageCreate(const char* filename, int cineon, int xsize, int ysize, int channels);
-
-/* byte conversion routines for mapping logImage (usually) 10 bit values to 8 bit */
-/* see Kodak docs for details... */
-
-int logImageGetByteConversionDefaults(LogImageByteConversionParameters* params);
-int logImageGetByteConversion(const LogImageFile* logImage, LogImageByteConversionParameters* params);
-int logImageSetByteConversion(LogImageFile* logImage, const LogImageByteConversionParameters* params);
-
-/* get/set scanline of converted bytes */
-int logImageGetRowBytes(LogImageFile* logImage, unsigned short* row, int y);
-int logImageSetRowBytes(LogImageFile* logImage, const unsigned short* row, int y);
-
-/* closes file and deletes data */
-void logImageClose(LogImageFile* logImage);
-
-/* read file and dump header info */
-void logImageDump(const char* filename);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LOGIMAGELIB_H__ */
diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c
index a9938582f2a..3914f6dc633 100644
--- a/source/blender/imbuf/intern/cineon/logmemfile.c
+++ b/source/blender/imbuf/intern/cineon/logmemfile.c
@@ -1,21 +1,23 @@
/*
- * Cineon image file format library routines.
+ * Cineon image file format library routines.
*
- * Copyright 2006 Joseph Eagar (joeedh@gmail.com)
+ * Copyright 2006 Joseph Eagar (joeedh@gmail.com)
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
@@ -23,64 +25,102 @@
* \ingroup imbcineon
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "logImageCore.h"
+#include "logmemfile.h"
-#include "logmemfile.h" /* own include */
-
-int logimage_fseek(void* logfile, intptr_t offsett, int origin)
-{
- struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile;
- intptr_t offset = offsett;
-
- if (file->file) fseek(file->file, offset, origin);
- else { /*we're seeking in memory*/
- if (origin==SEEK_SET) {
- if (offset > file->membuffersize) return 1;
- file->memcursor = file->membuffer + offset;
+int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin)
+{
+ if (logFile->file)
+ fseek(logFile->file, offset, origin);
+ else { /* we're seeking in memory */
+ if (origin == SEEK_SET) {
+ if (offset > logFile->memBufferSize)
+ return 1;
+ logFile->memCursor = logFile->memBuffer + offset;
}
- else if (origin==SEEK_END) {
- if (offset > file->membuffersize) return 1;
- file->memcursor = (file->membuffer + file->membuffersize) - offset;
+ else if (origin == SEEK_END) {
+ if (offset > logFile->memBufferSize)
+ return 1;
+ logFile->memCursor = (logFile->memBuffer + logFile->memBufferSize) - offset;
}
- else if (origin==SEEK_CUR) {
- uintptr_t pos = (uintptr_t)file->membuffer - (uintptr_t)file->memcursor;
- if (pos + offset > file->membuffersize) return 1;
- if (pos < 0) return 1;
- file->memcursor += offset;
+ else if (origin == SEEK_CUR) {
+ uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
+ if (pos + offset > logFile->memBufferSize || pos < 0)
+ return 1;
+
+ logFile->memCursor += offset;
}
}
return 0;
}
-int logimage_fwrite(void *buffer, unsigned int size, unsigned int count, void *logfile)
+int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
{
- struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile;
- if (file->file) return fwrite(buffer, size, count, file->file);
- else { /*we're writing to memory*/
- /*do nothing as this isn't supported yet*/
+ if (logFile->file)
+ return fwrite(buffer, size, count, logFile->file);
+ else { /* we're writing to memory */
+ /* do nothing as this isn't supported yet */
return count;
}
}
-int logimage_fread(void *buffer, unsigned int size, unsigned int count, void *logfile)
+int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
{
- struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile;
- if (file->file) return fread(buffer, size, count, file->file);
- else { /*we're reading from memory*/
- int i;
- /* we convert ot uchar just on the off chance some platform can't handle
- * pointer arithmetic with type (void*). */
- unsigned char *buf = (unsigned char *) buffer;
-
- for (i=0; i<count; i++) {
- memcpy(buf, file->memcursor, size);
- file->memcursor += size;
- buf += size;
+ if (logFile->file) {
+ return fread(buffer, size, count, logFile->file);
+ }
+ else { /* we're reading from memory */
+ unsigned char *buf = (unsigned char *)buffer;
+ uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
+ size_t total_size = size * count;
+ if (pos + total_size > logFile->memBufferSize) {
+ /* how many elements can we read without overflow ? */
+ count = (logFile->memBufferSize - pos) / size;
+ /* recompute the size */
+ total_size = size * count;
}
+
+ if (total_size != 0)
+ memcpy(buf, logFile->memCursor, total_size);
+
return count;
}
}
+
+int logimage_read_uchar(unsigned char *x, LogImageFile *logFile)
+{
+ uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
+ if (pos + sizeof(unsigned char) > logFile->memBufferSize)
+ return 1;
+
+ *x = *(unsigned char *)logFile->memCursor;
+ logFile->memCursor += sizeof(unsigned char);
+ return 0;
+}
+
+int logimage_read_ushort(unsigned short *x, LogImageFile *logFile)
+{
+ uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
+ if (pos + sizeof(unsigned short) > logFile->memBufferSize)
+ return 1;
+
+ *x = *(unsigned short *)logFile->memCursor;
+ logFile->memCursor += sizeof(unsigned short);
+ return 0;
+}
+
+int logimage_read_uint(unsigned int *x, LogImageFile *logFile)
+{
+ uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
+ if (pos + sizeof(unsigned int) > logFile->memBufferSize)
+ return 1;
+
+ *x = *(unsigned int *)logFile->memCursor;
+ logFile->memCursor += sizeof(unsigned int);
+ return 0;
+}
diff --git a/source/blender/imbuf/intern/cineon/logmemfile.h b/source/blender/imbuf/intern/cineon/logmemfile.h
index df3589a70d3..068a53e641b 100644
--- a/source/blender/imbuf/intern/cineon/logmemfile.h
+++ b/source/blender/imbuf/intern/cineon/logmemfile.h
@@ -1,33 +1,43 @@
/*
- * Cineon image file format library routines.
+ * Cineon image file format library routines.
*
- * Copyright 2006 Joseph Eagar (joeedh@gmail.com)
+ * Copyright 2006 Joseph Eagar (joeedh@gmail.com)
*
- * 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 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.
+ * 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.
+ * 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.
+ *
+ * Contributor(s): Julien Enche.
*
*/
-
-#ifndef __LOGMEMFILE_H__
-#define __LOGMEMFILE_H__
/** \file blender/imbuf/intern/cineon/logmemfile.h
* \ingroup imbcineon
*/
-int logimage_fseek(void* logfile, intptr_t offsett, int origin);
-int logimage_fwrite(void *buffer, unsigned int size, unsigned int count, void *logfile);
-int logimage_fread(void *buffer, unsigned int size, unsigned int count, void *logfile);
-#endif /* __LOGMEMFILE_H__ */
+#ifndef __LOGMEMFILE_H__
+#define __LOGMEMFILE_H__
+
+#include "logImageCore.h"
+
+#include <stdlib.h>
+
+int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin);
+int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile);
+int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile);
+int logimage_read_uchar(unsigned char *x, LogImageFile *logFile);
+int logimage_read_ushort(unsigned short *x, LogImageFile *logFile);
+int logimage_read_uint(unsigned int *x, LogImageFile *logFile);
+
+#endif /* __LOGMEMFILE_H__ */
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 37510c10e9a..b9774a9f7b0 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -99,6 +99,7 @@ static pthread_mutex_t processor_lock = BLI_MUTEX_INITIALIZER;
typedef struct ColormanageProcessor {
OCIO_ConstProcessorRcPtr *processor;
CurveMapping *curve_mapping;
+ int is_data_result;
} ColormanageProcessor;
/*********************** Color managed cache *************************/
@@ -889,7 +890,7 @@ void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
{
ColorSpace *colorspace = colormanage_colorspace_get_named(from_colorspace);
- if (colorspace->is_data) {
+ if (colorspace && colorspace->is_data) {
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
return;
}
@@ -1082,7 +1083,7 @@ void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name)
{
ColorSpace *colorspace = colormanage_colorspace_get_named(name);
- if (colorspace->is_data)
+ if (colorspace && colorspace->is_data)
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
else
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
@@ -1094,7 +1095,7 @@ void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
ibuf->float_colorspace = colorspace;
- if (colorspace->is_data)
+ if (colorspace && colorspace->is_data)
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
else
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
@@ -1106,7 +1107,7 @@ void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
ibuf->rect_colorspace = colorspace;
- if (colorspace->is_data)
+ if (colorspace && colorspace->is_data)
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
else
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
@@ -1207,6 +1208,7 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
int predivide = handle->predivide;
int is_data = handle->is_data;
+ int is_data_display = handle->cm_processor->is_data_result;
linear_buffer = MEM_callocN(buffer_size * sizeof(float), "color conversion linear buffer");
@@ -1223,12 +1225,12 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
/* first convert byte buffer to float, keep in image space */
for (i = 0, fp = linear_buffer, cp = byte_buffer;
i < channels * width * height;
- i++, fp++, cp++)
+ i++, fp++, cp++)
{
*fp = (float)(*cp) / 255.0f;
}
- if (!is_data) {
+ if (!is_data && !is_data_display) {
/* convert float buffer to scene linear space */
IMB_colormanagement_transform(linear_buffer, width, height, channels,
from_colorspace, to_colorspace, predivide);
@@ -1822,7 +1824,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
if (global_tot_display)
ibuf->display_buffer_flags = MEM_callocN(sizeof(unsigned int) * global_tot_display, "imbuf display_buffer_flags");
}
- else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) {
+ else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) {
/* all display buffers were marked as invalid from other areas,
* now propagate this flag to internal color management routines
*/
@@ -2347,7 +2349,6 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
}
else if (byte_buffer) {
rgba_uchar_to_float(pixel, byte_buffer + linear_index);
-
IMB_colormanagement_colorspace_to_scene_linear_v3(pixel, rect_colorspace);
}
@@ -2382,9 +2383,9 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer,
int stride, int offset_x, int offset_y, const ColorManagedViewSettings *view_settings,
const ColorManagedDisplaySettings *display_settings,
- int xmin, int ymin, int xmax, int ymax)
+ int xmin, int ymin, int xmax, int ymax, int update_orig_byte_buffer)
{
- if (ibuf->rect && ibuf->rect_float) {
+ if ((ibuf->rect && ibuf->rect_float) || update_orig_byte_buffer) {
/* update byte buffer created by legacy color management */
unsigned char *rect = (unsigned char *) ibuf->rect;
@@ -2449,28 +2450,29 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManag
const ColorManagedDisplaySettings *display_settings)
{
ColormanageProcessor *cm_processor;
+ ColorManagedViewSettings default_view_settings;
+ const ColorManagedViewSettings *applied_view_settings;
+ ColorSpace *display_space;
cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor");
- {
- ColorManagedViewSettings default_view_settings;
- const ColorManagedViewSettings *applied_view_settings;
+ if (view_settings) {
+ applied_view_settings = view_settings;
+ }
+ else {
+ init_default_view_settings(display_settings, &default_view_settings);
+ applied_view_settings = &default_view_settings;
+ }
- if (view_settings) {
- applied_view_settings = view_settings;
- }
- else {
- init_default_view_settings(display_settings, &default_view_settings);
- applied_view_settings = &default_view_settings;
- }
+ display_space = display_transform_get_colorspace(applied_view_settings, display_settings);
+ cm_processor->is_data_result = display_space->is_data;
- cm_processor->processor = create_display_buffer_processor(applied_view_settings->view_transform, display_settings->display_device,
- applied_view_settings->exposure, applied_view_settings->gamma);
+ cm_processor->processor = create_display_buffer_processor(applied_view_settings->view_transform, display_settings->display_device,
+ applied_view_settings->exposure, applied_view_settings->gamma);
- if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
- cm_processor->curve_mapping = curvemapping_copy(applied_view_settings->curve_mapping);
- curvemapping_premultiply(cm_processor->curve_mapping, FALSE);
- }
+ if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
+ cm_processor->curve_mapping = curvemapping_copy(applied_view_settings->curve_mapping);
+ curvemapping_premultiply(cm_processor->curve_mapping, FALSE);
}
return cm_processor;
@@ -2479,9 +2481,13 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManag
ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
{
ColormanageProcessor *cm_processor;
+ ColorSpace *color_space;
cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor");
+ color_space = colormanage_colorspace_get_named(to_colorspace);
+ cm_processor->is_data_result = color_space->is_data;
+
cm_processor->processor = create_colorspace_transform_processor(from_colorspace, to_colorspace);
return cm_processor;
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp
index f5e9e536e41..db2ca5969ec 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -232,7 +232,7 @@ void BlockDXT1::decodeBlock(ColorBlock * block) const
uint idx = (row[j] >> (2 * i)) & 3;
block->color(i, j) = color_array[idx];
}
- }
+ }
}
void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const
@@ -592,7 +592,7 @@ void BlockCTX1::decodeBlock(ColorBlock * block) const
uint idx = (row[j] >> (2 * i)) & 3;
block->color(i, j) = color_array[idx];
}
- }
+ }
}
void BlockCTX1::setIndices(int * idx)
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h
index c6712f4f058..0291816cd03 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.h
+++ b/source/blender/imbuf/intern/dds/BlockDXT.h
@@ -173,24 +173,24 @@ struct AlphaBlockDXT5
};
*/
uint64 u;
- uint8 alpha0() const { return u & 0xffLL; };
- uint8 alpha1() const { return (u >> 8) & 0xffLL; };
- uint8 bits0() const { return (u >> 16) & 0x7LL; };
- uint8 bits1() const { return (u >> 19) & 0x7LL; };
- uint8 bits2() const { return (u >> 22) & 0x7LL; };
- uint8 bits3() const { return (u >> 25) & 0x7LL; };
- uint8 bits4() const { return (u >> 28) & 0x7LL; };
- uint8 bits5() const { return (u >> 31) & 0x7LL; };
- uint8 bits6() const { return (u >> 34) & 0x7LL; };
- uint8 bits7() const { return (u >> 37) & 0x7LL; };
- uint8 bits8() const { return (u >> 40) & 0x7LL; };
- uint8 bits9() const { return (u >> 43) & 0x7LL; };
- uint8 bitsA() const { return (u >> 46) & 0x7LL; };
- uint8 bitsB() const { return (u >> 49) & 0x7LL; };
- uint8 bitsC() const { return (u >> 52) & 0x7LL; };
- uint8 bitsD() const { return (u >> 55) & 0x7LL; };
- uint8 bitsE() const { return (u >> 58) & 0x7LL; };
- uint8 bitsF() const { return (u >> 61) & 0x7LL; };
+ uint8 alpha0() const { return u & 0xffLL; }
+ uint8 alpha1() const { return (u >> 8) & 0xffLL; }
+ uint8 bits0() const { return (u >> 16) & 0x7LL; }
+ uint8 bits1() const { return (u >> 19) & 0x7LL; }
+ uint8 bits2() const { return (u >> 22) & 0x7LL; }
+ uint8 bits3() const { return (u >> 25) & 0x7LL; }
+ uint8 bits4() const { return (u >> 28) & 0x7LL; }
+ uint8 bits5() const { return (u >> 31) & 0x7LL; }
+ uint8 bits6() const { return (u >> 34) & 0x7LL; }
+ uint8 bits7() const { return (u >> 37) & 0x7LL; }
+ uint8 bits8() const { return (u >> 40) & 0x7LL; }
+ uint8 bits9() const { return (u >> 43) & 0x7LL; }
+ uint8 bitsA() const { return (u >> 46) & 0x7LL; }
+ uint8 bitsB() const { return (u >> 49) & 0x7LL; }
+ uint8 bitsC() const { return (u >> 52) & 0x7LL; }
+ uint8 bitsD() const { return (u >> 55) & 0x7LL; }
+ uint8 bitsE() const { return (u >> 58) & 0x7LL; }
+ uint8 bitsF() const { return (u >> 61) & 0x7LL; }
void evaluatePalette(uint8 alpha[8]) const;
void evaluatePalette8(uint8 alpha[8]) const;
@@ -271,4 +271,4 @@ void mem_read(Stream & mem, BlockATI1 & block);
void mem_read(Stream & mem, BlockATI2 & block);
void mem_read(Stream & mem, BlockCTX1 & block);
-#endif // __BLOCKDXT_H__
+#endif /* __BLOCKDXT_H__ */
diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt
index e514b7ab6f9..57603725ce1 100644
--- a/source/blender/imbuf/intern/dds/CMakeLists.txt
+++ b/source/blender/imbuf/intern/dds/CMakeLists.txt
@@ -39,9 +39,21 @@ set(INC_SYS
)
set(SRC
+ BlockDXT.h
+ Color.h
+ ColorBlock.h
+ Common.h
+ DirectDrawSurface.h
+ FlipDXT.h
+ Image.h
+ PixelFormat.h
+ Stream.h
+ dds_api.h
+
BlockDXT.cpp
ColorBlock.cpp
DirectDrawSurface.cpp
+ FlipDXT.cpp
Image.cpp
Stream.cpp
dds_api.cpp
@@ -51,4 +63,4 @@ if(WITH_IMAGE_DDS)
add_definitions(-DWITH_DDS)
endif()
-blender_add_lib(bf_imbuf_dds "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(bf_imbuf_dds "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/imbuf/intern/dds/Color.h b/source/blender/imbuf/intern/dds/Color.h
index 17de0a596c6..6676057d710 100644
--- a/source/blender/imbuf/intern/dds/Color.h
+++ b/source/blender/imbuf/intern/dds/Color.h
@@ -96,4 +96,4 @@ public:
};
};
-#endif // __COLOR_H__
+#endif /* __COLOR_H__ */
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp
index 0b9f5c163fb..dbd87bf1426 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.cpp
+++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp
@@ -393,7 +393,7 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 * start, Color32 * end)
int mini, maxi;
mini = maxi = 0;
- float min, max;
+ float min, max;
min = max = dot(Vector3(m_color[0].r, m_color[0].g, m_color[0].b), axis);
for (uint i = 1; i < 16; i++)
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.h b/source/blender/imbuf/intern/dds/ColorBlock.h
index 2bf362f2780..f0864f06e6f 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.h
+++ b/source/blender/imbuf/intern/dds/ColorBlock.h
@@ -104,4 +104,4 @@ inline Color32 & ColorBlock::color(uint x, uint y)
return m_color[y * 4 + x];
}
-#endif // __COLORBLOCK_H__
+#endif /* __COLORBLOCK_H__ */
diff --git a/source/blender/imbuf/intern/dds/Common.h b/source/blender/imbuf/intern/dds/Common.h
index 4e3e3e024f7..ab929b82264 100644
--- a/source/blender/imbuf/intern/dds/Common.h
+++ b/source/blender/imbuf/intern/dds/Common.h
@@ -42,9 +42,9 @@ template<typename T>
inline void
swap(T & a, T & b)
{
- T tmp = a;
- a = b;
- b = tmp;
+ T tmp = a;
+ a = b;
+ b = tmp;
}
typedef unsigned char uint8;
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index d9d0cb86ee0..ccf72f9af86 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -280,19 +280,19 @@ static const uint DDPF_SRGB = 0x40000000U;
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
- DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
- DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
- DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
- DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
- DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
-
- DXGI_FORMAT_BC6H_TYPELESS = 94,
- DXGI_FORMAT_BC6H_UF16 = 95,
- DXGI_FORMAT_BC6H_SF16 = 96,
-
- DXGI_FORMAT_BC7_TYPELESS = 97,
- DXGI_FORMAT_BC7_UNORM = 98,
- DXGI_FORMAT_BC7_UNORM_SRGB = 99,
+ DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
+ DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
+ DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
+ DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
+ DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
+
+ DXGI_FORMAT_BC6H_TYPELESS = 94,
+ DXGI_FORMAT_BC6H_UF16 = 95,
+ DXGI_FORMAT_BC6H_SF16 = 96,
+
+ DXGI_FORMAT_BC7_TYPELESS = 97,
+ DXGI_FORMAT_BC7_UNORM = 98,
+ DXGI_FORMAT_BC7_UNORM_SRGB = 99,
};
enum D3D10_RESOURCE_DIMENSION
@@ -496,60 +496,60 @@ void mem_read(Stream & mem, DDSHeader & header)
namespace
{
- struct FormatDescriptor
- {
- uint format;
- uint bitcount;
- uint rmask;
- uint gmask;
- uint bmask;
- uint amask;
- };
-
- static const FormatDescriptor s_d3dFormats[] =
- {
- { D3DFMT_R8G8B8, 24, 0xFF0000, 0xFF00, 0xFF, 0 },
- { D3DFMT_A8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000 }, // DXGI_FORMAT_B8G8R8A8_UNORM
- { D3DFMT_X8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0 }, // DXGI_FORMAT_B8G8R8X8_UNORM
- { D3DFMT_R5G6B5, 16, 0xF800, 0x7E0, 0x1F, 0 }, // DXGI_FORMAT_B5G6R5_UNORM
- { D3DFMT_X1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0 },
- { D3DFMT_A1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0x8000 }, // DXGI_FORMAT_B5G5R5A1_UNORM
- { D3DFMT_A4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0xF000 },
- { D3DFMT_R3G3B2, 8, 0xE0, 0x1C, 0x3, 0 },
- { D3DFMT_A8, 8, 0, 0, 0, 8 }, // DXGI_FORMAT_A8_UNORM
- { D3DFMT_A8R3G3B2, 16, 0xE0, 0x1C, 0x3, 0xFF00 },
- { D3DFMT_X4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0 },
- { D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 }, // DXGI_FORMAT_R10G10B10A2
- { D3DFMT_A8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000 }, // DXGI_FORMAT_R8G8B8A8_UNORM
- { D3DFMT_X8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0 },
- { D3DFMT_G16R16, 32, 0xFFFF, 0xFFFF0000, 0, 0 }, // DXGI_FORMAT_R16G16_UNORM
- { D3DFMT_A2R10G10B10, 32, 0x3FF00000, 0xFFC00, 0x3FF, 0xC0000000 },
- { D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 },
-
- { D3DFMT_L8, 8, 8, 0, 0, 0 }, // DXGI_FORMAT_R8_UNORM
- { D3DFMT_L16, 16, 16, 0, 0, 0 }, // DXGI_FORMAT_R16_UNORM
- };
-
- static const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
+struct FormatDescriptor
+{
+ uint format;
+ uint bitcount;
+ uint rmask;
+ uint gmask;
+ uint bmask;
+ uint amask;
+};
+
+static const FormatDescriptor s_d3dFormats[] =
+{
+ { D3DFMT_R8G8B8, 24, 0xFF0000, 0xFF00, 0xFF, 0 },
+ { D3DFMT_A8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000 }, /* DXGI_FORMAT_B8G8R8A8_UNORM */
+ { D3DFMT_X8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0 }, /* DXGI_FORMAT_B8G8R8X8_UNORM */
+ { D3DFMT_R5G6B5, 16, 0xF800, 0x7E0, 0x1F, 0 }, /* DXGI_FORMAT_B5G6R5_UNORM */
+ { D3DFMT_X1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0 },
+ { D3DFMT_A1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0x8000 }, /* DXGI_FORMAT_B5G5R5A1_UNORM */
+ { D3DFMT_A4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0xF000 },
+ { D3DFMT_R3G3B2, 8, 0xE0, 0x1C, 0x3, 0 },
+ { D3DFMT_A8, 8, 0, 0, 0, 8 }, /* DXGI_FORMAT_A8_UNORM */
+ { D3DFMT_A8R3G3B2, 16, 0xE0, 0x1C, 0x3, 0xFF00 },
+ { D3DFMT_X4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0 },
+ { D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 }, /* DXGI_FORMAT_R10G10B10A2 */
+ { D3DFMT_A8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000 }, /* DXGI_FORMAT_R8G8B8A8_UNORM */
+ { D3DFMT_X8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0 },
+ { D3DFMT_G16R16, 32, 0xFFFF, 0xFFFF0000, 0, 0 }, /* DXGI_FORMAT_R16G16_UNORM */
+ { D3DFMT_A2R10G10B10, 32, 0x3FF00000, 0xFFC00, 0x3FF, 0xC0000000 },
+ { D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 },
+
+ { D3DFMT_L8, 8, 8, 0, 0, 0 }, /* DXGI_FORMAT_R8_UNORM */
+ { D3DFMT_L16, 16, 16, 0, 0, 0 }, /* DXGI_FORMAT_R16_UNORM */
+};
+
+static const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
} // namespace
static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
{
- for (int i = 0; i < s_d3dFormatCount; i++)
- {
- if (s_d3dFormats[i].bitcount == bitcount &&
- s_d3dFormats[i].rmask == rmask &&
- s_d3dFormats[i].gmask == gmask &&
- s_d3dFormats[i].bmask == bmask &&
- s_d3dFormats[i].amask == amask)
- {
- return s_d3dFormats[i].format;
- }
- }
+ for (int i = 0; i < s_d3dFormatCount; i++)
+ {
+ if (s_d3dFormats[i].bitcount == bitcount &&
+ s_d3dFormats[i].rmask == rmask &&
+ s_d3dFormats[i].gmask == gmask &&
+ s_d3dFormats[i].bmask == bmask &&
+ s_d3dFormats[i].amask == amask)
+ {
+ return s_d3dFormats[i].format;
+ }
+ }
- return 0;
- }
+ return 0;
+}
@@ -566,7 +566,7 @@ DDSHeader::DDSHeader()
for (uint i = 0; i < 11; i++) this->reserved[i] = 0;
// Store version information on the reserved header attributes.
- this->reserved[9] = FOURCC_NVTT;
+ this->reserved[9] = FOURCC_NVTT;
this->reserved[10] = (2 << 16) | (1 << 8) | (0); // major.minor.revision
this->pf.size = 32;
@@ -613,7 +613,7 @@ void DDSHeader::setMipmapCount(uint count)
if (count == 0 || count == 1)
{
this->flags &= ~DDSD_MIPMAPCOUNT;
- this->mipmapcount = 1;
+ this->mipmapcount = 1;
if (this->caps.caps2 == 0) {
this->caps.caps1 = DDSCAPS_TEXTURE;
@@ -715,14 +715,14 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
if (rmask != 0 || gmask != 0 || bmask != 0)
{
- if (gmask == 0 && bmask == 0)
- {
- this->pf.flags = DDPF_LUMINANCE;
- }
- else
- {
- this->pf.flags = DDPF_RGB;
- }
+ if (gmask == 0 && bmask == 0)
+ {
+ this->pf.flags = DDPF_LUMINANCE;
+ }
+ else
+ {
+ this->pf.flags = DDPF_RGB;
+ }
if (amask != 0) {
this->pf.flags |= DDPF_ALPHAPIXELS;
@@ -737,17 +737,17 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
{
// Compute bit count from the masks.
uint total = rmask | gmask | bmask | amask;
- while(total != 0) {
+ while (total != 0) {
bitcount++;
total >>= 1;
}
}
- // D3DX functions do not like this:
+ // D3DX functions do not like this:
this->pf.fourcc = 0; //findD3D9Format(bitcount, rmask, gmask, bmask, amask);
- /*if (this->pf.fourcc) {
- this->pf.flags |= DDPF_FOURCC;
- }*/
+ /*if (this->pf.fourcc) {
+ this->pf.flags |= DDPF_FOURCC;
+ }*/
if (!(bitcount > 0 && bitcount <= 32)) {
printf("DDS: bad bit count, pixel format not set\n");
@@ -775,8 +775,8 @@ void DDSHeader::setNormalFlag(bool b)
void DDSHeader::setSrgbFlag(bool b)
{
- if (b) this->pf.flags |= DDPF_SRGB;
- else this->pf.flags &= ~DDPF_SRGB;
+ if (b) this->pf.flags |= DDPF_SRGB;
+ else this->pf.flags &= ~DDPF_SRGB;
}
void DDSHeader::setHasAlphaFlag(bool b)
@@ -787,8 +787,8 @@ void DDSHeader::setHasAlphaFlag(bool b)
void DDSHeader::setUserVersion(int version)
{
- this->reserved[7] = FOURCC_UVER;
- this->reserved[8] = version;
+ this->reserved[7] = FOURCC_UVER;
+ this->reserved[8] = version;
}
/*
@@ -836,45 +836,45 @@ bool DDSHeader::hasDX10Header() const
uint DDSHeader::signature() const
{
- return this->reserved[9];
+ return this->reserved[9];
}
uint DDSHeader::toolVersion() const
{
- return this->reserved[10];
+ return this->reserved[10];
}
uint DDSHeader::userVersion() const
{
- if (this->reserved[7] == FOURCC_UVER) {
- return this->reserved[8];
- }
- return 0;
+ if (this->reserved[7] == FOURCC_UVER) {
+ return this->reserved[8];
+ }
+ return 0;
}
bool DDSHeader::isNormalMap() const
{
- return (pf.flags & DDPF_NORMAL) != 0;
+ return (pf.flags & DDPF_NORMAL) != 0;
}
bool DDSHeader::isSrgb() const
{
- return (pf.flags & DDPF_SRGB) != 0;
+ return (pf.flags & DDPF_SRGB) != 0;
}
bool DDSHeader::hasAlpha() const
{
- return (pf.flags & DDPF_ALPHAPIXELS) != 0;
+ return (pf.flags & DDPF_ALPHAPIXELS) != 0;
}
uint DDSHeader::d3d9Format() const
{
- if (pf.flags & DDPF_FOURCC) {
- return pf.fourcc;
- }
- else {
- return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
- }
+ if (pf.flags & DDPF_FOURCC) {
+ return pf.fourcc;
+ }
+ else {
+ return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
+ }
}
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
@@ -949,9 +949,9 @@ bool DirectDrawSurface::isSupported() const
return false;
}
}
- else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE))
- {
- // All RGB and luminance formats are supported now.
+ else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE))
+ {
+ // All RGB and luminance formats are supported now.
}
else
{
@@ -1001,7 +1001,7 @@ bool DirectDrawSurface::hasAlpha() const
}
else
{
- // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
+ // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
return true;
}
}
@@ -1089,7 +1089,7 @@ void DirectDrawSurface::setHasAlphaFlag(bool b)
void DirectDrawSurface::setUserVersion(int version)
{
- header.setUserVersion(version);
+ header.setUserVersion(version);
}
void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap)
@@ -1268,15 +1268,15 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba)
block.decodeBlock(rgba);
}
else if (fourcc == FOURCC_DXT2 ||
- header.pf.fourcc == FOURCC_DXT3)
+ header.pf.fourcc == FOURCC_DXT3)
{
BlockDXT3 block;
mem_read(stream, block);
block.decodeBlock(rgba);
}
else if (fourcc == FOURCC_DXT4 ||
- header.pf.fourcc == FOURCC_DXT5 ||
- header.pf.fourcc == FOURCC_RXGB)
+ header.pf.fourcc == FOURCC_DXT5 ||
+ header.pf.fourcc == FOURCC_RXGB)
{
BlockDXT5 block;
mem_read(stream, block);
@@ -1393,8 +1393,8 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
}
else if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE))
{
- uint pitch = computePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects.
-
+ uint pitch = computePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects.
+
return pitch * h * d;
}
else {
@@ -1461,7 +1461,7 @@ void DirectDrawSurface::printInfo() const
printf("Pixel Format:\n");
printf("\tFlags: 0x%.8X\n", header.pf.flags);
if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n");
- if (header.pf.flags & DDPF_LUMINANCE) printf("\t\tDDPF_LUMINANCE\n");
+ if (header.pf.flags & DDPF_LUMINANCE) printf("\t\tDDPF_LUMINANCE\n");
if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n");
if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n");
if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n");
@@ -1472,24 +1472,24 @@ void DirectDrawSurface::printInfo() const
if (header.pf.flags & DDPF_ALPHAPREMULT) printf("\t\tDDPF_ALPHAPREMULT\n");
if (header.pf.flags & DDPF_NORMAL) printf("\t\tDDPF_NORMAL\n");
- if (header.pf.fourcc != 0) {
- // Display fourcc code even when DDPF_FOURCC flag not set.
- printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
- ((header.pf.fourcc >> 0) & 0xFF),
- ((header.pf.fourcc >> 8) & 0xFF),
- ((header.pf.fourcc >> 16) & 0xFF),
- ((header.pf.fourcc >> 24) & 0xFF),
- header.pf.fourcc);
- }
-
- if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0))
+ if (header.pf.fourcc != 0) {
+ // Display fourcc code even when DDPF_FOURCC flag not set.
+ printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
+ ((header.pf.fourcc >> 0) & 0xFF),
+ ((header.pf.fourcc >> 8) & 0xFF),
+ ((header.pf.fourcc >> 16) & 0xFF),
+ ((header.pf.fourcc >> 24) & 0xFF),
+ header.pf.fourcc);
+ }
+
+ if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0))
{
- printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
- (header.pf.bitcount >> 0) & 0xFF,
- (header.pf.bitcount >> 8) & 0xFF,
- (header.pf.bitcount >> 16) & 0xFF,
- (header.pf.bitcount >> 24) & 0xFF,
- header.pf.bitcount);
+ printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
+ (header.pf.bitcount >> 0) & 0xFF,
+ (header.pf.bitcount >> 8) & 0xFF,
+ (header.pf.bitcount >> 16) & 0xFF,
+ (header.pf.bitcount >> 24) & 0xFF,
+ header.pf.bitcount);
}
else
{
@@ -1535,7 +1535,7 @@ void DirectDrawSurface::printInfo() const
printf("\tArray size: %u\n", header.header10.arraySize);
}
- if (header.reserved[9] == FOURCC_NVTT)
+ if (header.reserved[9] == FOURCC_NVTT)
{
int major = (header.reserved[10] >> 16) & 0xFF;
int minor = (header.reserved[10] >> 8) & 0xFF;
@@ -1545,9 +1545,9 @@ void DirectDrawSurface::printInfo() const
printf("\tNVIDIA Texture Tools %d.%d.%d\n", major, minor, revision);
}
- if (header.reserved[7] == FOURCC_UVER)
- {
- printf("User Version: %u\n", header.reserved[8]);
- }
+ if (header.reserved[7] == FOURCC_UVER)
+ {
+ printf("User Version: %u\n", header.reserved[8]);
+ }
}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
index a851533b1f3..72a524daba2 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
@@ -169,7 +169,7 @@ public:
void setNormalFlag(bool b);
void setHasAlphaFlag(bool b);
- void setUserVersion(int version);
+ void setUserVersion(int version);
void mipmap(Image * img, uint f, uint m);
void* readData(uint &size);
@@ -200,4 +200,4 @@ void mem_read(Stream & mem, DDSCaps & caps);
void mem_read(Stream & mem, DDSHeader & header);
void mem_read(Stream & mem, DDSHeader10 & header);
-#endif // __DIRECTDRAWSURFACE_H__
+#endif /* __DIRECTDRAWSURFACE_H__ */
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp
new file mode 100644
index 00000000000..05821b27ca6
--- /dev/null
+++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * 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.
+ */
+
+// This file comes from the chromium project, adapted to Blender to add DDS
+// flipping to OpenGL convention for Blender
+
+#include "IMB_imbuf_types.h"
+
+#include <string.h>
+
+#include <Common.h>
+#include <Stream.h>
+#include <ColorBlock.h>
+#include <BlockDXT.h>
+#include <FlipDXT.h>
+
+// A function that flips a DXTC block.
+typedef void (*FlipBlockFunction)(uint8_t *block);
+
+// Flips a full DXT1 block in the y direction.
+static void FlipDXT1BlockFull(uint8_t *block)
+{
+ // A DXT1 block layout is:
+ // [0-1] color0.
+ // [2-3] color1.
+ // [4-7] color bitmap, 2 bits per pixel.
+ // So each of the 4-7 bytes represents one line, flipping a block is just
+ // flipping those bytes.
+ uint8_t tmp = block[4];
+ block[4] = block[7];
+ block[7] = tmp;
+ tmp = block[5];
+ block[5] = block[6];
+ block[6] = tmp;
+}
+
+// Flips the first 2 lines of a DXT1 block in the y direction.
+static void FlipDXT1BlockHalf(uint8_t *block)
+{
+ // See layout above.
+ uint8_t tmp = block[4];
+ block[4] = block[5];
+ block[5] = tmp;
+}
+
+// Flips a full DXT3 block in the y direction.
+static void FlipDXT3BlockFull(uint8_t *block)
+{
+ // A DXT3 block layout is:
+ // [0-7] alpha bitmap, 4 bits per pixel.
+ // [8-15] a DXT1 block.
+
+ // We can flip the alpha bits at the byte level (2 bytes per line).
+ uint8_t tmp = block[0];
+
+ block[0] = block[6];
+ block[6] = tmp;
+ tmp = block[1];
+ block[1] = block[7];
+ block[7] = tmp;
+ tmp = block[2];
+ block[2] = block[4];
+ block[4] = tmp;
+ tmp = block[3];
+ block[3] = block[5];
+ block[5] = tmp;
+
+ // And flip the DXT1 block using the above function.
+ FlipDXT1BlockFull(block + 8);
+}
+
+// Flips the first 2 lines of a DXT3 block in the y direction.
+static void FlipDXT3BlockHalf(uint8_t *block)
+{
+ // See layout above.
+ uint8_t tmp = block[0];
+
+ block[0] = block[2];
+ block[2] = tmp;
+ tmp = block[1];
+ block[1] = block[3];
+ block[3] = tmp;
+ FlipDXT1BlockHalf(block + 8);
+}
+
+// Flips a full DXT5 block in the y direction.
+static void FlipDXT5BlockFull(uint8_t *block)
+{
+ // A DXT5 block layout is:
+ // [0] alpha0.
+ // [1] alpha1.
+ // [2-7] alpha bitmap, 3 bits per pixel.
+ // [8-15] a DXT1 block.
+
+ // The alpha bitmap doesn't easily map lines to bytes, so we have to
+ // interpret it correctly. Extracted from
+ // http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt :
+ //
+ // The 6 "bits" bytes of the block are decoded into one 48-bit integer:
+ //
+ // bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
+ // 256 * (bits_4 + 256 * bits_5))))
+ //
+ // bits is a 48-bit unsigned integer, from which a three-bit control code
+ // is extracted for a texel at location (x,y) in the block using:
+ //
+ // code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
+ //
+ // where bit 47 is the most significant and bit 0 is the least
+ // significant bit.
+ unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
+ unsigned int line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
+ // swap lines 0 and 1 in line_0_1.
+ unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) |
+ ((line_0_1 & 0xfff000) >> 12);
+ // swap lines 2 and 3 in line_2_3.
+ unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) |
+ ((line_2_3 & 0xfff000) >> 12);
+
+ block[2] = line_3_2 & 0xff;
+ block[3] = (line_3_2 & 0xff00) >> 8;
+ block[4] = (line_3_2 & 0xff0000) >> 8;
+ block[5] = line_1_0 & 0xff;
+ block[6] = (line_1_0 & 0xff00) >> 8;
+ block[7] = (line_1_0 & 0xff0000) >> 8;
+
+ // And flip the DXT1 block using the above function.
+ FlipDXT1BlockFull(block + 8);
+}
+
+// Flips the first 2 lines of a DXT5 block in the y direction.
+static void FlipDXT5BlockHalf(uint8_t *block)
+{
+ // See layout above.
+ unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
+ unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) |
+ ((line_0_1 & 0xfff000) >> 12);
+ block[2] = line_1_0 & 0xff;
+ block[3] = (line_1_0 & 0xff00) >> 8;
+ block[4] = (line_1_0 & 0xff0000) >> 8;
+ FlipDXT1BlockHalf(block + 8);
+}
+
+// Flips a DXTC image, by flipping and swapping DXTC blocks as appropriate.
+int FlipDXTCImage(unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data)
+{
+ // must have valid dimensions
+ if (width == 0 || height == 0)
+ return 0;
+ // height must be a power-of-two
+ if ((height & (height - 1)) != 0)
+ return 0;
+
+ FlipBlockFunction full_block_function;
+ FlipBlockFunction half_block_function;
+ unsigned int block_bytes = 0;
+
+ switch (fourcc) {
+ case FOURCC_DXT1:
+ full_block_function = FlipDXT1BlockFull;
+ half_block_function = FlipDXT1BlockHalf;
+ block_bytes = 8;
+ break;
+ case FOURCC_DXT3:
+ full_block_function = FlipDXT3BlockFull;
+ half_block_function = FlipDXT3BlockHalf;
+ block_bytes = 16;
+ break;
+ case FOURCC_DXT5:
+ full_block_function = FlipDXT5BlockFull;
+ half_block_function = FlipDXT5BlockHalf;
+ block_bytes = 16;
+ break;
+ default:
+ return 0;
+ }
+
+ unsigned int mip_width = width;
+ unsigned int mip_height = height;
+
+ for (unsigned int i = 0; i < levels; ++i) {
+ unsigned int blocks_per_row = (mip_width + 3) / 4;
+ unsigned int blocks_per_col = (mip_height + 3) / 4;
+ unsigned int blocks = blocks_per_row * blocks_per_col;
+
+ if (mip_height == 1) {
+ // no flip to do, and we're done.
+ break;
+ }
+ else if (mip_height == 2) {
+ // flip the first 2 lines in each block.
+ for (unsigned int i = 0; i < blocks_per_row; ++i) {
+ half_block_function(data + i * block_bytes);
+ }
+ }
+ else {
+ // flip each block.
+ for (unsigned int i = 0; i < blocks; ++i)
+ full_block_function(data + i * block_bytes);
+
+ // swap each block line in the first half of the image with the
+ // corresponding one in the second half.
+ // note that this is a no-op if mip_height is 4.
+ unsigned int row_bytes = block_bytes * blocks_per_row;
+ uint8_t *temp_line = new uint8_t[row_bytes];
+
+ for (unsigned int y = 0; y < blocks_per_col / 2; ++y) {
+ uint8_t *line1 = data + y * row_bytes;
+ uint8_t *line2 = data + (blocks_per_col - y - 1) * row_bytes;
+
+ memcpy(temp_line, line1, row_bytes);
+ memcpy(line1, line2, row_bytes);
+ memcpy(line2, temp_line, row_bytes);
+ }
+
+ delete temp_line;
+ }
+
+ // mip levels are contiguous.
+ data += block_bytes * blocks;
+ mip_width = max(1U, mip_width >> 1);
+ mip_height = max(1U, mip_height >> 1);
+ }
+
+ return 1;
+}
+
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.h b/source/blender/imbuf/intern/dds/FlipDXT.h
new file mode 100644
index 00000000000..8d0ae8139a1
--- /dev/null
+++ b/source/blender/imbuf/intern/dds/FlipDXT.h
@@ -0,0 +1,32 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors: Amorilia (amorilia@users.sourceforge.net)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __FLIPDXT_H__
+#define __FLIPDXT_H__
+
+#include "MEM_sys_types.h"
+
+/* flip compressed DXT image vertically to fit OpenGL convention */
+int FlipDXTCImage(unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data);
+
+#endif
+
diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h
index 5dcf3011c76..81074fba6b7 100644
--- a/source/blender/imbuf/intern/dds/Image.h
+++ b/source/blender/imbuf/intern/dds/Image.h
@@ -101,4 +101,4 @@ inline Color32 & Image::pixel(uint x, uint y)
return pixel(y * width() + x);
}
-#endif // __IMAGE_H__
+#endif /* __IMAGE_H__ */
diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h
index 308ea810f03..2bb1864e49d 100644
--- a/source/blender/imbuf/intern/dds/PixelFormat.h
+++ b/source/blender/imbuf/intern/dds/PixelFormat.h
@@ -101,38 +101,38 @@
}
}
- inline float quantizeCeil(float f, int inbits, int outbits)
- {
- //uint i = f * (float(1 << inbits) - 1);
- //i = convert(i, inbits, outbits);
- //float result = float(i) / (float(1 << outbits) - 1);
- //nvCheck(result >= f);
- float result;
- int offset = 0;
- do {
- uint i = offset + uint(f * (float(1 << inbits) - 1));
- i = convert(i, inbits, outbits);
- result = float(i) / (float(1 << outbits) - 1);
- offset++;
- } while (result < f);
-
- return result;
- }
-
- /*
- inline float quantizeRound(float f, int bits)
- {
- float scale = float(1 << bits);
- return fround(f * scale) / scale;
- }
-
- inline float quantizeFloor(float f, int bits)
- {
- float scale = float(1 << bits);
- return floor(f * scale) / scale;
- }
- */
+ inline float quantizeCeil(float f, int inbits, int outbits)
+ {
+ //uint i = f * (float(1 << inbits) - 1);
+ //i = convert(i, inbits, outbits);
+ //float result = float(i) / (float(1 << outbits) - 1);
+ //nvCheck(result >= f);
+ float result;
+ int offset = 0;
+ do {
+ uint i = offset + uint(f * (float(1 << inbits) - 1));
+ i = convert(i, inbits, outbits);
+ result = float(i) / (float(1 << outbits) - 1);
+ offset++;
+ } while (result < f);
+
+ return result;
+ }
+
+#if 0
+ inline float quantizeRound(float f, int bits)
+ {
+ float scale = float(1 << bits);
+ return fround(f * scale) / scale;
+ }
+
+ inline float quantizeFloor(float f, int bits)
+ {
+ float scale = float(1 << bits);
+ return floor(f * scale) / scale;
+ }
+#endif
} // PixelFormat namespace
-#endif // _DDS_IMAGE_PIXELFORMAT_H
+#endif /* __PIXELFORMAT_H__ */
diff --git a/source/blender/imbuf/intern/dds/SConscript b/source/blender/imbuf/intern/dds/SConscript
index 4245f5001b9..d5a613f5981 100644
--- a/source/blender/imbuf/intern/dds/SConscript
+++ b/source/blender/imbuf/intern/dds/SConscript
@@ -1,7 +1,7 @@
#!/usr/bin/python
Import ('env')
-source_files = ['dds_api.cpp', 'DirectDrawSurface.cpp', 'Stream.cpp', 'BlockDXT.cpp', 'ColorBlock.cpp', 'Image.cpp']
+source_files = ['dds_api.cpp', 'DirectDrawSurface.cpp', 'Stream.cpp', 'BlockDXT.cpp', 'ColorBlock.cpp', 'Image.cpp', 'FlipDXT.cpp']
incs = ['.',
'../../',
diff --git a/source/blender/imbuf/intern/dds/Stream.h b/source/blender/imbuf/intern/dds/Stream.h
index 9f513ca8aba..a1ac49b58da 100644
--- a/source/blender/imbuf/intern/dds/Stream.h
+++ b/source/blender/imbuf/intern/dds/Stream.h
@@ -35,7 +35,7 @@ struct Stream
unsigned char *mem; // location in memory
unsigned int size; // size
unsigned int pos; // current position
- Stream(unsigned char *m, unsigned int s) : mem(m), size(s), pos(0) {};
+ Stream(unsigned char *m, unsigned int s) : mem(m), size(s), pos(0) {}
unsigned int seek(unsigned int p);
};
@@ -45,5 +45,4 @@ unsigned int mem_read(Stream & mem, unsigned short & i);
unsigned int mem_read(Stream & mem, unsigned char & i);
unsigned int mem_read(Stream & mem, unsigned char *i, unsigned int cnt);
-#endif // __STREAM_H__
-
+#endif /* __STREAM_H__ */
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 7aacbf20bae..5459cffe590 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -29,6 +29,7 @@
#include <dds_api.h>
#include <Stream.h>
#include <DirectDrawSurface.h>
+#include <FlipDXT.h>
#include <stdio.h> // printf
#include <fstream>
@@ -162,13 +163,18 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colo
rect[i] = col;
}
- if (ibuf->dds_data.fourcc != FOURCC_DDS)
+ if (ibuf->dds_data.fourcc != FOURCC_DDS) {
ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size);
+
+ /* flip compressed texture */
+ FlipDXTCImage(dds.width(), dds.height(), dds.mipmapCount(), dds.fourCC(), ibuf->dds_data.data);
+ }
else {
ibuf->dds_data.data = NULL;
ibuf->dds_data.size = 0;
}
+ /* flip uncompressed texture */
IMB_flipy(ibuf);
}
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index aa236af3507..8d289de9970 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -62,7 +62,7 @@ void IMB_de_interlace(ImBuf *ibuf)
tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect);
tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect);
- ibuf->x *= 2;
+ ibuf->x *= 2;
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
@@ -561,7 +561,7 @@ void IMB_rect_from_float(ImBuf *ibuf)
}
/* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */
-void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h)
+void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data)
{
float *rect_float;
uchar *rect_byte;
@@ -580,14 +580,27 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
rect_float = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
rect_byte = (uchar *)ibuf->rect + (x + y * ibuf->x) * 4;
- IMB_buffer_float_from_float(buffer, rect_float,
- ibuf->channels, IB_PROFILE_SRGB, profile_from, predivide,
- w, h, w, ibuf->x);
+ if (is_data) {
+ /* exception for non-color data, just copy float */
+ IMB_buffer_float_from_float(buffer, rect_float,
+ ibuf->channels, IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, 0,
+ w, h, w, ibuf->x);
- /* XXX: need to convert to image buffer's rect space */
- IMB_buffer_byte_from_float(rect_byte, buffer,
- 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0,
- w, h, ibuf->x, w);
+ /* and do color space conversion to byte */
+ IMB_buffer_byte_from_float(rect_byte, rect_float,
+ 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
+ w, h, ibuf->x, w);
+ }
+ else {
+ IMB_buffer_float_from_float(buffer, rect_float,
+ ibuf->channels, IB_PROFILE_SRGB, profile_from, predivide,
+ w, h, w, ibuf->x);
+
+ /* XXX: need to convert to image buffer's rect space */
+ IMB_buffer_byte_from_float(rect_byte, buffer,
+ 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0,
+ w, h, ibuf->x, w);
+ }
/* ensure user flag is reset */
ibuf->userflags &= ~IB_RECT_INVALID;
@@ -710,7 +723,7 @@ void IMB_buffer_float_clamp(float *buf, int width, int height)
{
int i, total = width * height * 4;
for (i = 0; i < total; i++) {
- buf[i] = minf(1.0, buf[i]);
+ buf[i] = min_ff(1.0, buf[i]);
}
}
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index ed4db50035d..5c2dc0c7df9 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -74,8 +74,8 @@ ImFileType IMB_FILE_TYPES[] = {
{NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA, COLOR_ROLE_DEFAULT_BYTE},
{NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC, COLOR_ROLE_DEFAULT_BYTE},
#ifdef WITH_CINEON
- {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX, COLOR_ROLE_DEFAULT_FLOAT},
- {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON, COLOR_ROLE_DEFAULT_FLOAT},
+ {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_load_dpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX, COLOR_ROLE_DEFAULT_FLOAT},
+ {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_load_cineon, imb_save_cineon, NULL, IM_FTYPE_FLOAT, CINEON, COLOR_ROLE_DEFAULT_FLOAT},
#endif
#ifdef WITH_TIFF
{imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF, COLOR_ROLE_DEFAULT_BYTE},
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 863b8424cc2..57fbce710a1 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -444,7 +444,7 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char outI[4], float
outF[2] = dataF[2];
outF[3] = dataF[3];
}
- }
+ }
}
void neareast_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout)
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index f35a4345366..38bd28452f3 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -36,18 +36,19 @@
#include "IMB_indexer.h"
#include "IMB_anim.h"
-#include "AVI_avi.h"
#include "imbuf.h"
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "BKE_global.h"
-#ifdef WITH_FFMPEG
-
-#include "ffmpeg_compat.h"
+#ifdef WITH_AVI
+# include "AVI_avi.h"
+#endif
-#endif //WITH_FFMPEG
+#ifdef WITH_FFMPEG
+# include "ffmpeg_compat.h"
+#endif
static char magic[] = "BlenMIdx";
@@ -869,9 +870,9 @@ static void index_rebuild_ffmpeg_proc_decoded_frame(
context->start_pts_set = TRUE;
}
- context->frameno = floor((pts - context->start_pts)
- * context->pts_time_base
- * context->frame_rate + 0.5f);
+ context->frameno = floor((pts - context->start_pts) *
+ context->pts_time_base *
+ context->frame_rate + 0.5);
/* decoding starts *always* on I-Frames,
* so: P-Frames won't work, even if all the
@@ -989,6 +990,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
* - internal AVI (fallback) rebuilder
* ---------------------------------------------------------------------- */
+#ifdef WITH_AVI
typedef struct FallbackIndexBuilderContext {
int anim_type;
@@ -1149,6 +1151,8 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
}
}
+#endif /* WITH_AVI */
+
/* ----------------------------------------------------------------------
* - public API
* ---------------------------------------------------------------------- */
@@ -1164,15 +1168,19 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecod
context = index_ffmpeg_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality);
break;
#endif
+#ifdef WITH_AVI
default:
context = index_fallback_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality);
break;
+#endif
}
if (context)
context->anim_type = anim->curtype;
return context;
+
+ (void)tcs_in_use, (void)proxy_sizes_in_use, (void)quality;
}
void IMB_anim_index_rebuild(struct IndexBuildContext *context,
@@ -1184,10 +1192,14 @@ void IMB_anim_index_rebuild(struct IndexBuildContext *context,
index_rebuild_ffmpeg((FFmpegIndexBuilderContext *)context, stop, do_update, progress);
break;
#endif
+#ifdef WITH_AVI
default:
index_rebuild_fallback((FallbackIndexBuilderContext *)context, stop, do_update, progress);
break;
+#endif
}
+
+ (void)stop, (void)do_update, (void)progress;
}
void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop)
@@ -1198,10 +1210,15 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop)
index_rebuild_ffmpeg_finish((FFmpegIndexBuilderContext *)context, stop);
break;
#endif
+#ifdef WITH_AVI
default:
index_rebuild_fallback_finish((FallbackIndexBuilderContext *)context, stop);
break;
+#endif
}
+
+ (void)stop;
+ (void)proxy_sizes; /* static defined at top of the file */
}
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 549a28a0453..dec5f6fb39e 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -408,7 +408,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colo
}
MEM_freeN(starttab);
- MEM_freeN(lengthtab);
+ MEM_freeN(lengthtab);
}
else {
@@ -613,7 +613,7 @@ static void expandrow2(float *optr, unsigned char *iptr, int z)
optr += 4;
}
}
- }
+ }
}
static void expandrow(unsigned char *optr, unsigned char *iptr, int z)
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 01523463712..d94f6368298 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -41,7 +41,7 @@
#include "openjpeg.h"
-#define JP2_FILEHEADER_SIZE 14
+// #define JP2_FILEHEADER_SIZE 14 /* UNUSED */
static char JP2_HEAD[] = {0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A};
static char J2K_HEAD[] = {0xFF, 0x4F, 0xFF, 0x51, 0x00};
@@ -436,7 +436,7 @@ static void cinema_parameters(opj_cparameters_t *parameters)
parameters->image_offset_y0 = 0;
/*Codeblock size = 32 * 32*/
- parameters->cblockw_init = 32;
+ parameters->cblockw_init = 32;
parameters->cblockh_init = 32;
parameters->csty |= 0x01;
@@ -602,7 +602,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
prec = 12;
numcomps = 3;
}
- else {
+ else {
/* Get settings from the imbuf */
color_space = (ibuf->ftype & JP2_YCC) ? CLRSPC_SYCC : CLRSPC_SRGB;
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 61275a8937c..d96a01d7093 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -235,19 +235,19 @@ static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t
*/
#define INPUT_BYTE(cinfo, V, action) \
MAKESTMT(MAKE_BYTE_AVAIL(cinfo,action); \
- bytes_in_buffer--; \
- V = GETJOCTET(*next_input_byte++); )
+ bytes_in_buffer--; \
+ V = GETJOCTET(*next_input_byte++); )
/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
* V should be declared unsigned int or perhaps INT32.
*/
#define INPUT_2BYTES(cinfo, V, action) \
MAKESTMT(MAKE_BYTE_AVAIL(cinfo,action); \
- bytes_in_buffer--; \
- V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
- MAKE_BYTE_AVAIL(cinfo, action); \
- bytes_in_buffer--; \
- V += GETJOCTET(*next_input_byte++); )
+ bytes_in_buffer--; \
+ V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
+ MAKE_BYTE_AVAIL(cinfo, action); \
+ bytes_in_buffer--; \
+ V += GETJOCTET(*next_input_byte++); )
static boolean
diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt
index a5afc1abdc6..d5cb8e8a3b6 100644
--- a/source/blender/imbuf/intern/openexr/CMakeLists.txt
+++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt
@@ -39,6 +39,9 @@ set(INC_SYS
)
set(SRC
+ openexr_api.h
+ openexr_multi.h
+
openexr_api.cpp
)
@@ -49,4 +52,4 @@ if(WITH_IMAGE_OPENEXR)
add_definitions(-DWITH_OPENEXR)
endif()
-blender_add_lib(bf_imbuf_openexr "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(bf_imbuf_openexr "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 066d07a36c5..60c6e184070 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -238,19 +238,19 @@ public:
Iex::throwErrnoExc();
}
- virtual void write(const char c[], int n)
+ virtual void write(const char c[], int n)
{
errno = 0;
ofs.write(c, n);
check_error();
}
- virtual Int64 tellp()
+ virtual Int64 tellp()
{
return std::streamoff(ofs.tellp());
}
- virtual void seekp(Int64 pos)
+ virtual void seekp(Int64 pos)
{
ofs.seekp(pos);
check_error();
diff --git a/source/blender/imbuf/intern/openexr/openexr_stub.cpp b/source/blender/imbuf/intern/openexr/openexr_stub.cpp
index 7262656d4e8..21fa878c08a 100644
--- a/source/blender/imbuf/intern/openexr/openexr_stub.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_stub.cpp
@@ -33,25 +33,25 @@
#include "openexr_multi.h"
-void * IMB_exr_get_handle (void) {return NULL;}
-void IMB_exr_add_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; }
+void *IMB_exr_get_handle (void) {return NULL;}
+void IMB_exr_add_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; }
-int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height) { (void)handle; (void)filename; (void)width; (void)height; return 0;}
-int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress) { (void)handle; (void)filename; (void)width; (void)height; (void)compress; return 0;}
-void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley) { (void)handle; (void)filename; (void)mipmap; (void)width; (void)height; (void)tilex; (void)tiley; }
+int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height) { (void)handle; (void)filename; (void)width; (void)height; return 0;}
+int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress) { (void)handle; (void)filename; (void)width; (void)height; (void)compress; return 0;}
+void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley) { (void)handle; (void)filename; (void)mipmap; (void)width; (void)height; (void)tilex; (void)tiley; }
-void IMB_exr_set_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; }
+void IMB_exr_set_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; }
-void IMB_exr_read_channels (void *handle) { (void)handle; }
-void IMB_exr_write_channels (void *handle) { (void)handle; }
-void IMB_exrtile_write_channels (void *handle, int partx, int party, int level) { (void)handle; (void)partx; (void)party; (void)level; }
-void IMB_exrtile_clear_channels (void *handle) { (void)handle; }
+void IMB_exr_read_channels (void *handle) { (void)handle; }
+void IMB_exr_write_channels (void *handle) { (void)handle; }
+void IMB_exrtile_write_channels (void *handle, int partx, int party, int level) { (void)handle; (void)partx; (void)party; (void)level; }
+void IMB_exrtile_clear_channels (void *handle) { (void)handle; }
-void IMB_exr_multilayer_convert (void *handle, void *base,
- void * (*addlayer)(void *base, const char *str),
- void (*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id))
- {
- (void)handle; (void)base; (void)addlayer; (void)addpass;
- }
+void IMB_exr_multilayer_convert (void *handle, void *base,
+ void * (*addlayer)(void *base, const char *str),
+ void (*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id))
+{
+ (void)handle; (void)base; (void)addlayer; (void)addpass;
+}
-void IMB_exr_close (void *handle) { (void)handle; }
+void IMB_exr_close (void *handle) { (void)handle; }
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 6310d8e105f..dcfebb95b87 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -558,7 +558,8 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I
MEM_freeN(pixels);
if (pixels16)
MEM_freeN(pixels16);
- MEM_freeN(row_pointers);
+ if (row_pointers)
+ MEM_freeN(row_pointers);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return(ibuf);
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index 53b00f441c8..03ed1bb8008 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -65,7 +65,6 @@
#define BLU 2
#define EXP 3
#define COLXS 128
-#define STR_MAX 540
typedef unsigned char RGBE[4];
typedef float fCOLOR[3];
@@ -154,7 +153,7 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe)
if (d <= 1e-32f)
rgbe[RED] = rgbe[GRN] = rgbe[BLU] = rgbe[EXP] = 0;
else {
- d = frexp(d, &e) * 256.f / d;
+ d = (float)frexp(d, &e) * 256.0f / d;
rgbe[RED] = (unsigned char)(fcol[RED] * d);
rgbe[GRN] = (unsigned char)(fcol[GRN] * d);
rgbe[BLU] = (unsigned char)(fcol[BLU] * d);
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index a1fa05d1098..be20c80bdec 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -100,7 +100,8 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char co
}
}
- fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);
+ if ((flags & IB_test) == 0)
+ fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);
return NULL;
}
@@ -170,11 +171,12 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
return ibuf;
}
-ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
+ImBuf *IMB_testiffname(const char *filepath, int flags)
{
ImBuf *ibuf;
int file;
char filepath_tx[IB_FILENAME_SIZE];
+ char colorspace[IM_MAX_SPACE] = "\0";
imb_cache_filename(filepath_tx, filepath, flags);
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index a11f16d5669..d2b0645cf93 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -447,7 +447,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
drectf += destskip * 4;
srectf += srcskip * 4;
- }
+ }
}
}
}
@@ -482,13 +482,13 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4])
*rrectf++ = col[2];
*rrectf++ = col[3];
}
- }
+ }
}
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
- const float col[4], struct ColorManagedDisplay *display,
- int x1, int y1, int x2, int y2)
+ const float col[4], struct ColorManagedDisplay *display,
+ int x1, int y1, int x2, int y2)
{
int i, j;
float a; /* alpha */
@@ -587,7 +587,7 @@ void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, i
{
if (!ibuf) return;
buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, display,
- x1, y1, x2, y2);
+ x1, y1, x2, y2);
}
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 527f334d6a4..b9525ccccf1 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -331,13 +331,13 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
for (y = ibuf2->y; y > 0; y--) {
p2f = p1f + (ibuf1->x << 2);
for (x = ibuf2->x; x > 0; x--) {
- destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
- destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
- destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
- destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
- p1f += 8;
- p2f += 8;
- destf += 4;
+ destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
+ destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
+ destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
+ destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
+ p1f += 8;
+ p2f += 8;
+ destf += 4;
}
p1f = p2f;
if (ibuf1->x & 1) p1f += 4;
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 253680e4bea..eaad77f1ff9 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -55,9 +55,9 @@
/***/
typedef struct TARGA {
- unsigned char numid;
+ unsigned char numid;
unsigned char maptyp;
- unsigned char imgtyp;
+ unsigned char imgtyp;
short maporig;
short mapsize;
unsigned char mapbits;
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index ff7218d649c..94bb85b49ea 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -175,7 +175,7 @@ static void to_hex_char(char *hexbytes, const unsigned char *bytes, int len)
static int uri_from_filename(const char *path, char *uri)
{
- char orig_uri[URI_MAX];
+ char orig_uri[URI_MAX];
const char *dirstart = path;
#ifdef WIN32
@@ -265,7 +265,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
char thumb[40];
short tsize = 128;
short ex, ey;
- float scaledx, scaledy;
+ float scaledx, scaledy;
struct stat info;
switch (size) {
@@ -334,7 +334,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
}
else {
IMB_freeImBuf(img);
- img = IMB_anim_previewframe(anim);
+ img = IMB_anim_previewframe(anim);
}
IMB_free_anim(anim);
}
@@ -401,7 +401,7 @@ ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
if (!uri_from_filename(path, uri)) {
return NULL;
}
- if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
+ if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL);
}
@@ -436,9 +436,9 @@ ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
struct stat st;
ImBuf *img = NULL;
- if (stat(path, &st)) {
+ if (BLI_stat(path, &st)) {
return NULL;
- }
+ }
if (!uri_from_filename(path, uri)) {
return NULL;
}
diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c
index cfc49d8cef5..73ced4095f9 100644
--- a/source/blender/imbuf/intern/thumbs_blend.c
+++ b/source/blender/imbuf/intern/thumbs_blend.c
@@ -166,7 +166,7 @@ void IMB_overlayblend_thumb(unsigned int *thumb, int width, int height, float as
margin_t = height - margin_b;
}
- {
+ {
int x, y;
int stride_x = (margin_r - margin_l) - 2;
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 833671e3f2f..fe138a71a4a 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -211,7 +211,12 @@ int IMB_ispic(const char *filename)
static int isavi(const char *name)
{
+#ifdef WITH_AVI
return AVI_is_avi(name);
+#else
+ (void)name;
+ return FALSE;
+#endif
}
#ifdef WITH_QUICKTIME
@@ -223,6 +228,10 @@ static int isqtime(const char *name)
#ifdef WITH_FFMPEG
+/* BLI_vsnprintf in ffmpeg_log_callback() causes invalid warning */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
+
static char ffmpeg_last_error[1024];
static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg)
@@ -240,6 +249,8 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_lis
}
}
+#pragma GCC diagnostic pop
+
void IMB_ffmpeg_init(void)
{
av_register_all();
@@ -405,7 +416,7 @@ int IMB_isanim(const char *filename)
type = imb_get_anim_type(filename);
}
else {
- return(FALSE);
+ return(FALSE);
}
}
else { /* no quicktime */
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index d75c6019825..d8d1ad78451 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -563,6 +563,7 @@ typedef enum eDopeSheet_FilterFlag {
/* general filtering 3 */
ADS_FILTER_INCL_HIDDEN = (1 << 26), /* include 'hidden' channels too (i.e. those from hidden Objects/Bones) */
ADS_FILTER_BY_FCU_NAME = (1 << 27), /* for F-Curves, filter by the displayed name (i.e. to isolate all Location curves only) */
+ ADS_FILTER_ONLY_ERRORS = (1 << 28), /* show only F-Curves which are disabled/have errors - for debugging drivers */
/* combination filters (some only used at runtime) */
ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM | ADS_FILTER_NOMAT | ADS_FILTER_NOLAM | ADS_FILTER_NOCUR | ADS_FILTER_NOPART | ADS_FILTER_NOARM | ADS_FILTER_NOSPK)
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 4a5ad69cb91..b445d59db2c 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -46,21 +46,21 @@ typedef struct bAddObjectActuator {
struct Object *ob;
} bAddObjectActuator;
-typedef struct bActionActuator {
- struct bAction *act; /* Pointer to action */
- short type, flag; /* Playback type */ // not in use
- float sta, end; /* Start & End frames */
- char name[64]; /* For property-driven playback, MAX_NAME */
- char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */
- short blendin; /* Number of frames of blending */
- short priority; /* Execution priority */
- short layer; /* Animation layer */
- short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
- short strideaxis; /* Displacement axis */
- short pad;
- float stridelength; /* Displacement incurred by cycle */ // not in use
- float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */
-} bActionActuator;
+typedef struct bActionActuator {
+ struct bAction *act; /* Pointer to action */
+ short type, flag; /* Playback type */ // not in use
+ float sta, end; /* Start & End frames */
+ char name[64]; /* For property-driven playback, MAX_NAME */
+ char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */
+ short blendin; /* Number of frames of blending */
+ short priority; /* Execution priority */
+ short layer; /* Animation layer */
+ short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
+ short strideaxis; /* Displacement axis */
+ short pad;
+ float stridelength; /* Displacement incurred by cycle */ // not in use
+ float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */
+} bActionActuator;
typedef struct Sound3D {
float min_gain;
@@ -261,7 +261,7 @@ typedef struct bActuator {
/**
* For ipo's and props: to find out which object the actuator
* belongs to */
- struct Object *ob;
+ struct Object *ob;
} bActuator;
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 7cf0d588710..1ac6e6db94b 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -246,13 +246,13 @@ typedef enum eFMod_Noise_Modifications {
/* stepped modifier data */
typedef struct FMod_Stepped {
- float step_size; /* Number of frames each interpolated value should be held */
- float offset; /* Reference frame number that stepping starts from */
-
- float start_frame; /* start frame of the frame range that modifier works in */
- float end_frame; /* end frame of the frame range that modifier works in */
-
- int flag; /* various settings */
+ float step_size; /* Number of frames each interpolated value should be held */
+ float offset; /* Reference frame number that stepping starts from */
+
+ float start_frame; /* start frame of the frame range that modifier works in */
+ float end_frame; /* end frame of the frame range that modifier works in */
+
+ int flag; /* various settings */
} FMod_Stepped;
/* stepped modifier range flags */
@@ -325,14 +325,14 @@ typedef enum eDriverTarget_TransformChannels {
*/
typedef struct DriverVar {
struct DriverVar *next, *prev;
-
- char name[64]; /* name of the variable to use in py-expression (must be valid python identifier) */
-
- DriverTarget targets[8]; /* MAX_DRIVER_TARGETS, target slots */
- short num_targets; /* number of targets actually used by this variable */
-
- short type; /* type of driver target (eDriverTarget_Types) */
- float curval; /* result of previous evaluation */
+
+ char name[64]; /* name of the variable to use in py-expression (must be valid python identifier) */
+
+ DriverTarget targets[8]; /* MAX_DRIVER_TARGETS, target slots */
+ short num_targets; /* number of targets actually used by this variable */
+
+ short type; /* type of driver target (eDriverTarget_Types) */
+ float curval; /* result of previous evaluation */
} DriverVar;
/* Driver Variable Types */
@@ -556,36 +556,36 @@ typedef struct AnimMapper {
*/
typedef struct NlaStrip {
struct NlaStrip *next, *prev;
-
- ListBase strips; /* 'Child' strips (used for 'meta' strips) */
- bAction *act; /* Action that is referenced by this strip (strip is 'user' of the action) */
- AnimMapper *remap; /* Remapping info this strip (for tweaking correspondence of action with context) */
-
- ListBase fcurves; /* F-Curves for controlling this strip's influence and timing */ // TODO: move out?
- ListBase modifiers; /* F-Curve modifiers to be applied to the entire strip's referenced F-Curves */
-
- char name[64]; /* User-Visible Identifier for Strip */
-
- float influence; /* Influence of strip */
- float strip_time; /* Current 'time' within action being used (automatically evaluated, but can be overridden) */
-
- float start, end; /* extents of the strip */
- float actstart, actend; /* range of the action to use */
-
- float repeat; /* The number of times to repeat the action range (only when no F-Curves) */
- float scale; /* The amount the action range is scaled by (only when no F-Curves) */
-
- float blendin, blendout; /* strip blending length (only used when there are no F-Curves) */
- short blendmode; /* strip blending mode (layer-based mixing) */
-
- short extendmode; /* strip extrapolation mode (time-based mixing) */
+
+ ListBase strips; /* 'Child' strips (used for 'meta' strips) */
+ bAction *act; /* Action that is referenced by this strip (strip is 'user' of the action) */
+ AnimMapper *remap; /* Remapping info this strip (for tweaking correspondence of action with context) */
+
+ ListBase fcurves; /* F-Curves for controlling this strip's influence and timing */ // TODO: move out?
+ ListBase modifiers; /* F-Curve modifiers to be applied to the entire strip's referenced F-Curves */
+
+ char name[64]; /* User-Visible Identifier for Strip */
+
+ float influence; /* Influence of strip */
+ float strip_time; /* Current 'time' within action being used (automatically evaluated, but can be overridden) */
+
+ float start, end; /* extents of the strip */
+ float actstart, actend; /* range of the action to use */
+
+ float repeat; /* The number of times to repeat the action range (only when no F-Curves) */
+ float scale; /* The amount the action range is scaled by (only when no F-Curves) */
+
+ float blendin, blendout; /* strip blending length (only used when there are no F-Curves) */
+ short blendmode; /* strip blending mode (layer-based mixing) */
+
+ short extendmode; /* strip extrapolation mode (time-based mixing) */
short pad1;
-
- short type; /* type of NLA strip */
-
- void *speaker_handle; /* handle for speaker objects */
-
- int flag; /* settings */
+
+ short type; /* type of NLA strip */
+
+ void *speaker_handle; /* handle for speaker objects */
+
+ int flag; /* settings */
int pad2;
} NlaStrip;
@@ -600,48 +600,48 @@ typedef enum eNlaStrip_Blend_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 */
- NLASTRIP_EXTEND_HOLD = 0,
+ NLASTRIP_EXTEND_HOLD = 0,
/* only hold+extend last frame */
- NLASTRIP_EXTEND_HOLD_FORWARD,
+ NLASTRIP_EXTEND_HOLD_FORWARD = 1,
/* don't contribute at all */
- NLASTRIP_EXTEND_NOTHING
+ NLASTRIP_EXTEND_NOTHING = 2
} eNlaStrip_Extrapolate_Mode;
/* 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),
+ 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
+ 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 twaking 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_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),
-
+ 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),
+ NLASTRIP_FLAG_AUTO_BLENDS = (1<<10),
/* NLA strip is played back in reverse order */
- NLASTRIP_FLAG_REVERSE = (1<<11),
+ NLASTRIP_FLAG_REVERSE = (1<<11),
/* NLA strip is muted (i.e. doesn't contribute in any way) */
- NLASTRIP_FLAG_MUTED = (1<<12),
+ NLASTRIP_FLAG_MUTED = (1<<12),
/* NLA Strip is played back in 'ping-pong' style */
- NLASTRIP_FLAG_MIRROR = (1<<13),
-
+ NLASTRIP_FLAG_MIRROR = (1<<13),
+
/* temporary editing flags */
/* NLA-Strip is really just a temporary meta used to facilitate easier transform code */
- NLASTRIP_FLAG_TEMP_META = (1<<30),
- NLASTRIP_FLAG_EDIT_TOUCHED = (1<<31)
+ NLASTRIP_FLAG_TEMP_META = (1<<30),
+ NLASTRIP_FLAG_EDIT_TOUCHED = (1<<31)
} eNlaStrip_Flag;
/* NLA Strip Type */
@@ -651,7 +651,7 @@ typedef enum eNlaStrip_Type {
/* 'transition' - blends between the adjacent strips */
NLASTRIP_TYPE_TRANSITION,
/* 'meta' - a strip which acts as a container for a few others */
- NLASTRIP_TYPE_META,
+ NLASTRIP_TYPE_META,
/* 'emit sound' - a strip which is used for timing when speaker emits sounds */
NLASTRIP_TYPE_SOUND
@@ -827,71 +827,71 @@ typedef struct AnimOverride {
* This datablock should be placed immediately after the ID block where it is used, so that
* the code which retrieves this data can do so in an easier manner. See blenkernel/intern/anim_sys.c for details.
*/
-typedef struct AnimData {
+typedef struct AnimData {
/* active action - acts as the 'tweaking track' for the NLA */
- bAction *action;
- /* temp-storage for the 'real' active action (i.e. the one used before the tweaking-action
- * took over to be edited in the Animation Editors)
+ bAction *action;
+ /* temp-storage for the 'real' active action (i.e. the one used before the tweaking-action
+ * took over to be edited in the Animation Editors)
*/
- bAction *tmpact;
- /* remapping-info for active action - should only be used if needed
- * (for 'foreign' actions that aren't working correctly)
+ bAction *tmpact;
+ /* remapping-info for active action - should only be used if needed
+ * (for 'foreign' actions that aren't working correctly)
*/
- AnimMapper *remap;
-
+ AnimMapper *remap;
+
/* nla-tracks */
- ListBase nla_tracks;
+ ListBase nla_tracks;
/* active NLA-strip (only set/used during tweaking, so no need to worry about dangling pointers) */
- NlaStrip *actstrip;
-
- /* 'drivers' for this ID-block's settings - FCurves, but are completely
- * separate from those for animation data
+ NlaStrip *actstrip;
+
+ /* 'drivers' for this ID-block's settings - FCurves, but are completely
+ * separate from those for animation data
*/
- ListBase drivers; /* standard user-created Drivers/Expressions (used as part of a rig) */
- ListBase overrides; /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */
-
+ ListBase drivers; /* standard user-created Drivers/Expressions (used as part of a rig) */
+ ListBase overrides; /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */
+
/* settings for animation evaluation */
- int flag; /* user-defined settings */
- int recalc; /* depsgraph recalculation flags */
-
+ int flag; /* user-defined settings */
+ int recalc; /* depsgraph recalculation flags */
+
/* settings for active action evaluation (based on NLA strip settings) */
- short act_blendmode; /* accumulation mode for active action */
- short act_extendmode; /* extrapolation mode for active action */
- float act_influence; /* influence for active action */
+ short act_blendmode; /* accumulation mode for active action */
+ short act_extendmode; /* extrapolation mode for active action */
+ float act_influence; /* influence for active action */
} 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),
+ ADT_NLA_SOLO_TRACK = (1<<0),
/* don't use NLA */
- ADT_NLA_EVAL_OFF = (1<<1),
+ ADT_NLA_EVAL_OFF = (1<<1),
/* NLA is being 'tweaked' (i.e. in EditMode) */
- ADT_NLA_EDIT_ON = (1<<2),
+ ADT_NLA_EDIT_ON = (1<<2),
/* active Action for 'tweaking' does not have mapping applied for editing */
- ADT_NLA_EDIT_NOMAP = (1<<3),
+ ADT_NLA_EDIT_NOMAP = (1<<3),
/* NLA-Strip F-Curves are expanded in UI */
- ADT_NLA_SKEYS_COLLAPSED = (1<<4),
-
+ ADT_NLA_SKEYS_COLLAPSED = (1<<4),
+
/* drivers expanded in UI */
- ADT_DRIVERS_COLLAPSED = (1<<10),
+ ADT_DRIVERS_COLLAPSED = (1<<10),
/* don't execute drivers */
- ADT_DRIVERS_DISABLED = (1<<11),
-
+ ADT_DRIVERS_DISABLED = (1<<11),
+
/* AnimData block is selected in UI */
- ADT_UI_SELECTED = (1<<14),
+ ADT_UI_SELECTED = (1<<14),
/* AnimData block is active in UI */
- ADT_UI_ACTIVE = (1<<15),
-
+ ADT_UI_ACTIVE = (1<<15),
+
/* F-Curves from this AnimData block are not visible in the Graph Editor */
- ADT_CURVES_NOT_VISIBLE = (1<<16)
+ ADT_CURVES_NOT_VISIBLE = (1<<16)
} eAnimData_Flag;
/* Animation Data recalculation settings (to be set by depsgraph) */
typedef enum eAnimData_Recalc {
- ADT_RECALC_DRIVERS = (1<<0),
- ADT_RECALC_ANIM = (1<<1),
- ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM)
+ ADT_RECALC_DRIVERS = (1 << 0),
+ ADT_RECALC_ANIM = (1 << 1),
+ ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM)
} eAnimData_Recalc;
/* Base Struct for Anim ------------------------------------- */
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 0a20a60c893..fd68a6d9a27 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -45,91 +45,91 @@ struct AnimData;
*/
typedef struct Bone {
- struct Bone *next, *prev; /* Next/prev elements within this list */
- IDProperty *prop; /* User-Defined Properties on this Bone */
- struct Bone *parent; /* Parent (ik parent if appropriate flag is set */
- ListBase childbase; /* Children */
- char name[64]; /* Name of the bone - must be unique within the armature, MAXBONENAME */
-
- float roll; /* roll is input for editmode, length calculated */
- float head[3];
- float tail[3]; /* head/tail and roll in Bone Space */
- float bone_mat[3][3]; /* rotation derived from head/tail/roll */
-
- int flag;
-
- float arm_head[3];
- float arm_tail[3]; /* head/tail in Armature Space (rest pos) */
- float arm_mat[4][4]; /* matrix: (bonemat(b)+head(b))*arm_mat(b-1), rest pos*/
- float arm_roll; /* roll in Armature Space (rest pos) */
-
- float dist, weight; /* dist, weight: for non-deformgroup deforms */
- float xwidth, length, zwidth; /* width: for block bones. keep in this order, transform! */
- float ease1, ease2; /* length of bezier handles */
- float rad_head, rad_tail; /* radius for head/tail sphere, defining deform as well, parent->rad_tip overrides rad_head*/
-
- float size[3]; /* patch for upward compat, UNUSED! */
- int layer; /* layers that bone appears on */
- short segments; /* for B-bones */
- short pad[1];
+ struct Bone *next, *prev; /* Next/prev elements within this list */
+ IDProperty *prop; /* User-Defined Properties on this Bone */
+ struct Bone *parent; /* Parent (ik parent if appropriate flag is set */
+ ListBase childbase; /* Children */
+ char name[64]; /* Name of the bone - must be unique within the armature, MAXBONENAME */
+
+ float roll; /* roll is input for editmode, length calculated */
+ float head[3];
+ float tail[3]; /* head/tail and roll in Bone Space */
+ float bone_mat[3][3]; /* rotation derived from head/tail/roll */
+
+ int flag;
+
+ float arm_head[3];
+ float arm_tail[3]; /* head/tail in Armature Space (rest pos) */
+ float arm_mat[4][4]; /* matrix: (bonemat(b)+head(b))*arm_mat(b-1), rest pos*/
+ float arm_roll; /* roll in Armature Space (rest pos) */
+
+ float dist, weight; /* dist, weight: for non-deformgroup deforms */
+ float xwidth, length, zwidth; /* width: for block bones. keep in this order, transform! */
+ float ease1, ease2; /* length of bezier handles */
+ float rad_head, rad_tail; /* radius for head/tail sphere, defining deform as well, parent->rad_tip overrides rad_head */
+
+ float size[3]; /* patch for upward compat, UNUSED! */
+ int layer; /* layers that bone appears on */
+ short segments; /* for B-bones */
+ short pad[1];
} Bone;
typedef struct bArmature {
- ID id;
+ ID id;
struct AnimData *adt;
-
- ListBase bonebase;
- ListBase chainbase;
- ListBase *edbo; /* editbone listbase, we use pointer so we can check state */
-
+
+ ListBase bonebase;
+ ListBase chainbase;
+ ListBase *edbo; /* editbone listbase, we use pointer so we can check state */
+
/* active bones should work like active object where possible
* - active and selection are unrelated
- * - active & hidden is not allowed
+ * - active & hidden is not allowed
* - from the user perspective active == last selected
* - active should be ignored when not visible (hidden layer) */
- Bone *act_bone; /* active bone (when not in editmode) */
- void *act_edbone; /* active editbone (in editmode) */
-
- void *sketch; /* sketch struct for etch-a-ton */
-
- int flag;
- int drawtype;
- int gevertdeformer; /* how vertex deformation is handled in the ge */
- int pad;
- short deformflag;
- short pathflag;
-
- unsigned int layer_used; /* for UI, to show which layers are there */
- unsigned int layer, layer_protected; /* for buttons to work, both variables in this order together */
-
+ Bone *act_bone; /* active bone (when not in editmode) */
+ void *act_edbone; /* active editbone (in editmode) */
+
+ void *sketch; /* sketch struct for etch-a-ton */
+
+ int flag;
+ int drawtype;
+ int gevertdeformer; /* how vertex deformation is handled in the ge */
+ int pad;
+ short deformflag;
+ short pathflag;
+
+ unsigned int layer_used; /* for UI, to show which layers are there */
+ unsigned int layer, layer_protected; /* for buttons to work, both variables in this order together */
+
// XXX deprecated... old animaton system (armature only viz) ---
- short ghostep, ghostsize; /* number of frames to ghosts to show, and step between them */
- short ghosttype, pathsize; /* ghost drawing options and number of frames between points of path */
- int ghostsf, ghostef; /* start and end frames of ghost-drawing range */
- int pathsf, pathef; /* start and end frames of path-calculation range for all bones */
- int pathbc, pathac; /* number of frames before/after current frame of path-calculation for all bones */
+ short ghostep, ghostsize; /* number of frames to ghosts to show, and step between them */
+ short ghosttype, pathsize; /* ghost drawing options and number of frames between points of path */
+ int ghostsf, ghostef; /* start and end frames of ghost-drawing range */
+ int pathsf, pathef; /* start and end frames of path-calculation range for all bones */
+ int pathbc, pathac; /* number of frames before/after current frame of path-calculation for all bones */
// XXX end of deprecated code ----------------------------------
} bArmature;
/* armature->flag */
/* don't use bit 7, was saved in files to disable stuff */
typedef enum eArmature_Flag {
- ARM_RESTPOS = (1<<0),
- ARM_DRAWXRAY = (1<<1), /* XRAY is here only for backwards converting */
- ARM_DRAWAXES = (1<<2),
- ARM_DRAWNAMES = (1<<3),
- ARM_POSEMODE = (1<<4),
- ARM_EDITMODE = (1<<5),
- ARM_DELAYDEFORM = (1<<6),
- ARM_DONT_USE = (1<<7),
- ARM_MIRROR_EDIT = (1<<8),
- ARM_AUTO_IK = (1<<9),
- ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */
- ARM_COL_CUSTOM = (1<<11), /* draw custom colors */
- ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ /* XXX deprecated */
- ARM_DS_EXPAND = (1<<13), /* dopesheet channel is expanded */
- ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualizing various states (hack for efficient updates) */
+ ARM_RESTPOS = (1<<0),
+ ARM_DRAWXRAY = (1<<1), /* XRAY is here only for backwards converting */
+ ARM_DRAWAXES = (1<<2),
+ ARM_DRAWNAMES = (1<<3),
+ ARM_POSEMODE = (1<<4),
+ ARM_EDITMODE = (1<<5),
+ ARM_DELAYDEFORM = (1<<6),
+ ARM_DONT_USE = (1<<7),
+ ARM_MIRROR_EDIT = (1<<8),
+ ARM_AUTO_IK = (1<<9),
+ ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */
+ ARM_COL_CUSTOM = (1<<11), /* draw custom colors */
+ ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ /* XXX deprecated */
+ ARM_DS_EXPAND = (1<<13), /* dopesheet channel is expanded */
+ ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualizing various states (hack for efficient updates) */
} eArmature_Flag;
/* armature->drawtype */
@@ -176,29 +176,29 @@ typedef enum eArmature_GhostType {
/* bone->flag */
typedef enum eBone_Flag {
- BONE_SELECTED = (1<<0),
- BONE_ROOTSEL = (1<<1),
- BONE_TIPSEL = (1<<2),
- BONE_TRANSFORM = (1<<3), /* Used instead of BONE_SELECTED during transform */
- BONE_CONNECTED = (1<<4), /* when bone has a parent, connect head of bone to parent's tail*/
- /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */
- BONE_HIDDEN_P = (1<<6), /* hidden Bones when drawing PoseChannels */
- BONE_DONE = (1<<7), /* For detecting cyclic dependencies */
- BONE_DRAW_ACTIVE = (1<<8), /* active is on mouse clicks only - deprecated, ONLY USE FOR DRAWING */
- BONE_HINGE = (1<<9), /* No parent rotation or scale */
- BONE_HIDDEN_A = (1<<10), /* hidden Bones when drawing Armature Editmode */
- BONE_MULT_VG_ENV = (1<<11), /* multiplies vgroup with envelope */
- BONE_NO_DEFORM = (1<<12), /* bone doesn't deform geometry */
- BONE_UNKEYED = (1<<13), /* set to prevent destruction of its unkeyframed pose (after transform) */
- BONE_HINGE_CHILD_TRANSFORM = (1<<14), /* set to prevent hinge child bones from influencing the transform center */
- BONE_NO_SCALE = (1<<15), /* No parent scale */
- BONE_HIDDEN_PG = (1<<16), /* hidden bone when drawing PoseChannels (for ghost drawing) */
- BONE_DRAWWIRE = (1<<17), /* bone should be drawn as OB_WIRE, regardless of draw-types of view+armature */
- BONE_NO_CYCLICOFFSET = (1<<18), /* when no parent, bone will not get cyclic offset */
- BONE_EDITMODE_LOCKED = (1<<19), /* bone transforms are locked in EditMode */
- BONE_TRANSFORM_CHILD = (1<<20), /* Indicates that a parent is also being transformed */
- BONE_UNSELECTABLE = (1<<21), /* bone cannot be selected */
- BONE_NO_LOCAL_LOCATION = (1<<22) /* bone location is in armature space */
+ BONE_SELECTED = (1 << 0),
+ BONE_ROOTSEL = (1 << 1),
+ BONE_TIPSEL = (1 << 2),
+ BONE_TRANSFORM = (1 << 3), /* Used instead of BONE_SELECTED during transform */
+ BONE_CONNECTED = (1 << 4), /* when bone has a parent, connect head of bone to parent's tail*/
+ /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */
+ BONE_HIDDEN_P = (1 << 6), /* hidden Bones when drawing PoseChannels */
+ BONE_DONE = (1 << 7), /* For detecting cyclic dependencies */
+ BONE_DRAW_ACTIVE = (1 << 8), /* active is on mouse clicks only - deprecated, ONLY USE FOR DRAWING */
+ BONE_HINGE = (1 << 9), /* No parent rotation or scale */
+ BONE_HIDDEN_A = (1 << 10), /* hidden Bones when drawing Armature Editmode */
+ BONE_MULT_VG_ENV = (1 << 11), /* multiplies vgroup with envelope */
+ BONE_NO_DEFORM = (1 << 12), /* bone doesn't deform geometry */
+ BONE_UNKEYED = (1 << 13), /* set to prevent destruction of its unkeyframed pose (after transform) */
+ BONE_HINGE_CHILD_TRANSFORM = (1 << 14), /* set to prevent hinge child bones from influencing the transform center */
+ BONE_NO_SCALE = (1 << 15), /* No parent scale */
+ BONE_HIDDEN_PG = (1 << 16), /* hidden bone when drawing PoseChannels (for ghost drawing) */
+ BONE_DRAWWIRE = (1 << 17), /* bone should be drawn as OB_WIRE, regardless of draw-types of view+armature */
+ BONE_NO_CYCLICOFFSET = (1 << 18), /* when no parent, bone will not get cyclic offset */
+ BONE_EDITMODE_LOCKED = (1 << 19), /* bone transforms are locked in EditMode */
+ BONE_TRANSFORM_CHILD = (1 << 20), /* Indicates that a parent is also being transformed */
+ BONE_UNSELECTABLE = (1 << 21), /* bone cannot be selected */
+ BONE_NO_LOCAL_LOCATION = (1 << 22) /* bone location is in armature space */
} eBone_Flag;
#define MAXBONENAME 64
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index ce5fc4b0c3c..f1930ffd643 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -36,18 +36,18 @@
typedef enum BoidRuleType {
eBoidRuleType_None = 0,
- eBoidRuleType_Goal = 1, /* go to goal assigned object or loudest assigned signal source */
- eBoidRuleType_Avoid = 2, /* get away from assigned object or loudest assigned signal source */
- eBoidRuleType_AvoidCollision = 3, /* manoeuver to avoid collisions with other boids and deflector object in near future */
- eBoidRuleType_Separate = 4, /* keep from going through other boids */
- eBoidRuleType_Flock = 5, /* move to center of neighbors and match their velocity */
- eBoidRuleType_FollowLeader = 6, /* follow a boid or assigned object */
- eBoidRuleType_AverageSpeed = 7, /* maintain speed, flight level or wander*/
- eBoidRuleType_Fight = 8, /* go to closest enemy and attack when in range */
- //eBoidRuleType_Protect = 9, /* go to enemy closest to target and attack when in range */
- //eBoidRuleType_Hide = 10, /* find a deflector move to it's other side from closest enemy */
- //eBoidRuleType_FollowPath = 11, /* move along a assigned curve or closest curve in a group */
- //eBoidRuleType_FollowWall = 12, /* move next to a deflector object's in direction of it's tangent */
+ eBoidRuleType_Goal = 1, /* go to goal assigned object or loudest assigned signal source */
+ eBoidRuleType_Avoid = 2, /* get away from assigned object or loudest assigned signal source */
+ eBoidRuleType_AvoidCollision = 3, /* manoeuver to avoid collisions with other boids and deflector object in near future */
+ eBoidRuleType_Separate = 4, /* keep from going through other boids */
+ eBoidRuleType_Flock = 5, /* move to center of neighbors and match their velocity */
+ eBoidRuleType_FollowLeader = 6, /* follow a boid or assigned object */
+ eBoidRuleType_AverageSpeed = 7, /* maintain speed, flight level or wander*/
+ eBoidRuleType_Fight = 8, /* go to closest enemy and attack when in range */
+ //eBoidRuleType_Protect = 9, /* go to enemy closest to target and attack when in range */
+ //eBoidRuleType_Hide = 10, /* find a deflector move to it's other side from closest enemy */
+ //eBoidRuleType_FollowPath = 11, /* move along a assigned curve or closest curve in a group */
+ //eBoidRuleType_FollowWall = 12, /* move next to a deflector object's in direction of it's tangent */
NUM_BOID_RULE_TYPES
} BoidRuleType;
@@ -67,7 +67,7 @@ typedef struct BoidRuleGoalAvoid {
BoidRule rule;
struct Object *ob;
int options;
- float fear_factor;
+ float fear_factor;
/* signals */
int signal_id, channels;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 4928a88b33e..df1cba6a44d 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -45,7 +45,7 @@
*/
typedef struct ClothSimSettings {
- struct LinkNode *cache; /* UNUSED atm */
+ struct LinkNode *cache; /* UNUSED atm */
float mingoal; /* see SB */
float Cdis; /* Mechanical damping of springs. */
float Cvi; /* Viscous/fluid damping. */
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 8b1e7e12e17..f1b7a7c3cc3 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -170,7 +170,7 @@ typedef struct bSplineIKConstraint {
short numpoints; /* number of points to bound in points array */
short chainlen; /* number of bones ('n') that are in the chain */
- /* settings */
+ /* settings */
short flag; /* general settings for constraint */
short xzScaleMode; /* method used for determining the x & z scaling of the bones */
} bSplineIKConstraint;
@@ -340,7 +340,7 @@ typedef struct bTransformConstraint {
float from_max[3]; /* to map on to to_min/max range. */
float to_min[3]; /* range of motion on owner caused by target */
- float to_max[3];
+ float to_max[3];
} bTransformConstraint;
/* Pivot Constraint */
@@ -486,7 +486,7 @@ typedef enum eBConstraint_Flags {
CONSTRAINT_EXPAND = (1<<0),
/* pre-check for illegal object name or bone name */
CONSTRAINT_DISABLE = (1<<2),
- /* to indicate which Ipo should be shown, maybe for 3d access later too */
+ /* to indicate which Ipo should be shown, maybe for 3d access later too */
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),
@@ -664,7 +664,7 @@ typedef enum eSplineIK_Flags {
/* bones in the chain should not scale to fit the curve */
CONSTRAINT_SPLINEIK_SCALE_LIMITED = (1<<2),
/* evenly distribute the bones along the path regardless of length */
- CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3),
+ CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3),
/* don't adjust the x and z scaling of the bones by the curve radius */
CONSTRAINT_SPLINEIK_NO_CURVERAD = (1<<4)
} eSplineIK_Flags;
@@ -751,7 +751,7 @@ typedef enum eChildOf_Flags {
/* Restrictions for Pivot Constraint axis to consider for enabling constraint */
typedef enum ePivotConstraint_Axis {
/* do not consider this activity-clamping */
- PIVOTCON_AXIS_NONE = -1,
+ PIVOTCON_AXIS_NONE = -1,
/* consider -ve x-axis rotations */
PIVOTCON_AXIS_X_NEG = 0,
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 9fbe045226e..deb9902c35d 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -201,8 +201,8 @@ typedef struct Curve {
float twist_smooth, smallcaps_scale;
int pathlen;
- short pad, totcol;
- short flag, bevresol;
+ short bevresol, totcol;
+ int flag;
float width, ext1, ext2;
/* default */
@@ -234,11 +234,11 @@ typedef struct Curve {
float ctime; /* current evaltime - for use by Objects parented to curves */
int totbox, actbox;
- struct TextBox *tb;
+ struct TextBox *tb;
- int selstart, selend;
+ int selstart, selend;
- struct CharInfo *strinfo;
+ struct CharInfo *strinfo;
struct CharInfo curinfo;
float bevfac1, bevfac2;
@@ -269,6 +269,7 @@ typedef struct Curve {
#define CU_PATH_RADIUS 4096 /* make use of the path radius if this is enabled (default for new curves) */
#define CU_DEFORM_FILL 8192 /* fill 2d curve after deformation */
#define CU_FILL_CAPS 16384 /* fill bevel caps */
+#define CU_MAP_TAPER 32768 /* map taper object to bevelled area */
/* twist mode */
#define CU_TWIST_Z_UP 0
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 9d40af92638..6f7bb5a723e 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -80,7 +80,7 @@ typedef struct CustomData {
#define CD_MCOL 6
#define CD_ORIGINDEX 7
#define CD_NORMAL 8
-#define CD_POLYINDEX 9
+//#define CD_POLYINDEX 9
#define CD_PROP_FLT 10
#define CD_PROP_INT 11
#define CD_PROP_STR 12
@@ -124,7 +124,7 @@ typedef struct CustomData {
#define CD_MASK_MCOL (1 << CD_MCOL)
#define CD_MASK_ORIGINDEX (1 << CD_ORIGINDEX)
#define CD_MASK_NORMAL (1 << CD_NORMAL)
-#define CD_MASK_POLYINDEX (1 << CD_POLYINDEX)
+// #define CD_MASK_POLYINDEX (1 << CD_POLYINDEX)
#define CD_MASK_PROP_FLT (1 << CD_PROP_FLT)
#define CD_MASK_PROP_INT (1 << CD_PROP_INT)
#define CD_MASK_PROP_STR (1 << CD_PROP_STR)
diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h
index 20f7bb44e92..2d1549ff487 100644
--- a/source/blender/makesdna/DNA_genfile.h
+++ b/source/blender/makesdna/DNA_genfile.h
@@ -35,8 +35,8 @@
struct SDNA;
-extern unsigned char DNAstr[]; /* DNA.c */
-extern int DNAlen;
+extern const unsigned char DNAstr[]; /* DNA.c */
+extern const int DNAlen;
typedef enum eSDNA_Type {
SDNA_TYPE_CHAR = 0,
@@ -56,7 +56,7 @@ typedef enum eSDNA_Type {
/* define so switch statements don't complain */
#define SDNA_TYPE_VOID 9
-struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap);
+struct SDNA *DNA_sdna_from_data(const void *data, const int datalen, int do_endian_swap);
void DNA_sdna_free(struct SDNA *sdna);
int DNA_struct_find_nr(struct SDNA *sdna, const char *str);
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 71b344d23d7..100968e7257 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -39,7 +39,7 @@
* This assumes that the bottom-left corner is (0,0)
*/
typedef struct bGPDspoint {
- float x, y, z; /* co-ordinates of point (usually 2d, but can be 3d as well) */
+ float x, y, z; /* co-ordinates of point (usually 2d, but can be 3d as well) */
float pressure; /* pressure of input device (from 0 to 1) at this point */
} bGPDspoint;
@@ -53,7 +53,7 @@ typedef struct bGPDstroke {
bGPDspoint *points; /* array of data-points for stroke */
int totpoints; /* number of data-points in array */
- short thickness; /* thickness of stroke (currently not used) */
+ short thickness; /* thickness of stroke (currently not used) */
short flag; /* various settings about this stroke */
} bGPDstroke;
@@ -94,7 +94,7 @@ typedef struct bGPDlayer {
ListBase frames; /* list of annotations to display for frames (bGPDframe list) */
bGPDframe *actframe; /* active frame (should be the frame that is currently being displayed) */
- int flag; /* settings for layer */
+ int flag; /* settings for layer */
short thickness; /* current thickness to apply to strokes */
short gstep; /* max number of frames between active and ghost to show (0=only those on either side) */
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index 38058dbb699..fe3550327f7 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -137,6 +137,7 @@ typedef struct Image {
#define IMA_CLAMP_U 16
#define IMA_CLAMP_V 32
#define IMA_TPAGE_REFRESH 64
+#define IMA_GLBIND_IS_DATA 128 /* opengl image texture bound as non-color data */
/* ima->type and ima->source moved to BKE_image.h, for API */
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index a73fc9073fa..3e641fba1ac 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -93,7 +93,7 @@ typedef struct Ipo {
rctf cur; /* Rect defining extents of keyframes? */
short blocktype, showkey; /* blocktype: self-explanatory; showkey: either 0 or 1 (show vertical yellow lines for editing) */
- short muteipo, pad; /* muteipo: either 0 or 1 (whether ipo block is muted) */
+ short muteipo, pad; /* muteipo: either 0 or 1 (whether ipo block is muted) */
} Ipo;
/* ----------- adrcodes (for matching ipo-curves to data) ------------- */
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index 4884db14c57..f36e65085c9 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -109,7 +109,7 @@ typedef struct Lamp {
struct PreviewImage *preview;
/* nodes */
- struct bNodeTree *nodetree;
+ struct bNodeTree *nodetree;
} Lamp;
/* **************** LAMP ********************* */
diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h
index bf388d8c018..5b25d1a072c 100644
--- a/source/blender/makesdna/DNA_mask_types.h
+++ b/source/blender/makesdna/DNA_mask_types.h
@@ -211,4 +211,4 @@ enum {
MASK_ANIMF_EXPAND = (1 << 4)
};
-#endif // __DNA_MASK_TYPES_H__
+#endif /* __DNA_MASK_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 374cc8e7379..9a8d3bf981c 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -86,7 +86,7 @@ typedef struct Material {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
- short material_type, flag;
+ short material_type, flag;
/* note, keep this below synced with render_types.h */
float r, g, b;
float specr, specg, specb;
@@ -156,7 +156,7 @@ typedef struct Material {
float rampfac_col, rampfac_spec;
struct MTex *mtex[18]; /* MAX_MTEX */
- struct bNodeTree *nodetree;
+ struct bNodeTree *nodetree;
struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
struct Group *group; /* light group */
struct PreviewImage *preview;
@@ -292,6 +292,7 @@ typedef struct Material {
#define MA_CUBIC 1
#define MA_OBCOLOR 2
#define MA_APPROX_OCCLUSION 4
+#define MA_GROUP_LOCAL 8
/* diff_shader */
#define MA_DIFF_LAMBERT 0
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 7040bc72f18..0c193e9be21 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -72,7 +72,7 @@ typedef struct MVert {
* at the moment alpha is abused for vertex painting
* and not used for transparency, note that red and blue are swapped */
typedef struct MCol {
- char a, r, g, b;
+ char a, r, g, b;
} MCol;
/* new face structure, replaces MFace, which is now
diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h
index 2912650c77c..5b37ff523cb 100644
--- a/source/blender/makesdna/DNA_meta_types.h
+++ b/source/blender/makesdna/DNA_meta_types.h
@@ -93,7 +93,7 @@ typedef struct MetaBall {
/* used in editmode */
/*ListBase edit_elems;*/
- MetaElem *lastelem;
+ MetaElem *lastelem;
} MetaBall;
/* **************** METABALL ********************* */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 99df51e9ec4..2c896e4893f 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -75,6 +75,7 @@ typedef enum ModifierType {
eModifierType_DynamicPaint = 40,
eModifierType_Remesh = 41,
eModifierType_Skin = 42,
+ eModifierType_LaplacianSmooth = 43,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -348,7 +349,7 @@ typedef struct UVProjectModifierData {
int flags;
int num_projectors;
float aspectx, aspecty;
- float scalex, scaley;
+ float scalex, scaley;
char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
int uvlayer_tmp, pad;
} UVProjectModifierData;
@@ -361,10 +362,30 @@ typedef struct UVProjectModifierData {
typedef struct DecimateModifierData {
ModifierData modifier;
- float percent;
- int faceCount;
+ float percent; /* (mode == MOD_DECIM_MODE_COLLAPSE) */
+ short iter; /* (mode == MOD_DECIM_MODE_UNSUBDIV) */
+ short pad;
+ float angle; /* (mode == MOD_DECIM_MODE_DISSOLVE) */
+
+ char defgrp_name[64]; /* MAX_VGROUP_NAME */
+ short flag, mode;
+
+ /* runtime only */
+ int face_count, pad2;
} DecimateModifierData;
+enum {
+ MOD_DECIM_FLAG_INVERT_VGROUP = (1 << 0),
+ MOD_DECIM_FLAG_TRIANGULATE = (1 << 1), /* for collapse only. dont convert tri pairs back to quads */
+ MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS = (1 << 2) /* for dissolve only. collapse all verts between 2 faces */
+};
+
+enum {
+ MOD_DECIM_MODE_COLLAPSE,
+ MOD_DECIM_MODE_UNSUBDIV,
+ MOD_DECIM_MODE_DISSOLVE /* called planar in the UI */
+};
+
/* Smooth modifier flags */
#define MOD_SMOOTH_X (1<<1)
#define MOD_SMOOTH_Y (1<<2)
@@ -644,7 +665,8 @@ typedef struct ShrinkwrapModifierData {
float keepDist; /* distance offset to keep from mesh/projection point */
short shrinkType; /* shrink type projection */
short shrinkOpts; /* shrink options */
- char projAxis; /* axis to project over */
+ float projLimit; /* limit the projection ray cast */
+ char projAxis; /* axis to project over */
/*
* if using projection over vertex normal this controls the
@@ -653,7 +675,7 @@ typedef struct ShrinkwrapModifierData {
*/
char subsurfLevels;
- char pad[6];
+ char pad[2];
} ShrinkwrapModifierData;
@@ -683,7 +705,7 @@ typedef struct SimpleDeformModifierData {
struct Object *origin; /* object to control the origin of modifier space coordinates */
char vgroup_name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */
float factor; /* factors to control simple deforms */
- float limit[2]; /* lower and upper limit */
+ float limit[2]; /* lower and upper limit */
char mode; /* deform function */
char axis; /* lock axis (for taper and strech) */
@@ -1092,4 +1114,17 @@ enum {
MOD_SKIN_SMOOTH_SHADING = 1
};
+/* Smooth modifier flags */
+#define MOD_LAPLACIANSMOOTH_X (1<<1)
+#define MOD_LAPLACIANSMOOTH_Y (1<<2)
+#define MOD_LAPLACIANSMOOTH_Z (1<<3)
+#define MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION (1<<4)
+
+typedef struct LaplacianSmoothModifierData {
+ ModifierData modifier;
+ float lambda, lambda_border, pad1;
+ char defgrp_name[64]; /* MAX_VGROUP_NAME */
+ short flag, repeat;
+} LaplacianSmoothModifierData;
+
#endif
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index cda51779528..499f1c50155 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -118,38 +118,50 @@ typedef struct MovieClipScopes {
} MovieClipScopes;
/* MovieClipProxy->build_size_flag */
-#define MCLIP_PROXY_SIZE_25 (1 << 0)
-#define MCLIP_PROXY_SIZE_50 (1 << 1)
-#define MCLIP_PROXY_SIZE_75 (1 << 2)
-#define MCLIP_PROXY_SIZE_100 (1 << 3)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_25 (1 << 4)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_50 (1 << 5)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_75 (1 << 6)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_100 (1 << 7)
+enum {
+ MCLIP_PROXY_SIZE_25 = (1 << 0),
+ MCLIP_PROXY_SIZE_50 = (1 << 1),
+ MCLIP_PROXY_SIZE_75 = (1 << 2),
+ MCLIP_PROXY_SIZE_100 = (1 << 3),
+ MCLIP_PROXY_UNDISTORTED_SIZE_25 = (1 << 4),
+ MCLIP_PROXY_UNDISTORTED_SIZE_50 = (1 << 5),
+ MCLIP_PROXY_UNDISTORTED_SIZE_75 = (1 << 6),
+ MCLIP_PROXY_UNDISTORTED_SIZE_100 = (1 << 7)
+};
/* MovieClip->source */
-#define MCLIP_SRC_SEQUENCE 1
-#define MCLIP_SRC_MOVIE 2
+enum {
+ MCLIP_SRC_SEQUENCE = 1,
+ MCLIP_SRC_MOVIE = 2
+};
/* MovieClip->selection types */
-#define MCLIP_SEL_NONE 0
-#define MCLIP_SEL_TRACK 1
+enum {
+ MCLIP_SEL_NONE = 0,
+ MCLIP_SEL_TRACK = 1
+};
/* MovieClip->flag */
-#define MCLIP_USE_PROXY (1 << 0)
-#define MCLIP_USE_PROXY_CUSTOM_DIR (1 << 1)
-/*#define MCLIP_CUSTOM_START_FRAME (1<<2)*/ /* UNUSED */
+enum {
+ MCLIP_USE_PROXY = (1 << 0),
+ MCLIP_USE_PROXY_CUSTOM_DIR = (1 << 1),
+ /* MCLIP_CUSTOM_START_FRAME = (1<<2), */ /* UNUSED */
-#define MCLIP_TIMECODE_FLAGS (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR)
+ MCLIP_TIMECODE_FLAGS = (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR)
+};
/* MovieClip->render_size */
-#define MCLIP_PROXY_RENDER_SIZE_FULL 0
-#define MCLIP_PROXY_RENDER_SIZE_25 1
-#define MCLIP_PROXY_RENDER_SIZE_50 2
-#define MCLIP_PROXY_RENDER_SIZE_75 3
-#define MCLIP_PROXY_RENDER_SIZE_100 4
+enum {
+ MCLIP_PROXY_RENDER_SIZE_FULL = 0,
+ MCLIP_PROXY_RENDER_SIZE_25 = 1,
+ MCLIP_PROXY_RENDER_SIZE_50 = 2,
+ MCLIP_PROXY_RENDER_SIZE_75 = 3,
+ MCLIP_PROXY_RENDER_SIZE_100 = 4
+};
/* MovieClip->render_flag */
-#define MCLIP_PROXY_RENDER_UNDISTORT 1
+enum {
+ MCLIP_PROXY_RENDER_UNDISTORT = 1
+};
#endif
diff --git a/source/blender/makesdna/DNA_nla_types.h b/source/blender/makesdna/DNA_nla_types.h
index 43b52ed65eb..5837f891ae0 100644
--- a/source/blender/makesdna/DNA_nla_types.h
+++ b/source/blender/makesdna/DNA_nla_types.h
@@ -50,7 +50,7 @@ typedef struct bActionModifier {
/* path deform modifier */
short no_rot_axis;
- struct Object *ob;
+ struct Object *ob;
} bActionModifier;
/* NLA-Modifier Types */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 3f1f4933585..1684cf28b3c 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -118,7 +118,8 @@ typedef struct bNodeSocket {
#define SOCK_BOOLEAN 4
#define SOCK_MESH 5
#define SOCK_INT 6
-#define NUM_SOCKET_TYPES 7 /* must be last! */
+#define SOCK_STRING 7
+#define NUM_SOCKET_TYPES 8 /* must be last! */
/* socket side (input/output) */
#define SOCK_IN 1
@@ -167,6 +168,7 @@ typedef struct bNode {
struct ID *id; /* optional link to libdata */
void *storage; /* custom data, must be struct, for storage in file */
struct bNode *original; /* the original node in the tree (for localized tree) */
+ ListBase internal_links; /* list of cached internal links (input to output), for muted nodes and operators */
float locx, locy; /* root offset for drawing (parent space) */
float width, height; /* node custom width and height */
@@ -240,6 +242,7 @@ typedef struct bNodeLink {
/* link->flag */
#define NODE_LINKFLAG_HILITE 1 /* link has been successfully validated */
#define NODE_LINK_VALID 2
+#define NODE_LINK_TEST 4 /* free test flag, undefined */
/* tree->edit_quality/tree->render_quality */
#define NTREE_QUALITY_HIGH 0
@@ -351,6 +354,11 @@ typedef struct bNodeSocketValueRGBA {
float value[4];
} bNodeSocketValueRGBA;
+typedef struct bNodeSocketValueString {
+ int subtype;
+ int pad;
+ char value[1024]; /* 1024 = FILEMAX */
+} bNodeSocketValueString;
/* data structs, for node->storage */
enum {
@@ -702,6 +710,37 @@ typedef struct NodeTrackPosData {
char track_name[64];
} NodeTrackPosData;
+typedef struct NodeShaderScript {
+ int mode;
+ int flag;
+
+ char filepath[1024]; /* 1024 = FILE_MAX */
+
+ char bytecode_hash[64];
+ char *bytecode;
+
+ IDProperty *prop;
+} NodeShaderScript;
+
+typedef struct NodeShaderTangent {
+ int direction_type;
+ int axis;
+ char uv_map[64];
+} NodeShaderTangent;
+
+typedef struct NodeShaderNormalMap {
+ int space;
+ char uv_map[64];
+} NodeShaderNormalMap;
+
+/* script node mode */
+#define NODE_SCRIPT_INTERNAL 0
+#define NODE_SCRIPT_EXTERNAL 1
+
+/* script node flag */
+#define NODE_SCRIPT_AUTO_UPDATE 1
+
+
/* frame node flags */
#define NODE_FRAME_SHRINK 1 /* keep the bounding box minimal */
#define NODE_FRAME_RESIZEABLE 2 /* test flag, if frame can be resized by user */
@@ -778,6 +817,20 @@ typedef struct NodeTrackPosData {
#define SHD_PROJ_FLAT 0
#define SHD_PROJ_BOX 1
+/* tangent */
+#define SHD_TANGENT_RADIAL 0
+#define SHD_TANGENT_UVMAP 1
+
+/* tangent */
+#define SHD_TANGENT_AXIS_X 0
+#define SHD_TANGENT_AXIS_Y 1
+#define SHD_TANGENT_AXIS_Z 2
+
+/* normal map space */
+#define SHD_NORMAL_MAP_TANGENT 0
+#define SHD_NORMAL_MAP_OBJECT 1
+#define SHD_NORMAL_MAP_WORLD 2
+
/* blur node */
#define CMP_NODE_BLUR_ASPECT_NONE 0
#define CMP_NODE_BLUR_ASPECT_Y 1
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 1dd2aa6c59b..5cc56d861a3 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -54,6 +54,7 @@ typedef enum PFieldType {
PFIELD_BOID = 10, /* Defines predator / goal for boids */
PFIELD_TURBULENCE = 11, /* Force defined by BLI_gTurbulence */
PFIELD_DRAG = 12, /* Linear & quadratic drag */
+ PFIELD_SMOKEFLOW = 13, /* Force based on smoke simulation air flow */
NUM_PFIELD_TYPES
} PFieldType;
@@ -110,14 +111,17 @@ typedef struct PartDeflect {
struct RNG *rng; /* random noise generator for e.g. wind */
float f_noise; /* noise of force */
int seed; /* noise random seed */
+
+ struct Object *f_source; /* force source object */
} PartDeflect;
typedef struct EffectorWeights {
struct Group *group; /* only use effectors from this group of objects */
- float weight[13]; /* effector type specific weights */
+ float weight[14]; /* effector type specific weights */
float global_gravity;
short flag, rt[3];
+ int pad;
} EffectorWeights;
/* EffectorWeights->flag */
@@ -276,7 +280,7 @@ typedef struct SoftBody {
float nodemass; /* softbody mass of *vertex* */
char namedVG_Mass[64]; /* MAX_VGROUP_NAME */
/* along with it introduce mass painting
- * starting to fix old bug .. nastyness that VG are indexes
+ * starting to fix old bug .. nastiness that VG are indexes
* rather find them by name tag to find it -> jow20090613 */
float grav; /* softbody amount of gravitaion to apply */
float mediafrict; /* friction to env */
@@ -291,7 +295,7 @@ typedef struct SoftBody {
float defgoal; /* default goal for vertices without vgroup */
short vertgroup; /* index starting at 1 */
char namedVG_Softgoal[64]; /* MAX_VGROUP_NAME */
- /* starting to fix old bug .. nastyness that VG are indexes
+ /* starting to fix old bug .. nastiness that VG are indexes
* rather find them by name tag to find it -> jow20090613 */
short fuzzyness; /* */
@@ -301,7 +305,7 @@ typedef struct SoftBody {
float infrict; /* softbody inner springs friction */
char namedVG_Spring_K[64]; /* MAX_VGROUP_NAME */
/* along with it introduce Spring_K painting
- * starting to fix old bug .. nastyness that VG are indexes
+ * starting to fix old bug .. nastiness that VG are indexes
* rather find them by name tag to find it -> jow20090613 */
/* baking */
@@ -365,6 +369,7 @@ typedef struct SoftBody {
#define PFIELD_DO_LOCATION (1<<14)
#define PFIELD_DO_ROTATION (1<<15)
#define PFIELD_GUIDE_PATH_WEIGHT (1<<16) /* apply curve weights */
+#define PFIELD_SMOKE_DENSITY (1<<17) /* multiply smoke force by density */
/* pd->falloff */
#define PFIELD_FALL_SPHERE 0
@@ -395,7 +400,7 @@ typedef struct SoftBody {
//#define PTCACHE_BAKE_EDIT 16
//#define PTCACHE_BAKE_EDIT_ACTIVE 32
#define PTCACHE_DISK_CACHE 64
-#define PTCACHE_QUICK_CACHE 128
+//#define PTCACHE_QUICK_CACHE 128 /* removed since 2.64 - [#30974], could be added back in a more useful way */
#define PTCACHE_FRAMES_SKIPPED 256
#define PTCACHE_EXTERNAL 512
#define PTCACHE_READ_INFO 1024
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 3a8620fdaba..89328c33674 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -209,7 +209,9 @@ typedef struct Object {
float step_height;
float jump_speed;
float fall_speed;
- char pad1[4];
+
+ /** Collision mask settings */
+ unsigned short col_group, col_mask;
short rotmode; /* rotation mode - uses defines set out in DNA_action_types.h for PoseChannel rotations... */
@@ -295,22 +297,19 @@ typedef struct ObHook {
typedef struct DupliObject {
struct DupliObject *next, *prev;
struct Object *ob;
- unsigned int origlay;
- int index;
+ unsigned int origlay, pad;
float mat[4][4], omat[4][4];
float orco[3], uv[2];
short type; /* from Object.transflag */
char no_draw, animated;
- /* Lowest-level particle index.
- * Note: This is needed for particle info in shaders.
- * Otherwise dupli groups in particle systems would override the
- * index value from higher dupli levels. Would be nice to have full generic access
- * to all dupli levels somehow, but for now this should cover most use-cases.
- */
- int particle_index;
- int pad;
+ /* persistent identifier for a dupli object, for inter-frame matching of
+ * objects with motion blur, or inter-update matching for syncing */
+ int persistent_id[8]; /* MAX_DUPLI_RECUR */
+
+ /* particle this dupli was generated from */
+ struct ParticleSystem *particle_system;
} DupliObject;
/* **************** OBJECT ********************* */
@@ -378,6 +377,7 @@ typedef struct DupliObject {
#define OB_DUPLIPARTS 2048
#define OB_RENDER_DUPLI 4096
#define OB_NO_CONSTRAINTS 8192 /* runtime constraints disable */
+#define OB_NO_PSYS_UPDATE 16384 /* hack to work around particle issue */
/* (short) ipoflag */
/* XXX: many old flags for features removed due to incompatibility
@@ -478,6 +478,9 @@ typedef struct DupliObject {
/* controller state */
#define OB_MAX_STATES 30
+/* collision masks */
+#define OB_MAX_COL_MASKS 8
+
/* ob->gameflag */
#define OB_DYNAMIC 1
#define OB_CHILD 2
diff --git a/source/blender/makesdna/DNA_packedFile_types.h b/source/blender/makesdna/DNA_packedFile_types.h
index f01e89d18c9..ef0a0f642d6 100644
--- a/source/blender/makesdna/DNA_packedFile_types.h
+++ b/source/blender/makesdna/DNA_packedFile_types.h
@@ -35,9 +35,9 @@
#define __DNA_PACKEDFILE_TYPES_H__
typedef struct PackedFile {
- int size;
- int seek;
- void * data;
+ int size;
+ int seek;
+ void *data;
} PackedFile;
enum PF_FileStatus
@@ -45,7 +45,7 @@ enum PF_FileStatus
PF_EQUAL = 0,
PF_DIFFERS = 1,
PF_NOFILE = 2,
-
+
PF_WRITE_ORIGINAL = 3,
PF_WRITE_LOCAL = 4,
PF_USE_LOCAL = 5,
@@ -53,7 +53,7 @@ enum PF_FileStatus
PF_KEEP = 7,
PF_REMOVE = 8,
PF_NOOP = 9,
-
+
PF_ASK = 10
};
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index f26b1d5535d..9dc4480fc35 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -318,10 +318,11 @@ typedef struct ImageFormatData {
/* return values from BKE_imtype_valid_depths, note this is depts per channel */
#define R_IMF_CHAN_DEPTH_1 (1<<0) /* 1bits (unused) */
#define R_IMF_CHAN_DEPTH_8 (1<<1) /* 8bits (default) */
-#define R_IMF_CHAN_DEPTH_12 (1<<2) /* 12bits (uncommon, jp2 supports) */
-#define R_IMF_CHAN_DEPTH_16 (1<<3) /* 16bits (tiff, halff float exr) */
-#define R_IMF_CHAN_DEPTH_24 (1<<4) /* 24bits (unused) */
-#define R_IMF_CHAN_DEPTH_32 (1<<5) /* 32bits (full float exr) */
+#define R_IMF_CHAN_DEPTH_10 (1<<2) /* 10bits (uncommon, Cineon/DPX support) */
+#define R_IMF_CHAN_DEPTH_12 (1<<3) /* 12bits (uncommon, jp2/DPX support) */
+#define R_IMF_CHAN_DEPTH_16 (1<<4) /* 16bits (tiff, halff float exr) */
+#define R_IMF_CHAN_DEPTH_24 (1<<5) /* 24bits (unused) */
+#define R_IMF_CHAN_DEPTH_32 (1<<6) /* 32bits (full float exr) */
/* ImageFormatData.planes */
#define R_IMF_PLANES_RGB 24
@@ -395,11 +396,16 @@ typedef struct RenderData {
/**
* The number of part to use in the x direction
*/
- short xparts;
+ short xparts DNA_DEPRECATED;
/**
* The number of part to use in the y direction
*/
- short yparts;
+ short yparts DNA_DEPRECATED;
+
+ /**
+ * render tile dimensions
+ */
+ short tilex, tiley;
short planes DNA_DEPRECATED, imtype DNA_DEPRECATED, subimtype DNA_DEPRECATED, quality DNA_DEPRECATED; /*deprecated!*/
@@ -447,6 +453,8 @@ typedef struct RenderData {
short frs_sec, edgeint;
+ int pad;
+
/* safety, border and display rect */
rctf safety, border;
@@ -475,7 +483,7 @@ typedef struct RenderData {
int color_mgt_flag;
/** post-production settings. deprecated, but here for upwards compat (initialized to 1) */
- float postgamma, posthue, postsat;
+ float postgamma, posthue, postsat;
/* Dither noise intensity */
float dither_intensity;
@@ -1094,7 +1102,7 @@ typedef struct Scene {
short use_nodes;
- struct bNodeTree *nodetree;
+ struct bNodeTree *nodetree;
struct Editing *ed; /* sequence editor data is allocated here */
@@ -1187,15 +1195,16 @@ typedef struct Scene {
/* Use the same flag for autothreads */
#define R_FIXED_THREADS 0x80000
-#define R_SPEED 0x100000
-#define R_SSS 0x200000
-#define R_NO_OVERWRITE 0x400000 /* skip existing files */
-#define R_TOUCH 0x800000 /* touch files before rendering */
-#define R_SIMPLIFY 0x1000000
+#define R_SPEED 0x100000
+#define R_SSS 0x200000
+#define R_NO_OVERWRITE 0x400000 /* skip existing files */
+#define R_TOUCH 0x800000 /* touch files before rendering */
+#define R_SIMPLIFY 0x1000000
+#define R_PERSISTENT_DATA 0x2000000 /* keep data around for re-render */
/* seq_flag */
#define R_SEQ_GL_PREV 1
-#define R_SEQ_GL_REND 2
+// #define R_SEQ_GL_REND 2 // UNUSED, opengl render has its own operator now.
/* displaymode */
@@ -1309,6 +1318,7 @@ typedef struct Scene {
/* sequencer seq_prev_type seq_rend_type */
+
/* **************** SCENE ********************* */
/* for general use */
@@ -1361,8 +1371,8 @@ typedef struct Scene {
#define SFRA (scene->r.sfra)
#define EFRA (scene->r.efra)
#define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE)
-#define PSFRA ((PRVRANGEON)? (scene->r.psfra): (scene->r.sfra))
-#define PEFRA ((PRVRANGEON)? (scene->r.pefra): (scene->r.efra))
+#define PSFRA ((PRVRANGEON) ? (scene->r.psfra) : (scene->r.sfra))
+#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra))
#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec)
#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base)
#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base)
@@ -1460,6 +1470,7 @@ typedef enum SculptFlags {
SCULPT_SYMMETRY_FEATHER = (1<<6),
SCULPT_USE_OPENMP = (1<<7),
SCULPT_ONLY_DEFORM = (1<<8),
+ SCULPT_SHOW_DIFFUSE = (1<<9),
} SculptFlags;
/* ImagePaintSettings.flag */
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 4d259fad246..f106c8f918a 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -100,6 +100,9 @@ typedef struct Strip {
StripCrop *crop;
StripTransform *transform;
StripColorBalance *color_balance DNA_DEPRECATED;
+
+ /* color management */
+ ColorManagedColorspaceSettings colorspace_settings;
} Strip;
/**
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index cceb7333478..76ba3fcf7f8 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -39,6 +39,7 @@
#define MOD_SMOKE_HIGH_SMOOTH (1<<5) /* smoothens high res emission*/
#define MOD_SMOKE_FILE_LOAD (1<<6) /* flag for file load */
+#define MOD_SMOKE_ADAPTIVE_DOMAIN (1<<7)
/* noise */
#define MOD_SMOKE_NOISEWAVE (1<<0)
@@ -61,6 +62,12 @@
#define SM_COLL_RIGID 1
#define SM_COLL_ANIMATED 2
+/* smoke data fileds (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)
+
typedef struct SmokeDomainSettings {
struct SmokeModifierData *smd; /* for fast RNA access */
struct FLUID_3D *fluid;
@@ -71,17 +78,37 @@ typedef struct SmokeDomainSettings {
struct GPUTexture *tex;
struct GPUTexture *tex_wt;
struct GPUTexture *tex_shadow;
+ struct GPUTexture *tex_flame;
float *shadow;
- float p0[3]; /* start point of BB */
- float p1[3]; /* end point of BB */
- float dx; /* edge length of one cell */
- float omega; /* smoke color - from 0 to 1 */
- float temp; /* fluid temperature */
- float tempAmb; /* ambient temperature */
+
+ /* simulation data */
+ float p0[3]; /* start point of BB in local space (includes sub-cell shift for adaptive domain)*/
+ float p1[3]; /* end point of BB in local space */
+ float dp0[3]; /* difference from object center to grid start point */
+ float cell_size[3]; /* size of simulation cell in local space */
+ float global_size[3]; /* global size of domain axises */
+ float prev_loc[3];
+ int shift[3]; /* current domain shift in simulation cells */
+ float shift_f[3]; /* exact domain shift */
+ float obj_shift_f[3]; /* how much object has shifted since previous smoke frame (used to "lock" domain while drawing) */
+ float imat[4][4]; /* domain object imat */
+ float obmat[4][4]; /* domain obmat */
+
+ int base_res[3]; /* initial "non-adapted" resolution */
+ int res_min[3]; /* cell min */
+ int res_max[3]; /* cell max */
+ int res[3]; /* data resolution (res_max-res_min) */
+ int total_cells;
+ float dx; /* 1.0f / res */
+ float scale; /* largest domain size */
+
+ /* user settings */
+ int adapt_margin;
+ int adapt_res;
+ float adapt_threshold;
+
float alpha;
float beta;
- float scale; /* largest domain size */
- int res[3]; /* domain resolution */
int amplify; /* wavelet amplification */
int maxres; /* longest axis on the BB gets this resolution assigned */
int flags; /* show up-res or low res, etc */
@@ -92,7 +119,6 @@ typedef struct SmokeDomainSettings {
float strength;
int res_wt[3];
float dx_wt;
- int v3dnum;
int cache_comp;
int cache_high_comp;
@@ -103,31 +129,67 @@ typedef struct SmokeDomainSettings {
int border_collisions; /* How domain border collisions are handled */
float time_scale;
float vorticity;
- int pad2;
+ int active_fields;
+ float active_color[3]; /* monitor color situation of simulation */
+ int pad;
+
+ /* flame parameters */
+ float burning_rate, flame_smoke, flame_vorticity;
+ float flame_ignition, flame_max_temp;
+ float flame_smoke_color[3];
} SmokeDomainSettings;
/* inflow / outflow */
/* type */
-#define MOD_SMOKE_FLOW_TYPE_OUTFLOW (1<<1)
+#define MOD_SMOKE_FLOW_TYPE_SMOKE 0
+#define MOD_SMOKE_FLOW_TYPE_FIRE 1
+#define MOD_SMOKE_FLOW_TYPE_OUTFLOW 2
+#define MOD_SMOKE_FLOW_TYPE_SMOKEFIRE 3
+
+/* flow source */
+#define MOD_SMOKE_FLOW_SOURCE_PARTICLES 0
+#define MOD_SMOKE_FLOW_SOURCE_MESH 1
+
+/* flow texture type */
+#define MOD_SMOKE_FLOW_TEXTURE_MAP_AUTO 0
+#define MOD_SMOKE_FLOW_TEXTURE_MAP_UV 1
/* flags */
#define MOD_SMOKE_FLOW_ABSOLUTE (1<<1) /*old style emission*/
#define MOD_SMOKE_FLOW_INITVELOCITY (1<<2) /* passes particles speed to the smoke */
+#define MOD_SMOKE_FLOW_TEXTUREEMIT (1<<3) /* use texture to control emission speed */
typedef struct SmokeFlowSettings {
struct SmokeModifierData *smd; /* for fast RNA access */
+ struct DerivedMesh *dm;
struct ParticleSystem *psys;
+ struct Tex *noise_texture;
+
+ /* initial velocity */
+ float *verts_old; /* previous vertex positions in domain space */
+ int numverts;
+ float vel_multi; // Multiplier for inherited velocity
+ float vel_normal;
+ float vel_random;
+ /* emission */
float density;
+ float color[3];
+ float fuel_amount;
float temp; /* delta temperature (temp - ambient temp) */
- float velocity[2]; /* UNUSED, velocity taken from particles */
- float vel_multi; // Multiplier for particle velocity
- float vgrp_heat_scale[2]; /* min and max scaling for vgroup_heat */
- short vgroup_flow; /* where inflow/outflow happens - red=1=action */
+ float volume_density; /* density emitted within mesh volume */
+ float surface_distance; /* maximum emission distance from mesh surface */
+ /* texture control */
+ float texture_size;
+ float texture_offset;
+ int pad;
+ char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
short vgroup_density;
- short vgroup_heat;
- short type; /* inflow =0 or outflow = 1 */
+
+ short type; /* smoke, flames, both, outflow */
+ short source;
+ short texture_type;
int flags; /* absolute emission etc*/
} SmokeFlowSettings;
@@ -139,20 +201,11 @@ typedef struct SmokeFlowSettings {
/* collision objects (filled with smoke) */
typedef struct SmokeCollSettings {
struct SmokeModifierData *smd; /* for fast RNA access */
- struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */
- float *points;
- float *points_old;
- float *vel; // UNUSED
- int *tridivs;
- float mat[4][4];
- float mat_old[4][4];
- int numpoints;
- int numverts; // check if mesh changed
- int numtris;
- float dx; /* global domain cell length taken from (scale / resolution) */
+ struct DerivedMesh *dm;
+ float *verts_old;
+ int numverts;
short type; // static = 0, rigid = 1, dynamic = 2
short pad;
- int pad2;
} SmokeCollSettings;
#endif
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 4b8fc9c7ed6..be6464778e5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -618,7 +618,7 @@ enum FileSortTypeE {
#define FILE_MAXFILE 256
#define FILE_MAX 1024
-#define FILE_MAX_LIBEXTRA (FILE_MAX + 32)
+#define FILE_MAX_LIBEXTRA (FILE_MAX + MAX_ID_NAME)
/* filesel types */
#define FILE_UNIX 8
@@ -792,10 +792,10 @@ typedef struct SpaceText {
float blockscale DNA_DEPRECATED;
short blockhandler[8] DNA_DEPRECATED;
- struct Text *text;
+ struct Text *text;
int top, viewlines;
- short flags, menunr;
+ short flags, menunr;
short lheight; /* user preference */
char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 9fdd9216549..dd63e6aad59 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -161,7 +161,7 @@ typedef struct PointDensity {
float speed_scale, falloff_speed_scale, pdpad2;
struct ColorBand *coba; /* for time -> color */
- struct CurveMapping *falloff_curve; /* falloff density curve */
+ struct CurveMapping *falloff_curve; /* falloff density curve */
} PointDensity;
typedef struct VoxelData {
@@ -171,9 +171,12 @@ typedef struct VoxelData {
short flag;
short extend;
short smoked_type;
+ short data_type;
+ short pad;
+ int _pad;
struct Object *object; /* for rendering smoke sims */
- float int_multiplier;
+ float int_multiplier;
int still_frame;
char source_path[1024]; /* 1024 = FILE_MAX */
@@ -470,6 +473,7 @@ typedef struct ColorMapping {
#define MTEX_BUMP_TEXTURESPACE 2048
/* #define MTEX_BUMP_FLIPPED 4096 */ /* UNUSED */
#define MTEX_BICUBIC_BUMP 8192
+#define MTEX_MAPTO_BOUNDS 16384
/* blendtype */
#define MTEX_BLEND 0
@@ -577,6 +581,11 @@ typedef struct ColorMapping {
#define TEX_VD_SMOKEDENSITY 0
#define TEX_VD_SMOKEHEAT 1
#define TEX_VD_SMOKEVEL 2
+#define TEX_VD_SMOKEFLAME 3
+
+/* data_type */
+#define TEX_VD_INTENSITY 0
+#define TEX_VD_RGBA_PREMUL 1
/******************** Ocean *****************************/
/* output */
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 1ab64ed1cc1..9c80d30bca4 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -162,7 +162,13 @@ typedef struct MovieTrackingSettings {
short speed; /* speed of tracking */
/* ** reconstruction settings ** */
- int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */
+ int keyframe1 DNA_DEPRECATED,
+ keyframe2 DNA_DEPRECATED; /* two keyframes for reconstrution initialization
+ * were moved to per-tracking object settings
+ */
+
+ float reconstruction_success_threshold;
+ int reconstruction_flag;
/* which camera intrinsics to refine. uses on the REFINE_* flags */
short refine_camera_intrinsics, pad2;
@@ -220,6 +226,9 @@ typedef struct MovieTrackingObject {
ListBase tracks; /* list of tracks use to tracking this object */
MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */
+
+ /* reconstruction options */
+ int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */
} MovieTrackingObject;
typedef struct MovieTrackingStats {
@@ -275,92 +284,129 @@ enum {
};
/* MovieTrackingMarker->flag */
-#define MARKER_DISABLED (1 << 0)
-#define MARKER_TRACKED (1 << 1)
-#define MARKER_GRAPH_SEL_X (1 << 2)
-#define MARKER_GRAPH_SEL_Y (1 << 3)
-#define MARKER_GRAPH_SEL (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)
+enum {
+ MARKER_DISABLED = (1 << 0),
+ MARKER_TRACKED = (1 << 1),
+ MARKER_GRAPH_SEL_X = (1 << 2),
+ MARKER_GRAPH_SEL_Y = (1 << 3),
+ MARKER_GRAPH_SEL = (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)
+};
/* MovieTrackingTrack->flag */
-#define TRACK_HAS_BUNDLE (1 << 1)
-#define TRACK_DISABLE_RED (1 << 2)
-#define TRACK_DISABLE_GREEN (1 << 3)
-#define TRACK_DISABLE_BLUE (1 << 4)
-#define TRACK_HIDDEN (1 << 5)
-#define TRACK_LOCKED (1 << 6)
-#define TRACK_CUSTOMCOLOR (1 << 7)
-#define TRACK_USE_2D_STAB (1 << 8)
-#define TRACK_PREVIEW_GRAYSCALE (1 << 9)
-#define TRACK_DOPE_SEL (1 << 10)
-#define TRACK_PREVIEW_ALPHA (1 << 11)
+enum {
+ TRACK_HAS_BUNDLE = (1 << 1),
+ TRACK_DISABLE_RED = (1 << 2),
+ TRACK_DISABLE_GREEN = (1 << 3),
+ TRACK_DISABLE_BLUE = (1 << 4),
+ TRACK_HIDDEN = (1 << 5),
+ TRACK_LOCKED = (1 << 6),
+ TRACK_CUSTOMCOLOR = (1 << 7),
+ TRACK_USE_2D_STAB = (1 << 8),
+ TRACK_PREVIEW_GRAYSCALE = (1 << 9),
+ TRACK_DOPE_SEL = (1 << 10),
+ TRACK_PREVIEW_ALPHA = (1 << 11)
+};
/* MovieTrackingTrack->motion_model */
-#define TRACK_MOTION_MODEL_TRANSLATION 0
-#define TRACK_MOTION_MODEL_TRANSLATION_ROTATION 1
-#define TRACK_MOTION_MODEL_TRANSLATION_SCALE 2
-#define TRACK_MOTION_MODEL_TRANSLATION_ROTATION_SCALE 3
-#define TRACK_MOTION_MODEL_AFFINE 4
-#define TRACK_MOTION_MODEL_HOMOGRAPHY 5
+enum {
+ TRACK_MOTION_MODEL_TRANSLATION = 0,
+ TRACK_MOTION_MODEL_TRANSLATION_ROTATION = 1,
+ TRACK_MOTION_MODEL_TRANSLATION_SCALE = 2,
+ TRACK_MOTION_MODEL_TRANSLATION_ROTATION_SCALE = 3,
+ TRACK_MOTION_MODEL_AFFINE = 4,
+ TRACK_MOTION_MODEL_HOMOGRAPHY = 5
+};
/* MovieTrackingTrack->algorithm_flag */
-#define TRACK_ALGORITHM_FLAG_USE_BRUTE (1 << 0)
-#define TRACK_ALGORITHM_FLAG_USE_NORMALIZATION (1 << 2)
-#define TRACK_ALGORITHM_FLAG_USE_MASK (1 << 3)
+enum {
+ TRACK_ALGORITHM_FLAG_USE_BRUTE = (1 << 0),
+ TRACK_ALGORITHM_FLAG_USE_NORMALIZATION = (1 << 2),
+ TRACK_ALGORITHM_FLAG_USE_MASK = (1 << 3)
+};
/* MovieTrackingTrack->adjframes */
-#define TRACK_MATCH_KEYFRAME 0
-#define TRACK_MATCH_PREVFRAME 1
+enum {
+ TRACK_MATCH_KEYFRAME = 0,
+ TRACK_MATCH_PREVFRAME = 1
+};
/* MovieTrackingSettings->flag */
-#define TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED (1 << 0)
+enum {
+ TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED = (1 << 0)
+};
/* MovieTrackingSettings->motion_flag */
-#define TRACKING_MOTION_TRIPOD (1 << 0)
+enum {
+ TRACKING_MOTION_TRIPOD = (1 << 0),
-#define TRACKING_MOTION_MODAL (TRACKING_MOTION_TRIPOD)
+ TRACKING_MOTION_MODAL = (TRACKING_MOTION_TRIPOD)
+};
/* MovieTrackingSettings->speed */
-#define TRACKING_SPEED_FASTEST 0
-#define TRACKING_SPEED_REALTIME 1
-#define TRACKING_SPEED_HALF 2
-#define TRACKING_SPEED_QUARTER 4
-#define TRACKING_SPEED_DOUBLE 5
+enum {
+ TRACKING_SPEED_FASTEST = 0,
+ TRACKING_SPEED_REALTIME = 1,
+ TRACKING_SPEED_HALF = 2,
+ TRACKING_SPEED_QUARTER = 4,
+ TRACKING_SPEED_DOUBLE = 5
+};
+
+/* MovieTrackingObject->reconstruction_flag */
+enum {
+ TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0)
+};
/* MovieTrackingSettings->refine_camera_intrinsics */
-#define REFINE_FOCAL_LENGTH (1 << 0)
-#define REFINE_PRINCIPAL_POINT (1 << 1)
-#define REFINE_RADIAL_DISTORTION_K1 (1 << 2)
-#define REFINE_RADIAL_DISTORTION_K2 (1 << 4)
+enum {
+ REFINE_FOCAL_LENGTH = (1 << 0),
+ REFINE_PRINCIPAL_POINT = (1 << 1),
+ REFINE_RADIAL_DISTORTION_K1 = (1 << 2),
+ REFINE_RADIAL_DISTORTION_K2 = (1 << 4)
+};
/* MovieTrackingStrabilization->flag */
-#define TRACKING_2D_STABILIZATION (1 << 0)
-#define TRACKING_AUTOSCALE (1 << 1)
-#define TRACKING_STABILIZE_ROTATION (1 << 2)
+enum {
+ TRACKING_2D_STABILIZATION = (1 << 0),
+ TRACKING_AUTOSCALE = (1 << 1),
+ TRACKING_STABILIZE_ROTATION = (1 << 2)
+};
/* MovieTrackingStrabilization->filter */
-#define TRACKING_FILTER_NEAREAST 0
-#define TRACKING_FILTER_BILINEAR 1
-#define TRACKING_FILTER_BICUBIC 2
+enum {
+ TRACKING_FILTER_NEAREAST = 0,
+ TRACKING_FILTER_BILINEAR = 1,
+ TRACKING_FILTER_BICUBIC = 2
+};
/* MovieTrackingReconstruction->flag */
-#define TRACKING_RECONSTRUCTED (1 << 0)
+enum {
+ TRACKING_RECONSTRUCTED = (1 << 0)
+};
/* MovieTrackingObject->flag */
-#define TRACKING_OBJECT_CAMERA (1 << 0)
+enum {
+ TRACKING_OBJECT_CAMERA = (1 << 0)
+};
-#define TRACKING_CLEAN_SELECT 0
-#define TRACKING_CLEAN_DELETE_TRACK 1
-#define TRACKING_CLEAN_DELETE_SEGMENT 2
+enum {
+ TRACKING_CLEAN_SELECT = 0,
+ TRACKING_CLEAN_DELETE_TRACK = 1,
+ TRACKING_CLEAN_DELETE_SEGMENT = 2
+};
/* MovieTrackingDopesheet->sort_method */
-#define TRACKING_DOPE_SORT_NAME 0
-#define TRACKING_DOPE_SORT_LONGEST 1
-#define TRACKING_DOPE_SORT_TOTAL 2
-#define TRACKING_DOPE_SORT_AVERAGE_ERROR 3
+enum {
+ TRACKING_DOPE_SORT_NAME = 0,
+ TRACKING_DOPE_SORT_LONGEST = 1,
+ TRACKING_DOPE_SORT_TOTAL = 2,
+ TRACKING_DOPE_SORT_AVERAGE_ERROR = 3
+};
/* MovieTrackingDopesheet->flag */
-#define TRACKING_DOPE_SORT_INVERSE (1 << 0)
-#define TRACKING_DOPE_SELECTED_ONLY (1 << 1)
-#define TRACKING_DOPE_SHOW_HIDDEN (1 << 2)
+enum {
+ TRACKING_DOPE_SORT_INVERSE = (1 << 0),
+ TRACKING_DOPE_SELECTED_ONLY = (1 << 1),
+ TRACKING_DOPE_SHOW_HIDDEN = (1 << 2)
+};
#endif
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 218027209a8..69e67461a56 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -49,11 +49,14 @@ struct ColorBand;
#define MAX_STYLE_NAME 64
/* default uifont_id offered by Blender */
-#define UIFONT_DEFAULT 0
-/*#define UIFONT_BITMAP 1*/ /*UNUSED*/
-/* free slots */
-#define UIFONT_CUSTOM1 2
-#define UIFONT_CUSTOM2 3
+typedef enum eUIFont_ID {
+ UIFONT_DEFAULT = 0,
+/* UIFONT_BITMAP = 1 */ /* UNUSED */
+
+ /* free slots */
+ UIFONT_CUSTOM1 = 2,
+ UIFONT_CUSTOM2 = 3
+} eUIFont_ID;
/* default fonts to load/initalize */
/* first font is the default (index 0), others optional */
@@ -64,7 +67,6 @@ typedef struct uiFont {
short uifont_id; /* own id */
short r_to_l; /* fonts that read from left to right */
short pad;
-
} uiFont;
/* this state defines appearance of text */
@@ -79,13 +81,14 @@ typedef struct uiFontStyle {
short align; /* text align hint */
float shadowalpha; /* total alpha */
float shadowcolor; /* 1 value, typically white or black anyway */
-
} uiFontStyle;
/* uiFontStyle->align */
-#define UI_STYLE_TEXT_LEFT 0
-#define UI_STYLE_TEXT_CENTER 1
-#define UI_STYLE_TEXT_RIGHT 2
+typedef enum eFontStyle_Align {
+ UI_STYLE_TEXT_LEFT = 0,
+ UI_STYLE_TEXT_CENTER = 1,
+ UI_STYLE_TEXT_RIGHT = 2
+} eFontStyle_Align;
/* this is fed to the layout engine and widget code */
@@ -145,7 +148,6 @@ typedef struct uiPanelColors {
} uiPanelColors;
typedef struct ThemeUI {
-
/* Interface Elements (buttons, menus, icons) */
uiWidgetColors wcol_regular, wcol_tool, wcol_text;
uiWidgetColors wcol_radio, wcol_option, wcol_toggle;
@@ -160,7 +162,8 @@ typedef struct ThemeUI {
char iconfile[256]; // FILE_MAXFILE length
float icon_alpha;
- float pad;
+ /* Axis Colors */
+ char xaxis[4], yaxis[4], zaxis[4];
} ThemeUI;
/* try to put them all in one, if needed a special struct can be created as well
@@ -182,7 +185,7 @@ typedef struct ThemeSpace {
/* button/tool regions */
char button[4];
char button_title[4];
- char button_text[4];
+ char button_text[4];
char button_text_hi[4];
/* listview regions */
@@ -193,8 +196,8 @@ typedef struct ThemeSpace {
/* float panel */
char panel[4];
- char panel_title[4];
- char panel_text[4];
+ char panel_title[4];
+ char panel_text[4];
char panel_text_hi[4];
char shade1[4];
@@ -209,8 +212,8 @@ typedef struct ThemeSpace {
char vertex[4], vertex_select[4];
char edge[4], edge_select[4];
char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4];
- char face[4], face_select[4]; // solid faces
- char face_dot[4]; // selected color
+ char face[4], face_select[4]; /* solid faces */
+ char face_dot[4]; /* selected color */
char extra_edge_len[4], extra_face_angle[4], extra_face_area[4], pad3[4];
char normal[4];
char vertex_normal[4];
@@ -224,7 +227,7 @@ typedef struct ThemeSpace {
char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], handle_auto_clamped[4];
char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], handle_sel_auto_clamped[4];
- char ds_channel[4], ds_subchannel[4]; // dopesheet
+ char ds_channel[4], ds_subchannel[4]; /* dopesheet */
char console_output[4], console_input[4], console_info[4], console_error[4];
char console_cursor[4];
@@ -232,10 +235,10 @@ typedef struct ThemeSpace {
char vertex_size, outline_width, facedot_size;
char noodle_curving;
- char syntaxl[4], syntaxn[4], syntaxb[4]; // syntax for textwindow and nodes
+ char syntaxl[4], syntaxn[4], syntaxb[4]; /* syntax for textwindow and nodes */
char syntaxv[4], syntaxc[4];
- char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; // for sequence editor
+ char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; /* for sequence editor */
char effect[4], hpad0[4], transition[4], meta[4];
char editmesh_active[4];
@@ -287,8 +290,10 @@ typedef struct ThemeWireColor {
} ThemeWireColor;
/* flags for ThemeWireColor */
-#define TH_WIRECOLOR_CONSTCOLS (1<<0)
-#define TH_WIRECOLOR_TEXTCOLS (1<<1)
+typedef enum eWireColor_Flags {
+ TH_WIRECOLOR_CONSTCOLS = (1 << 0),
+ TH_WIRECOLOR_TEXTCOLS = (1 << 1),
+} eWireColor_Flags;
/* A theme */
typedef struct bTheme {
@@ -298,7 +303,7 @@ typedef struct bTheme {
ThemeUI tui;
/* Individual Spacetypes */
- ThemeSpace tbuts;
+ ThemeSpace tbuts;
ThemeSpace tv3d;
ThemeSpace tfile;
ThemeSpace tipo;
@@ -312,7 +317,7 @@ typedef struct bTheme {
ThemeSpace ttime;
ThemeSpace tnode;
ThemeSpace tlogic;
- ThemeSpace tuserpref;
+ ThemeSpace tuserpref;
ThemeSpace tconsole;
ThemeSpace tclip;
@@ -321,7 +326,6 @@ typedef struct bTheme {
/*ThemeWireColor tobj[20];*/
int active_theme_area, pad;
-
} bTheme;
/* for the moment only the name. may want to store options with this later */
@@ -345,8 +349,8 @@ typedef struct UserDef {
char pythondir[768];
char sounddir[768];
char i18ndir[768];
- char image_editor[1024]; /* 1024 = FILE_MAX */
- char anim_player[1024]; /* 1024 = FILE_MAX */
+ char image_editor[1024]; /* 1024 = FILE_MAX */
+ char anim_player[1024]; /* 1024 = FILE_MAX */
int anim_player_preset;
short v2d_min_gridsize; /* minimum spacing between gridlines in View2D grids */
@@ -393,7 +397,7 @@ typedef struct UserDef {
int memcachelimit;
int prefetchframes;
short frameserverport;
- short pad_rot_angle; /*control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use*/
+ short pad_rot_angle; /* control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use */
short obcenter_dia;
short rvisize; /* rotating view icon size */
short rvibright; /* rotating view icon brightness */
@@ -414,15 +418,17 @@ typedef struct UserDef {
float ndof_sensitivity; /* overall sensitivity of 3D mouse */
float ndof_orbit_sensitivity;
- float pad4;
int ndof_flag; /* flags for 3D mouse */
+ short ogl_multisamples; /* amount of samples for OpenGL FSA, if zero no FSA */
+ short pad4;
+
float glalphaclip;
short autokey_mode; /* autokeying mode */
short autokey_flag; /* flags for autokeying */
- short text_render, pad9; /*options for text rendering*/
+ short text_render, pad9; /* options for text rendering */
struct ColorBand coba_weight; /* from texture.h */
@@ -445,217 +451,270 @@ extern UserDef U; /* from blenkernel blender.c */
/* ***************** USERDEF ****************** */
/* userpref/section */
-#define USER_SECTION_INTERFACE 0
-#define USER_SECTION_EDIT 1
-#define USER_SECTION_FILE 2
-#define USER_SECTION_SYSTEM 3
-#define USER_SECTION_THEME 4
-#define USER_SECTION_INPUT 5
-#define USER_SECTION_ADDONS 6
+typedef enum eUserPref_Section {
+ USER_SECTION_INTERFACE = 0,
+ USER_SECTION_EDIT = 1,
+ USER_SECTION_FILE = 2,
+ USER_SECTION_SYSTEM = 3,
+ USER_SECTION_THEME = 4,
+ USER_SECTION_INPUT = 5,
+ USER_SECTION_ADDONS = 6,
+} eUserPref_Section;
/* flag */
-#define USER_AUTOSAVE (1 << 0)
-/*#define USER_AUTOGRABGRID (1 << 1) deprecated */
-/*#define USER_AUTOROTGRID (1 << 2) deprecated */
-/*#define USER_AUTOSIZEGRID (1 << 3) deprecated */
-#define USER_SCENEGLOBAL (1 << 4)
-#define USER_TRACKBALL (1 << 5)
-/*#define USER_DUPLILINK (1 << 6) deprecated */
-/*#define USER_FSCOLLUM (1 << 7) deprecated */
-#define USER_MAT_ON_OB (1 << 8)
-/*#define USER_NO_CAPSLOCK (1 << 9)*/ /* not used anywhere */
-/*#define USER_VIEWMOVE (1 << 10)*/ /* not used anywhere */
-#define USER_TOOLTIPS (1 << 11)
-#define USER_TWOBUTTONMOUSE (1 << 12)
-#define USER_NONUMPAD (1 << 13)
-#define USER_LMOUSESELECT (1 << 14)
-#define USER_FILECOMPRESS (1 << 15)
-#define USER_SAVE_PREVIEWS (1 << 16)
-#define USER_CUSTOM_RANGE (1 << 17)
-#define USER_ADD_EDITMODE (1 << 18)
-#define USER_ADD_VIEWALIGNED (1 << 19)
-#define USER_RELPATHS (1 << 20)
-#define USER_RELEASECONFIRM (1 << 21)
-#define USER_SCRIPT_AUTOEXEC_DISABLE (1 << 22)
-#define USER_FILENOUI (1 << 23)
-#define USER_NONEGFRAMES (1 << 24)
-#define USER_TXT_TABSTOSPACES_DISABLE (1 << 25)
-#define USER_TOOLTIPS_PYTHON (1 << 26)
-
+typedef enum eUserPref_Flag {
+ USER_AUTOSAVE = (1 << 0),
+/* USER_AUTOGRABGRID = (1 << 1), deprecated */
+/* USER_AUTOROTGRID = (1 << 2), deprecated */
+/* USER_AUTOSIZEGRID = (1 << 3), deprecated */
+ USER_SCENEGLOBAL = (1 << 4),
+ USER_TRACKBALL = (1 << 5),
+/* USER_DUPLILINK = (1 << 6), deprecated */
+/* USER_FSCOLLUM = (1 << 7), deprecated */
+ USER_MAT_ON_OB = (1 << 8),
+/* USER_NO_CAPSLOCK = (1 << 9), */ /* not used anywhere */
+/* USER_VIEWMOVE = (1 << 10), */ /* not used anywhere */
+ USER_TOOLTIPS = (1 << 11),
+ USER_TWOBUTTONMOUSE = (1 << 12),
+ USER_NONUMPAD = (1 << 13),
+ USER_LMOUSESELECT = (1 << 14),
+ 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;
+
/* helper macro for checking frame clamping */
#define FRAMENUMBER_MIN_CLAMP(cfra) { \
if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \
cfra = 0; \
} (void)0
-/* viewzom */
-#define USER_ZOOM_CONT 0
-#define USER_ZOOM_SCALE 1
-#define USER_ZOOM_DOLLY 2
+/* viewzoom */
+typedef enum eViewZoom_Style {
+ USER_ZOOM_CONT = 0,
+ USER_ZOOM_SCALE = 1,
+ USER_ZOOM_DOLLY = 2
+} eViewZoom_Style;
/* uiflag */
-// old flag for #define USER_KEYINSERTACT (1 << 0)
-// old flag for #define USER_KEYINSERTOBJ (1 << 1)
-#define USER_WHEELZOOMDIR (1 << 2)
-#define USER_FILTERFILEEXTS (1 << 3)
-#define USER_DRAWVIEWINFO (1 << 4)
-#define USER_PLAINMENUS (1 << 5) // old EVTTOCONSOLE print ghost events, here for tuhopuu compat. --phase
- // old flag for hide pulldown was here
-/*#define USER_FLIPFULLSCREEN (1 << 7)*/ /* deprecated */
-#define USER_ALLWINCODECS (1 << 8)
-#define USER_MENUOPENAUTO (1 << 9)
-#define USER_ZBUF_CURSOR (1 << 10)
-#define USER_AUTOPERSP (1 << 11)
-#define USER_LOCKAROUND (1 << 12)
-#define USER_GLOBALUNDO (1 << 13)
-#define USER_ORBIT_SELECTION (1 << 14)
-#define USER_ZBUF_ORBIT (1 << 15)
-#define USER_HIDE_DOT (1 << 16)
-#define USER_SHOW_ROTVIEWICON (1 << 17)
-#define USER_SHOW_VIEWPORTNAME (1 << 18)
-#define USER_CAM_LOCK_NO_PARENT (1 << 19)
-#define USER_ZOOM_TO_MOUSEPOS (1 << 20)
-#define USER_SHOW_FPS (1 << 21)
-#define USER_MMB_PASTE (1 << 22)
-#define USER_MENUFIXEDORDER (1 << 23)
-#define USER_CONTINUOUS_MOUSE (1 << 24)
-#define USER_ZOOM_INVERT (1 << 25)
-#define USER_ZOOM_HORIZ (1 << 26) /* for CONTINUE and DOLLY zoom */
-#define USER_SPLASH_DISABLE (1 << 27)
-#define USER_HIDE_RECENT (1 << 28)
-#define USER_SHOW_THUMBNAILS (1 << 29)
-#define USER_QUIT_PROMPT (1 << 30)
+typedef enum eUserpref_UI_Flag {
+ /* flags 0 and 1 were old flags (for autokeying) that aren't used anymore */
+ USER_WHEELZOOMDIR = (1 << 2),
+ USER_FILTERFILEEXTS = (1 << 3),
+ USER_DRAWVIEWINFO = (1 << 4),
+ USER_PLAINMENUS = (1 << 5),
+ /* flags 6 and 7 were old flags that are no-longer used */
+ USER_ALLWINCODECS = (1 << 8),
+ USER_MENUOPENAUTO = (1 << 9),
+ USER_ZBUF_CURSOR = (1 << 10),
+ USER_AUTOPERSP = (1 << 11),
+ USER_LOCKAROUND = (1 << 12),
+ USER_GLOBALUNDO = (1 << 13),
+ USER_ORBIT_SELECTION = (1 << 14),
+ USER_ZBUF_ORBIT = (1 << 15),
+ USER_HIDE_DOT = (1 << 16),
+ USER_SHOW_ROTVIEWICON = (1 << 17),
+ USER_SHOW_VIEWPORTNAME = (1 << 18),
+ USER_CAM_LOCK_NO_PARENT = (1 << 19),
+ USER_ZOOM_TO_MOUSEPOS = (1 << 20),
+ USER_SHOW_FPS = (1 << 21),
+ USER_MMB_PASTE = (1 << 22),
+ USER_MENUFIXEDORDER = (1 << 23),
+ USER_CONTINUOUS_MOUSE = (1 << 24),
+ USER_ZOOM_INVERT = (1 << 25),
+ USER_ZOOM_HORIZ = (1 << 26), /* for CONTINUE and DOLLY zoom */
+ USER_SPLASH_DISABLE = (1 << 27),
+ USER_HIDE_RECENT = (1 << 28),
+ USER_SHOW_THUMBNAILS = (1 << 29),
+ USER_QUIT_PROMPT = (1 << 30),
+ USER_HIDE_SYSTEM_BOOKMARKS = (1 << 31)
+} eUserpref_UI_Flag;
/* Auto-Keying mode */
+typedef enum eAutokey_Mode {
/* AUTOKEY_ON is a bitflag */
-#define AUTOKEY_ON 1
+ AUTOKEY_ON = 1,
+
/* AUTOKEY_ON + 2**n... (i.e. AUTOKEY_MODE_NORMAL = AUTOKEY_ON + 2) to preserve setting, even when autokey turned off */
-#define AUTOKEY_MODE_NORMAL 3
-#define AUTOKEY_MODE_EDITKEYS 5
+ AUTOKEY_MODE_NORMAL = 3,
+ AUTOKEY_MODE_EDITKEYS = 5
+} eAutokey_Mode;
/* Auto-Keying flag
* U.autokey_flag (not strictly used when autokeying only - is also used when keyframing these days)
* note: AUTOKEY_FLAG_* is used with a macro, search for lines like IS_AUTOKEY_FLAG(INSERTAVAIL)
*/
-#define AUTOKEY_FLAG_INSERTAVAIL (1<<0)
-#define AUTOKEY_FLAG_INSERTNEEDED (1<<1)
-#define AUTOKEY_FLAG_AUTOMATKEY (1<<2)
-#define AUTOKEY_FLAG_XYZ2RGB (1<<3)
-
-/* toolsettings->autokey_flag */
-#define AUTOKEY_FLAG_ONLYKEYINGSET (1<<6)
-#define ANIMRECORD_FLAG_WITHNLA (1<<10)
+typedef enum eAutokey_Flag {
+ AUTOKEY_FLAG_INSERTAVAIL = (1 << 0),
+ AUTOKEY_FLAG_INSERTNEEDED = (1 << 1),
+ AUTOKEY_FLAG_AUTOMATKEY = (1 << 2),
+ AUTOKEY_FLAG_XYZ2RGB = (1 << 3),
+
+ /* toolsettings->autokey_flag */
+ AUTOKEY_FLAG_ONLYKEYINGSET = (1 << 6),
+ AUTOKEY_FLAG_NOWARNING = (1 << 7),
+ ANIMRECORD_FLAG_WITHNLA = (1 << 10),
+} eAutokey_Flag;
/* transopts */
-#define USER_TR_TOOLTIPS (1 << 0)
-#define USER_TR_IFACE (1 << 1)
-/*#define USER_TR_MENUS (1 << 2) deprecated*/
-/*#define USER_TR_FILESELECT (1 << 3) deprecated*/
-/*#define USER_TR_TEXTEDIT (1 << 4) deprecated*/
-#define USER_DOTRANSLATE (1 << 5)
-#define USER_USETEXTUREFONT (1 << 6)
-/*#define CONVERT_TO_UTF8 (1 << 7) deprecated*/
+typedef enum eUserpref_Translation_Flags {
+ USER_TR_TOOLTIPS = (1 << 0),
+ USER_TR_IFACE = (1 << 1),
+/* USER_TR_MENUS = (1 << 2) deprecated */
+/* USER_TR_FILESELECT = (1 << 3) deprecated */
+/* USER_TR_TEXTEDIT = (1 << 4) deprecated */
+ USER_DOTRANSLATE = (1 << 5),
+ USER_USETEXTUREFONT = (1 << 6),
+/* CONVERT_TO_UTF8 = (1 << 7) deprecated */
+} eUserpref_Translation_Flags;
/* dupflag */
-#define USER_DUP_MESH (1 << 0)
-#define USER_DUP_CURVE (1 << 1)
-#define USER_DUP_SURF (1 << 2)
-#define USER_DUP_FONT (1 << 3)
-#define USER_DUP_MBALL (1 << 4)
-#define USER_DUP_LAMP (1 << 5)
-#define USER_DUP_IPO (1 << 6)
-#define USER_DUP_MAT (1 << 7)
-#define USER_DUP_TEX (1 << 8)
-#define USER_DUP_ARM (1 << 9)
-#define USER_DUP_ACT (1 << 10)
-#define USER_DUP_PSYS (1 << 11)
+typedef enum eDupli_ID_Flags {
+ USER_DUP_MESH = (1 << 0),
+ USER_DUP_CURVE = (1 << 1),
+ USER_DUP_SURF = (1 << 2),
+ USER_DUP_FONT = (1 << 3),
+ USER_DUP_MBALL = (1 << 4),
+ USER_DUP_LAMP = (1 << 5),
+ USER_DUP_IPO = (1 << 6),
+ USER_DUP_MAT = (1 << 7),
+ USER_DUP_TEX = (1 << 8),
+ USER_DUP_ARM = (1 << 9),
+ USER_DUP_ACT = (1 << 10),
+ USER_DUP_PSYS = (1 << 11)
+} eDupli_ID_Flags;
/* gameflags */
-// #define USER_DEPRECATED_FLAG 1
-// #define USER_DISABLE_SOUND 2 deprecated, don't use without checking for
-// backwards compatibilty in do_versions!
-#define USER_DISABLE_MIPMAP 4
-#define USER_DISABLE_VBO 8
-#define USER_DISABLE_AA 16
+typedef enum eOpenGL_RenderingOptions {
+ /* USER_DEPRECATED_FLAG = (1 << 0), */
+ /* USER_DISABLE_SOUND = (1 << 1), */ /* deprecated, don't use without checking for */
+ /* backwards compatibilty in do_versions! */
+ USER_DISABLE_MIPMAP = (1 << 2),
+ USER_DISABLE_VBO = (1 << 3),
+ USER_DISABLE_AA = (1 << 4),
+} eOpenGL_RenderingOptions;
/* wm draw method */
-#define USER_DRAW_TRIPLE 0
-#define USER_DRAW_OVERLAP 1
-#define USER_DRAW_FULL 2
-#define USER_DRAW_AUTOMATIC 3
-#define USER_DRAW_OVERLAP_FLIP 4
-
-/* text draw options*/
-#define USER_TEXT_DISABLE_AA (1 << 0)
+typedef enum eWM_DrawMethod {
+ USER_DRAW_TRIPLE = 0,
+ USER_DRAW_OVERLAP = 1,
+ USER_DRAW_FULL = 2,
+ USER_DRAW_AUTOMATIC = 3,
+ USER_DRAW_OVERLAP_FLIP = 4,
+} eWM_DrawMethod;
+
+/* text draw options */
+typedef enum eText_Draw_Options {
+ USER_TEXT_DISABLE_AA = (1 << 0),
+} eText_Draw_Options;
/* tw_flag (transform widget) */
/* gp_settings (Grease Pencil Settings) */
-#define GP_PAINT_DOSMOOTH (1<<0)
-#define GP_PAINT_DOSIMPLIFY (1<<1)
+typedef enum eGP_UserdefSettings {
+ GP_PAINT_DOSMOOTH = (1 << 0),
+ GP_PAINT_DOSIMPLIFY = (1 << 1),
+} eGP_UserdefSettings;
/* color picker types */
-#define USER_CP_CIRCLE 0
-#define USER_CP_SQUARE_SV 1
-#define USER_CP_SQUARE_HS 2
-#define USER_CP_SQUARE_HV 3
+typedef enum eColorPicker_Types {
+ USER_CP_CIRCLE = 0,
+ USER_CP_SQUARE_SV = 1,
+ USER_CP_SQUARE_HS = 2,
+ USER_CP_SQUARE_HV = 3,
+} eColorPicker_Types;
/* timecode display styles */
+typedef enum eTimecodeStyles {
/* as little info as is necessary to show relevant info
* with '+' to denote the frames
* i.e. HH:MM:SS+FF, MM:SS+FF, SS+FF, or MM:SS
*/
-#define USER_TIMECODE_MINIMAL 0
+ USER_TIMECODE_MINIMAL = 0,
+
/* reduced SMPTE - (HH:)MM:SS:FF */
-#define USER_TIMECODE_SMPTE_MSF 1
+ USER_TIMECODE_SMPTE_MSF = 1,
+
/* full SMPTE - HH:MM:SS:FF */
-#define USER_TIMECODE_SMPTE_FULL 2
+ USER_TIMECODE_SMPTE_FULL = 2,
+
/* milliseconds for sub-frames - HH:MM:SS.sss */
-#define USER_TIMECODE_MILLISECONDS 3
+ USER_TIMECODE_MILLISECONDS = 3,
+
/* seconds only */
-#define USER_TIMECODE_SECONDS_ONLY 4
+ USER_TIMECODE_SECONDS_ONLY = 4,
+} eTimecodeStyles;
/* theme drawtypes */
-#define TH_MINIMAL 0
-#define TH_ROUNDSHADED 1
-#define TH_ROUNDED 2
-#define TH_OLDSKOOL 3
-#define TH_SHADED 4
+/* XXX: These are probably only for the old UI engine? */
+typedef enum eTheme_DrawTypes {
+ TH_MINIMAL = 0,
+ TH_ROUNDSHADED = 1,
+ TH_ROUNDED = 2,
+ TH_OLDSKOOL = 3,
+ TH_SHADED = 4
+} eTheme_DrawTypes;
/* ndof_flag (3D mouse options) */
-#define NDOF_SHOW_GUIDE (1 << 0)
-#define NDOF_FLY_HELICOPTER (1 << 1)
-#define NDOF_LOCK_HORIZON (1 << 2)
-/* the following might not need to be saved between sessions,
- * but they do need to live somewhere accessible... */
-#define NDOF_SHOULD_PAN (1 << 3)
-#define NDOF_SHOULD_ZOOM (1 << 4)
-#define NDOF_SHOULD_ROTATE (1 << 5)
-/* orbit navigation modes
- * only two options, so it's sort of a hybrid bool/enum
- * if ((U.ndof_flag & NDOF_ORBIT_MODE) == NDOF_OM_OBJECT)... */
-
-// #define NDOF_ORBIT_MODE (1 << 6)
-// #define NDOF_OM_TARGETCAMERA 0
-// #define NDOF_OM_OBJECT NDOF_ORBIT_MODE
-
-/* actually... users probably don't care about what the mode
- * is called, just that it feels right */
-/* zoom is up/down if this flag is set (otherwise forward/backward) */
-#define NDOF_ZOOM_UPDOWN (1 << 7)
-#define NDOF_ZOOM_INVERT (1 << 8)
-#define NDOF_ROTATE_INVERT_AXIS (1 << 9)
-#define NDOF_TILT_INVERT_AXIS (1 << 10)
-#define NDOF_ROLL_INVERT_AXIS (1 << 11)
-#define NDOF_PANX_INVERT_AXIS (1 << 12)
-#define NDOF_PANY_INVERT_AXIS (1 << 13)
-#define NDOF_PANZ_INVERT_AXIS (1 << 14)
-#define NDOF_TURNTABLE (1 << 15)
+typedef enum eNdof_Flag {
+ NDOF_SHOW_GUIDE = (1 << 0),
+ NDOF_FLY_HELICOPTER = (1 << 1),
+ NDOF_LOCK_HORIZON = (1 << 2),
+
+ /* the following might not need to be saved between sessions,
+ * but they do need to live somewhere accessible... */
+ NDOF_SHOULD_PAN = (1 << 3),
+ NDOF_SHOULD_ZOOM = (1 << 4),
+ NDOF_SHOULD_ROTATE = (1 << 5),
+
+ /* orbit navigation modes
+ * only two options, so it's sort of a hybrid bool/enum
+ * if ((U.ndof_flag & NDOF_ORBIT_MODE) == NDOF_OM_OBJECT)... */
+
+ // NDOF_ORBIT_MODE = (1 << 6),
+ // #define NDOF_OM_TARGETCAMERA 0
+ // #define NDOF_OM_OBJECT NDOF_ORBIT_MODE
+
+ /* actually... users probably don't care about what the mode
+ * is called, just that it feels right */
+ /* zoom is up/down if this flag is set (otherwise forward/backward) */
+ NDOF_ZOOM_UPDOWN = (1 << 7),
+ NDOF_ZOOM_INVERT = (1 << 8),
+ NDOF_ROTATE_INVERT_AXIS = (1 << 9),
+ NDOF_TILT_INVERT_AXIS = (1 << 10),
+ NDOF_ROLL_INVERT_AXIS = (1 << 11),
+ NDOF_PANX_INVERT_AXIS = (1 << 12),
+ NDOF_PANY_INVERT_AXIS = (1 << 13),
+ NDOF_PANZ_INVERT_AXIS = (1 << 14),
+ NDOF_TURNTABLE = (1 << 15),
+} eNdof_Flag;
/* compute_device_type */
-#define USER_COMPUTE_DEVICE_NONE 0
-#define USER_COMPUTE_DEVICE_OPENCL 1
-#define USER_COMPUTE_DEVICE_CUDA 2
+typedef enum eCompute_Device_Type {
+ USER_COMPUTE_DEVICE_NONE = 0,
+ USER_COMPUTE_DEVICE_OPENCL = 1,
+ USER_COMPUTE_DEVICE_CUDA = 2,
+} eCompute_Device_Type;
+
+
+typedef enum eMultiSample_Type {
+ USER_MULTISAMPLE_NONE = 0,
+ USER_MULTISAMPLE_2 = 2,
+ USER_MULTISAMPLE_4 = 4,
+ USER_MULTISAMPLE_8 = 8,
+ USER_MULTISAMPLE_16 = 16,
+} eMultiSample_Type;
+
+
#ifdef __cplusplus
}
diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h
index a3f4b362672..084496871bf 100644
--- a/source/blender/makesdna/DNA_view2d_types.h
+++ b/source/blender/makesdna/DNA_view2d_types.h
@@ -128,7 +128,7 @@ typedef struct View2D {
#define V2D_SCROLL_HORIZONTAL (V2D_SCROLL_TOP|V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)
/* scale markings - vertical */
#define V2D_SCROLL_SCALE_VERTICAL (1<<5)
- /* scale markings - horizontal */
+ /* scale markings - horizontal */
#define V2D_SCROLL_SCALE_HORIZONTAL (1<<6)
/* induce hiding of scrollbars - set by region drawing in response to size of region */
#define V2D_SCROLL_VERTICAL_HIDE (1<<7)
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 9da10381af0..c83b0bc366f 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -169,6 +169,7 @@ typedef struct View3D {
short view DNA_DEPRECATED;
struct Object *camera, *ob_centre;
+ rctf render_border;
struct ListBase bgpicbase;
struct BGpic *bgpic DNA_DEPRECATED; /* deprecated, use bgpicbase, only kept for do_versions(...) */
@@ -267,6 +268,7 @@ typedef struct View3D {
#define V3D_SHOW_CAMERAPATH 256
#define V3D_SHOW_BUNDLENAME 512
#define V3D_BACKFACE_CULLING 1024
+#define V3D_RENDER_BORDER 2048
/* View3D->around */
#define V3D_CENTER 0
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 780ca0b5878..2294abc0735 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -334,7 +334,7 @@ typedef struct wmOperator {
#define OPERATOR_FLAGS_ALL ((1<<5)-1)
/* sanity checks for debug mode only */
-#define OPERATOR_RETVAL_CHECK(ret) BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
+#define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
/* wmOperator flag */
#define OP_GRAB_POINTER 1
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index b3c10406d4c..8a14564f8a4 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -61,14 +61,14 @@ typedef struct World {
float ambr, ambg, ambb;
float pad2;
- unsigned int fastcol;
+ unsigned int fastcol;
/**
* Exposure= mult factor. unused now, but maybe back later. Kept in to be upward compat.
* New is exp/range control. linfac & logfac are constants... don't belong in
* file, but allocating 8 bytes for temp mem isn't useful either.
*/
- float exposure, exp, range;
+ float exposure, exp, range;
float linfac, logfac;
/**
@@ -129,7 +129,7 @@ typedef struct World {
struct PreviewImage *preview;
/* nodes */
- struct bNodeTree *nodetree;
+ struct bNodeTree *nodetree;
} World;
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index f5cf7e3ea3b..10c3b0bbee4 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -62,7 +62,7 @@ typedef long long __int64;
* - if you want a struct not to be in DNA file: add two hash marks above it (#<enter>#<enter>)
*
* Structure DNA data is added to each blender file and to each executable, this to detect
- * in .blend files new veriables in structs, changed array sizes, etc. It's also used for
+ * in .blend files new variables in structs, changed array sizes, etc. It's also used for
* converting endian and pointer size (32-64 bits)
* As an extra, Python uses a call to detect run-time the contents of a blender struct.
*
@@ -506,7 +506,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
}
}
-SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap)
+SDNA *DNA_sdna_from_data(const void *data, const int datalen, int do_endian_swap)
{
SDNA *sdna = MEM_mallocN(sizeof(*sdna), "sdna");
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 494cb875169..fa0b313a120 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -87,14 +87,14 @@ static const char *includefiles[] = {
"DNA_mesh_types.h",
"DNA_meshdata_types.h",
"DNA_modifier_types.h",
- "DNA_lattice_types.h",
+ "DNA_lattice_types.h",
"DNA_object_types.h",
"DNA_object_force.h",
"DNA_object_fluidsim.h",
"DNA_world_types.h",
"DNA_scene_types.h",
"DNA_view3d_types.h",
- "DNA_view2d_types.h",
+ "DNA_view2d_types.h",
"DNA_space_types.h",
"DNA_userdef_types.h",
"DNA_screen_types.h",
@@ -485,11 +485,15 @@ static int preprocess_include(char *maindata, int len)
}
/* do not copy when: */
- if (comment) ;
- else if (cp[0] == ' ' && cp[1] == ' ') ;
- else if (cp[-1] == '*' && cp[0] == ' ') ; /* pointers with a space */
-
- /* skip special keywords */
+ if (comment) {
+ /* pass */
+ }
+ else if (cp[0] == ' ' && cp[1] == ' ') {
+ /* pass */
+ }
+ else if (cp[-1] == '*' && cp[0] == ' ') {
+ /* pointers with a space */
+ } /* skip special keywords */
else if (strncmp("DNA_DEPRECATED", cp, 14) == 0) {
/* single values are skipped already, so decrement 1 less */
a -= 13;
@@ -997,7 +1001,7 @@ static int make_structDNA(char *baseDirectory, FILE *file)
/* FOR DEBUG */
if (debugSDNA > 1) {
int a, b;
-/* short *elem; */
+ /* short *elem; */
short num_types;
printf("nr_names %d nr_types %d nr_structs %d\n", nr_names, nr_types, nr_structs);
@@ -1028,7 +1032,9 @@ static int make_structDNA(char *baseDirectory, FILE *file)
if (debugSDNA > -1) printf("Writing file ... ");
- if (nr_names == 0 || nr_structs == 0) ;
+ if (nr_names == 0 || nr_structs == 0) {
+ /* pass */
+ }
else {
strcpy(str, "SDNA");
dna_write(file, str, 4);
@@ -1088,7 +1094,9 @@ static int make_structDNA(char *baseDirectory, FILE *file)
int a;
fp = fopen("padding.c", "w");
- if (fp == NULL) ;
+ if (fp == NULL) {
+ /* pass */
+ }
else {
/* add all include files defined in the global array */
@@ -1166,7 +1174,7 @@ int main(int argc, char **argv)
strcpy(baseDirectory, BASE_HEADER);
}
- fprintf(file, "unsigned char DNAstr[]= {\n");
+ fprintf(file, "const unsigned char DNAstr[] = {\n");
if (make_structDNA(baseDirectory, file)) {
/* error */
fclose(file);
@@ -1175,7 +1183,7 @@ int main(int argc, char **argv)
}
else {
fprintf(file, "};\n");
- fprintf(file, "int DNAlen = sizeof(DNAstr);\n");
+ fprintf(file, "const int DNAlen = sizeof(DNAstr);\n");
fclose(file);
}
@@ -1187,7 +1195,7 @@ int main(int argc, char **argv)
}
/* handy but fails on struct bounds which makesdna doesnt care about
- * unless structs are nested */
+ * with quite the same strictness as GCC does */
#if 0
/* include files for automatic dependencies */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 8e387dd4eba..5f667db4425 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -286,6 +286,7 @@ extern StructRNA RNA_KinematicConstraint;
extern StructRNA RNA_Lamp;
extern StructRNA RNA_LampSkySettings;
extern StructRNA RNA_LampTextureSlot;
+extern StructRNA RNA_LaplacianSmoothModifier;
extern StructRNA RNA_Lattice;
extern StructRNA RNA_LatticeModifier;
extern StructRNA RNA_LatticePoint;
@@ -456,6 +457,7 @@ extern StructRNA RNA_ShaderNodeMath;
extern StructRNA RNA_ShaderNodeMixRGB;
extern StructRNA RNA_ShaderNodeNormal;
extern StructRNA RNA_ShaderNodeOutput;
+extern StructRNA RNA_ShaderNodeScript;
extern StructRNA RNA_ShaderNodeRGB;
extern StructRNA RNA_ShaderNodeRGBCurve;
extern StructRNA RNA_ShaderNodeRGBToBW;
@@ -960,7 +962,9 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name);
}
/* check if the idproperty exists, for operators */
+int RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, int use_ghost);
int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop);
+int RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, int use_ghost);
int RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier);
int RNA_property_is_idprop(PropertyRNA *prop);
@@ -1029,6 +1033,13 @@ short RNA_type_to_ID_code(StructRNA *type);
StructRNA *ID_code_to_RNA_type(short idcode);
+#define RNA_POINTER_INVALIDATE(ptr) { \
+ /* this is checked for validity */ \
+ (ptr)->type = \
+ /* should not be needed but prevent bad pointer access, just in case */ \
+ (ptr)->id.data = NULL; \
+} (void)0
+
/* macro which inserts the function name */
#if defined __GNUC__ || defined __sun
# define RNA_warning(format, args ...) _RNA_warning("%s: " format "\n", __func__, ##args)
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 511999dfa37..87504dc6eb7 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -113,6 +113,7 @@ typedef enum PropertySubType {
PROP_BYTESTRING = 4, /* a string which should be represented as bytes
* in python, still NULL terminated though. */
PROP_TRANSLATE = 5, /* a string which should be translated */
+ PROP_PASSWORD = 6, /* a string which should not be displayed in UI */
/* numbers */
PROP_UNSIGNED = 13,
@@ -312,6 +313,7 @@ typedef enum FunctionFlag {
FUNC_USE_CONTEXT = 4,
FUNC_USE_REPORTS = 8,
FUNC_USE_SELF_ID = 2048,
+ FUNC_ALLOW_WRITE = 4096,
/* registering */
FUNC_REGISTER = 16,
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index af857b61e26..7a3bb230a78 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -61,7 +61,6 @@
/* Replace if different */
#define TMP_EXT ".tmp"
-
/* copied from BLI_file_older */
#include <sys/stat.h>
static int file_older(const char *file1, const char *file2)
@@ -76,6 +75,24 @@ static int file_older(const char *file1, const char *file2)
}
static const char *makesrna_path = NULL;
+/* forward declarations */
+static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc,
+ const char *name_override, int close_prototype);
+
+/* helpers */
+#define WRITE_COMMA \
+ { \
+ if (!first) \
+ fprintf(f, ", "); \
+ first = 0; \
+ } (void)0
+
+#define WRITE_PARAM(param) \
+ { \
+ WRITE_COMMA; \
+ fprintf(f, param); \
+ }
+
static int replace_if_different(char *tmpfile, const char *dep_files[])
{
/* return 0; *//* use for testing had edited rna */
@@ -212,6 +229,8 @@ static const char *rna_safe_id(const char *id)
return "default_value";
else if (strcmp(id, "operator") == 0)
return "operator_value";
+ else if (strcmp(id, "new") == 0)
+ return "create";
return id;
}
@@ -322,13 +341,26 @@ static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp))
fprintf(f, " ID *id= ptr->id.data;\n");
}
+static void rna_construct_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
+{
+ snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
+}
+
+static void rna_construct_wrapper_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
+{
+ if (type == NULL || type[0] == '\0')
+ snprintf(buffer, size, "%s_%s", structname, propname);
+ else
+ snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
+}
+
static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type)
{
AllocDefRNA *alloc;
char buffer[2048];
char *result;
- snprintf(buffer, sizeof(buffer), "%s_%s_%s", structname, propname, type);
+ rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type);
result = MEM_callocN(sizeof(char) * strlen(buffer) + 1, "rna_alloc_function_name");
strcpy(result, buffer);
@@ -627,17 +659,17 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
"get_length");
fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
- fprintf(f, " for (i=0; i<len; i++) {\n");
+ fprintf(f, " for (i=0; i < len; i++) {\n");
MEM_freeN(lenfunc);
}
else {
fprintf(f, " int i;\n\n");
- fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength);
+ fprintf(f, " for (i=0; i < %u; i++) {\n", prop->totarraylength);
}
if (dp->dnaarraylength == 1) {
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
- fprintf(f, " values[i] = %s((data->%s & (%d<<i)) != 0);\n",
+ fprintf(f, " values[i] = %s((data->%s & (%d << i)) != 0);\n",
(dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
}
else {
@@ -653,7 +685,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
fprintf(f, ") != 0);\n");
}
else if (rna_color_quantize(prop, dp)) {
- fprintf(f, " values[i] = (%s)(data->%s[i]*(1.0f/255.0f));\n",
+ fprintf(f, " values[i] = (%s)(data->%s[i]*(1.0f / 255.0f));\n",
rna_type_type(prop), dp->dnaname);
}
else if (dp->dnatype) {
@@ -878,20 +910,20 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
rna_clamp_value_range(f, prop);
- fprintf(f, " for (i=0; i<len; i++) {\n");
+ fprintf(f, " for (i=0; i < len; i++) {\n");
MEM_freeN(lenfunc);
}
else {
fprintf(f, " int i;\n\n");
rna_clamp_value_range(f, prop);
- fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength);
+ fprintf(f, " for (i=0; i < %u; i++) {\n", prop->totarraylength);
}
if (dp->dnaarraylength == 1) {
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
fprintf(f, " if (%svalues[i]) data->%s |= (%d<<i);\n",
(dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
- fprintf(f, " else data->%s &= ~(%d<<i);\n", dp->dnaname, dp->booleanbit);
+ fprintf(f, " else data->%s &= ~(%d << i);\n", dp->dnaname, dp->booleanbit);
}
else {
fprintf(f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
@@ -1015,9 +1047,9 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
else {
rna_print_data_get(f, dp);
if (dp->dnalengthname)
- fprintf(f, " return (data->%s == NULL)? 0: data->%s;\n", dp->dnaname, dp->dnalengthname);
+ fprintf(f, " return (data->%s == NULL) ? 0 : data->%s;\n", dp->dnaname, dp->dnalengthname);
else
- fprintf(f, " return (data->%s == NULL)? 0: %d;\n", dp->dnaname, dp->dnalengthfixed);
+ fprintf(f, " return (data->%s == NULL) ? 0 : %d;\n", dp->dnaname, dp->dnalengthfixed);
}
fprintf(f, "}\n\n");
}
@@ -1102,8 +1134,8 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
return NULL;
/* only supported in case of standard next functions */
- if (strcmp(nextfunc, "rna_iterator_array_next") == 0) ;
- else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) ;
+ if (strcmp(nextfunc, "rna_iterator_array_next") == 0) {}
+ else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {}
else return NULL;
}
@@ -1372,9 +1404,12 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
const char *nextfunc = (const char *)cprop->next;
- if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) ;
- else if (dp->dnalengthname || dp->dnalengthfixed)
+ if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) {
+ /* pass */
+ }
+ else if (dp->dnalengthname || dp->dnalengthfixed) {
cprop->length = (void *)rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length);
+ }
/* test if we can allow raw array access, if it is using our standard
* array get/next function, we can be sure it is an actual array */
@@ -1437,15 +1472,15 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
{
if (!prop->arraydimension) {
fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
- /*fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); */
+ fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
}
else if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength);
- /*fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->arraylength); */
+ fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->totarraylength);
}
else {
fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
- /*fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func); */
+ fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func);
}
break;
}
@@ -1453,15 +1488,15 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
{
if (!prop->arraydimension) {
fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
- /*fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func); */
+ fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
}
else if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength);
- /*fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->arraylength); */
+ fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->totarraylength);
}
else {
fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
- /*fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);\n", func); */
+ fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);", func);
}
break;
}
@@ -1482,7 +1517,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
}
fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
- /*fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); */
+ fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
break;
}
@@ -1496,7 +1531,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func);
fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
- /*fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func); */
+ fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func);
break;
}
@@ -1508,19 +1543,38 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
}
case PROP_COLLECTION:
{
+ CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func);
fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func);
fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func);
- /*fprintf(f, "int %slength(PointerRNA *ptr);\n", func); */
- /*fprintf(f, "void %slookup_int(PointerRNA *ptr, int key, StructRNA **type);\n", func); */
- /*fprintf(f, "void %slookup_string(PointerRNA *ptr, const char *key, StructRNA **type);\n", func); */
+ if (cprop->length)
+ fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
+ if (cprop->lookupint)
+ fprintf(f, "int %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func);
+ if (cprop->lookupstring)
+ fprintf(f, "int %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n", func);
break;
}
}
+ if (prop->getlength) {
+ char funcname[2048];
+ rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, prop->identifier, "get_length");
+ fprintf(f, "int %s(PointerRNA *ptr, int *arraylen);\n", funcname);
+ }
+
fprintf(f, "\n");
}
+static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
+{
+ FunctionRNA *func = dfunc->func;
+ char funcname[2048];
+
+ rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
+ rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 1);
+}
+
static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
{
PropertyRNA *prop;
@@ -1540,26 +1594,50 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
switch (prop->type) {
case PROP_BOOLEAN:
{
- if (!prop->arraydimension)
- fprintf(f, "\tinline bool %s(void);", rna_safe_id(prop->identifier));
- else if (prop->totarraylength)
- fprintf(f, "\tinline Array<int, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier));
+ if (!prop->arraydimension) {
+ fprintf(f, "\tinline bool %s(void);\n", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier));
+ }
+ else if (prop->totarraylength) {
+ fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength);
+ }
+ else if (prop->getlength) {
+ fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_INT:
{
- if (!prop->arraydimension)
- fprintf(f, "\tinline int %s(void);", rna_safe_id(prop->identifier));
- else if (prop->totarraylength)
- fprintf(f, "\tinline Array<int, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier));
+ if (!prop->arraydimension) {
+ fprintf(f, "\tinline int %s(void);\n", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier));
+ }
+ else if (prop->totarraylength) {
+ fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength);
+ }
+ else if (prop->getlength) {
+ fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_FLOAT:
{
- if (!prop->arraydimension)
- fprintf(f, "\tinline float %s(void);", rna_safe_id(prop->identifier));
- else if (prop->totarraylength)
- fprintf(f, "\tinline Array<float, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier));
+ if (!prop->arraydimension) {
+ fprintf(f, "\tinline float %s(void);\n", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(float value);", rna_safe_id(prop->identifier));
+ }
+ else if (prop->totarraylength) {
+ fprintf(f, "\tinline Array<float, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(float values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength);
+ }
+ else if (prop->getlength) {
+ fprintf(f, "\tinline DynamicArray<float> %s(void);\n", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(float values[]);", rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_ENUM:
@@ -1578,12 +1656,14 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
fprintf(f, "\t};\n");
}
- fprintf(f, "\tinline %s_enum %s(void);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline %s_enum %s(void);\n", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(%s_enum value);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier));
break;
}
case PROP_STRING:
{
fprintf(f, "\tinline std::string %s(void);", rna_safe_id(prop->identifier));
+ fprintf(f, "\tinline void %s(const std::string& value);", rna_safe_id(prop->identifier));
break;
}
case PROP_POINTER:
@@ -1599,13 +1679,19 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
case PROP_COLLECTION:
{
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
+ const char *collection_funcs = "DefaultCollectionFunctions";
+
+ if (!(dp->prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN)) && cprop->property.srna)
+ collection_funcs = (char*)cprop->property.srna;
if (cprop->item_type)
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (const char *)cprop->item_type, srna->identifier,
- rna_safe_id(prop->identifier));
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, (const char *)cprop->item_type, srna->identifier,
+ rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"),
+ (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
else
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier,
- rna_safe_id(prop->identifier));
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, "UnknownType", srna->identifier,
+ rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"),
+ (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
break;
}
}
@@ -1613,6 +1699,96 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
fprintf(f, "\n");
}
+static const char *rna_parameter_type_cpp_name(PropertyRNA *prop)
+{
+ if (prop->type == PROP_POINTER) {
+ /* for cpp api we need to use RNA structures names for pointers */
+ PointerPropertyRNA *pprop = (PointerPropertyRNA *) prop;
+
+ return (const char *) pprop->type;
+ }
+ else {
+ return rna_parameter_type_name(prop);
+ }
+}
+
+static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc,
+ const char *namespace, int close_prototype)
+{
+ PropertyDefRNA *dp;
+ FunctionRNA *func = dfunc->func;
+
+ int first = 1;
+ const char *retval_type = "void";
+
+ if (func->c_ret) {
+ dp = rna_find_parameter_def(func->c_ret);
+ retval_type = rna_parameter_type_cpp_name(dp->prop);
+ }
+
+ if (namespace && namespace[0])
+ fprintf(f, "\tinline %s %s::%s(", retval_type, namespace, rna_safe_id(func->identifier));
+ else
+ fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier));
+
+ if (func->flag & FUNC_USE_MAIN)
+ WRITE_PARAM("void *main");
+
+ if (func->flag & FUNC_USE_CONTEXT)
+ WRITE_PARAM("Context C");
+
+ for (dp = dfunc->cont.properties.first; dp; dp = dp->next) {
+ int type, flag, pout;
+ const char *ptrstr;
+
+ if (dp->prop == func->c_ret)
+ continue;
+
+ type = dp->prop->type;
+ flag = dp->prop->flag;
+ pout = (flag & PROP_OUTPUT);
+
+ if (type == PROP_POINTER)
+ ptrstr = "";
+ else if ((type == PROP_POINTER) && (flag & PROP_RNAPTR) && !(flag & PROP_THICK_WRAP))
+ ptrstr = "*";
+ else if (type == PROP_POINTER || dp->prop->arraydimension)
+ ptrstr = "*";
+ else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
+ ptrstr = "";
+ else
+ ptrstr = pout ? "*" : "";
+
+ WRITE_COMMA;
+
+ if (flag & PROP_DYNAMIC)
+ fprintf(f, "int %s%s_len, ", (flag & PROP_OUTPUT) ? "*" : "", dp->prop->identifier);
+
+ if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension)
+ fprintf(f, "%s %s[%u]", rna_parameter_type_cpp_name(dp->prop),
+ rna_safe_id(dp->prop->identifier), dp->prop->totarraylength);
+ else
+ fprintf(f, "%s %s%s", rna_parameter_type_cpp_name(dp->prop),
+ ptrstr, rna_safe_id(dp->prop->identifier));
+ }
+
+ fprintf(f, ")");
+ if (close_prototype)
+ fprintf(f, ";\n");
+}
+
+static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
+{
+ FunctionRNA *func = dfunc->func;
+
+ if (!dfunc->call)
+ return;
+
+ fprintf(f, "\n\t/* %s */\n", func->description);
+
+ rna_def_struct_function_prototype_cpp(f, srna, dfunc, NULL, 1);
+}
+
static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
{
PropertyRNA *prop;
@@ -1630,6 +1806,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
else if (prop->totarraylength)
fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength,
rna_safe_id(prop->identifier));
+ else if (prop->getlength)
+ fprintf(f, "\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier,
+ rna_safe_id(prop->identifier));
break;
}
case PROP_INT:
@@ -1639,6 +1818,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
else if (prop->totarraylength)
fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength,
rna_safe_id(prop->identifier));
+ else if (prop->getlength)
+ fprintf(f, "\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier,
+ rna_safe_id(prop->identifier));
break;
}
case PROP_FLOAT:
@@ -1648,6 +1830,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
else if (prop->totarraylength)
fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength,
rna_safe_id(prop->identifier));
+ else if (prop->getlength)
+ fprintf(f, "\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier,
+ rna_safe_id(prop->identifier));
break;
}
case PROP_ENUM:
@@ -1680,10 +1865,13 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
if (cprop->type)
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (const char *)cprop->type, srna->identifier,
- prop->identifier);
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, srna->identifier,
+ prop->identifier, (cprop->length ? "TRUE" : "FALSE"),
+ (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
else
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier,
+ prop->identifier, (cprop->length ? "TRUE" : "FALSE"),
+ (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
#endif
break;
}
@@ -1692,6 +1880,181 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
fprintf(f, "\n");
}
+static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
+{
+ PropertyDefRNA *dp;
+ StructDefRNA *dsrna;
+ FunctionRNA *func = dfunc->func;
+ char funcname[2048];
+
+ int first = 1;
+
+ rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
+
+ fprintf(f, "%s(", funcname);
+
+ dsrna = rna_find_struct_def(srna);
+
+ if (func->flag & FUNC_USE_SELF_ID)
+ WRITE_PARAM("(::ID *) ptr.id.data");
+
+ if ((func->flag & FUNC_NO_SELF) == 0) {
+ WRITE_COMMA;
+ if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
+ else fprintf(f, "(::%s *) this->ptr.data", srna->identifier);
+ }
+
+ if (func->flag & FUNC_USE_MAIN)
+ WRITE_PARAM("(::Main *) main");
+
+ if (func->flag & FUNC_USE_CONTEXT)
+ WRITE_PARAM("(::bContext *) C.ptr.data");
+
+ if (func->flag & FUNC_USE_REPORTS)
+ WRITE_PARAM("NULL");
+
+ dp = dfunc->cont.properties.first;
+ for (; dp; dp = dp->next) {
+ if (dp->prop == func->c_ret)
+ continue;
+
+ WRITE_COMMA;
+
+ if (dp->prop->flag & PROP_DYNAMIC)
+ fprintf(f, "%s_len, ", dp->prop->identifier);
+
+ if (dp->prop->type == PROP_POINTER)
+ if ((dp->prop->flag & PROP_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP))
+ fprintf(f, "(::%s *) &%s.ptr", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier));
+ else
+ fprintf(f, "(::%s *) %s.ptr.data", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier));
+ else
+ fprintf(f, "%s", rna_safe_id(dp->prop->identifier));
+ }
+
+ fprintf(f, ");\n");
+}
+
+static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
+{
+ PropertyDefRNA *dp;
+ PointerPropertyRNA *pprop;
+
+ FunctionRNA *func = dfunc->func;
+
+ if (!dfunc->call)
+ return;
+
+ rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0);
+
+ fprintf(f, " {\n");
+
+ if (func->c_ret) {
+ dp = rna_find_parameter_def(func->c_ret);
+
+ if (dp->prop->type == PROP_POINTER) {
+ pprop = (PointerPropertyRNA *) dp->prop;
+
+ fprintf(f, "\t\tPointerRNA result;\n");
+
+ if ((dp->prop->flag & PROP_RNAPTR) == 0) {
+ StructRNA *ret_srna = rna_find_struct((const char *) pprop->type);
+ fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop));
+ rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
+ if (ret_srna->flag & STRUCT_ID)
+ fprintf(f, "\t\tRNA_id_pointer_create((::ID *) retdata, &result);\n");
+ else
+ fprintf(f, "\t\tRNA_pointer_create((::ID *) ptr.id.data, &RNA_%s, retdata, &result);\n", (const char *) pprop->type);
+ }
+ else {
+ fprintf(f, "\t\tresult = ");
+ rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
+ }
+
+ fprintf(f, "\t\treturn %s(result);\n", (const char *) pprop->type);
+ }
+ else {
+ fprintf(f, "\t\treturn ");
+ rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
+ }
+ }
+ else {
+ fprintf(f, "\t\t");
+ rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
+ }
+
+ fprintf(f, "\t}\n\n");
+}
+
+static void rna_def_property_wrapper_funcs(FILE *f, StructDefRNA *dsrna, PropertyDefRNA *dp)
+{
+ if (dp->prop->getlength) {
+ char funcname[2048];
+ rna_construct_wrapper_function_name(funcname, sizeof(funcname), dsrna->srna->identifier, dp->prop->identifier, "get_length");
+ fprintf(f, "int %s(PointerRNA *ptr, int *arraylen)\n", funcname);
+ fprintf(f, "{\n");
+ fprintf(f, "\treturn %s(ptr, arraylen);\n", rna_function_string(dp->prop->getlength));
+ fprintf(f, "}\n\n");
+ }
+}
+
+static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
+{
+ StructRNA *srna = dsrna->srna;
+ FunctionRNA *func = dfunc->func;
+ PropertyDefRNA *dparm;
+
+ int first;
+ char funcname[2048];
+
+ if (!dfunc->call)
+ return;
+
+ rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
+
+ rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 0);
+
+ fprintf(f, "\n{\n");
+
+ if (func->c_ret)
+ fprintf(f, "\treturn %s(", dfunc->call);
+ else
+ fprintf(f, "\t%s(", dfunc->call);
+
+ first = 1;
+
+ if (func->flag & FUNC_USE_SELF_ID)
+ WRITE_PARAM("_selfid");
+
+ if ((func->flag & FUNC_NO_SELF) == 0)
+ WRITE_PARAM("_self");
+
+ if (func->flag & FUNC_USE_MAIN)
+ WRITE_PARAM("bmain");
+
+ if (func->flag & FUNC_USE_CONTEXT)
+ WRITE_PARAM("C");
+
+ if (func->flag & FUNC_USE_REPORTS)
+ WRITE_PARAM("reports");
+
+ dparm = dfunc->cont.properties.first;
+ for (; dparm; dparm = dparm->next) {
+ if (dparm->prop == func->c_ret)
+ continue;
+
+ WRITE_COMMA;
+
+ if (dparm->prop->flag & PROP_DYNAMIC)
+ fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier);
+ else
+ fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
+ }
+
+ fprintf(f, ");\n");
+ fprintf(f, "}\n\n");
+}
+
static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
{
StructRNA *srna;
@@ -1741,6 +2104,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
/* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */
else if (type == PROP_POINTER || dparm->prop->arraydimension)
ptrstr = "*";
+ else if ((type == PROP_POINTER) && (flag & PROP_RNAPTR) && !(flag & PROP_THICK_WRAP))
+ ptrstr = "*";
/* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
* but type name for string props is already char*, so leave empty */
else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
@@ -1792,6 +2157,10 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
ptrstr = "**";
valstr = "*";
}
+ else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) {
+ ptrstr = "**";
+ valstr = "*";
+ }
else if (type == PROP_POINTER || dparm->prop->arraydimension) {
ptrstr = "*";
valstr = "";
@@ -1991,6 +2360,7 @@ static const char *rna_property_subtypename(PropertySubType type)
case PROP_COORDS: return "PROP_COORDS";
case PROP_LAYER: return "PROP_LAYER";
case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER";
+ case PROP_PASSWORD: return "PROP_PASSWORD";
default: {
/* in case we don't have a type preset that includes the subtype */
if (RNA_SUBTYPE_UNIT(type)) {
@@ -2107,7 +2477,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna,
fprintf(f, "\n");
}
-static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionDefRNA *dfunc, FILE *f)
+static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, const char *name_override, int close_prototype)
{
FunctionRNA *func;
PropertyDefRNA *dparm;
@@ -2138,7 +2508,10 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S
fprintf(f, "void ");
/* function name */
- fprintf(f, "%s(", dfunc->call);
+ if (name_override == NULL || name_override[0] == '\0')
+ fprintf(f, "%s(", dfunc->call);
+ else
+ fprintf(f, "%s(", name_override);
first = 1;
@@ -2147,7 +2520,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S
fprintf(f, "struct ID *_selfid");
first = 0;
}
-
+
if ((func->flag & FUNC_NO_SELF) == 0) {
if (!first) fprintf(f, ", ");
if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
@@ -2200,17 +2573,19 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S
if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension)
fprintf(f, "%s%s %s[%u]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
- dparm->prop->identifier, dparm->prop->totarraylength);
+ rna_safe_id(dparm->prop->identifier), dparm->prop->totarraylength);
else
fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
- ptrstr, dparm->prop->identifier);
+ ptrstr, rna_safe_id(dparm->prop->identifier));
}
- fprintf(f, ");\n");
+ fprintf(f, ")");
+ if (close_prototype)
+ fprintf(f, ";\n");
}
-static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
+static void rna_generate_static_function_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
{
FunctionRNA *func;
FunctionDefRNA *dfunc;
@@ -2225,7 +2600,50 @@ static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA
first = 0;
}
- rna_generate_static_parameter_prototypes(brna, srna, dfunc, f);
+ rna_generate_static_parameter_prototypes(f, srna, dfunc, NULL, 1);
+ }
+ }
+
+ fprintf(f, "\n");
+}
+
+static void rna_generate_struct_prototypes(FILE *f)
+{
+ StructDefRNA *ds;
+ PropertyDefRNA *dp;
+ FunctionDefRNA *dfunc;
+ const char *structures[2048];
+ int all_structures = 0;
+
+ /* structures definitions */
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
+ if (dfunc->call) {
+ for (dp = dfunc->cont.properties.first; dp; dp = dp->next) {
+ if (dp->prop->type == PROP_POINTER) {
+ int a, found = 0;
+ const char *struct_name = rna_parameter_type_name(dp->prop);
+
+ for (a = 0; a < all_structures; a++) {
+ if (strcmp(struct_name, structures[a]) == 0) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found == 0) {
+ fprintf(f, "struct %s;\n", struct_name);
+
+ if (all_structures >= sizeof(structures) / sizeof(structures[0])) {
+ printf("Array size to store all structures names is too small\n");
+ exit(1);
+ }
+
+ structures[all_structures++] = struct_name;
+ }
+ }
+ }
+ }
}
}
@@ -2791,8 +3209,13 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
if (!filename || ds->filename == filename) {
- for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ rna_def_property_wrapper_funcs(f, ds, dp);
+
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
+ rna_def_function_wrapper_funcs(f, ds, dfunc);
rna_def_function_funcs(f, ds, dfunc);
+ }
rna_generate_static_function_prototypes(brna, ds->srna, f);
}
@@ -2816,6 +3239,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
StructDefRNA *ds;
PropertyDefRNA *dp;
StructRNA *srna;
+ FunctionDefRNA *dfunc;
fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n");
fprintf(f, "#define __RNA_BLENDER_H__\n\n");
@@ -2853,6 +3277,9 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
for (dp = ds->cont.properties.first; dp; dp = dp->next)
rna_def_property_funcs_header(f, ds->srna, dp);
+
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ rna_def_function_funcs_header(f, ds->srna, dfunc);
}
fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n");
@@ -2868,43 +3295,141 @@ static const char *cpp_classes = ""
"namespace BL {\n"
"\n"
"#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
-" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; }\n"
+" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; } \\\n"
+" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
" inline Array<int,size> sname::identifier(void) \\\n"
-" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
+" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
+" inline void sname::identifier(int values[size]) \\\n"
+" { sname##_##identifier##_set(&ptr, values); } \\\n"
+"\n"
+"#define BOOLEAN_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
+" inline DynamicArray<int> sname::identifier(void) { \\\n"
+" int arraylen[3]; \\\n"
+" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
+" DynamicArray<int> ar(len); \\\n"
+" sname##_##identifier##_get(&ptr, ar.data); \\\n"
+" return ar; } \\\n"
+" inline void sname::identifier(int values[]) \\\n"
+" { sname##_##identifier##_set(&ptr, values); } \\\n"
"\n"
"#define INT_PROPERTY(sname, identifier) \\\n"
-" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
+" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
+" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
" inline Array<int,size> sname::identifier(void) \\\n"
-" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
+" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
+" inline void sname::identifier(int values[size]) \\\n"
+" { sname##_##identifier##_set(&ptr, values); } \\\n"
+"\n"
+"#define INT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
+" inline DynamicArray<int> sname::identifier(void) { \\\n"
+" int arraylen[3]; \\\n"
+" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
+" DynamicArray<int> ar(len); \\\n"
+" sname##_##identifier##_get(&ptr, ar.data); \\\n"
+" return ar; } \\\n"
+" inline void sname::identifier(int values[]) \\\n"
+" { sname##_##identifier##_set(&ptr, values); } \\\n"
"\n"
"#define FLOAT_PROPERTY(sname, identifier) \\\n"
-" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
+" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
+" inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
" inline Array<float,size> sname::identifier(void) \\\n"
-" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
+" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
+" inline void sname::identifier(float values[size]) \\\n"
+" { sname##_##identifier##_set(&ptr, values); } \\\n"
+"\n"
+"#define FLOAT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
+" inline DynamicArray<float> sname::identifier(void) { \\\n"
+" int arraylen[3]; \\\n"
+" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
+" DynamicArray<float> ar(len); \\\n"
+" sname##_##identifier##_get(&ptr, ar.data); \\\n"
+" return ar; } \\\n"
+" inline void sname::identifier(float values[]) \\\n"
+" { sname##_##identifier##_set(&ptr, values); } \\\n"
"\n"
"#define ENUM_PROPERTY(type, sname, identifier) \\\n"
-" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); }\n"
+" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); } \\\n"
+" inline void sname::identifier(sname::type value) { sname##_##identifier##_set(&ptr, value); }\n"
"\n"
"#define STRING_PROPERTY(sname, identifier) \\\n"
" inline std::string sname::identifier(void) { \\\n"
" int len= sname##_##identifier##_length(&ptr); \\\n"
" std::string str; str.resize(len); \\\n"
" sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
+" inline void sname::identifier(const std::string& value) { \\\n"
+" sname##_##identifier##_set(&ptr, value.c_str()); } \\\n"
"\n"
"#define POINTER_PROPERTY(type, sname, identifier) \\\n"
" inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
"\n"
-"#define COLLECTION_PROPERTY(type, sname, identifier) \\\n"
+"#define COLLECTION_PROPERTY_LENGTH_FALSE(sname, identifier) \\\n"
+" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
+" { \\\n"
+" CollectionPropertyIterator iter; \\\n"
+" int length = 0; \\\n"
+" sname##_##identifier##_begin(&iter, ptr); \\\n"
+" while (iter.valid) { \\\n"
+" sname##_##identifier##_next(&iter); \\\n"
+" ++length; \\\n"
+" } \\\n"
+" sname##_##identifier##_end(&iter); \\\n"
+" return length; \\\n"
+" } \n"
+"#define COLLECTION_PROPERTY_LENGTH_TRUE(sname, identifier) \\\n"
+" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
+" { return sname##_##identifier##_length(ptr); } \n"
+"\n"
+"#define COLLECTION_PROPERTY_LOOKUP_INT_FALSE(sname, identifier) \\\n"
+" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n"
+" { \\\n"
+" CollectionPropertyIterator iter; \\\n"
+" int i = 0, found = 0; \\\n"
+" sname##_##identifier##_begin(&iter, ptr); \\\n"
+" while (iter.valid) { \\\n"
+" if (i == key) { \\\n"
+" *r_ptr = iter.ptr; \\\n"
+" found = 1; \\\n"
+" break; \\\n"
+" } \\\n"
+" sname##_##identifier##_next(&iter); \\\n"
+" ++i; \\\n"
+" } \\\n"
+" sname##_##identifier##_end(&iter); \\\n"
+" if (!found) \\\n"
+" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
+" return found; \\\n"
+" } \n"
+"#define COLLECTION_PROPERTY_LOOKUP_INT_TRUE(sname, identifier) \\\n"
+" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n"
+" { return sname##_##identifier##_lookup_int(ptr, key, r_ptr); } \n"
+"\n"
+"#define COLLECTION_PROPERTY_LOOKUP_STRING_FALSE(sname, identifier) \\\n"
+" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n"
+" { \\\n"
+" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
+" return 0; \\\n"
+" } \n"
+"#define COLLECTION_PROPERTY_LOOKUP_STRING_TRUE(sname, identifier) \\\n"
+" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n"
+" { return sname##_##identifier##_lookup_string(ptr, key, r_ptr); } \n"
+"\n"
+"#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, has_lookup_int, has_lookup_string) \\\n"
" typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
" sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n"
+" COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n"
+" COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n"
+" COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n"
" Collection<sname, type, sname##_##identifier##_begin, \\\n"
-" sname##_##identifier##_next, sname##_##identifier##_end> identifier;\n"
+" sname##_##identifier##_next, sname##_##identifier##_end, \\\n"
+" sname##_##identifier##_length_wrap, \\\n"
+" sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap, collection_funcs> identifier;\n"
"\n"
"class Pointer {\n"
"public:\n"
@@ -2923,7 +3448,7 @@ static const char *cpp_classes = ""
"public:\n"
" T data[Tsize];\n"
"\n"
-" Array() {}\n"
+" Array() {}\n"
" Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n"
" const Array<T, Tsize>& operator=(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); "
"return *this; }\n"
@@ -2931,9 +3456,36 @@ static const char *cpp_classes = ""
" operator T*() { return data; }\n"
"};\n"
"\n"
+"template<typename T>\n"
+"class DynamicArray {\n"
+"public:\n"
+" T *data;\n"
+" int length;\n"
+"\n"
+" DynamicArray() : data(NULL), length(0) {}\n"
+" DynamicArray(int new_length) : data(NULL), length(new_length) { data = (float*)malloc(sizeof(T) * new_length); }\n"
+" DynamicArray(const DynamicArray<T>& other) { copy_from(other); }\n"
+" const DynamicArray<T>& operator=(const DynamicArray<T>& other) { copy_from(other); return *this; }\n"
+"\n"
+" ~DynamicArray() { if (data) free(data); }\n"
+"\n"
+" operator T*() { return data; }\n"
+"\n"
+"protected:\n"
+" void copy_from(const DynamicArray<T>& other) {\n"
+" if (data) free(data);\n"
+" data = (float*)malloc(sizeof(T) * other.length);\n"
+" memcpy(data, other.data, sizeof(T) * other.length);\n"
+" length = other.length;\n"
+" }\n"
+"};\n"
+"\n"
"typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n"
"typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n"
"typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n"
+"typedef int (*TLengthFunc)(PointerRNA *ptr);\n"
+"typedef int (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n"
+"typedef int (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n"
"\n"
"template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
"class CollectionIterator {\n"
@@ -2964,26 +3516,97 @@ static const char *cpp_classes = ""
" bool init;\n"
"};\n"
"\n"
-"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
-"class Collection {\n"
+"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n"
+" TLengthFunc Tlength, TLookupIntFunc Tlookup_int, TLookupStringFunc Tlookup_string,\n"
+" typename Tcollection_funcs>\n"
+"class Collection : public Tcollection_funcs {\n"
"public:\n"
-" Collection(const PointerRNA &p) : ptr(p) {}\n"
+" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
"\n"
" void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n"
" { iter.begin(ptr); }\n"
" CollectionIterator<T, Tbegin, Tnext, Tend> end()\n"
" { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n"
+""
+" int length()\n"
+" { return Tlength(&ptr); }\n"
+" T operator[](int key)\n"
+" { PointerRNA r_ptr; Tlookup_int(&ptr, key, &r_ptr); return T(r_ptr); }\n"
+" T operator[](const std::string &key)\n"
+" { PointerRNA r_ptr; Tlookup_string(&ptr, key.c_str(), &r_ptr); return T(r_ptr); }\n"
"\n"
"private:\n"
" PointerRNA ptr;\n"
"};\n"
+"\n"
+"class DefaultCollectionFunctions {\n"
+"public:\n"
+" DefaultCollectionFunctions(const PointerRNA &p) {}\n"
+"};\n"
+"\n"
"\n";
+static int rna_is_collection_prop(PropertyRNA *prop)
+{
+ if (!(prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN)))
+ if (prop->type == PROP_COLLECTION)
+ return 1;
+
+ return 0;
+}
+
+static int rna_is_collection_functions_struct(const char **collection_structs, const char *struct_name)
+{
+ int a = 0, found = 0;
+
+ while (collection_structs[a]) {
+ if (!strcmp(collection_structs[a], struct_name)) {
+ found = 1;
+ break;
+ }
+ a++;
+ }
+
+ return found;
+}
+
+static void rna_generate_header_class_cpp(StructDefRNA *ds, FILE *f)
+{
+ StructRNA *srna = ds->srna;
+ PropertyDefRNA *dp;
+ FunctionDefRNA *dfunc;
+
+ fprintf(f, "/**************** %s ****************/\n\n", srna->name);
+
+ fprintf(f, "class %s : public %s {\n", srna->identifier, (srna->base) ? srna->base->identifier : "Pointer");
+ fprintf(f, "public:\n");
+ fprintf(f, "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)", srna->identifier,
+ (srna->base) ? srna->base->identifier : "Pointer");
+ for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ if (rna_is_collection_prop(dp->prop))
+ fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier);
+ fprintf(f, "\n\t\t{}\n\n");
+
+ for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ rna_def_property_funcs_header_cpp(f, ds->srna, dp);
+
+ fprintf(f, "\n");
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ rna_def_struct_function_header_cpp(f, srna, dfunc);
+
+ fprintf(f, "};\n\n");
+}
+
static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
{
StructDefRNA *ds;
PropertyDefRNA *dp;
StructRNA *srna;
+ FunctionDefRNA *dfunc;
+ const char *first_collection_func_struct = NULL;
+ const char *collection_func_structs[256] = {NULL};
+ int all_collection_func_structs = 0;
+ int max_collection_func_structs = sizeof(collection_func_structs) / sizeof(collection_func_structs[0]) - 1;
fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n");
fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n");
@@ -3000,38 +3623,86 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
fprintf(f, "/**************** Declarations ****************/\n\n");
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
fprintf(f, "class %s;\n", ds->srna->identifier);
+ }
fprintf(f, "\n");
+ /* first get list of all structures used as collection functions, so they'll be declared first */
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
+ if (rna_is_collection_prop(dp->prop)) {
+ PropertyRNA *prop = dp->prop;
+
+ if (prop->srna) {
+ /* store name of structure which first uses custom functions for collections */
+ if (first_collection_func_struct == NULL)
+ first_collection_func_struct = ds->srna->identifier;
+
+ if (!rna_is_collection_functions_struct(collection_func_structs, (char*)prop->srna)) {
+ if (all_collection_func_structs >= max_collection_func_structs) {
+ printf("Array size to store all collection structures names is too small\n");
+ exit(1);
+ }
+
+ collection_func_structs[all_collection_func_structs++] = (char*)prop->srna;
+ }
+ }
+ }
+ }
+ }
+
+ /* declare all structures in such order:
+ * - first N structures which doesn't use custom functions for collections
+ * - all structures used for custom functions in collections
+ * - all the rest structures
+ * such an order prevents usage of non-declared classes
+ */
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
srna = ds->srna;
- fprintf(f, "/**************** %s ****************/\n\n", srna->name);
+ if (!strcmp(srna->identifier, first_collection_func_struct)) {
+ StructDefRNA *ds2;
+ StructRNA *srna2;
- fprintf(f, "class %s : public %s {\n", srna->identifier, (srna->base) ? srna->base->identifier : "Pointer");
- fprintf(f, "public:\n");
- fprintf(f, "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)", srna->identifier,
- (srna->base) ? srna->base->identifier : "Pointer");
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
- if (!(dp->prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN)))
- if (dp->prop->type == PROP_COLLECTION)
- fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier);
- fprintf(f, "\n\t\t{}\n\n");
+ for (ds2 = DefRNA.structs.first; ds2; ds2 = ds2->cont.next) {
+ srna2 = ds2->srna;
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
- rna_def_property_funcs_header_cpp(f, ds->srna, dp);
- fprintf(f, "};\n\n");
+ if (rna_is_collection_functions_struct(collection_func_structs, srna2->identifier)) {
+ rna_generate_header_class_cpp(ds2, f);
+ }
+ }
+ }
+
+ if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier))
+ rna_generate_header_class_cpp(ds, f);
}
+ fprintf(f, "} /* namespace BL */\n");
+ fprintf(f, "\n");
fprintf(f, "/**************** Implementation ****************/\n");
+ fprintf(f, "\n");
+
+ fprintf(f, "/* Structure prototypes */\n\n");
+ fprintf(f, "extern \"C\" {\n");
+ rna_generate_struct_prototypes(f);
+ fprintf(f, "}\n\n");
+
+ fprintf(f, "namespace BL {\n");
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ srna = ds->srna;
+
for (dp = ds->cont.properties.first; dp; dp = dp->next)
rna_def_property_funcs_impl_cpp(f, ds->srna, dp);
fprintf(f, "\n");
+
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ rna_def_struct_function_impl_cpp(f, srna, dfunc);
+
+ fprintf(f, "\n");
}
fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n");
@@ -3068,34 +3739,8 @@ static int rna_preprocess(const char *outfile)
rna_auto_types();
-
- /* create RNA_blender_cpp.h */
- strcpy(deffile, outfile);
- strcat(deffile, "RNA_blender_cpp.h" TMP_EXT);
-
status = (DefRNA.error != 0);
- if (status) {
- make_bad_file(deffile, __LINE__);
- }
- else {
- file = fopen(deffile, "w");
-
- if (!file) {
- fprintf(stderr, "Unable to open file: %s\n", deffile);
- status = 1;
- }
- else {
- rna_generate_header_cpp(brna, file);
- fclose(file);
- status = (DefRNA.error != 0);
- }
- }
-
- replace_if_different(deffile, NULL);
-
- rna_sort(brna);
-
/* create rna_gen_*.c files */
for (i = 0; PROCESS_ITEMS[i].filename; i++) {
strcpy(deffile, outfile);
@@ -3128,6 +3773,31 @@ static int rna_preprocess(const char *outfile)
replace_if_different(deffile, deps);
}
+ /* create RNA_blender_cpp.h */
+ strcpy(deffile, outfile);
+ strcat(deffile, "RNA_blender_cpp.h" TMP_EXT);
+
+ if (status) {
+ make_bad_file(deffile, __LINE__);
+ }
+ else {
+ file = fopen(deffile, "w");
+
+ if (!file) {
+ fprintf(stderr, "Unable to open file: %s\n", deffile);
+ status = 1;
+ }
+ else {
+ rna_generate_header_cpp(brna, file);
+ fclose(file);
+ status = (DefRNA.error != 0);
+ }
+ }
+
+ replace_if_different(deffile, NULL);
+
+ rna_sort(brna);
+
/* create RNA_blender.h */
strcpy(deffile, outfile);
strcat(deffile, "RNA_blender.h" TMP_EXT);
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 3ff63380491..11ce7345e41 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -243,8 +243,8 @@ StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports,
* owns the string pointer which it could potentially free while blender
* is running. */
if (BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) {
- BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is "
- STRINGIFY(MAX_IDPROP_NAME), identifier);
+ BKE_reportf(reports, RPT_ERROR, "Registering id property class: '%s' is too long, maximum length is %d",
+ identifier, MAX_IDPROP_NAME);
return NULL;
}
@@ -287,7 +287,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
switch (GS(id->name)) {
case ID_OB:
if (flag & ~(OB_RECALC_ALL)) {
- BKE_report(reports, RPT_ERROR, "'refresh' incompatible with Object ID type");
+ BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with Object ID type");
return;
}
break;
@@ -295,7 +295,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
#if 0
case ID_PA:
if (flag & ~(OB_RECALC_ALL | PSYS_RECALC)) {
- BKE_report(reports, RPT_ERROR, "'refresh' incompatible with ParticleSettings ID type");
+ BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with ParticleSettings ID type");
return;
}
break;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index c88944b4584..69332dcd250 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -996,7 +996,7 @@ void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin
IDProperty *item;
item = IDP_GetPropertyTypeFromGroup(idp_ui, "min", IDP_DOUBLE);
- *hardmin = item ? (float)IDP_Double(item) : FLT_MIN;
+ *hardmin = item ? (float)IDP_Double(item) : -FLT_MAX;
item = IDP_GetPropertyTypeFromGroup(idp_ui, "max", IDP_DOUBLE);
*hardmax = item ? (float)IDP_Double(item) : FLT_MAX;
@@ -3169,7 +3169,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
itemtype = RNA_property_type(iprop);
}
else {
- BKE_reportf(reports, RPT_ERROR, "Property named %s not found", propname);
+ BKE_reportf(reports, RPT_ERROR, "Property named '%s' not found", propname);
err = 1;
break;
}
@@ -3606,7 +3606,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
/* copy string, taking into account escaped ] */
if (bracket) {
for (p = *path, i = 0, j = 0; i < len; i++, p++) {
- if (*p == '\\' && *(p + 1) == quote) ;
+ if (*p == '\\' && *(p + 1) == quote) {}
else buf[j++] = *p;
}
@@ -3647,7 +3647,8 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *index)
{
PropertyRNA *prop;
- PointerRNA curptr, nextptr;
+ PointerRNA curptr;
+ PointerRNA nextptr; /* keep uninitialized, helps expose bugs in collection accessor functions */
char fixedbuf[256], *token;
int type, intkey;
@@ -3713,7 +3714,12 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
/* check for "" to see if it is a string */
if (rna_token_strip_quotes(token)) {
- RNA_property_collection_lookup_string(&curptr, prop, token + 1, &nextptr);
+ if (RNA_property_collection_lookup_string(&curptr, prop, token + 1, &nextptr)) {
+ /* pass */
+ }
+ else {
+ nextptr.data = NULL;
+ }
}
else {
/* otherwise do int lookup */
@@ -3721,7 +3727,12 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
if (intkey == 0 && (token[0] != '0' || token[1] != '\0')) {
return 0; /* we can be sure the fixedbuf was used in this case */
}
- RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr);
+ if (RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr)) {
+ /* pass */
+ }
+ else {
+ nextptr.data = NULL;
+ }
}
if (token != fixedbuf) {
@@ -3730,13 +3741,14 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
}
else {
PointerRNA c_ptr;
-
- /* ensure we quit on invalid values */
- nextptr.data = NULL;
if (RNA_property_collection_type_get(&curptr, prop, &c_ptr)) {
nextptr = c_ptr;
}
+ else {
+ /* ensure we quit on invalid values */
+ nextptr.data = NULL;
+ }
}
if (nextptr.data) {
@@ -3999,12 +4011,15 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee
BLI_assert(haystack->type == IDP_GROUP);
link.up = parent_link;
+ /* always set both name and index,
+ * else a stale value might get used */
link.name = NULL;
link.index = -1;
for (i = 0, iter = haystack->data.group.first; iter; iter = iter->next, i++) {
if (needle == iter) { /* found! */
link.name = iter->name;
+ link.index = -1;
path = rna_idp_path_create(&link);
break;
}
@@ -4014,6 +4029,7 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee
PointerRNA child_ptr = RNA_pointer_get(ptr, iter->name);
if (child_ptr.type) {
link.name = iter->name;
+ link.index = -1;
if ((path = rna_idp_path(&child_ptr, iter, needle, &link))) {
break;
}
@@ -4512,6 +4528,17 @@ int RNA_collection_length(PointerRNA *ptr, const char *name)
}
}
+int RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, int use_ghost)
+{
+ if (prop->flag & PROP_IDPROPERTY) {
+ IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier);
+ return ((idprop != NULL) && (use_ghost == FALSE || !(idprop->flag & IDP_FLAG_GHOST)));
+ }
+ else {
+ return 1;
+ }
+}
+
int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
{
if (prop->flag & PROP_IDPROPERTY) {
@@ -4523,6 +4550,20 @@ int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
}
}
+int RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, int use_ghost)
+{
+ PropertyRNA *prop = RNA_struct_find_property(ptr, identifier);
+
+ if (prop) {
+ return RNA_property_is_set_ex(ptr, prop, use_ghost);
+ }
+ else {
+ /* python raises an error */
+ /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */
+ return 0;
+ }
+}
+
int RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, identifier);
@@ -5219,7 +5260,7 @@ static int rna_function_format_array_length(const char *format, int ofs, int fle
lenbuf[idx] = format[ofs];
if (ofs < flen && format[ofs + 1] == ']') {
- /* XXX put better error reporting for ofs>=flen or idx over lenbuf capacity */
+ /* XXX put better error reporting for (ofs >= flen) or idx over lenbuf capacity */
lenbuf[idx] = '\0';
return atoi(lenbuf);
}
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 00a257ab4f9..1f9503f1cc9 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -45,9 +46,13 @@
#ifdef RNA_RUNTIME
-#include "ED_keyframing.h"
+#include "BLI_math_base.h"
+
#include "BKE_fcurve.h"
+#include "ED_keyframing.h"
+
+
static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal = iter->internal;
@@ -68,29 +73,30 @@ static bActionGroup *rna_Action_groups_new(bAction *act, const char name[])
return action_groups_add_new(act, name);
}
-static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionGroup *agrp)
+static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerRNA *agrp_ptr)
{
+ bActionGroup *agrp = agrp_ptr->data;
FCurve *fcu, *fcn;
/* try to remove the F-Curve from the action */
- if (!BLI_remlink_safe(&act->groups, agrp)) {
- BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name + 2);
+ if (BLI_remlink_safe(&act->groups, agrp) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "Action group '%s' not found in action '%s'", agrp->name, act->id.name + 2);
return;
}
/* move every one one of the group's F-Curves out into the Action again */
for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcn) {
fcn = fcu->next;
-
+
/* remove from group */
action_groups_remove_channel(act, fcu);
-
+
/* tack onto the end */
BLI_addtail(&act->curves, fcu);
}
-
- /* XXX, invalidates PyObject */
+
MEM_freeN(agrp);
+ RNA_POINTER_INVALIDATE(agrp_ptr);
}
static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path,
@@ -112,17 +118,19 @@ static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const ch
return verify_fcurve(act, group, NULL, data_path, index, 1);
}
-static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu)
+static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerRNA *fcu_ptr)
{
+ FCurve *fcu = fcu_ptr->data;
if (fcu->grp) {
if (BLI_findindex(&act->groups, fcu->grp) == -1) {
- BKE_reportf(reports, RPT_ERROR, "F-Curve's ActionGroup '%s' not found in action '%s'",
+ BKE_reportf(reports, RPT_ERROR, "F-Curve's action group '%s' not found in action '%s'",
fcu->grp->name, act->id.name + 2);
return;
}
action_groups_remove_channel(act, fcu);
free_fcurve(fcu);
+ RNA_POINTER_INVALIDATE(fcu_ptr);
}
else {
if (BLI_findindex(&act->curves, fcu) == -1) {
@@ -132,6 +140,7 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *
BLI_remlink(&act->curves, fcu);
free_fcurve(fcu);
+ RNA_POINTER_INVALIDATE(fcu_ptr);
}
}
@@ -145,15 +154,16 @@ static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[])
return marker;
}
-static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, TimeMarker *marker)
+static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, PointerRNA *marker_ptr)
{
- if (!BLI_remlink_safe(&act->markers, marker)) {
- BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in Action '%s'", marker->name, act->id.name + 2);
+ TimeMarker *marker = marker_ptr->data;
+ if (BLI_remlink_safe(&act->markers, marker) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in action '%s'", marker->name, act->id.name + 2);
return;
}
- /* XXX, invalidates PyObject */
MEM_freeN(marker);
+ RNA_POINTER_INVALIDATE(marker_ptr);
}
static PointerRNA rna_Action_active_pose_marker_get(PointerRNA *ptr)
@@ -185,8 +195,7 @@ static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min,
bAction *act = (bAction *)ptr->data;
*min = 0;
- *max = BLI_countlist(&act->markers) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&act->markers) - 1);
}
@@ -256,15 +265,14 @@ static void rna_def_dopesheet(BlenderRNA *brna)
srna = RNA_def_struct(brna, "DopeSheet", NULL);
RNA_def_struct_sdna(srna, "bDopeSheet");
- RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in Animation Editors");
+ RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in animation editors");
/* Source of DopeSheet data */
/* XXX: make this obsolete? */
prop = RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ID");
RNA_def_property_ui_text(prop, "Source",
- "ID-Block representing source data, currently ID_SCE (for Dopesheet), "
- "and ID_SC (for Grease Pencil)");
+ "ID-Block representing source data, usually ID_SCE (i.e. Scene)");
/* Show datablock filters */
prop = RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE);
@@ -283,22 +291,29 @@ static void rna_def_dopesheet(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_INCL_HIDDEN);
- RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible");
+ RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that are not visible");
RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ /* Debug Filtering Settings */
+ prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS);
+ RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and drivers that are disabled or have errors");
+ RNA_def_property_ui_icon(prop, ICON_HELP, 0); /* XXX: this doesn't quite fit */
+ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+
/* Object Group Filtering Settings */
prop = RNA_def_property(srna, "show_only_group_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP);
RNA_def_property_ui_text(prop, "Only Objects in Group",
- "Only include channels from Objects in the specified Group");
+ "Only include channels from objects in the specified group");
RNA_def_property_ui_icon(prop, ICON_GROUP, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "filter_grp");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Filtering Group", "Group that included Object should be a member of");
+ RNA_def_property_ui_text(prop, "Filtering Group", "Group that included object should be a member of");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
/* FCurve Display Name Search Settings */
@@ -318,21 +333,21 @@ static void rna_def_dopesheet(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT);
RNA_def_property_ui_text(prop, "Include Missing NLA",
- "Include Animation Data blocks with no NLA data (NLA Editor only)");
+ "Include animation data blocks with no NLA data (NLA editor only)");
RNA_def_property_ui_icon(prop, ICON_ACTION, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
/* Summary Settings (DopeSheet editors only) */
prop = RNA_def_property(srna, "show_summary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY);
- RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet Editors only)");
+ RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet editors only)");
RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_expanded_summary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED);
RNA_def_property_ui_text(prop, "Collapse Summary",
- "Collapse summary when shown, so all other channels get hidden (DopeSheet Editors Only)");
+ "Collapse summary when shown, so all other channels get hidden (DopeSheet editors only)");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -340,97 +355,97 @@ static void rna_def_dopesheet(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_transforms", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOOBJ);
RNA_def_property_ui_text(prop, "Display Transforms",
- "Include visualization of Object-level Animation data (mostly Transforms)");
+ "Include visualization of object-level animation data (mostly transforms)");
RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); /* XXX? */
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS);
- RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of ShapeKey related Animation data");
+ RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of shape key related animation data");
RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH);
- RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of Mesh related Animation data");
+ RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of mesh related animation data");
RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT);
- RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of Lattice related Animation data");
+ RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of lattice related animation data");
RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM);
- RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data");
+ RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of camera related animation data");
RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMAT);
- RNA_def_property_ui_text(prop, "Display Material", "Include visualization of Material related Animation data");
+ RNA_def_property_ui_text(prop, "Display Material", "Include visualization of material related animation data");
RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM);
- RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of Lamp related Animation data");
+ RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data");
RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOTEX);
- RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of Texture related Animation data");
+ RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of texture related animation data");
RNA_def_property_ui_icon(prop, ICON_TEXTURE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_curves", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCUR);
- RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of Curve related Animation data");
+ RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of curve related animation data");
RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_worlds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOWOR);
- RNA_def_property_ui_text(prop, "Display World", "Include visualization of World related Animation data");
+ RNA_def_property_ui_text(prop, "Display World", "Include visualization of world related animation data");
RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_scenes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSCE);
- RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of Scene related Animation data");
+ RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of scene related animation data");
RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOPART);
- RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of Particle related Animation data");
+ RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of particle related animation data");
RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA);
- RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of Metaball related Animation data");
+ RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of metaball related animation data");
RNA_def_property_ui_icon(prop, ICON_META_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM);
- RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of Armature related Animation data");
+ RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of armature related animation data");
RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NONTREE);
- RNA_def_property_ui_text(prop, "Display Node", "Include visualization of Node related Animation data");
+ RNA_def_property_ui_text(prop, "Display Node", "Include visualization of node related animation data");
RNA_def_property_ui_icon(prop, ICON_NODETREE, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSPK);
- RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of Speaker related Animation data");
+ RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of speaker related animation data");
RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
@@ -467,17 +482,17 @@ static void rna_def_action_group(BlenderRNA *brna)
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED);
- RNA_def_property_ui_text(prop, "Select", "Action Group is selected");
+ RNA_def_property_ui_text(prop, "Select", "Action group is selected");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED);
- RNA_def_property_ui_text(prop, "Lock", "Action Group is locked");
+ RNA_def_property_ui_text(prop, "Lock", "Action group is locked");
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_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED);
- RNA_def_property_ui_text(prop, "Expanded", "Action Group is expanded");
+ RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
/* color set */
@@ -510,7 +525,8 @@ static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove action group");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "action_group", "ActionGroup", "", "Action group to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
@@ -541,7 +557,8 @@ static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove action group");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -569,14 +586,15 @@ static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a timeline marker");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "TimelineMarker");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_funcs(prop, "rna_Action_active_pose_marker_get",
"rna_Action_active_pose_marker_set", NULL, NULL);
- RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this Action");
+ RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this action");
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "active_marker");
@@ -599,7 +617,7 @@ static void rna_def_action(BlenderRNA *brna)
prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "curves", NULL);
RNA_def_property_struct_type(prop, "FCurve");
- RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action");
+ RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the action");
rna_def_action_fcurves(brna, prop);
prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
@@ -611,7 +629,7 @@ static void rna_def_action(BlenderRNA *brna)
prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
RNA_def_property_struct_type(prop, "TimelineMarker");
- RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses");
+ RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this action, for labeling poses");
rna_def_action_pose_markers(brna, prop);
/* properties */
@@ -626,8 +644,8 @@ static void rna_def_action(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "idroot");
RNA_def_property_enum_items(prop, id_type_items);
RNA_def_property_ui_text(prop, "ID Root Type",
- "Type of ID-block that action can be used on - "
- "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING");
+ "Type of ID block that action can be used on - "
+ "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING");
/* API calls */
RNA_api_action(srna);
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index d50cb663b97..7229dddf6d6 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -54,6 +54,8 @@ EnumPropertyItem keyingset_path_grouping_items[] = {
#ifdef RNA_RUNTIME
+#include "BLI_math_base.h"
+
#include "BKE_animsys.h"
#include "BKE_fcurve.h"
#include "BKE_nla.h"
@@ -296,6 +298,43 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
/* ****************************** */
+static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
+{
+ KeyingSet *ks = (KeyingSet *)ptr->data;
+
+ /* update names of corresponding groups if name changes */
+ if (strcmp(ks->name, value)) {
+ KS_Path *ksp;
+
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) {
+ AnimData *adt = BKE_animdata_from_id(ksp->id);
+
+ /* TODO: NLA strips? */
+ if (adt && adt->action) {
+ bActionGroup *agrp;
+
+ /* lazy check - should really find the F-Curve for the affected path and check its group
+ * but this way should be faster and work well for most cases, as long as there are no
+ * conflicts
+ */
+ for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) {
+ if (strcmp(ks->name, agrp->name) == 0) {
+ /* there should only be one of these in the action, so can stop... */
+ BLI_strncpy(agrp->name, value, sizeof(agrp->name));
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* finally, update name to new value */
+ BLI_strncpy(ks->name, value, sizeof(ks->name));
+}
+
+
static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr)
{
KeyingSet *ks = (KeyingSet *)ptr->data;
@@ -334,8 +373,7 @@ static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, i
KeyingSet *ks = (KeyingSet *)ptr->data;
*min = 0;
- *max = BLI_countlist(&ks->paths) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ks->paths) - 1);
}
static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr)
@@ -369,27 +407,30 @@ static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *report
keyingset->active_path = BLI_countlist(&keyingset->paths);
}
else {
- BKE_report(reports, RPT_ERROR, "Keying Set Path could not be added");
+ BKE_report(reports, RPT_ERROR, "Keying set path could not be added");
}
/* return added path */
return ksp;
}
-static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports, KS_Path *ksp)
+static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports, PointerRNA *ksp_ptr)
{
+ KS_Path *ksp = ksp_ptr->data;
+
/* if data is valid, call the API function for this */
- if (keyingset && ksp) {
- /* remove the active path from the KeyingSet */
- BKE_keyingset_free_path(keyingset, ksp);
-
- /* the active path number will most likely have changed */
- /* TODO: we should get more fancy and actually check if it was removed, but this will do for now */
- keyingset->active_path = 0;
- }
- else {
- BKE_report(reports, RPT_ERROR, "Keying Set Path could not be removed");
+ if ((keyingset && ksp) == FALSE) {
+ BKE_report(reports, RPT_ERROR, "Keying set path could not be removed");
+ return;
}
+
+ /* remove the active path from the KeyingSet */
+ BKE_keyingset_free_path(keyingset, ksp);
+ RNA_POINTER_INVALIDATE(ksp_ptr);
+
+ /* the active path number will most likely have changed */
+ /* TODO: we should get more fancy and actually check if it was removed, but this will do for now */
+ keyingset->active_path = 0;
}
static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports)
@@ -408,7 +449,7 @@ static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports)
keyingset->active_path = 0;
}
else {
- BKE_report(reports, RPT_ERROR, "Keying Set Paths could not be removed");
+ BKE_report(reports, RPT_ERROR, "Keying set paths could not be removed");
}
}
@@ -422,9 +463,17 @@ static NlaTrack *rna_NlaTrack_new(AnimData *adt, bContext *C, NlaTrack *track)
return new_track;
}
-static void rna_NlaTrack_remove(AnimData *adt, bContext *C, NlaTrack *track)
+static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports, PointerRNA *track_ptr)
{
+ NlaTrack *track = track_ptr->data;
+
+ if (BLI_findindex(&adt->nla_tracks, track) == -1) {
+ BKE_reportf(reports, RPT_ERROR, "NlaTrack '%s' cannot be removed", track->name);
+ return;
+ }
+
free_nlatrack(&adt->nla_tracks, track);
+ RNA_POINTER_INVALIDATE(track_ptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
}
@@ -448,7 +497,7 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_
{
/* verify that we've got a driver to duplicate */
if (ELEM(NULL, src_driver, src_driver->driver)) {
- BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of");
+ BKE_report(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of");
return NULL;
}
else {
@@ -678,7 +727,8 @@ static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
/* path to remove */
parm = RNA_def_pointer(func, "path", "KeyingSetPath", "Path", "");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* Remove All Paths */
@@ -709,19 +759,20 @@ static void rna_def_keyingset(BlenderRNA *brna)
srna = RNA_def_struct(brna, "KeyingSet", NULL);
RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
- /* Id/Label. */
+ /* Id/Label */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "idname");
RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
- RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
+/* RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_KeyingSet_name_set");
RNA_def_property_ui_text(prop, "UI Name", "");
RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
RNA_def_struct_name_property(srna, prop);
-/* RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/
+ RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
RNA_def_property_string_sdna(prop, NULL, "description");
@@ -783,10 +834,11 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_NlaTrack_remove");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Remove a NLA Track");
parm = RNA_def_pointer(func, "track", "NlaTrack", "", "NLA Track to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "NlaTrack");
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index 39128b48cd8..492659fdc2e 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -56,11 +56,11 @@ static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList
if (success != 0) {
switch (success) {
case MODIFYKEY_INVALID_CONTEXT:
- BKE_report(reports, RPT_ERROR, "Invalid context for Keying Set");
+ BKE_report(reports, RPT_ERROR, "Invalid context for keying set");
break;
case MODIFYKEY_MISSING_TYPEINFO:
- BKE_report(reports, RPT_ERROR, "Incomplete built-in Keying Set. Appears to be missing type info");
+ BKE_report(reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info");
break;
}
}
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index ceadaa036f1..4c566d71981 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -29,6 +29,7 @@
#include "BLI_math.h"
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -103,25 +104,27 @@ static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value)
static EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const char *name)
{
if (arm->edbo == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant add an editbone", arm->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot add an editbone", arm->id.name + 2);
return NULL;
}
return ED_armature_edit_bone_add(arm, name);
}
-static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone)
+static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, PointerRNA *ebone_ptr)
{
+ EditBone *ebone = ebone_ptr->data;
if (arm->edbo == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant remove an editbone", arm->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot remove an editbone", arm->id.name + 2);
return;
}
if (BLI_findindex(arm->edbo, ebone) == -1) {
- BKE_reportf(reports, RPT_ERROR, "Armature '%s' doesn't contain bone '%s'", arm->id.name + 2, ebone->name);
+ BKE_reportf(reports, RPT_ERROR, "Armature '%s' does not contain bone '%s'", arm->id.name + 2, ebone->name);
return;
}
ED_armature_edit_bone_remove(arm, ebone);
+ RNA_POINTER_INVALIDATE(ebone_ptr);
}
static void rna_Armature_update_layers(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
@@ -564,7 +567,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
else RNA_def_property_update(prop, 0, "rna_Armature_update_data");
RNA_def_property_float_sdna(prop, NULL, "rad_head");
- /* XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); */
+ /* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */
/*RNA_def_property_range(prop, 0, 1000); */
RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)");
@@ -573,7 +576,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
else RNA_def_property_update(prop, 0, "rna_Armature_update_data");
RNA_def_property_float_sdna(prop, NULL, "rad_tail");
- /* XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); */
+ /* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */
/*RNA_def_property_range(prop, 0, 1000); */
RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only)");
@@ -865,7 +868,8 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove an existing bone from the armature");
/* target to remove*/
parm = RNA_def_pointer(func, "bone", "EditBone", "", "EditBone to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_armature(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 2a6ea2994fa..3da718afd1c 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -80,6 +80,8 @@ EnumPropertyItem boidruleset_type_items[] = {
#ifdef RNA_RUNTIME
+#include "BLI_math_base.h"
+
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_particle.h"
@@ -157,8 +159,7 @@ static void rna_BoidState_active_boid_rule_index_range(PointerRNA *ptr, int *min
{
BoidState *state = (BoidState *)ptr->data;
*min = 0;
- *max = BLI_countlist(&state->rules) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&state->rules) - 1);
}
static int rna_BoidState_active_boid_rule_index_get(PointerRNA *ptr)
@@ -224,8 +225,7 @@ static void rna_BoidSettings_active_boid_state_index_range(PointerRNA *ptr, int
{
BoidSettings *boids = (BoidSettings *)ptr->data;
*min = 0;
- *max = BLI_countlist(&boids->states) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&boids->states) - 1);
}
static int rna_BoidSettings_active_boid_state_index_get(PointerRNA *ptr)
@@ -436,7 +436,7 @@ static void rna_def_boidrule(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "On Land", "Use rule when boid is on land");
RNA_def_property_update(prop, 0, "rna_Boids_reset");
- /*prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */
+ /*prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */
/*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 e96ed4f38d3..7bdebd620ee 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -146,8 +146,8 @@ static int rna_SculptCapabilities_has_overlay_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
return ELEM(br->mtex.brush_map_mode,
- MTEX_MAP_MODE_VIEW,
- MTEX_MAP_MODE_TILED);
+ MTEX_MAP_MODE_VIEW,
+ MTEX_MAP_MODE_TILED);
}
static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index ad926d6a08e..b72bba0422a 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -258,7 +258,7 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_title_safe", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWTITLESAFE);
- RNA_def_property_ui_text(prop, "Show Title Safe", "Show indicators for the title safe zone in Camera view");
+ RNA_def_property_ui_text(prop, "Show Safe Areas", "Show TV title safe and action safe zones in Camera view");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 5f1ce4f2773..b9e86e116a2 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -419,41 +419,41 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
/* unused still */
#if 0
- prop= RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shear");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness");
#endif
/* unused still */
#if 0
- prop= RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max_shear");
RNA_def_property_range(prop, 0.0f, upperLimitf);
RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value");
#endif
/* unused still */
#if 0
- prop= RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "eff_force_scale");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Effector Force Scale", "");
#endif
/* unused still */
#if 0
- prop= RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "eff_wind_scale");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Effector Wind Scale", "");
#endif
/* unused still */
#if 0
- prop= RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_TEARING);
RNA_def_property_ui_text(prop, "Tearing", "");
#endif
/* unused still */
#if 0
- prop= RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "maxspringlen");
RNA_def_property_range(prop, 1.0, 1000.0);
RNA_def_property_ui_text(prop, "Maximum Spring Extension", "Maximum extension before spring gets cut");
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 7fb4a1d3839..5752fd318c7 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -45,6 +45,7 @@
#include "DNA_material_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_node_types.h"
+#include "DNA_sequence_types.h"
#include "MEM_guardedalloc.h"
@@ -53,6 +54,7 @@
#include "BKE_image.h"
#include "BKE_movieclip.h"
#include "BKE_node.h"
+#include "BKE_sequencer.h"
#include "BKE_texture.h"
#include "ED_node.h"
@@ -314,7 +316,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
}
}
-void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4])
+static void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4])
{
do_colorband(coba, position, color);
}
@@ -329,12 +331,27 @@ static CBData *rna_ColorRampElement_new(struct ColorBand *coba, ReportList *repo
return element;
}
-static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, CBData *element)
+static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, PointerRNA *element_ptr)
{
+ CBData *element = element_ptr->data;
int index = (int)(element - coba->data);
- if (colorband_element_remove(coba, index) == 0)
+ if (colorband_element_remove(coba, index) == FALSE) {
BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(element_ptr);
+}
+
+void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr)
+{
+ CurveMapPoint *point = point_ptr->data;
+ if (curvemap_remove_point(cuma, point) == FALSE) {
+ BKE_report(reports, RPT_ERROR, "Unable to remove curve point");
+ return;
+ }
+ RNA_POINTER_INVALIDATE(point_ptr);
}
static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -474,14 +491,55 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
if (GS(id->name) == ID_IM) {
Image *ima = (Image *) id;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ DAG_id_tag_update(&ima->id, 0);
+
+ BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);
+
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
+ WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
}
else if (GS(id->name) == ID_MC) {
MovieClip *clip = (MovieClip *) id;
BKE_movieclip_reload(clip);
+
+ /* all sequencers for now, we don't know which scenes are using this clip as a strip */
+ BKE_sequencer_cache_cleanup();
+ BKE_sequencer_preprocessed_cache_cleanup();
+
WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id);
+ WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, &clip->id);
+ }
+ else if (GS(id->name) == ID_SCE) {
+ Scene *scene = (Scene *) id;
+
+ if (scene->ed) {
+ ColorManagedColorspaceSettings *colorspace_settings = (ColorManagedColorspaceSettings *) ptr->data;
+ Sequence *seq;
+ int seq_found = FALSE;
+
+ if (&scene->sequencer_colorspace_settings != colorspace_settings) {
+ SEQ_BEGIN(scene->ed, seq);
+ {
+ if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) {
+ seq_found = TRUE;
+ break;
+ }
+ }
+ SEQ_END;
+ }
+
+ if (seq_found) {
+ BKE_sequence_invalidate_cache(scene, seq);
+ BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
+ }
+ else {
+ BKE_sequencer_cache_cleanup();
+ BKE_sequencer_preprocessed_cache_cleanup();
+ }
+
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
+ }
}
}
@@ -553,10 +611,12 @@ static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "New point");
RNA_def_function_return(func, parm);
- func = RNA_def_function(srna, "remove", "curvemap_remove_point");
+ func = RNA_def_function(srna, "remove", "rna_CurveMap_remove_point");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Delete point from CurveMap");
parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "PointElement to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_curvemap(BlenderRNA *brna)
@@ -705,7 +765,8 @@ static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Delete element from ColorRamp");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_color_ramp(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index f2454a2dcfb..7b6b629ca82 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -703,11 +703,6 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lock Z Rot", "Constraint rotation along Z axis");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
- prop = RNA_def_property(srna, "use_target", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_AUTO);
- RNA_def_property_ui_text(prop, "Target", "Disable for targetless IK");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_STRETCH);
RNA_def_property_ui_text(prop, "Stretch", "Enable IK Stretching");
@@ -2422,7 +2417,7 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "rot_error");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Rot error",
- "Amount of residual error in radiant for constraints that work on orientation");
+ "Amount of residual error in radians for constraints that work on orientation");
/* pointers */
rna_def_constrainttarget(brna);
diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c
index aef1f765fe2..c59e376da82 100644
--- a/source/blender/makesrna/intern/rna_controller.c
+++ b/source/blender/makesrna/intern/rna_controller.c
@@ -240,7 +240,7 @@ void RNA_def_controller(BlenderRNA *brna)
/* State */
/* array of OB_MAX_STATES */
- /*prop= RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */
+ /*prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */
/*RNA_def_property_array(prop, OB_MAX_STATES); */
/*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
/*RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)"); */
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index c47cb8ef2af..1e1a8c82b8e 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -62,9 +63,9 @@ EnumPropertyItem keyframe_handle_type_items[] = {
};
EnumPropertyItem beztriple_interpolation_mode_items[] = {
- {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""},
- {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""},
- {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""},
+ {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation, value of A gets held until B is encountered"},
+ {BEZT_IPO_LIN, "LINEAR", 0, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"},
+ {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"},
{0, NULL, 0, NULL, NULL}
};
@@ -241,16 +242,14 @@ static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max,
{
Curve *cu = (Curve *)ptr->id.data;
*min = 0;
- *max = cu->totcol - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, cu->totcol - 1);
}
static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
Curve *cu = (Curve *)ptr->id.data;
*min = 0;
- *max = cu->totbox - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, cu->totbox - 1);
}
@@ -511,7 +510,7 @@ static void rna_Nurb_update_knot_v(Main *bmain, Scene *scene, PointerRNA *ptr)
static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number)
{
if (nu->type == CU_BEZIER) {
- BKE_report(reports, RPT_ERROR, "Bezier spline can't have points added");
+ BKE_report(reports, RPT_ERROR, "Bezier spline cannot have points added");
}
else if (number == 0) {
/* do nothing */
@@ -573,20 +572,18 @@ static Nurb *rna_Curve_spline_new(Curve *cu, int type)
return nu;
}
-static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu)
+static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, PointerRNA *nu_ptr)
{
- int found = 0;
+ Nurb *nu = nu_ptr->data;
ListBase *nurbs = BKE_curve_nurbs_get(cu);
- found = BLI_remlink_safe(nurbs, nu);
-
- if (!found) {
- BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" does not contain spline given", cu->id.name + 2);
+ if (BLI_remlink_safe(nurbs, nu) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "Curve '%s' does not contain spline given", cu->id.name + 2);
return;
}
BKE_nurb_free(nu);
- /* invalidate pointer!, no can do */
+ RNA_POINTER_INVALIDATE(nu_ptr);
DAG_id_tag_update(&cu->id, OB_RECALC_DATA);
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
@@ -721,7 +718,7 @@ static void rna_def_bpoint(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
/* Number values */
- prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "alfa");
/*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
@@ -808,13 +805,14 @@ static void rna_def_beztriple(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Curve_update_points");
/* Number values */
- prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "alfa");
/*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
- prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "weight");
RNA_def_property_range(prop, 0.01f, 100.0f);
RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
@@ -1108,7 +1106,7 @@ static void rna_def_charinfo(BlenderRNA *brna)
/* probably there is no reason to expose this */
#if 0
- prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP);
RNA_def_property_ui_text(prop, "Wrap", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */
@@ -1163,14 +1161,15 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "add", "rna_Curve_spline_points_add");
RNA_def_function_ui_description(func, "Add a number of points to this spline");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
- RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
+ RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
#if 0
- func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
+ func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
RNA_def_function_ui_description(func, "Remove a spline from a curve");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
#endif
}
@@ -1190,14 +1189,15 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add");
RNA_def_function_ui_description(func, "Add a number of points to this spline");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
- RNA_def_int(func, "count", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
+ RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
#if 0
func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
RNA_def_function_ui_description(func, "Remove a spline from a curve");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
#endif
}
@@ -1226,7 +1226,8 @@ static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a spline from a curve");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_Curve_spline_clear");
RNA_def_function_ui_description(func, "Remove all spline from a curve");
@@ -1421,6 +1422,11 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for beveled curves");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+ prop = RNA_def_property(srna, "use_map_taper", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_MAP_TAPER);
+ RNA_def_property_ui_text(prop, "Map Taper", "Map effect of taper object on actually bevelled curve");
+ RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
/* texture space */
prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 45092d09ce1..bb1ecea6a24 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -42,10 +42,23 @@
#include "BLI_listbase.h"
#include "BLI_ghash.h"
+#include "BLF_translation.h"
+
#include "RNA_define.h"
#include "rna_internal.h"
+
+#ifdef DEBUG
+# define ASSERT_SOFT_HARD_LIMITS \
+ if (softmin < hardmin || softmax > hardmax) { \
+ fprintf(stderr, "Error with soft/hard limits: %s.%s\n", CONTAINER_RNA_ID(cont), identifier); \
+ BLI_assert(!"invalid soft/hard limits"); \
+ } (void)0
+#else
+# define ASSERT_SOFT_HARD_LIMITS (void)0
+#endif
+
/* Global used during defining */
BlenderDefRNA DefRNA = {NULL, {NULL, NULL}, {NULL, NULL}, NULL, 0, 0, 0, 1};
@@ -887,7 +900,7 @@ void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
{
- /*StructRNA *srna= DefRNA.laststruct;*/ /* invalid for python defined props */
+ /*StructRNA *srna = DefRNA.laststruct;*/ /* invalid for python defined props */
ContainerRNA *cont = cont_;
ContainerDefRNA *dcont;
PropertyDefRNA *dprop = NULL;
@@ -968,8 +981,10 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier
sprop->defaultvalue = "";
break;
}
- case PROP_ENUM:
case PROP_POINTER:
+ prop->flag |= PROP_THICK_WRAP; /* needed for default behavior when PROP_RNAPTR is set */
+ break;
+ case PROP_ENUM:
case PROP_COLLECTION:
break;
default:
@@ -2248,12 +2263,15 @@ PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *iden
return prop;
}
-PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin,
- int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
+PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value,
+ int hardmin, int hardmax, const char *ui_name, const char *ui_description,
+ int softmin, int softmax)
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, default_value);
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
@@ -2270,6 +2288,8 @@ PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifi
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); /* XXX */
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_int_array_default(prop, default_value);
@@ -2287,6 +2307,8 @@ PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifie
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_int_array_default(prop, default_value);
@@ -2426,6 +2448,8 @@ PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, f
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, default_value);
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
@@ -2442,6 +2466,8 @@ PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identi
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_float_array_default(prop, default_value);
@@ -2472,6 +2498,8 @@ PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identif
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_float_array_default(prop, default_value);
@@ -2489,10 +2517,9 @@ PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identi
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
- int length[2];
+ const int length[2] = {rows, columns};
- length[0] = rows;
- length[1] = columns;
+ ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX);
RNA_def_property_multi_array(prop, 2, length);
@@ -2510,7 +2537,9 @@ PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *iden
{
ContainerRNA *cont = cont_;
PropertyRNA *prop;
-
+
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, (len != 0) ? PROP_EULER : PROP_ANGLE);
if (len != 0) {
RNA_def_property_array(prop, len);
@@ -2534,6 +2563,8 @@ PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identif
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
if (len != 0) RNA_def_property_array(prop, len);
if (default_value) RNA_def_property_float_array_default(prop, default_value);
@@ -2551,6 +2582,8 @@ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_, const char *id
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_default(prop, default_value);
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
@@ -2567,6 +2600,8 @@ PropertyRNA *RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identi
ContainerRNA *cont = cont_;
PropertyRNA *prop;
+ ASSERT_SOFT_HARD_LIMITS;
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, default_value);
if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
@@ -2777,14 +2812,26 @@ int rna_parameter_size(PropertyRNA *parm)
{
#ifdef RNA_RUNTIME
if (parm->flag & PROP_RNAPTR)
- return sizeof(PointerRNA);
+ if (parm->flag & PROP_THICK_WRAP) {
+ return sizeof(PointerRNA);
+ }
+ else {
+ return sizeof(PointerRNA *);
+ }
else
return sizeof(void *);
#else
- if (parm->flag & PROP_RNAPTR)
- return sizeof(PointerRNA);
- else
+ if (parm->flag & PROP_RNAPTR) {
+ if (parm->flag & PROP_THICK_WRAP) {
+ return sizeof(PointerRNA);
+ }
+ else {
+ return sizeof(PointerRNA *);
+ }
+ }
+ else {
return sizeof(void *);
+ }
#endif
}
case PROP_COLLECTION:
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 24b14fdb884..4250acf5848 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -409,14 +409,16 @@ static DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
return driver_add_new_variable(driver);
}
-static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
+static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, PointerRNA *dvar_ptr)
{
+ DriverVar *dvar = dvar_ptr->data;
if (BLI_findindex(&driver->variables, dvar) == -1) {
BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver");
return;
}
driver_free_variable(driver, dvar);
+ RNA_POINTER_INVALIDATE(dvar_ptr);
}
@@ -438,13 +440,16 @@ static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
return add_fmodifier(&fcu->modifiers, type);
}
-static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm)
+static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, PointerRNA *fcm_ptr)
{
+ FModifier *fcm = fcm_ptr->data;
if (BLI_findindex(&fcu->modifiers, fcm) == -1) {
BKE_reportf(reports, RPT_ERROR, "F-Curve modifier '%s' not found in F-Curve", fcm->name);
return;
}
+
remove_fmodifier(&fcu->modifiers, fcm);
+ RNA_POINTER_INVALIDATE(fcm_ptr);
}
static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
@@ -610,8 +615,9 @@ static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
}
}
-static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
+static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, PointerRNA *bezt_ptr, int do_fast)
{
+ BezTriple *bezt = bezt_ptr->data;
int index = (int)(bezt - fcu->bezt);
if (index < 0 || index >= fcu->totvert) {
BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve");
@@ -619,6 +625,7 @@ static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTri
}
delete_fcurve_key(fcu, index, !do_fast);
+ RNA_POINTER_INVALIDATE(bezt_ptr);
}
static void rna_fcurve_range(FCurve *fcu, float range[2])
@@ -1263,7 +1270,8 @@ static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop
RNA_def_function_flag(func, FUNC_USE_REPORTS);
/* target to remove */
parm = RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_channeldriver(BlenderRNA *brna)
@@ -1458,7 +1466,8 @@ static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a modifier from this F-Curve");
/* modifier to remove */
parm = RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
/* fcurve.keyframe_points */
@@ -1497,13 +1506,14 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
- RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
+ RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* optional */
RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
}
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index daa661175a1..84ff53ee68f 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -699,7 +699,7 @@ void RNA_def_fluidsim(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Type of participation in the fluid simulation");
RNA_def_property_update(prop, 0, "rna_FluidSettings_update_type");
- /*prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); */
+ /*prop = RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); */
/*RNA_def_property_ui_text(prop, "IPO Curves", "IPO curves used by fluid simulation settings"); */
/* types */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index bf7f4984ea1..b3c1f4dd505 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -111,6 +112,116 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
}
+static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count)
+{
+ if (count > 0) {
+ if (stroke->points == NULL)
+ stroke->points = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points");
+ else
+ stroke->points = MEM_reallocN(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count));
+
+ stroke->totpoints += count;
+ }
+}
+
+static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, int index)
+{
+ bGPDspoint *pt_tmp = stroke->points;
+
+ /* python style negative indexing */
+ if (index < 0) {
+ index += stroke->totpoints;
+ }
+
+ if (stroke->totpoints <= index || index < 0) {
+ BKE_report(reports, RPT_ERROR, "GPencilStrokePoints.pop: index out of range");
+ return;
+ }
+
+ stroke->totpoints--;
+
+ stroke->points = MEM_callocN(sizeof(bGPDspoint) * stroke->totpoints, "gp_stroke_points");
+
+ if (index > 0)
+ memcpy(stroke->points, pt_tmp, sizeof(bGPDspoint) * index);
+
+ if (index < stroke->totpoints)
+ memcpy(&stroke->points[index], &pt_tmp[index + 1], sizeof(bGPDspoint) * (stroke->totpoints - index));
+
+ /* free temp buffer */
+ MEM_freeN(pt_tmp);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
+
+static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame)
+{
+ bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
+
+ BLI_addtail(&frame->strokes, stroke);
+
+ return stroke;
+}
+
+static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, PointerRNA *stroke_ptr)
+{
+ bGPDstroke *stroke = stroke_ptr->data;
+ if (BLI_findindex(&frame->strokes, stroke) == -1) {
+ BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame");
+ return;
+ }
+
+ BLI_freelinkN(&frame->strokes, stroke);
+ RNA_POINTER_INVALIDATE(stroke_ptr);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
+
+static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, int frame_number)
+{
+ bGPDframe *frame;
+
+ if (BKE_gpencil_layer_find_frame(layer, frame_number)) {
+ BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number %d", frame_number);
+ return NULL;
+ }
+
+ frame = gpencil_frame_addnew(layer, frame_number);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+
+ return frame;
+}
+
+static void rna_GPencil_frame_remove(bGPDlayer *layer, ReportList *reports, PointerRNA *frame_ptr)
+{
+ bGPDframe *frame = frame_ptr->data;
+ if (BLI_findindex(&layer->frames, frame) == -1) {
+ BKE_report(reports, RPT_ERROR, "Frame not found in grease pencil layer");
+ return;
+ }
+
+ gpencil_layer_delframe(layer, frame);
+ RNA_POINTER_INVALIDATE(frame_ptr);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
+
+static bGPDframe *rna_GPencil_frame_copy(bGPDlayer *layer, bGPDframe *src)
+{
+ bGPDframe *frame = gpencil_frame_duplicate(src);
+
+ while (BKE_gpencil_layer_find_frame(layer, frame->framenum)) {
+ frame->framenum++;
+ }
+
+ BLI_addtail(&layer->frames, frame);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+
+ return frame;
+}
+
static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int setactive)
{
bGPDlayer *gl = gpencil_layer_addnew(gpd, name, setactive);
@@ -120,21 +231,37 @@ static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int seta
return gl;
}
-static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlayer *layer)
+static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, PointerRNA *layer_ptr)
{
- bGPDlayer *gl;
-
- for (gl = gpd->layers.first; gl; gl = gl->next) {
- if (gl == layer)
- break;
- }
-
- if (gl == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Layer not found in grease pencil data");
+ bGPDlayer *layer = layer_ptr->data;
+ if (BLI_findindex(&gpd->layers, layer) == -1) {
+ BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data");
return;
}
-
+
gpencil_layer_delete(gpd, layer);
+ RNA_POINTER_INVALIDATE(layer_ptr);
+
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+}
+
+static void rna_GPencil_frame_clear(bGPDframe *frame)
+{
+ free_gpencil_strokes(frame);
+
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+}
+
+static void rna_GPencil_layer_clear(bGPDlayer *layer)
+{
+ free_gpencil_frames(layer);
+
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+}
+
+static void rna_GPencil_clear(bGPdata *gpd)
+{
+ free_gpencil_layers(&gpd->layers);
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@@ -154,19 +281,49 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Coordinates", "");
- RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pressure");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it");
- RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+}
+
+static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ /* PropertyRNA *parm; */
+
+ RNA_def_property_srna(cprop, "GPencilStrokePoints");
+ srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL);
+ RNA_def_struct_sdna(srna, "bGPDstroke");
+ RNA_def_struct_ui_text(srna, "Grease Pencil Stroke Points", "Collection of grease pencil stroke points");
+
+ func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add");
+ RNA_def_function_ui_description(func, "Add a new grease pencil stroke point");
+ RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX);
+
+ func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop");
+ RNA_def_function_ui_description(func, "Remove a grease pencil stroke point");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "Index", "point index", INT_MIN, INT_MAX);
}
static void rna_def_gpencil_stroke(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+
+ static EnumPropertyItem stroke_draw_mode_items[] = {
+ {0, "SCREEN", 0, "Screen", "Stroke is in screen-space"},
+ {GP_STROKE_3DSPACE, "3DSPACE", 0, "3D Space", "Stroke is in 3D-space"},
+ {GP_STROKE_2DSPACE, "2DSPACE", 0, "2D Space", "Stroke is in 2D-space"},
+ {GP_STROKE_2DIMAGE, "2DIMAGE", 0, "2D Image", "Stroke is in 2D-space (but with special 'image' scaling)"},
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "GPencilStroke", NULL);
RNA_def_struct_sdna(srna, "bGPDstroke");
@@ -177,15 +334,46 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "points", "totpoints");
RNA_def_property_struct_type(prop, "GPencilStrokePoint");
RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points");
-
- /* Flags - Readonly type-info really... */
- /* TODO... */
+ rna_def_gpencil_stroke_points_api(brna, prop);
+
+ prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, stroke_draw_mode_items);
+ RNA_def_property_ui_text(prop, "Draw Mode", "");
+ RNA_def_property_update(prop, 0, "rna_GPencil_update");
+}
+
+static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "GPencilStrokes");
+ srna = RNA_def_struct(brna, "GPencilStrokes", NULL);
+ RNA_def_struct_sdna(srna, "bGPDframe");
+ RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames");
+
+ func = RNA_def_function(srna, "new", "rna_GPencil_stroke_new");
+ RNA_def_function_ui_description(func, "Add a new grease pencil frame");
+ parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "", "The newly created stroke");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_GPencil_stroke_remove");
+ RNA_def_function_ui_description(func, "Remove a grease pencil frame");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_gpencil_frame(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+
+ FunctionRNA *func;
srna = RNA_def_struct(brna, "GPencilFrame", NULL);
RNA_def_struct_sdna(srna, "bGPDframe");
@@ -196,7 +384,8 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "strokes", NULL);
RNA_def_property_struct_type(prop, "GPencilStroke");
RNA_def_property_ui_text(prop, "Strokes", "Freehand curves defining the sketch on this frame");
-
+ rna_def_gpencil_strokes_api(brna, prop);
+
/* Frame Number */
prop = RNA_def_property(srna, "frame_number", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "framenum");
@@ -211,12 +400,52 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_SELECT);
RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in the DopeSheet");
+
+ func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");
+ RNA_def_function_ui_description(func, "Remove all the grease pencil frame data");
+}
+
+static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "GPencilFrames");
+ srna = RNA_def_struct(brna, "GPencilFrames", NULL);
+ RNA_def_struct_sdna(srna, "bGPDlayer");
+ RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames");
+
+ 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, MINFRAME, MAXFRAME, "Frame Number", "The frame on which this sketch appears", MINFRAME, MAXFRAME);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_pointer(func, "frame", "GPencilFrame", "", "The newly created frame");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_GPencil_frame_remove");
+ RNA_def_function_ui_description(func, "Remove a grease pencil frame");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "frame", "GPencilFrame", "Frame", "The frame to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+
+ func = RNA_def_function(srna, "copy", "rna_GPencil_frame_copy");
+ RNA_def_function_ui_description(func, "Copy a grease pencil frame");
+ parm = RNA_def_pointer(func, "source", "GPencilFrame", "Source", "The source frame");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ parm = RNA_def_pointer(func, "copy", "GPencilFrame", "", "The newly copied frame");
+ RNA_def_function_return(func, parm);
}
static void rna_def_gpencil_layer(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+
+ FunctionRNA *func;
srna = RNA_def_struct(brna, "GPencilLayer", NULL);
RNA_def_struct_sdna(srna, "bGPDlayer");
@@ -234,7 +463,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "frames", NULL);
RNA_def_property_struct_type(prop, "GPencilFrame");
RNA_def_property_ui_text(prop, "Frames", "Sketches for this layer on different frames");
-
+ rna_def_gpencil_frames_api(brna, prop);
+
/* Active Frame */
prop = RNA_def_property(srna, "active_frame", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "actframe");
@@ -317,9 +547,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY);
RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
+ RNA_def_function_ui_description(func, "Remove all the grease pencil layer data");
}
-static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop)
+static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
@@ -334,7 +567,7 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new", "rna_GPencil_layer_new");
RNA_def_function_ui_description(func, "Add a new grease pencil layer");
- parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer");
+ parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_boolean(func, "set_active", 0, "Set Active", "Set the newly created layer to the active layer");
parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The newly created layer");
@@ -344,7 +577,8 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a grease pencil layer");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GreasePencil");
@@ -357,7 +591,8 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
+ FunctionRNA *func;
+
static EnumPropertyItem draw_mode_items[] = {
{GP_DATA_VIEWALIGN, "CURSOR", 0, "Cursor", "Draw stroke at the 3D cursor"},
{0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weird, GP_DATA_VIEWALIGN is inverted */
@@ -376,7 +611,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "layers", NULL);
RNA_def_property_struct_type(prop, "GPencilLayer");
RNA_def_property_ui_text(prop, "Layers", "");
- rna_def_gpencil_layers(brna, prop);
+ rna_def_gpencil_layers_api(brna, prop);
/* Flags */
prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE);
@@ -390,6 +625,8 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ func = RNA_def_function(srna, "clear", "rna_GPencil_clear");
+ RNA_def_function_ui_description(func, "Remove all the grease pencil data");
}
/* --- */
diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c
index 586b71aa2da..4baf46fd0b5 100644
--- a/source/blender/makesrna/intern/rna_group.c
+++ b/source/blender/makesrna/intern/rna_group.c
@@ -54,7 +54,7 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
static void rna_Group_objects_link(Group *group, bContext *C, ReportList *reports, Object *object)
{
if (!add_to_group(group, object, CTX_data_scene(C), NULL)) {
- BKE_reportf(reports, RPT_ERROR, "Object \"%s\" already in group \"%s\"", object->id.name + 2, group->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' already in group '%s'", object->id.name + 2, group->id.name + 2);
return;
}
@@ -64,7 +64,7 @@ static void rna_Group_objects_link(Group *group, bContext *C, ReportList *report
static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object)
{
if (!rem_from_group(group, object, CTX_data_scene(C), NULL)) {
- BKE_reportf(reports, RPT_ERROR, "Object \"%s\" not in group \"%s\"", object->id.name + 2, group->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' not in group '%s'", object->id.name + 2, group->id.name + 2);
return;
}
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index a77e93f6a56..f8af2427827 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -150,7 +150,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *
static char *rna_ImageUser_path(PointerRNA *ptr)
{
if (ptr->id.data) {
- /* ImageUser *iuser= ptr->data; */
+ /* ImageUser *iuser = ptr->data; */
switch (GS(((ID *)ptr->id.data)->name)) {
case ID_TE:
@@ -366,7 +366,7 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
((unsigned char *)ibuf->rect)[i] = FTOCHAR(values[i]);
}
- ibuf->userflags |= IB_BITMAPDIRTY;
+ ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
}
BKE_image_release_ibuf(ima, lock);
@@ -388,23 +388,27 @@ static void rna_def_imageuser(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
/* animation */
prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0);
RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "frames");
RNA_def_property_range(prop, 0, MAXFRAMEF);
RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "offset");
RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "sfra");
@@ -412,12 +416,14 @@ static void rna_def_imageuser(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Start Frame",
"Global starting frame of the movie/sequence, assuming first picture has a #1");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "fie_ima");
RNA_def_property_range(prop, 1, 200);
RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "layer");
@@ -499,7 +505,8 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
RNA_def_property_ui_text(prop, "Fields", "Use fields of the image");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update");
-
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL);
RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha");
@@ -528,23 +535,27 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_enum_items(prop, image_generated_type_items);
RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
-
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gen_x");
RNA_def_property_range(prop, 1, 16384);
RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
-
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gen_y");
RNA_def_property_range(prop, 1, 16384);
RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
-
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
/* realtime properties */
prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 71196ea2a97..4d951b54c26 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -79,7 +79,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
if (ibuf == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image");
+ BKE_report(reports, RPT_ERROR, "Could not acquire buffer from image");
}
else {
ImBuf *write_ibuf;
@@ -91,7 +91,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
write_ibuf->dither = scene->r.dither_intensity;
if (!BKE_imbuf_write(write_ibuf, path, &scene->r.im_format)) {
- BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path);
+ BKE_reportf(reports, RPT_ERROR, "Could not write image '%s'", path);
}
if (write_ibuf != ibuf)
@@ -101,7 +101,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
BKE_image_release_ibuf(image, lock);
}
else {
- BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters");
+ BKE_report(reports, RPT_ERROR, "Scene not in context, could not get save parameters");
}
}
@@ -115,7 +115,7 @@ static void rna_Image_save(Image *image, ReportList *reports)
if (image->packedfile) {
if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) {
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could saved packed file to \"%s\"", image->id.name + 2, image->name);
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'", image->id.name + 2, image->name);
}
}
else if (IMB_saveiff(ibuf, filename, ibuf->flags)) {
@@ -129,11 +129,11 @@ static void rna_Image_save(Image *image, ReportList *reports)
ibuf->userflags &= ~IB_BITMAPDIRTY;
}
else {
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could not be saved to \"%s\"", image->id.name + 2, image->name);
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' could not be saved to '%s'", image->id.name + 2, image->name);
}
}
else {
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
}
}
@@ -142,7 +142,7 @@ static void rna_Image_pack(Image *image, ReportList *reports, int as_png)
ImBuf *ibuf = BKE_image_get_ibuf(image, NULL);
if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- BKE_reportf(reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG");
+ BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
}
else {
if (as_png) {
@@ -179,17 +179,20 @@ static void rna_Image_update(Image *image, ReportList *reports)
ImBuf *ibuf = BKE_image_get_ibuf(image, NULL);
if (ibuf == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
return;
}
- IMB_rect_from_float(ibuf);
+ if (ibuf->rect)
+ IMB_rect_from_float(ibuf);
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
static void rna_Image_scale(Image *image, ReportList *reports, int width, int height)
{
if (!BKE_image_scale(image, width, height)) {
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
}
}
@@ -205,7 +208,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int
ibuf = BKE_image_get_ibuf(image, NULL);
if (ibuf == NULL || ibuf->rect == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
return (int)GL_INVALID_OPERATION;
}
@@ -296,9 +299,9 @@ void RNA_api_image(StructRNA *srna)
func = RNA_def_function(srna, "scale", "rna_Image_scale");
RNA_def_function_ui_description(func, "Scale the image in pixels");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_int(func, "width", 0, 1, 10000, "", "Width", 1, 10000);
+ parm = RNA_def_int(func, "width", 1, 1, 10000, "", "Width", 1, 10000);
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_int(func, "height", 0, 1, 10000, "", "Height", 1, 10000);
+ parm = RNA_def_int(func, "height", 1, 1, 10000, "", "Height", 1, 10000);
RNA_def_property_flag(parm, PROP_REQUIRED);
func = RNA_def_function(srna, "gl_touch", "rna_Image_gl_touch");
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index ffc78ef8ca4..6520f22fbf5 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -407,19 +407,8 @@ int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct Poi
/* Internal functions that cycles uses so we need to declare (tsk tsk) */
-struct Mesh *rna_Object_to_mesh(struct Object *ob, struct ReportList *reports, struct Scene *sce, int apply_modifiers, int settings);
-void rna_Main_meshes_remove(struct Main *bmain, struct ReportList *reports, struct Mesh *mesh);
-void rna_Object_create_duplilist(struct Object *ob, struct ReportList *reports, struct Scene *sce, int settings);
-void rna_Object_free_duplilist(struct Object *ob);
void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values);
void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values);
-int rna_Object_is_modified(struct Object *ob, struct Scene *scene, int settings);
-int rna_Object_is_deform_modified(struct Object *ob, struct Scene *scene, int settings);
-void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]);
-void rna_Scene_frame_set(struct Scene *scene, int frame, float subframe);
-
-void engine_tag_redraw(struct RenderEngine *engine);
-void engine_tag_update(struct RenderEngine *engine);
#endif /* __RNA_INTERNAL_H__ */
diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c
index d4082cf3d9f..e4a29d9c674 100644
--- a/source/blender/makesrna/intern/rna_lattice.c
+++ b/source/blender/makesrna/intern/rna_lattice.c
@@ -240,6 +240,12 @@ static void rna_def_latticepoint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Deformed Location", "");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
+ prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "weight");
+ RNA_def_property_range(prop, 0.01f, 100.0f);
+ RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
+ RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
+
prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next",
"rna_iterator_array_end", "rna_iterator_array_get",
@@ -320,7 +326,7 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next",
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Points", "Points of the lattice");
-
+
/* pointers */
rna_def_animdata_common(srna);
}
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index 74b3c431183..04b8d2fa3df 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -51,7 +51,7 @@ static int rna_Main_is_dirty_get(PointerRNA *ptr)
/* XXX, not totally nice to do it this way, should store in main ? */
Main *bmain = (Main *)ptr->data;
wmWindowManager *wm;
- for (wm = bmain->wm.first; wm; wm = wm->id.next) {
+ if ((wm = bmain->wm.first)) {
return !wm->file_saved;
}
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index f5c59aa583a..cf9415a75e7 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -71,6 +71,7 @@
#include "BKE_speaker.h"
#include "BKE_movieclip.h"
#include "BKE_mask.h"
+#include "BKE_gpencil.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
@@ -92,48 +93,55 @@
#include "DNA_node_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_mask_types.h"
+#include "DNA_gpencil_types.h"
#include "ED_screen.h"
+#include "BLF_translation.h"
+
static Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name)
{
ID *id = BKE_camera_add(name);
id_us_min(id);
return (Camera *)id;
}
-static void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera)
+static void rna_Main_cameras_remove(Main *bmain, ReportList *reports, PointerRNA *camera_ptr)
{
- if (ID_REAL_USERS(camera) <= 0)
+ Camera *camera = camera_ptr->data;
+ if (ID_REAL_USERS(camera) <= 0) {
BKE_libblock_free(&bmain->camera, camera);
- else
- BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(camera_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Camera '%s' must have zero users to be removed, found %d",
camera->id.name + 2, ID_REAL_USERS(camera));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name)
{
return BKE_scene_add(name);
}
-static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene)
+static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, PointerRNA *scene_ptr)
{
/* don't call BKE_libblock_free(...) directly */
- Scene *newscene;
+ Scene *scene = scene_ptr->data;
+ Scene *scene_new;
+
+ if ((scene_new = scene->id.prev) ||
+ (scene_new = scene->id.next))
+ {
+ bScreen *sc = CTX_wm_screen(C);
+ if (sc->scene == scene) {
+ ED_screen_set_scene(C, sc, scene_new);
+ }
- if (scene->id.prev)
- newscene = scene->id.prev;
- else if (scene->id.next)
- newscene = scene->id.next;
+ BKE_scene_unlink(bmain, scene, scene_new);
+ RNA_POINTER_INVALIDATE(scene_ptr);
+ }
else {
- BKE_reportf(reports, RPT_ERROR, "Scene \"%s\" is the last, cant ve removed", scene->id.name + 2);
- return;
+ BKE_reportf(reports, RPT_ERROR, "Scene '%s' is the last, cannot be removed", scene->id.name + 2);
}
-
- if (CTX_wm_screen(C)->scene == scene)
- ED_screen_set_scene(C, CTX_wm_screen(C), newscene);
-
- BKE_scene_unlink(bmain, scene, newscene);
}
static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data)
@@ -147,7 +155,7 @@ static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, co
type = OB_MESH;
break;
case ID_CU:
- type = BKE_curve_type_get((struct Curve *)data);
+ type = BKE_curve_type_get((Curve *)data);
break;
case ID_MB:
type = OB_MBALL;
@@ -173,7 +181,7 @@ static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, co
if (RNA_enum_id_from_value(id_type_items, GS(data->name), &idname) == 0)
idname = "UNKNOWN";
- BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for a object", idname);
+ BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname);
return NULL;
}
}
@@ -190,14 +198,16 @@ static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, co
return ob;
}
-static void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object)
+static void rna_Main_objects_remove(Main *bmain, ReportList *reports, PointerRNA *object_ptr)
{
+ Object *object = object_ptr->data;
if (ID_REAL_USERS(object) <= 0) {
BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */
BKE_libblock_free(&bmain->object, object);
+ RNA_POINTER_INVALIDATE(object_ptr);
}
else {
- BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d",
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' must have zero users to be removed, found %d",
object->id.name + 2, ID_REAL_USERS(object));
}
}
@@ -208,15 +218,17 @@ static Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name)
id_us_min(id);
return (Material *)id;
}
-static void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material)
+static void rna_Main_materials_remove(Main *bmain, ReportList *reports, PointerRNA *material_ptr)
{
- if (ID_REAL_USERS(material) <= 0)
+ Material *material = material_ptr->data;
+ if (ID_REAL_USERS(material) <= 0) {
BKE_libblock_free(&bmain->mat, material);
- else
- BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(material_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Material '%s' must have zero users to be removed, found %d",
material->id.name + 2, ID_REAL_USERS(material));
-
- /* XXX python now has invalid pointer? */
+ }
}
static bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type)
@@ -226,15 +238,17 @@ static bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, i
id_us_min(&tree->id);
return tree;
}
-static void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree)
+static void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, PointerRNA *tree_ptr)
{
- if (ID_REAL_USERS(tree) <= 0)
+ bNodeTree *tree = tree_ptr->data;
+ if (ID_REAL_USERS(tree) <= 0) {
BKE_libblock_free(&bmain->nodetree, tree);
- else
- BKE_reportf(reports, RPT_ERROR, "Node Tree \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(tree_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Node tree '%s' must have zero users to be removed, found %d",
tree->id.name + 2, ID_REAL_USERS(tree));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name)
@@ -243,15 +257,17 @@ static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name)
id_us_min(&me->id);
return me;
}
-void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh)
+static void rna_Main_meshes_remove(Main *bmain, ReportList *reports, PointerRNA *mesh_ptr)
{
- if (ID_REAL_USERS(mesh) <= 0)
+ Mesh *mesh = mesh_ptr->data;
+ if (ID_REAL_USERS(mesh) <= 0) {
BKE_libblock_free(&bmain->mesh, mesh);
- else
- BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(mesh_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Mesh '%s' must have zero users to be removed, found %d",
mesh->id.name + 2, ID_REAL_USERS(mesh));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type)
@@ -261,15 +277,17 @@ static Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type)
id_us_min(&lamp->id);
return lamp;
}
-static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp)
+static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, PointerRNA *lamp_ptr)
{
- if (ID_REAL_USERS(lamp) <= 0)
+ Lamp *lamp = lamp_ptr->data;
+ if (ID_REAL_USERS(lamp) <= 0) {
BKE_libblock_free(&bmain->lamp, lamp);
- else
- BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(lamp_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Lamp '%s' must have zero users to be removed, found %d",
lamp->id.name + 2, ID_REAL_USERS(lamp));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer)
@@ -286,21 +304,24 @@ static Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, con
errno = 0;
ima = BKE_image_load(filepath);
- if (!ima)
- BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath,
- errno ? strerror(errno) : "Unsupported image format");
+ if (!ima) {
+ BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
+ errno ? strerror(errno) : TIP_("unsupported image format"));
+ }
return ima;
}
-static void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
+static void rna_Main_images_remove(Main *bmain, ReportList *reports, PointerRNA *image_ptr)
{
- if (ID_REAL_USERS(image) <= 0)
+ Image *image = image_ptr->data;
+ if (ID_REAL_USERS(image) <= 0) {
BKE_libblock_free(&bmain->image, image);
- else
- BKE_reportf(reports, RPT_ERROR, "Image \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(image_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Image '%s' must have zero users to be removed, found %d",
image->id.name + 2, ID_REAL_USERS(image));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name)
@@ -309,13 +330,17 @@ static Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name)
id_us_min(&lt->id);
return lt;
}
-static void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt)
+static void rna_Main_lattices_remove(Main *bmain, ReportList *reports, PointerRNA *lt_ptr)
{
- if (ID_REAL_USERS(lt) <= 0)
+ Lattice *lt = lt_ptr->data;
+ if (ID_REAL_USERS(lt) <= 0) {
BKE_libblock_free(&bmain->latt, lt);
- else
- BKE_reportf(reports, RPT_ERROR, "Lattice \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(lt_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Lattice '%s' must have zero users to be removed, found %d",
lt->id.name + 2, ID_REAL_USERS(lt));
+ }
}
static Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type)
@@ -324,13 +349,17 @@ static Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int typ
id_us_min(&cu->id);
return cu;
}
-static void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu)
+static void rna_Main_curves_remove(Main *bmain, ReportList *reports, PointerRNA *cu_ptr)
{
- if (ID_REAL_USERS(cu) <= 0)
+ Curve *cu = cu_ptr->data;
+ if (ID_REAL_USERS(cu) <= 0) {
BKE_libblock_free(&bmain->curve, cu);
- else
- BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(cu_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Curve '%s' must have zero users to be removed, found %d",
cu->id.name + 2, ID_REAL_USERS(cu));
+ }
}
static MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name)
@@ -339,13 +368,17 @@ static MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name)
id_us_min(&mb->id);
return mb;
}
-static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb)
+static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, PointerRNA *mb_ptr)
{
- if (ID_REAL_USERS(mb) <= 0)
+ MetaBall *mb = mb_ptr->data;
+ if (ID_REAL_USERS(mb) <= 0) {
BKE_libblock_free(&bmain->mball, mb);
- else
- BKE_reportf(reports, RPT_ERROR, "Metaball \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(mb_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Metaball '%s' must have zero users to be removed, found %d",
mb->id.name + 2, ID_REAL_USERS(mb));
+ }
}
static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath)
@@ -356,21 +389,23 @@ static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *
font = BKE_vfont_load(bmain, filepath);
if (!font)
- BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath,
- errno ? strerror(errno) : "Unsupported font format");
+ BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
+ errno ? strerror(errno) : TIP_("unsupported font format"));
return font;
}
-static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
+static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, PointerRNA *vfont_ptr)
{
- if (ID_REAL_USERS(vfont) <= 0)
+ VFont *vfont = vfont_ptr->data;
+ if (ID_REAL_USERS(vfont) <= 0) {
BKE_libblock_free(&bmain->vfont, vfont);
- else
- BKE_reportf(reports, RPT_ERROR, "Font \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(vfont_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Font '%s' must have zero users to be removed, found %d",
vfont->id.name + 2, ID_REAL_USERS(vfont));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type)
@@ -380,13 +415,17 @@ static Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int typ
id_us_min(&tex->id);
return tex;
}
-static void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex)
+static void rna_Main_textures_remove(Main *bmain, ReportList *reports, PointerRNA *tex_ptr)
{
- if (ID_REAL_USERS(tex) <= 0)
+ Tex *tex = tex_ptr->data;
+ if (ID_REAL_USERS(tex) <= 0) {
BKE_libblock_free(&bmain->tex, tex);
- else
- BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(tex_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Texture '%s' must have zero users to be removed, found %d",
tex->id.name + 2, ID_REAL_USERS(tex));
+ }
}
static Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name)
@@ -395,13 +434,17 @@ static Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name)
id_us_min(&brush->id);
return brush;
}
-static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush)
+static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, PointerRNA *brush_ptr)
{
- if (ID_REAL_USERS(brush) <= 0)
+ Brush *brush = brush_ptr->data;
+ if (ID_REAL_USERS(brush) <= 0) {
BKE_libblock_free(&bmain->brush, brush);
- else
- BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(brush_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Brush '%s' must have zero users to be removed, found %d",
brush->id.name + 2, ID_REAL_USERS(brush));
+ }
}
static World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name)
@@ -410,24 +453,29 @@ static World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name)
id_us_min(&world->id);
return world;
}
-static void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world)
+static void rna_Main_worlds_remove(Main *bmain, ReportList *reports, PointerRNA *world_ptr)
{
- if (ID_REAL_USERS(world) <= 0)
+ Group *world = world_ptr->data;
+ if (ID_REAL_USERS(world) <= 0) {
BKE_libblock_free(&bmain->world, world);
- else
- BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(world_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "World '%s' must have zero users to be removed, found %d",
world->id.name + 2, ID_REAL_USERS(world));
+ }
}
static Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name)
{
return add_group(name);
}
-static void rna_Main_groups_remove(Main *bmain, Group *group)
+static void rna_Main_groups_remove(Main *bmain, PointerRNA *group_ptr)
{
+ Group *group = group_ptr->data;
BKE_group_unlink(group);
BKE_libblock_free(&bmain->group, group);
- /* XXX python now has invalid pointer? */
+ RNA_POINTER_INVALIDATE(group_ptr);
}
static Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name)
@@ -436,26 +484,29 @@ static Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name)
id_us_min(&speaker->id);
return speaker;
}
-static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker)
+static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, PointerRNA *speaker_ptr)
{
- if (ID_REAL_USERS(speaker) <= 0)
+ Speaker *speaker = speaker_ptr->data;
+ if (ID_REAL_USERS(speaker) <= 0) {
BKE_libblock_free(&bmain->speaker, speaker);
- else
- BKE_reportf(reports, RPT_ERROR, "Speaker \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(speaker_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Speaker '%s' must have zero users to be removed, found %d",
speaker->id.name + 2, ID_REAL_USERS(speaker));
-
- /* XXX python now has invalid pointer? */
+ }
}
static Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name)
{
return BKE_text_add(name);
}
-static void rna_Main_texts_remove(Main *bmain, Text *text)
+static void rna_Main_texts_remove(Main *bmain, PointerRNA *text_ptr)
{
+ Text *text = text_ptr->data;
BKE_text_unlink(bmain, text);
BKE_libblock_free(&bmain->text, text);
- /* XXX python now has invalid pointer? */
+ RNA_POINTER_INVALIDATE(text_ptr);
}
static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath)
@@ -466,8 +517,8 @@ static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *f
txt = BKE_text_load(filepath, bmain->name);
if (!txt)
- BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath,
- errno ? strerror(errno) : "Unable to load text");
+ BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
+ errno ? strerror(errno) : TIP_("unable to load text"));
return txt;
}
@@ -478,15 +529,17 @@ static bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name)
id_us_min(&arm->id);
return arm;
}
-static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm)
+static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, PointerRNA *arm_ptr)
{
- if (ID_REAL_USERS(arm) <= 0)
+ bArmature *arm = arm_ptr->data;
+ if (ID_REAL_USERS(arm) <= 0) {
BKE_libblock_free(&bmain->armature, arm);
- else
- BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(arm_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Armature '%s' must have zero users to be removed, found %d",
arm->id.name + 2, ID_REAL_USERS(arm));
-
- /* XXX python now has invalid pointer? */
+ }
}
static bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name)
@@ -496,15 +549,17 @@ static bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name)
act->id.flag &= ~LIB_FAKEUSER;
return act;
}
-static void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act)
+static void rna_Main_actions_remove(Main *bmain, ReportList *reports, PointerRNA *act_ptr)
{
- if (ID_REAL_USERS(act) <= 0)
+ bAction *act = act_ptr->data;
+ if (ID_REAL_USERS(act) <= 0) {
BKE_libblock_free(&bmain->action, act);
- else
- BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(act_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Action '%s' must have zero users to be removed, found %d",
act->id.name + 2, ID_REAL_USERS(act));
-
- /* XXX python now has invalid pointer? */
+ }
}
static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name)
@@ -513,15 +568,17 @@ static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name)
id_us_min(&part->id);
return part;
}
-static void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part)
+static void rna_Main_particles_remove(Main *bmain, ReportList *reports, PointerRNA *part_ptr)
{
- if (ID_REAL_USERS(part) <= 0)
+ ParticleSettings *part = part_ptr->data;
+ if (ID_REAL_USERS(part) <= 0) {
BKE_libblock_free(&bmain->particle, part);
- else
- BKE_reportf(reports, RPT_ERROR, "Particle Settings \"%s\" must have zero users to be removed, found %d",
+ RNA_POINTER_INVALIDATE(part_ptr);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Particle settings '%s' must have zero users to be removed, found %d",
part->id.name + 2, ID_REAL_USERS(part));
-
- /* XXX python now has invalid pointer? */
+ }
}
static MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath)
@@ -532,17 +589,18 @@ static MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *repor
clip = BKE_movieclip_file_add(filepath);
if (!clip)
- BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath,
- errno ? strerror(errno) : "Unable to load movie clip");
+ BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
+ errno ? strerror(errno) : TIP_("unable to load movie clip"));
return clip;
}
-static void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip)
+static void rna_Main_movieclips_remove(Main *bmain, PointerRNA *clip_ptr)
{
+ MovieClip *clip = clip_ptr->data;
BKE_movieclip_unlink(bmain, clip);
BKE_libblock_free(&bmain->movieclip, clip);
- /* XXX python now has invalid pointer? */
+ RNA_POINTER_INVALIDATE(clip_ptr);
}
static Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name)
@@ -554,11 +612,25 @@ static Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name)
return mask;
}
-static void rna_Main_masks_remove(Main *bmain, Mask *mask)
+static void rna_Main_masks_remove(Main *bmain, PointerRNA *mask_ptr)
{
+ Mask *mask = mask_ptr->data;
BKE_mask_free(bmain, mask);
BKE_libblock_free(&bmain->mask, mask);
- /* XXX python now has invalid pointer? */
+ RNA_POINTER_INVALIDATE(mask_ptr);
+}
+
+static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, PointerRNA *gpd_ptr)
+{
+ bGPdata *gpd = gpd_ptr->data;
+ if (ID_REAL_USERS(gpd) <= 0) {
+ BKE_gpencil_free(gpd);
+ BKE_libblock_free(&bmain->gpencil, gpd);
+ RNA_POINTER_INVALIDATE(gpd_ptr);
+ }
+ else
+ BKE_reportf(reports, RPT_ERROR, "Grease pencil '%s' must have zero users to be removed, found %d",
+ gpd->id.name + 2, ID_REAL_USERS(gpd));
}
/* tag functions, all the same */
@@ -664,7 +736,8 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a camera from the current blendfile");
parm = RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_cameras_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -699,7 +772,8 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a scene from the current blendfile");
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_scenes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -738,7 +812,8 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a object from the current blendfile");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_objects_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -773,7 +848,8 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a material from the current blendfile");
parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_materials_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -816,7 +892,8 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a node tree from the current blendfile");
parm = RNA_def_pointer(func, "tree", "NodeTree", "", "Node tree to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_node_groups_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -850,7 +927,8 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile");
parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_meshes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -886,7 +964,8 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile");
parm = RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -975,9 +1054,9 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a new image to the main database");
parm = RNA_def_string(func, "name", "Image", 0, "", "New name for the datablock");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image", 0, INT_MAX);
+ parm = RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image", 1, INT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_int(func, "height", 1024, 1, INT_MAX, "", "Height of the image", 0, INT_MAX);
+ parm = RNA_def_int(func, "height", 1024, 1, INT_MAX, "", "Height of the image", 1, INT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_boolean(func, "alpha", 0, "Alpha", "Use alpha channel");
RNA_def_boolean(func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color");
@@ -998,7 +1077,8 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove an image from the current blendfile");
parm = RNA_def_pointer(func, "image", "Image", "", "Image to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_images_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1033,7 +1113,8 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a lattice from the current blendfile");
parm = RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_lattices_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1069,7 +1150,8 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a curve from the current blendfile");
parm = RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_curves_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1103,7 +1185,8 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a metaball from the current blendfile");
parm = RNA_def_pointer(func, "metaball", "MetaBall", "", "Metaball to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_metaballs_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1138,7 +1221,8 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a font from the current blendfile");
parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "Font to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_fonts_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1174,7 +1258,8 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a texture from the current blendfile");
parm = RNA_def_pointer(func, "texture", "Texture", "", "Texture to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_textures_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1208,7 +1293,8 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a brush from the current blendfile");
parm = RNA_def_pointer(func, "brush", "Brush", "", "Brush to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_brushes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1243,7 +1329,8 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a world from the current blendfile");
parm = RNA_def_pointer(func, "world", "World", "", "World to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_worlds_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1277,7 +1364,8 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Main_groups_remove");
RNA_def_function_ui_description(func, "Remove a group from the current blendfile");
parm = RNA_def_pointer(func, "group", "Group", "", "Group to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_groups_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1312,7 +1400,8 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a speaker from the current blendfile");
parm = RNA_def_pointer(func, "speaker", "Speaker", "", "Speaker to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_speakers_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1346,7 +1435,8 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Main_texts_remove");
RNA_def_function_ui_description(func, "Remove a text from the current blendfile");
parm = RNA_def_pointer(func, "text", "Text", "", "Text to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* load func */
func = RNA_def_function(srna, "load", "rna_Main_texts_load");
@@ -1414,7 +1504,8 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a armature from the current blendfile");
parm = RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_armatures_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1448,7 +1539,8 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a action from the current blendfile");
parm = RNA_def_pointer(func, "action", "Action", "", "Action to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_actions_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1482,7 +1574,8 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a particle settings instance from the current blendfile");
parm = RNA_def_pointer(func, "particle", "ParticleSettings", "", "Particle Settings to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "tag", "rna_Main_particles_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1509,6 +1602,21 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ func = RNA_def_function(srna, "new", "gpencil_data_addnew");
+ RNA_def_function_flag(func, FUNC_NO_SELF);
+ parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the datablock");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* return type */
+ parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "New grease pencil datablock");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_Main_grease_pencil_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove a grease pencil instance from the current blendfile");
+ parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "Grease Pencil to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+
prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL);
@@ -1532,7 +1640,8 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Main_movieclips_remove");
RNA_def_function_ui_description(func, "Remove a movie clip from the current blendfile.");
parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* load func */
func = RNA_def_function(srna, "load", "rna_Main_movieclip_load");
@@ -1563,7 +1672,7 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
/* new func */
func = RNA_def_function(srna, "new", "rna_Main_mask_new");
RNA_def_function_ui_description(func, "Add a new mask with a given name to the main database");
- parm = RNA_def_string_file_path(func, "name", "", MAX_ID_NAME - 2, "Mask", "Name of new mask datablock");
+ RNA_def_string_file_path(func, "name", "", MAX_ID_NAME - 2, "Mask", "Name of new mask datablock");
/* return type */
parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask datablock");
RNA_def_function_return(func, parm);
@@ -1572,7 +1681,8 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Main_masks_remove");
RNA_def_function_ui_description(func, "Remove a masks from the current blendfile.");
parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 97d9cc961ef..3f23a376ea3 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -158,8 +158,7 @@ static void rna_Mask_layer_active_index_range(PointerRNA *ptr, int *min, int *ma
Mask *mask = (Mask *)ptr->id.data;
*min = 0;
- *max = mask->masklay_tot - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, mask->masklay_tot - 1);
*softmin = *min;
*softmax = *max;
@@ -315,14 +314,16 @@ static MaskLayer *rna_Mask_layers_new(Mask *mask, const char *name)
return masklay;
}
-static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, MaskLayer *masklay)
+static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, PointerRNA *masklay_ptr)
{
+ MaskLayer *masklay = masklay_ptr->data;
if (BLI_findindex(&mask->masklayers, masklay) == -1) {
- BKE_reportf(reports, RPT_ERROR, "MaskLayer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Mask layer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2);
return;
}
BKE_mask_layer_remove(mask, masklay);
+ RNA_POINTER_INVALIDATE(masklay_ptr);
WM_main_add_notifier(NC_MASK | NA_EDITED, mask);
}
@@ -705,7 +706,9 @@ static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Mask_layers_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove layer from this mask");
- RNA_def_pointer(func, "layer", "MaskLayer", "", "Shape to be removed");
+ parm = RNA_def_pointer(func, "layer", "MaskLayer", "", "Shape to be removed");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* clear all layers */
func = RNA_def_function(srna, "clear", "rna_Mask_layers_clear");
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 96529de074b..9232ae098ea 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -81,12 +81,14 @@ EnumPropertyItem ramp_blend_items[] = {
#include "MEM_guardedalloc.h"
#include "DNA_node_types.h"
+#include "DNA_object_types.h"
#include "BKE_depsgraph.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_texture.h"
#include "BKE_node.h"
+#include "BKE_paint.h"
#include "ED_node.h"
@@ -105,7 +107,18 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *p
}
}
-static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Material_update_previews(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Material *ma = ptr->id.data;
+
+ if (ma->nodetree)
+ ntreeClearPreview(ma->nodetree);
+
+ rna_Material_update(bmain, scene, ptr);
+}
+
+
+static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
Material *ma = ptr->id.data;
@@ -319,7 +332,7 @@ MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *re
{
MTex *mtex = add_mtex_id(self_id, -1);
if (mtex == NULL) {
- BKE_reportf(reports, RPT_ERROR, "maximum number of textures added %d", MAX_MTEX);
+ BKE_reportf(reports, RPT_ERROR, "Maximum number of textures added %d", MAX_MTEX);
return NULL;
}
@@ -334,7 +347,7 @@ MTex *rna_mtex_texture_slots_create(ID *self_id, struct bContext *C, ReportList
MTex *mtex;
if (index < 0 || index >= MAX_MTEX) {
- BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index);
+ BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
return NULL;
}
@@ -354,12 +367,12 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r
give_active_mtex(self_id, &mtex_ar, &act);
if (mtex_ar == NULL) {
- BKE_report(reports, RPT_ERROR, "mtex not found for this type");
+ BKE_report(reports, RPT_ERROR, "Mtex not found for this type");
return;
}
if (index < 0 || index >= MAX_MTEX) {
- BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index);
+ BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
return;
}
@@ -468,6 +481,12 @@ static void rna_def_material_mtex(BlenderRNA *brna)
"from their parent");
RNA_def_property_update(prop, 0, "rna_Material_update");
+ prop = RNA_def_property(srna, "use_map_to_bounds", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_MAPTO_BOUNDS);
+ RNA_def_property_ui_text(prop, "Map to Bounds",
+ "Map coordinates in object bounds");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
+
prop = RNA_def_property(srna, "use_from_original", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG);
RNA_def_property_ui_text(prop, "From Original",
@@ -1749,7 +1768,7 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "pr_type");
RNA_def_property_enum_items(prop, preview_type_items);
RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
- RNA_def_property_update(prop, 0, "rna_Material_update");
+ RNA_def_property_update(prop, 0, "rna_Material_update_previews");
prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "amb");
@@ -1817,7 +1836,12 @@ void RNA_def_material(BlenderRNA *brna)
"Material uses the light group exclusively - these lamps are excluded "
"from other scene lighting");
RNA_def_property_update(prop, 0, "rna_Material_update");
-
+
+ prop = RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL);
+ RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, material uses local light group with the same name");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
+
prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE);
RNA_def_property_ui_text(prop, "Traceable",
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 59cf202a416..287995e0aa6 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1010,8 +1010,7 @@ static void rna_MeshPoly_material_index_range(PointerRNA *ptr, int *min, int *ma
{
Mesh *me = rna_mesh(ptr);
*min = 0;
- *max = me->totcol - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, me->totcol - 1);
}
static int rna_MeshVertex_index_get(PointerRNA *ptr)
@@ -1275,12 +1274,12 @@ static PointerRNA rna_Mesh_tessface_vertex_color_new(struct Mesh *me, struct bCo
int index;
if (me->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add tessface colors's in editmode");
+ BKE_report(reports, RPT_ERROR, "Cannot add tessface colors in edit mode");
return PointerRNA_NULL;
}
if (me->mpoly) {
- BKE_report(reports, RPT_ERROR, "Can't add tessface colors's when MPoly's exist");
+ BKE_report(reports, RPT_ERROR, "Cannot add tessface colors when MPoly's exist");
return PointerRNA_NULL;
}
@@ -1368,12 +1367,12 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, struct bCont
int index;
if (me->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Can't add tessface uv's in editmode");
+ BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's in edit mode");
return PointerRNA_NULL;
}
if (me->mpoly) {
- BKE_report(reports, RPT_ERROR, "Can't add tessface uv's when MPoly's exist");
+ BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's when MPoly's exist");
return PointerRNA_NULL;
}
@@ -2394,7 +2393,8 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a vertex color layer");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
#endif
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
@@ -2571,7 +2571,8 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a vertex color layer");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
#endif
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
@@ -2808,7 +2809,7 @@ static void rna_def_mesh(BlenderRNA *brna)
prop = RNA_def_property(srna, "skin_vertices", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_skin_vertices_begin", NULL, NULL, NULL,
- "rna_Mesh_skin_vertices_length", NULL, NULL, NULL);
+ "rna_Mesh_skin_vertices_length", NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "MeshSkinVertexLayer");
RNA_def_property_ui_text(prop, "Skin Vertices", "All skin vertices");
rna_def_skin_vertices(brna, prop);
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index b63390c65ed..1e75569c841 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -78,7 +78,7 @@ void RNA_api_mesh(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func = RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare");
- parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to");
+ RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
/* return value */
parm = RNA_def_string(func, "result", "nothing", 64, "Return value", "String description of result of comparison");
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index c8b52b45604..08eefc082bf 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -126,19 +127,17 @@ static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type)
return ml;
}
-static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, MetaElem *ml)
+static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, PointerRNA *ml_ptr)
{
- int found = 0;
+ MetaElem *ml = ml_ptr->data;
- found = BLI_remlink_safe(&mb->elems, ml);
-
- if (!found) {
- BKE_reportf(reports, RPT_ERROR, "Metaball \"%s\" does not contain spline given", mb->id.name + 2);
+ if (BLI_remlink_safe(&mb->elems, ml) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "Metaball '%s' does not contain spline given", mb->id.name + 2);
return;
}
MEM_freeN(ml);
- /* invalidate pointer!, no can do */
+ RNA_POINTER_INVALIDATE(ml_ptr);
/* cheating way for importers to avoid slow updates */
if (mb->id.us > 0) {
@@ -254,7 +253,8 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove an element from the metaball");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_MetaBall_elements_clear");
RNA_def_function_ui_description(func, "Remove all elements from the metaball");
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index bc3fd6e2f3c..a381dd489c7 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -84,6 +84,7 @@ EnumPropertyItem modifier_type_items[] = {
{eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", ""},
{eModifierType_Displace, "DISPLACE", ICON_MOD_DISPLACE, "Displace", ""},
{eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", ""},
+ {eModifierType_LaplacianSmooth, "LAPLACIANSMOOTH", ICON_MOD_SMOOTH, "Laplacian Smooth", ""},
{eModifierType_Lattice, "LATTICE", ICON_MOD_LATTICE, "Lattice", ""},
{eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""},
{eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""},
@@ -210,6 +211,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_RemeshModifier;
case eModifierType_Skin:
return &RNA_SkinModifier;
+ case eModifierType_LaplacianSmooth:
+ return &RNA_LaplacianSmoothModifier;
default:
return &RNA_Modifier;
}
@@ -257,9 +260,6 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
{
SmokeModifierData *smd = (SmokeModifierData *)ptr->data;
Object *ob = (Object *)ptr->id.data;
- ParticleSystemModifierData *psmd = NULL;
- ParticleSystem *psys = NULL;
- ParticleSettings *part = NULL;
/* nothing changed */
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
@@ -273,28 +273,6 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
ob->dt = OB_WIRE;
break;
case MOD_SMOKE_TYPE_FLOW:
- for (psys = ob->particlesystem.first; psys; psys = psys->next)
- if (psys->part->type == PART_EMITTER)
- break;
- if (ob->type == OB_MESH && !psys) {
- /* add particle system */
- psmd = (ParticleSystemModifierData *)object_add_particle_system(scene, ob, NULL);
- if (psmd) {
- psys = psmd->psys;
- part = psys->part;
- part->lifetime = 1.0f;
- part->sta = 1.0f;
- part->end = 250.0f;
- part->ren_as = PART_DRAW_NOT;
- part->flag |= PART_UNBORN;
- part->draw_as = PART_DRAW_DOT;
- BLI_strncpy(psys->name, "SmokeParticles", sizeof(psys->name));
- psys->recalc |= (PSYS_RECALC_RESET | PSYS_RECALC_PHYS);
- DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
- }
- }
- if (smd->flow)
- smd->flow->psys = psys;
case MOD_SMOKE_TYPE_COLL:
case 0:
default:
@@ -384,6 +362,12 @@ static void rna_SmoothModifier_vgroup_set(PointerRNA *ptr, const char *value)
rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name));
}
+static void rna_LaplacianSmoothModifier_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ LaplacianSmoothModifierData *lmd = (LaplacianSmoothModifierData *)ptr->data;
+ rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name));
+}
+
static void rna_WaveModifier_vgroup_set(PointerRNA *ptr, const char *value)
{
WaveModifierData *lmd = (WaveModifierData *)ptr->data;
@@ -402,6 +386,12 @@ static void rna_SolidifyModifier_vgroup_set(PointerRNA *ptr, const char *value)
rna_object_vgroup_name_set(ptr, value, smd->defgrp_name, sizeof(smd->defgrp_name));
}
+static void rna_DecimateModifier_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ DecimateModifierData *dmd = (DecimateModifierData *)ptr->data;
+ rna_object_vgroup_name_set(ptr, value, dmd->defgrp_name, sizeof(dmd->defgrp_name));
+}
+
static void rna_WeightVGModifier_vgroup_set(PointerRNA *ptr, const char *value)
{
ModifierData *md = (ModifierData *)ptr->data;
@@ -491,8 +481,7 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max
MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
*min = 0;
- *max = mmd->totlvl; /* intentionally _not_ -1 */
- *max = MAX2(0, *max);
+ *max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */
}
static int rna_MultiresModifier_external_get(PointerRNA *ptr)
@@ -1129,6 +1118,13 @@ static void rna_def_modifier_mirror(BlenderRNA *brna)
static void rna_def_modifier_decimate(BlenderRNA *brna)
{
+ static EnumPropertyItem modifier_decim_mode_items[] = {
+ {MOD_DECIM_MODE_COLLAPSE, "COLLAPSE", 0, "Collapse", "Use edge collapsing"},
+ {MOD_DECIM_MODE_UNSUBDIV, "UNSUBDIV", 0, "Un-Subdivide", "Use un-subdivide face reduction"},
+ {MOD_DECIM_MODE_DISSOLVE, "DISSOLVE", 0, "Planar", "Dissolve geometry to form planar polygons"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
StructRNA *srna;
PropertyRNA *prop;
@@ -1137,15 +1133,65 @@ static void rna_def_modifier_decimate(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "DecimateModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_DECIM);
+ prop = RNA_def_property(srna, "decimate_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, modifier_decim_mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ /* (mode == MOD_DECIM_MODE_COLLAPSE) */
prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "percent");
RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_range(prop, 0, 1, 1, 2);
- RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to");
+ RNA_def_property_ui_range(prop, 0, 1, 1, 4);
+ RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to (collapse only)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ /* (mode == MOD_DECIM_MODE_UNSUBDIV) */
+ prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "iter");
+ RNA_def_property_range(prop, 0, SHRT_MAX);
+ RNA_def_property_ui_range(prop, 0, 100, 1, 0);
+ RNA_def_property_ui_text(prop, "Iterations", "Number of times reduce the geometry (unsubdivide only)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ /* (mode == MOD_DECIM_MODE_DISSOLVE) */
+ prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "angle");
+ RNA_def_property_range(prop, 0, DEG2RAD(180));
+ RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2);
+ RNA_def_property_ui_text(prop, "Angle Limit", "Only dissolve angles below this (planar only)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ /* (mode == MOD_DECIM_MODE_COLLAPSE) */
+ prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
+ RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name (collapse only)");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DecimateModifier_vgroup_set");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence (collapse only)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_collapse_triangulate", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_TRIANGULATE);
+ RNA_def_property_ui_text(prop, "Triangulate", "Keep triangulated faces resulting from decimation (collapse only)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ /* end collapse-only option */
+
+ /* (mode == MOD_DECIM_MODE_DISSOLVE) */
+ prop = RNA_def_property(srna, "use_dissolve_boundaries", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS);
+ RNA_def_property_ui_text(prop, "All Boundaries", "Dissolve all vertices inbetween face boundaries (planar only)");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ /* end dissolve-only option */
+
+
+ /* all modes use this */
prop = RNA_def_property(srna, "face_count", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "faceCount");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Face Count", "The current number of faces in the decimated mesh");
}
@@ -1742,6 +1788,64 @@ static void rna_def_modifier_smooth(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
+static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "LaplacianSmoothModifier", "Modifier");
+ RNA_def_struct_ui_text(srna, "Laplacian Smooth Modifier", "Smoothing effect modifier");
+ RNA_def_struct_sdna(srna, "LaplacianSmoothModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH);
+
+ prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_X);
+ RNA_def_property_ui_text(prop, "X", "Smooth object along X axis");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Y);
+ RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Z);
+ RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION);
+ RNA_def_property_ui_text(prop, "Preserve Volume", "Apply volume preservation after smooth");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "lambda_factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "lambda");
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0000001, 1000.0, 0.0000001, 8);
+ RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth factor effect");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "lambda_border", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "lambda_border");
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0000001, 1000.0, 0.0000001, 8);
+ RNA_def_property_ui_text(prop, "Lambda Border", "Lambda factor in border");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "repeat");
+ RNA_def_property_ui_range(prop, 0, 200, 1, 0);
+ RNA_def_property_ui_text(prop, "Repeat", "");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
+ 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_LaplacianSmoothModifier_vgroup_set");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
static void rna_def_modifier_cast(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2296,6 +2400,13 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Offset", "Distance to keep from the target");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "project_limit", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "projLimit");
+ RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0, 100, 1, 2);
+ RNA_def_property_ui_text(prop, "Project Limit", "Limit the distance used for projection (zero disables)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "use_project_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS);
RNA_def_property_ui_text(prop, "X", "");
@@ -3356,6 +3467,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_ocean(brna);
rna_def_modifier_remesh(brna);
rna_def_modifier_skin(brna);
+ rna_def_modifier_laplaciansmooth(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 4ff1365427e..574f06e9107 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -302,7 +303,7 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo
NlaStrip *strip = add_nlastrip(action);
if (strip == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Unable to create new strip");
+ BKE_report(reports, RPT_ERROR, "Unable to create new strip");
return NULL;
}
@@ -310,8 +311,8 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo
strip->start = start;
if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) {
- BKE_reportf(reports, RPT_ERROR,
- "Unable to add strip. Track doesn't have any space to accommodate this new strip");
+ BKE_report(reports, RPT_ERROR,
+ "Unable to add strip (the track does not have any space to accommodate this new strip)");
free_nlastrip(NULL, strip);
return NULL;
}
@@ -345,16 +346,18 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo
return strip;
}
-static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, NlaStrip *strip)
+static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, PointerRNA *strip_ptr)
{
+ NlaStrip *strip = strip_ptr->data;
if (BLI_findindex(&track->strips, strip) == -1) {
- BKE_reportf(reports, RPT_ERROR, "NLA's Strip '%s' not found in track '%s'", strip->name, track->name);
+ BKE_reportf(reports, RPT_ERROR, "NLA strip '%s' not found in track '%s'", strip->name, track->name);
return;
}
- else {
- free_nlastrip(&track->strips, strip);
- WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
- }
+
+ free_nlastrip(&track->strips, strip);
+ RNA_POINTER_INVALIDATE(strip_ptr);
+
+ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
}
/* Set the 'solo' setting for the given NLA-track, making sure that it is the only one
@@ -639,7 +642,8 @@ static void rna_api_nlatrack_strips(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a NLA Strip");
parm = RNA_def_pointer(func, "strip", "NlaStrip", "", "NLA Strip to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_nlatrack(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index d650c8dbf69..33a41ff6f6e 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -35,12 +35,16 @@
#include "rna_internal_types.h"
#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_text_types.h"
#include "DNA_texture_types.h"
#include "BKE_animsys.h"
@@ -48,9 +52,9 @@
#include "BKE_node.h"
#include "BKE_image.h"
#include "BKE_texture.h"
+#include "BKE_idprop.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
+#include "IMB_imbuf.h"
#include "WM_types.h"
@@ -71,12 +75,12 @@ EnumPropertyItem node_quality_items[] = {
};
EnumPropertyItem node_chunksize_items[] = {
- {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"},
- {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"},
- {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"},
- {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"},
- {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"},
- {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"},
+ {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"},
+ {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"},
+ {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"},
+ {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"},
+ {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"},
+ {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"},
{0, NULL, 0, NULL, NULL}
};
@@ -88,6 +92,7 @@ EnumPropertyItem node_socket_type_items[] = {
{SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
{SOCK_MESH, "MESH", 0, "Mesh", ""},
{SOCK_INT, "INT", 0, "Int", ""},
+ {SOCK_STRING, "STRING", 0, "String", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -188,6 +193,10 @@ EnumPropertyItem prop_wave_items[] = {
SUBTYPE(FLOAT, Float, TIME, Time) \
SUBTYPE(FLOAT, Float, DISTANCE, Distance)
+#define NODE_DEFINE_SUBTYPES_STRING \
+ SUBTYPE(STRING, String, NONE, None) \
+ SUBTYPE(STRING, String, FILEPATH, Filepath)
+
#define NODE_DEFINE_SUBTYPES_VECTOR \
SUBTYPE(VECTOR, Vector, NONE, None) \
SUBTYPE(VECTOR, Vector, TRANSLATION, Translation) \
@@ -200,14 +209,18 @@ EnumPropertyItem prop_wave_items[] = {
#define NODE_DEFINE_SUBTYPES \
NODE_DEFINE_SUBTYPES_INT \
NODE_DEFINE_SUBTYPES_FLOAT \
- NODE_DEFINE_SUBTYPES_VECTOR
+ NODE_DEFINE_SUBTYPES_STRING \
+ NODE_DEFINE_SUBTYPES_VECTOR \
#ifdef RNA_RUNTIME
#include "BLI_linklist.h"
+#include "BKE_global.h"
+
#include "ED_node.h"
+#include "RE_engine.h"
#include "RE_pipeline.h"
#include "DNA_scene_types.h"
@@ -226,10 +239,6 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr)
case NODE_GROUP:
return &RNA_NodeGroup;
- case NODE_FORLOOP:
- return &RNA_NodeForLoop;
- case NODE_WHILELOOP:
- return &RNA_NodeWhileLoop;
case NODE_FRAME:
return &RNA_NodeFrame;
case NODE_REROUTE:
@@ -290,6 +299,9 @@ static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr)
case SOCK_VECTOR:
NODE_DEFINE_SUBTYPES_VECTOR
break;
+ case SOCK_STRING:
+ NODE_DEFINE_SUBTYPES_STRING
+ break;
case SOCK_RGBA:
return &RNA_NodeSocketRGBA;
case SOCK_SHADER:
@@ -689,7 +701,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r
bNodeTemplate ntemp;
if (type == NODE_GROUP && group == NULL) {
- BKE_reportf(reports, RPT_ERROR, "node type \'GROUP\' missing group argument");
+ BKE_report(reports, RPT_ERROR, "Node type 'GROUP' missing group argument");
return NULL;
}
@@ -700,7 +712,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r
node = nodeAddNode(ntree, &ntemp);
if (node == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Unable to create node");
+ BKE_report(reports, RPT_ERROR, "Unable to create node");
}
else {
ntreeUpdateTree(ntree); /* update group node socket links*/
@@ -753,20 +765,20 @@ static bNode *rna_NodeTree_node_texture_new(bNodeTree *ntree, bContext *C, Repor
return node;
}
-static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNode *node)
+static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, PointerRNA *node_ptr)
{
+ bNode *node = node_ptr->data;
if (BLI_findindex(&ntree->nodes, node) == -1) {
- BKE_reportf(reports, RPT_ERROR, "Unable to locate node '%s' in nodetree", node->name);
+ BKE_reportf(reports, RPT_ERROR, "Unable to locate node '%s' in node tree", node->name);
+ return;
}
- else {
- if (node->id)
- id_us_min(node->id);
- nodeFreeNode(ntree, node);
- ntreeUpdateTree(ntree); /* update group node socket links*/
+ id_us_min(node->id);
+ nodeFreeNode(ntree, node);
+ RNA_POINTER_INVALIDATE(node_ptr);
- WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
- }
+ ntreeUpdateTree(ntree); /* update group node socket links */
+ WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
static void rna_NodeTree_node_clear(bNodeTree *ntree)
@@ -800,7 +812,7 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports,
nodeFindNode(ntree, tosock, &tonode, NULL, &to_in_out);
if (&from_in_out == &to_in_out) {
- BKE_reportf(reports, RPT_ERROR, "Same input/output direction of sockets");
+ BKE_report(reports, RPT_ERROR, "Same input/output direction of sockets");
return NULL;
}
@@ -824,17 +836,19 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports,
return ret;
}
-static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNodeLink *link)
+static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, PointerRNA *link_ptr)
{
+ bNodeLink *link = link_ptr->data;
if (BLI_findindex(&ntree->links, link) == -1) {
- BKE_reportf(reports, RPT_ERROR, "Unable to locate link in nodetree");
+ BKE_report(reports, RPT_ERROR, "Unable to locate link in node tree");
+ return;
}
- else {
- nodeRemLink(ntree, link);
- ntreeUpdateTree(ntree);
- WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
- }
+ nodeRemLink(ntree, link);
+ RNA_POINTER_INVALIDATE(link_ptr);
+
+ ntreeUpdateTree(ntree);
+ WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
static void rna_NodeTree_link_clear(bNodeTree *ntree)
@@ -882,9 +896,9 @@ static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *repo
int index, in_out;
if (!nodeFindNode(ntree, sock, &node, &index, &in_out))
- BKE_reportf(reports, RPT_ERROR, "Unable to locate socket in nodetree");
+ BKE_report(reports, RPT_ERROR, "Unable to locate socket in node tree");
else if (in_out != SOCK_IN)
- BKE_reportf(reports, RPT_ERROR, "Socket is not an input");
+ BKE_report(reports, RPT_ERROR, "Socket is not an input");
else {
/* XXX should check if tree is a group here! no good way to do this currently. */
gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_IN);
@@ -906,9 +920,9 @@ static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *rep
int index, in_out;
if (!nodeFindNode(ntree, sock, &node, &index, &in_out))
- BKE_reportf(reports, RPT_ERROR, "Unable to locate socket in nodetree");
+ BKE_report(reports, RPT_ERROR, "Unable to locate socket in node tree");
else if (in_out != SOCK_OUT)
- BKE_reportf(reports, RPT_ERROR, "Socket is not an output");
+ BKE_report(reports, RPT_ERROR, "Socket is not an output");
else {
/* XXX should check if tree is a group here! no good way to do this currently. */
gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_OUT);
@@ -997,6 +1011,145 @@ static void rna_NodeOutputFileSlotLayer_name_set(PointerRNA *ptr, const char *va
}
}
+static bNodeSocket *rna_ShaderNodeScript_find_socket(bNode *node, const char *name, int is_output)
+{
+ bNodeSocket *sock;
+
+ if (is_output) {
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (strcmp(sock->name, name) == 0) {
+ return sock;
+ }
+ }
+ }
+ else {
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (strcmp(sock->name, name) == 0) {
+ return sock;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+static void rna_ShaderNodeScript_remove_socket(ID *id, bNode *node, bNodeSocket *sock)
+{
+ bNodeTree *ntree = (bNodeTree *)id;
+
+ nodeRemoveSocket(ntree, node, sock);
+
+ ED_node_generic_update(G.main, ntree, node);
+}
+
+static bNodeSocket *rna_ShaderNodeScript_add_socket(ID *id, bNode *node, const char *name, int type, int is_output)
+{
+ bNodeTree *ntree = (bNodeTree *)id;
+ bNodeSocket *sock;
+
+ /* replace existing socket with the same name, to keep it unique */
+ sock = rna_ShaderNodeScript_find_socket(node, name, is_output);
+ if (sock)
+ nodeRemoveSocket(ntree, node, sock);
+ sock = nodeAddSocket(ntree, node, (is_output ? SOCK_OUT : SOCK_IN), name, type);
+
+ ED_node_generic_update(G.main, ntree, node);
+
+ return sock;
+}
+
+static void rna_ShaderNodeScript_mode_set(PointerRNA *ptr, int value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeShaderScript *nss = node->storage;
+
+ if (nss->mode != value) {
+ nss->mode = value;
+ nss->filepath[0] = '\0';
+ nss->flag &= ~NODE_SCRIPT_AUTO_UPDATE;
+
+ /* replace text datablock by filepath */
+ if (node->id) {
+ Text *text = (Text*)node->id;
+
+ if (value == NODE_SCRIPT_EXTERNAL && text->name) {
+ BLI_strncpy(nss->filepath, text->name, sizeof(nss->filepath));
+ BLI_path_rel(nss->filepath, G.main->name);
+ }
+
+ id_us_min(node->id);
+ node->id = NULL;
+ }
+
+ /* remove any bytecode */
+ if (nss->bytecode) {
+ MEM_freeN(nss->bytecode);
+ nss->bytecode = NULL;
+ }
+
+ nss->bytecode_hash[0] = '\0';
+ }
+}
+
+static void rna_ShaderNodeScript_bytecode_get(PointerRNA *ptr, char *value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeShaderScript *nss = node->storage;
+
+ strcpy(value, (nss->bytecode)? nss->bytecode: "");
+}
+
+static int rna_ShaderNodeScript_bytecode_length(PointerRNA *ptr)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeShaderScript *nss = node->storage;
+
+ return (nss->bytecode) ? strlen(nss->bytecode) : 0;
+}
+
+static void rna_ShaderNodeScript_bytecode_set(PointerRNA *ptr, const char *value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeShaderScript *nss = node->storage;
+
+ if (nss->bytecode)
+ MEM_freeN(nss->bytecode);
+
+ if (value && value[0])
+ nss->bytecode = BLI_strdup(value);
+ else
+ nss->bytecode = NULL;
+}
+
+static IDProperty *rna_ShaderNodeScript_idprops(PointerRNA *ptr, int create)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeShaderScript *nss = node->storage;
+
+ if (create && !nss->prop) {
+ IDPropertyTemplate val = {0};
+ nss->prop = IDP_New(IDP_GROUP, &val, "RNA_ShaderNodeScript ID properties");
+ }
+
+ return nss->prop;
+}
+
+static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bNodeTree *ntree = (bNodeTree *)ptr->id.data;
+ bNode *node = (bNode *)ptr->data;
+ RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
+
+ if(engine_type && engine_type->update_script_node) {
+ /* auto update node */
+ RenderEngine *engine = RE_engine_create(engine_type);
+ engine_type->update_script_node(engine, ntree, node);
+ RE_engine_free(engine);
+ }
+
+ node_update(bmain, scene, ntree, node);
+}
+
#else
static EnumPropertyItem prop_image_layer_items[] = {
@@ -1037,12 +1190,17 @@ static EnumPropertyItem node_glossy_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static EnumPropertyItem node_script_mode_items[] = {
+ {NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text datablock"},
+ {NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or .oso file"},
+ {0, NULL, 0, NULL, NULL}
+};
+
#define MaxNodes 50000
enum
{
Category_GroupNode,
- Category_LoopNode,
Category_LayoutNode,
Category_ShaderNode,
Category_CompositorNode,
@@ -1063,7 +1221,7 @@ typedef struct NodeInfo {
static NodeInfo nodes[MaxNodes];
static void reg_node(int ID, int category, const char *enum_name, const char *struct_name,
- const char *base_name, const char *ui_name, const char *ui_desc)
+ const char *base_name, const char *ui_name, const char *ui_desc)
{
NodeInfo *ni = nodes + ID;
@@ -1086,8 +1244,6 @@ static void init(void)
#include "rna_nodetree_types.h"
reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "SpecialNode", "Group", "");
- reg_node(NODE_FORLOOP, Category_LoopNode, "FORLOOP", "NodeForLoop", "SpecialNode", "ForLoop", "");
- reg_node(NODE_WHILELOOP, Category_LoopNode, "WHILELOOP", "NodeWhileLoop", "SpecialNode", "WhileLoop", "");
reg_node(NODE_FRAME, Category_LayoutNode, "FRAME", "NodeFrame", "SpecialNode", "Frame", "");
reg_node(NODE_REROUTE, Category_LayoutNode, "REROUTE", "NodeReroute", "SpecialNode", "Reroute", "");
}
@@ -1145,6 +1301,14 @@ static void alloc_node_type_items(EnumPropertyItem *items, int category)
item++;
+ item->value = NODE_FRAME;
+ item->identifier = "FRAME";
+ item->icon = 0;
+ item->name = "Frame";
+ item->description = "";
+
+ item++;
+
/* NOTE!, increase 'count' when adding items here */
memset(item, 0, sizeof(EnumPropertyItem));
@@ -1166,36 +1330,6 @@ static void def_group(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update");
}
-static void def_forloop(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "id");
- RNA_def_property_struct_type(prop, "NodeTree");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Node Tree", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update");
-}
-
-static void def_whileloop(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "id");
- RNA_def_property_struct_type(prop, "NodeTree");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Node Tree", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update");
-
- prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "custom1");
- RNA_def_property_range(prop, 0.0f, SHRT_MAX);
- RNA_def_property_ui_text(prop, "Max. Iterations", "Limit for number of iterations");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update");
-}
-
static void def_frame(StructRNA *srna)
{
PropertyRNA *prop;
@@ -1462,7 +1596,8 @@ static void def_sh_tex_sky(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "turbidity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Turbidity", "");
+ RNA_def_property_range(prop, 1.0f, 30.0f);
+ RNA_def_property_ui_text(prop, "Turbidity", "Atmospheric turbidity");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
@@ -1741,6 +1876,138 @@ static void def_glossy(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_sh_normal_map(StructRNA *srna)
+{
+ static EnumPropertyItem prop_space_items[] = {
+ {SHD_NORMAL_MAP_TANGENT, "TANGENT", 0, "Tangent Space", "Tangent space normal mapping"},
+ {SHD_NORMAL_MAP_OBJECT, "OBJECT", 0, "Object Space", "Object space normal mapping"},
+ {SHD_NORMAL_MAP_WORLD, "WORLD", 0, "World Space", "World space normal mapping"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeShaderNormalMap", "storage");
+
+ prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_space_items);
+ RNA_def_property_ui_text(prop, "Space", "Space of the input normal");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "uv_map", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "UV Map", "UV Map for tangent space maps");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "bNode", NULL);
+}
+
+static void def_sh_tangent(StructRNA *srna)
+{
+ static EnumPropertyItem prop_direction_type_items[] = {
+ {SHD_TANGENT_RADIAL, "RADIAL", 0, "Radial", "Radial tangent around the X, Y or Z axis"},
+ {SHD_TANGENT_UVMAP, "UV_MAP", 0, "UV Map", "Tangent from UV map"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_axis_items[] = {
+ {SHD_TANGENT_AXIS_X, "X", 0, "X", "X axis"},
+ {SHD_TANGENT_AXIS_Y, "Y", 0, "Y", "Y axis"},
+ {SHD_TANGENT_AXIS_Z, "Z", 0, "Z", "Z axis"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeShaderTangent", "storage");
+
+ prop = RNA_def_property(srna, "direction_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_direction_type_items);
+ RNA_def_property_ui_text(prop, "Direction", "Method to use for the tangent");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_axis_items);
+ RNA_def_property_ui_text(prop, "Axis", "Axis for radial tangents");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "uv_map", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "UV Map", "UV Map for tangent generated from UV");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "bNode", NULL);
+}
+
+static void def_sh_script(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *prop, *parm;
+
+ prop = RNA_def_property(srna, "script", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "id");
+ RNA_def_property_struct_type(prop, "Text");
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
+ RNA_def_property_ui_text(prop, "Script", "Internal shader script to define the shader");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeScript_update");
+
+ RNA_def_struct_sdna_from(srna, "NodeShaderScript", "storage");
+ RNA_def_struct_idprops_func(srna, "rna_ShaderNodeScript_idprops");
+
+ prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property_ui_text(prop, "File Path", "Shader script path");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeScript_update");
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_ShaderNodeScript_mode_set", NULL);
+ RNA_def_property_enum_items(prop, node_script_mode_items);
+ RNA_def_property_ui_text(prop, "Script Source", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "use_auto_update", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_SCRIPT_AUTO_UPDATE);
+ RNA_def_property_ui_text(prop, "Auto Update",
+ "Automatically update the shader when the .osl file changes (external scripts only)");
+
+ prop = RNA_def_property(srna, "bytecode", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_ShaderNodeScript_bytecode_get", "rna_ShaderNodeScript_bytecode_length",
+ "rna_ShaderNodeScript_bytecode_set");
+ RNA_def_property_ui_text(prop, "Bytecode", "Compile bytecode for shader script node");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "bytecode_hash", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Bytecode Hash", "Hash of compile bytecode, for quick equality checking");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ /* needs to be reset to avoid bad pointer type in API functions below */
+ RNA_def_struct_sdna_from(srna, "bNode", NULL);
+
+ /* API functions */
+
+ func = RNA_def_function(srna, "find_socket", "rna_ShaderNodeScript_find_socket");
+ RNA_def_function_ui_description(func, "Find a socket by name");
+ parm = RNA_def_string(func, "name", "", 0, "Socket name", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /*parm =*/ RNA_def_boolean(func, "is_output", FALSE, "Output", "Whether the socket is an output");
+ parm = RNA_def_pointer(func, "result", "NodeSocket", "", "");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "add_socket", "rna_ShaderNodeScript_add_socket");
+ RNA_def_function_ui_description(func, "Add a socket socket");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_string(func, "name", "", 0, "Name", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_enum(func, "type", node_socket_type_items, SOCK_FLOAT, "Type", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /*parm =*/ RNA_def_boolean(func, "is_output", FALSE, "Output", "Whether the socket is an output");
+ parm = RNA_def_pointer(func, "result", "NodeSocket", "", "");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove_socket", "rna_ShaderNodeScript_remove_socket");
+ RNA_def_function_ui_description(func, "Remove a socket socket");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_pointer(func, "sock", "NodeSocket", "Socket", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+}
+
/* -- Compositor Nodes ------------------------------------------------------ */
static void def_cmp_alpha_over(StructRNA *srna)
@@ -3994,8 +4261,6 @@ static void rna_def_special_node(BlenderRNA *brna)
static EnumPropertyItem specific_node_type_items[] = {
{NODE_GROUP, "GROUP", ICON_NODE, "Group", ""},
- {NODE_FORLOOP, "FORLOOP", ICON_NODE, "For Loop", ""},
- {NODE_WHILELOOP, "WHILELOOP", ICON_NODE, "While Loop", ""},
{NODE_FRAME, "FRAME", ICON_NODE, "Frame", ""},
{NODE_REROUTE, "REROUTE", ICON_NODE, "Reroute", ""},
{0, NULL, 0, NULL, NULL}
@@ -4039,7 +4304,8 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "remove a node link from the node tree");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "link", "NodeLink", "", "The node link to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_NodeTree_link_clear");
RNA_def_function_ui_description(func, "remove all node links from the node tree");
@@ -4083,7 +4349,8 @@ static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a node from this node tree");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "node", "Node", "", "The node to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
@@ -4116,7 +4383,8 @@ static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a node from this node tree");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "node", "Node", "", "The node to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
@@ -4149,7 +4417,8 @@ static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a node from this node tree");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "node", "Node", "", "The node to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
@@ -4291,6 +4560,20 @@ static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype,
RNA_def_property_ui_text(prop, "Default Value", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
break;
+ case SOCK_STRING:
+ RNA_def_struct_sdna_from(srna, "bNodeSocketValueString", "default_value");
+
+ prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "subtype");
+ RNA_def_property_enum_items(prop, subtype_items);
+ RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+
+ prop = RNA_def_property(srna, "default_value", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property_string_sdna(prop, NULL, "value");
+ RNA_def_property_ui_text(prop, "Default Value", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+ break;
}
/* XXX need to reset the from-type here, so subtype subclasses cast correctly! (RNA bug) */
@@ -4618,8 +4901,6 @@ void RNA_def_nodetree(BlenderRNA *brna)
#include "rna_nodetree_types.h"
define_specific_node(brna, NODE_GROUP, def_group);
- define_specific_node(brna, NODE_FORLOOP, def_forloop);
- define_specific_node(brna, NODE_WHILELOOP, def_whileloop);
define_specific_node(brna, NODE_FRAME, def_frame);
define_specific_node(brna, NODE_REROUTE, 0);
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index db1e1e16adf..fbbcbae6c12 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -65,11 +65,14 @@ DefNode( ShaderNode, SH_NODE_LAYER_WEIGHT, 0, "LA
DefNode( ShaderNode, SH_NODE_MIX_SHADER, 0, "MIX_SHADER", MixShader, "Mix Shader", "" )
DefNode( ShaderNode, SH_NODE_ADD_SHADER, 0, "ADD_SHADER", AddShader, "Add Shader", "" )
DefNode( ShaderNode, SH_NODE_ATTRIBUTE, def_sh_attribute, "ATTRIBUTE", Attribute, "Attribute", "" )
+DefNode( ShaderNode, SH_NODE_AMBIENT_OCCLUSION, 0, "AMBIENT_OCCLUSION", AmbientOcclusion, "Ambient Occlusion", "" )
DefNode( ShaderNode, SH_NODE_BACKGROUND, 0, "BACKGROUND", Background, "Background", "" )
DefNode( ShaderNode, SH_NODE_HOLDOUT, 0, "HOLDOUT", Holdout, "Holdout", "" )
+DefNode( ShaderNode, SH_NODE_BSDF_ANISOTROPIC, 0, "BSDF_ANISOTROPIC", BsdfAnisotropic, "Anisotropic Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_DIFFUSE, 0, "BSDF_DIFFUSE", BsdfDiffuse, "Diffuse Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_GLOSSY, def_glossy, "BSDF_GLOSSY", BsdfGlossy, "Glossy Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_GLASS, def_glossy, "BSDF_GLASS", BsdfGlass, "Glass Bsdf", "" )
+DefNode( ShaderNode, SH_NODE_BSDF_REFRACTION, def_glossy, "BSDF_REFRACTION", BsdfRefraction, "Refraction Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_TRANSLUCENT, 0, "BSDF_TRANSLUCENT", BsdfTranslucent, "Translucent Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BSDF_TRANSPARENT", BsdfTransparent, "Transparent Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet Bsdf", "" )
@@ -81,6 +84,10 @@ DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LI
DefNode( ShaderNode, SH_NODE_LIGHT_FALLOFF, 0, "LIGHT_FALLOFF", LightFalloff, "Light Falloff", "" )
DefNode( ShaderNode, SH_NODE_OBJECT_INFO, 0, "OBJECT_INFO", ObjectInfo, "Object Info", "" )
DefNode( ShaderNode, SH_NODE_PARTICLE_INFO, 0, "PARTICLE_INFO", ParticleInfo, "Particle Info", "" )
+DefNode( ShaderNode, SH_NODE_BUMP, 0, "BUMP", Bump, "Bump", "" )
+DefNode( ShaderNode, SH_NODE_NORMAL_MAP, def_sh_normal_map, "NORMAL_MAP", NormalMap, "Normal Map", "" )
+DefNode( ShaderNode, SH_NODE_TANGENT, def_sh_tangent, "TANGENT", Tangent, "Tangent", "" )
+DefNode( ShaderNode, SH_NODE_SCRIPT, def_sh_script, "SCRIPT", Script, "Script", "" )
DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "" )
DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture","" )
DefNode( ShaderNode, SH_NODE_TEX_SKY, def_sh_tex_sky, "TEX_SKY", TexSky, "Sky Texture", "" )
@@ -91,7 +98,7 @@ DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TE
DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "" )
DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "" )
DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" )
-DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" )
+DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" )
DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TEX_COORD", TexCoord, "Texture Coordinate","" )
DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" )
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 0b8afef0364..d436e4719ea 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -506,7 +506,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
ob->dup_group = grp;
else
BKE_report(NULL, RPT_ERROR,
- "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
+ "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle");
}
static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
@@ -547,8 +547,7 @@ static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&ob->defbase) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ob->defbase) - 1);
}
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
@@ -658,7 +657,7 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in
{
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = MAX2(ob->totcol - 1, 0);
+ *max = max_ii(ob->totcol - 1, 0);
}
/* returns active base material */
@@ -684,8 +683,7 @@ static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *
{
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&ob->particlesystem) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1);
}
static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
@@ -851,11 +849,11 @@ static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
if (value) {
ob->matbits[index] = 1;
- /* ob->colbits |= (1<<index); */ /* DEPRECATED */
+ /* ob->colbits |= (1 << index); */ /* DEPRECATED */
}
else {
ob->matbits[index] = 0;
- /* ob->colbits &= ~(1<<index); */ /* DEPRECATED */
+ /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */
}
}
@@ -1036,8 +1034,8 @@ static unsigned int rna_Object_layer_validate__internal(const int *values, unsig
return 0;
for (i = 0; i < 20; i++) {
- if (values[i]) lay |= (1 << i);
- else lay &= ~(1 << i);
+ if (values[i]) lay |= (1 << i);
+ else lay &= ~(1 << i);
}
return lay;
@@ -1072,8 +1070,9 @@ static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
int all_states = (ob->scaflag & OB_ALLSTATE ? 1 : 0);
memset(values, 0, sizeof(int) * OB_MAX_STATES);
- for (i = 0; i < OB_MAX_STATES; i++)
+ for (i = 0; i < OB_MAX_STATES; i++) {
values[i] = (ob->state & (1 << i)) | all_states;
+ }
}
static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
@@ -1111,6 +1110,65 @@ static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
}
}
+static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ values[i] = (ob->col_group & (1 << i));
+ }
+}
+
+static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i, tot = 0;
+
+ /* ensure we always have some group selected */
+ for (i = 0; i < OB_MAX_COL_MASKS; i++)
+ if (values[i])
+ tot++;
+
+ if (tot == 0)
+ return;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ if (values[i]) ob->col_group |= (1 << i);
+ else ob->col_group &= ~(1 << i);
+ }
+}
+
+static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ values[i] = (ob->col_mask & (1 << i));
+ }
+}
+
+static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i, tot = 0;
+
+ /* ensure we always have some mask selected */
+ for (i = 0; i < OB_MAX_COL_MASKS; i++)
+ if (values[i])
+ tot++;
+
+ if (tot == 0)
+ return;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ if (values[i]) ob->col_mask |= (1 << i);
+ else ob->col_mask &= ~(1 << i);
+ }
+}
+
+
static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
Object *ob = (Object *)ptr->id.data;
@@ -1199,14 +1257,17 @@ static bConstraint *rna_Object_constraints_new(Object *object, int type)
return add_ob_constraint(object, NULL, type);
}
-static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con)
+static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
{
+ bConstraint *con = con_ptr->data;
if (BLI_findindex(&object->constraints, con) == -1) {
BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2);
return;
}
remove_constraint(&object->constraints, con);
+ RNA_POINTER_INVALIDATE(con_ptr);
+
ED_object_constraint_update(object);
ED_object_constraint_set_active(object, NULL);
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
@@ -1228,9 +1289,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report
return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
}
-static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
+static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
{
- ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md);
+ ModifierData *md = md_ptr->data;
+ if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) == FALSE) {
+ /* error is already set */
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(md_ptr);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
}
@@ -1264,9 +1331,16 @@ static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
return defgroup;
}
-static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup)
+static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
{
+ bDeformGroup *defgroup = defgroup_ptr->data;
+ if (BLI_findindex(&ob->defbase, defgroup) == -1) {
+ BKE_reportf(reports, RPT_ERROR, "DeformGroup '%s' not in object '%s'", defgroup->name, ob->id.name + 2);
+ return;
+ }
+
ED_vgroup_delete(ob, defgroup);
+ RNA_POINTER_INVALIDATE(defgroup_ptr);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -1284,7 +1358,7 @@ static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *re
Object *ob = (Object *)id;
if (ED_vgroup_object_is_edit_mode(ob)) {
- BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode");
+ BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
return;
}
@@ -1299,7 +1373,7 @@ static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *
Object *ob = (Object *)id;
if (ED_vgroup_object_is_edit_mode(ob)) {
- BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode");
+ BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
return;
}
@@ -1314,7 +1388,7 @@ static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *report
float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
if (weight < 0) {
- BKE_reportf(reports, RPT_ERROR, "Vertex not in group");
+ BKE_report(reports, RPT_ERROR, "Vertex not in group");
}
return weight;
}
@@ -1345,6 +1419,12 @@ int rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
return ((Object *)value.id.data)->type == OB_CAMERA;
}
+int rna_DupliObject_index_get(PointerRNA *ptr)
+{
+ DupliObject *dob = (DupliObject *)ptr->data;
+ return dob->persistent_id[0];
+}
+
#else
static int rna_matrix_dimsize_4x4[] = {4, 4};
@@ -1578,6 +1658,17 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 1000.0);
RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
+ prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+ RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1);
+ RNA_def_property_array(prop, OB_MAX_COL_MASKS);
+ RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object");
+ RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set");
+
+ prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+ RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1);
+ RNA_def_property_array(prop, OB_MAX_COL_MASKS);
+ RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with");
+ RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set");
/* lock position */
prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
@@ -1745,7 +1836,8 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
/* constraint to remove */
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
RNA_def_function_ui_description(func, "Remove all constraint from this object");
@@ -1796,7 +1888,8 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
/* modifier to remove */
parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* clear all modifiers */
func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
@@ -1874,9 +1967,11 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Delete vertex group from object");
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
RNA_def_function_ui_description(func, "Delete all vertex groups from object");
@@ -2564,22 +2659,23 @@ static void rna_def_dupli_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render");
prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "index");
+ RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list");
-
- prop = RNA_def_property(srna, "particle_index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "particle_index");
+
+ prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur");
+
+ prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Particle Index", "Index in the lowest-level particle dupli list");
+ RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from");
prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
- RNA_def_property_float_sdna(prop, NULL, "orco");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space");
prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "uv");
RNA_def_property_array(prop, 2);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 879a77527cd..87fc3be28a2 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -74,7 +74,7 @@
/* copied from Mesh_getFromObject and adapted to RNA interface */
/* settings: 0 - preview, 1 - render */
-Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings)
+static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings)
{
Mesh *tmpmesh;
Curve *tmpcu = NULL, *copycu;
@@ -158,7 +158,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
/* BKE_mesh_from_nurbs changes the type to a mesh, check it worked */
if (tmpobj->type != OB_MESH) {
BKE_libblock_free_us(&(G.main->object), tmpobj);
- BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?");
+ BKE_report(reports, RPT_ERROR, "Cannot convert curve to mesh (does the curve have any segments?)");
return NULL;
}
@@ -321,7 +321,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e
}
}
- if (level == 0 && enable) {
+ if (enable) {
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
@@ -340,7 +340,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e
dupli_render_particle_set(scene, go->ob, level + 1, enable);
}
/* When no longer needed, duplilist should be freed with Object.free_duplilist */
-void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings)
+static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings)
{
int for_render = settings == eModifierMode_Render;
@@ -351,7 +351,7 @@ void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, in
/* free duplilist if a user forgets to */
if (ob->duplilist) {
- BKE_reportf(reports, RPT_WARNING, "Object.dupli_list has not been freed");
+ BKE_report(reports, RPT_WARNING, "Object.dupli_list has not been freed");
free_object_duplilist(ob->duplilist);
ob->duplilist = NULL;
@@ -364,7 +364,7 @@ void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, in
/* ob->duplilist should now be freed with Object.free_duplilist */
}
-void rna_Object_free_duplilist(Object *ob)
+static void rna_Object_free_duplilist(Object *ob)
{
if (ob->duplilist) {
free_object_duplilist(ob->duplilist);
@@ -387,7 +387,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *
return keyptr;
}
else {
- BKE_reportf(reports, RPT_ERROR, "Object \"%s\"does not support shapes", ob->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' does not support shapes", ob->id.name + 2);
return PointerRNA_NULL;
}
}
@@ -402,14 +402,14 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int
float weight, int assignmode)
{
if (ob->type != OB_MESH) {
- BKE_report(reports, RPT_ERROR, "Object should be of MESH type");
+ BKE_report(reports, RPT_ERROR, "Object should be of mesh type");
return;
}
Mesh *me = (Mesh *)ob->data;
int group_index = BLI_findlink(&ob->defbase, group);
if (group_index == -1) {
- BKE_report(reports, RPT_ERROR, "No deform groups assigned to mesh");
+ BKE_report(reports, RPT_ERROR, "No vertex groups assigned to mesh");
return;
}
@@ -441,7 +441,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start
BVHTreeFromMesh treeData = {NULL};
if (ob->derivedFinal == NULL) {
- BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting", ob->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for ray casting", ob->id.name + 2);
return;
}
@@ -449,7 +449,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start
bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
if (treeData.tree == NULL) {
- BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for ray casting", ob->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for ray casting", ob->id.name + 2);
return;
}
else {
@@ -483,7 +483,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl
BVHTreeFromMesh treeData = {NULL};
if (ob->derivedFinal == NULL) {
- BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for finding nearest point",
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point",
ob->id.name + 2);
return;
}
@@ -492,7 +492,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl
bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
if (treeData.tree == NULL) {
- BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for finding nearest point",
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point",
ob->id.name + 2);
return;
}
@@ -522,12 +522,12 @@ static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d)
base->lay = base->object->lay = v3d->lay;
}
-int rna_Object_is_modified(Object *ob, Scene *scene, int settings)
+static int rna_Object_is_modified(Object *ob, Scene *scene, int settings)
{
return BKE_object_is_modified(scene, ob) & settings;
}
-int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings)
+static int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings)
{
return BKE_object_is_deform_modified(scene, ob) & settings;
}
@@ -613,7 +613,7 @@ void RNA_api_object(StructRNA *srna)
"objects real matrix and layers");
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
- parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Generate texture coordinates for rendering");
+ RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Generate texture coordinates for rendering");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist");
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 1c896133408..6d7187da7d9 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -51,6 +51,9 @@ static EnumPropertyItem effector_shape_items[] = {
#ifdef RNA_RUNTIME
+#include "BLI_math_base.h"
+
+
/* type specific return values only used from functions */
static EnumPropertyItem curve_shape_items[] = {
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
@@ -239,8 +242,7 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min,
for (pid = pidlist.first; pid; pid = pid->next) {
if (pid->cache == cache) {
- *max = BLI_countlist(pid->ptcaches) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(pid->ptcaches) - 1);
break;
}
}
@@ -820,10 +822,13 @@ static void rna_def_pointcache(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "File Path", "Cache file path");
RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
+ /* removed, see PTCACHE_QUICK_CACHE */
+#if 0
prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE);
RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps");
RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
+#endif
prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "info");
@@ -1056,6 +1061,13 @@ static void rna_def_effector_weight(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
RNA_def_property_ui_text(prop, "Drag", "Drag effector weight");
RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
+
+ prop = RNA_def_property(srna, "smokeflow", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "weight[13]");
+ RNA_def_property_range(prop, -200.0f, 200.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
+ RNA_def_property_ui_text(prop, "Smoke Flow", "Smoke Flow effector weight");
+ RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
}
static void rna_def_field(BlenderRNA *brna)
@@ -1082,6 +1094,7 @@ static void rna_def_field(BlenderRNA *brna)
{PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
{PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", "Create turbulence with a noise field"},
{PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", "Create a force that dampens motion"},
+ {PFIELD_SMOKEFLOW, "SMOKE_FLOW", ICON_FORCE_SMOKEFLOW, "Smoke Flow", "Create a force based on smoke simulation air flow"},
{0, NULL, 0, NULL, NULL}
};
@@ -1307,7 +1320,7 @@ static void rna_def_field(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_2d_force", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_2D);
- RNA_def_property_ui_text(prop, "2D", "Apply force only in 2d");
+ RNA_def_property_ui_text(prop, "2D", "Apply force only in 2D");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
prop = RNA_def_property(srna, "use_root_coords", PROP_BOOLEAN, PROP_NONE);
@@ -1334,6 +1347,11 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_MULTIPLE_SPRINGS);
RNA_def_property_ui_text(prop, "Multiple Springs", "Every point is effected by multiple springs");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
+
+ prop = RNA_def_property(srna, "use_smoke_density", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_SMOKE_DENSITY);
+ RNA_def_property_ui_text(prop, "Apply Density", "Adjust force strength based on smoke density");
+ RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
/* Pointer */
@@ -1342,6 +1360,12 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Texture", "Texture to use as force");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
+
+ prop = RNA_def_property(srna, "source_object", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "f_source");
+ RNA_def_property_ui_text(prop, "Domain Object", "Select domain object of the smoke simulation");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
/********** Curve Guide Field Settings **********/
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 89638389fd2..6825d3d781d 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -530,8 +530,7 @@ static void rna_ParticleSystem_active_particle_target_index_range(PointerRNA *pt
{
ParticleSystem *psys = (ParticleSystem *)ptr->data;
*min = 0;
- *max = BLI_countlist(&psys->targets) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&psys->targets) - 1);
}
static int rna_ParticleSystem_active_particle_target_index_get(PointerRNA *ptr)
@@ -670,8 +669,7 @@ static void rna_ParticleDupliWeight_active_index_range(PointerRNA *ptr, int *min
{
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&part->dupliweights) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&part->dupliweights) - 1);
}
static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr)
@@ -823,12 +821,12 @@ static void psys_vg_name_set__internal(PointerRNA *ptr, const char *value, int i
psys->vgroup[index] = 0;
}
else {
- int vgroup_num = defgroup_name_index(ob, value);
+ int defgrp_index = defgroup_name_index(ob, value);
- if (vgroup_num == -1)
+ if (defgrp_index == -1)
return;
- psys->vgroup[index] = vgroup_num + 1;
+ psys->vgroup[index] = defgrp_index + 1;
}
}
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index df278e7cf16..412aad20a41 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -381,13 +381,7 @@ static void rna_PoseChannel_bone_group_index_range(PointerRNA *ptr, int *min, in
bPose *pose = (ob) ? ob->pose : NULL;
*min = 0;
-
- if (pose) {
- *max = BLI_countlist(&pose->agroups) - 1;
- *max = MAX2(0, *max);
- }
- else
- *max = 0;
+ *max = pose ? max_ii(0, BLI_countlist(&pose->agroups) - 1) : 0;
}
static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr)
@@ -419,8 +413,7 @@ static void rna_Pose_active_bone_group_index_range(PointerRNA *ptr, int *min, in
bPose *pose = (bPose *)ptr->data;
*min = 0;
- *max = BLI_countlist(&pose->agroups) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&pose->agroups) - 1);
}
#if 0
@@ -497,24 +490,28 @@ static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, int typ
return add_pose_constraint(NULL, pchan, NULL, type);
}
-static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, bConstraint *con)
+static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, PointerRNA *con_ptr)
{
+ bConstraint *con = con_ptr->data;
+ const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
+ Object *ob = (Object *)id;
+
if (BLI_findindex(&pchan->constraints, con) == -1) {
BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in pose bone '%s'", con->name, pchan->name);
return;
}
- else {
- Object *ob = (Object *)id;
- const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
- remove_constraint(&pchan->constraints, con);
- ED_object_constraint_update(ob);
- constraints_set_active(&pchan->constraints, NULL);
- WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id);
+ remove_constraint(&pchan->constraints, con);
+ RNA_POINTER_INVALIDATE(con_ptr);
- if (is_ik) {
- BIK_clear_data(ob->pose);
- }
+ ED_object_constraint_update(ob);
+
+ constraints_set_active(&pchan->constraints, NULL); /* XXX, is this really needed? - Campbell */
+
+ WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id);
+
+ if (is_ik) {
+ BIK_clear_data(ob->pose);
}
}
@@ -727,7 +724,8 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); /* ID needed for refresh */
/* constraint to remove */
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_pose_channel(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 039d50e4ee8..46b22cd0963 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -50,12 +50,12 @@
/* RenderEngine Callbacks */
-void engine_tag_redraw(RenderEngine *engine)
+static void engine_tag_redraw(RenderEngine *engine)
{
engine->flag |= RE_ENGINE_DO_DRAW;
}
-void engine_tag_update(RenderEngine *engine)
+static void engine_tag_update(RenderEngine *engine)
{
engine->flag |= RE_ENGINE_DO_UPDATE;
}
@@ -129,6 +129,24 @@ static void engine_view_draw(RenderEngine *engine, const struct bContext *contex
RNA_parameter_list_free(&list);
}
+static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node)
+{
+ extern FunctionRNA rna_RenderEngine_update_script_node_func;
+ PointerRNA ptr, nodeptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
+ RNA_pointer_create((ID*)ntree, &RNA_Node, node, &nodeptr);
+ func = &rna_RenderEngine_update_script_node_func;
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "node", &nodeptr);
+ engine->type->ext.call(NULL, &ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
/* RenderEngine registration */
static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type)
@@ -149,7 +167,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
RenderEngineType *et, dummyet = {NULL};
RenderEngine dummyengine = {NULL};
PointerRNA dummyptr;
- int have_function[4];
+ int have_function[5];
/* setup dummy engine & engine type to store static properties in */
dummyengine.type = &dummyet;
@@ -160,7 +178,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
return NULL;
if (strlen(identifier) >= sizeof(dummyet.idname)) {
- BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d",
+ BKE_reportf(reports, RPT_ERROR, "Registering render engine class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummyet.idname));
return NULL;
}
@@ -188,6 +206,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
et->render = (have_function[1]) ? engine_render : NULL;
et->view_update = (have_function[2]) ? engine_view_update : NULL;
et->view_draw = (have_function[3]) ? engine_view_draw : NULL;
+ et->update_script_node = (have_function[4]) ? engine_update_script_node : NULL;
BLI_addtail(&R_engines, et);
@@ -300,6 +319,13 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
RNA_def_pointer(func, "context", "Context", "", "");
+ /* shader script callbacks */
+ func = RNA_def_function(srna, "update_script_node", NULL);
+ RNA_def_function_ui_description(func, "Compile shader script node");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+ prop = RNA_def_pointer(func, "node", "Node", "", "");
+ RNA_def_property_flag(prop, PROP_RNAPTR);
+
/* tag for redraw */
RNA_def_function(srna, "tag_redraw", "engine_tag_redraw");
RNA_def_function_ui_description(func, "Request redraw for viewport rendering");
@@ -328,7 +354,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
func = RNA_def_function(srna, "end_result", "RE_engine_end_result");
prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
RNA_def_property_flag(prop, PROP_REQUIRED);
- prop = RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results");
+ RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results");
func = RNA_def_function(srna, "test_break", "RE_engine_test_break");
prop = RNA_def_boolean(func, "do_break", 0, "Break", "");
@@ -344,6 +370,11 @@ static void rna_def_render_engine(BlenderRNA *brna)
prop = RNA_def_float(func, "progress", 0, 0.0f, 1.0f, "", "Percentage of render that's done", 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_REQUIRED);
+ func = RNA_def_function(srna, "update_memory_stats", "RE_engine_update_memory_stats");
+ RNA_def_float(func, "memory_used", 0, 0.0f, FLT_MAX, "", "Current memory usage in megabytes", 0.0f, FLT_MAX);
+ RNA_def_float(func, "memory_peak", 0, 0.0f, FLT_MAX, "", "Peak memory usage in megabytes", 0.0f, FLT_MAX);
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+
func = RNA_def_function(srna, "report", "RE_engine_report");
prop = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", "");
RNA_def_property_flag(prop, PROP_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index db309ed8f1f..7355e464fc3 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -829,7 +829,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point
int totitem, free = 0;
rna_idproperty_check(&prop, ptr);
- /* eprop= (EnumPropertyRNA *)prop; */
+ /* eprop = (EnumPropertyRNA *)prop; */
RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free);
rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index ada41bb9818..0ba15193985 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -276,6 +276,7 @@ EnumPropertyItem image_color_mode_items[] = {
EnumPropertyItem image_color_depth_items[] = {
/* 1 (monochrome) not used */
{R_IMF_CHAN_DEPTH_8, "8", 0, "8", "8 bit color channels"},
+ {R_IMF_CHAN_DEPTH_10, "10", 0, "10", "10 bit color channels"},
{R_IMF_CHAN_DEPTH_12, "12", 0, "12", "12 bit color channels"},
{R_IMF_CHAN_DEPTH_16, "16", 0, "16", "16 bit color channels"},
/* 24 not used */
@@ -357,7 +358,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report
Base *base;
if (BKE_scene_base_find(scene, ob)) {
- BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\"", ob->id.name + 2, scene->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in scene '%s'", ob->id.name + 2, scene->id.name + 2);
return NULL;
}
@@ -389,7 +390,7 @@ static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *o
return;
}
if (base == scene->basact && ob->mode != OB_MODE_OBJECT) {
- BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in 'Object Mode' to unlink", ob->id.name + 2);
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in object mode to unlink", ob->id.name + 2);
return;
}
if (scene->basact == base) {
@@ -714,6 +715,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value)
R_IMF_CHAN_DEPTH_24,
R_IMF_CHAN_DEPTH_16,
R_IMF_CHAN_DEPTH_12,
+ R_IMF_CHAN_DEPTH_10,
R_IMF_CHAN_DEPTH_8,
R_IMF_CHAN_DEPTH_1,
0};
@@ -811,9 +813,10 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C,
const int is_float = ELEM3(imf->imtype, R_IMF_IMTYPE_RADHDR, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER);
EnumPropertyItem *item_8bit = &image_color_depth_items[0];
- EnumPropertyItem *item_12bit = &image_color_depth_items[1];
- EnumPropertyItem *item_16bit = &image_color_depth_items[2];
- EnumPropertyItem *item_32bit = &image_color_depth_items[3];
+ EnumPropertyItem *item_10bit = &image_color_depth_items[1];
+ EnumPropertyItem *item_12bit = &image_color_depth_items[2];
+ EnumPropertyItem *item_16bit = &image_color_depth_items[3];
+ EnumPropertyItem *item_32bit = &image_color_depth_items[4];
int totitem = 0;
EnumPropertyItem *item = NULL;
@@ -823,6 +826,10 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C,
RNA_enum_item_add(&item, &totitem, item_8bit);
}
+ if (depth_ok & R_IMF_CHAN_DEPTH_10) {
+ RNA_enum_item_add(&item, &totitem, item_10bit);
+ }
+
if (depth_ok & R_IMF_CHAN_DEPTH_12) {
RNA_enum_item_add(&item, &totitem, item_12bit);
}
@@ -995,8 +1002,7 @@ static void rna_RenderSettings_active_layer_index_range(PointerRNA *ptr, int *mi
RenderData *rd = (RenderData *)ptr->data;
*min = 0;
- *max = BLI_countlist(&rd->layers) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&rd->layers) - 1);
}
static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr)
@@ -1026,17 +1032,20 @@ static SceneRenderLayer *rna_RenderLayer_new(ID *id, RenderData *UNUSED(rd), con
}
static void rna_RenderLayer_remove(ID *id, RenderData *UNUSED(rd), Main *bmain, ReportList *reports,
- SceneRenderLayer *srl)
+ PointerRNA *srl_ptr)
{
+ SceneRenderLayer *srl = srl_ptr->data;
Scene *scene = (Scene *)id;
if (!BKE_scene_remove_render_layer(bmain, scene, srl)) {
- BKE_reportf(reports, RPT_ERROR, "RenderLayer '%s' could not be removed from scene '%s'",
+ BKE_reportf(reports, RPT_ERROR, "Render layer '%s' could not be removed from scene '%s'",
srl->name, scene->id.name + 2);
+ return;
}
- else {
- WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
- }
+
+ RNA_POINTER_INVALIDATE(srl_ptr);
+
+ WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
}
static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value)
@@ -1209,9 +1218,12 @@ static void object_simplify_update(Object *ob)
ModifierData *md;
ParticleSystem *psys;
- for (md = ob->modifiers.first; md; md = md->next)
- if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem))
- ob->recalc |= OB_RECALC_DATA | PSYS_RECALC_CHILD;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) {
+ ob->recalc |= PSYS_RECALC_CHILD;
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ }
for (psys = ob->particlesystem.first; psys; psys = psys->next)
psys->recalc |= PSYS_RECALC_CHILD;
@@ -1242,6 +1254,12 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr
rna_Scene_use_simplify_update(bmain, scene, ptr);
}
+static void rna_Scene_use_persistent_data_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
+{
+ if (!(scene->r.mode & R_PERSISTENT_DATA))
+ RE_FreePersistentData();
+}
+
static int rna_Scene_use_audio_get(PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->data;
@@ -1323,15 +1341,16 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[])
return marker;
}
-static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *marker)
+static void rna_TimeLine_remove(Scene *scene, ReportList *reports, PointerRNA *marker_ptr)
{
- if (!BLI_remlink_safe(&scene->markers, marker)) {
- BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in scene '%s'", marker->name, scene->id.name + 2);
+ TimeMarker *marker = marker_ptr->data;
+ if (BLI_remlink_safe(&scene->markers, marker) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in scene '%s'", marker->name, scene->id.name + 2);
return;
}
- /* XXX, invalidates PyObject */
MEM_freeN(marker);
+ RNA_POINTER_INVALIDATE(marker_ptr);
WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL);
WM_main_add_notifier(NC_ANIMATION | ND_MARKERS, NULL);
@@ -1357,7 +1376,7 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons
return ks;
}
else {
- BKE_report(reports, RPT_ERROR, "Keying Set could not be added");
+ BKE_report(reports, RPT_ERROR, "Keying set could not be added");
return NULL;
}
}
@@ -1404,6 +1423,12 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
DAG_id_tag_update(&camera->id, 0);
}
+static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ BKE_sequencer_cache_cleanup();
+ BKE_sequencer_preprocessed_cache_cleanup();
+}
+
#else
static void rna_def_transform_orientation(BlenderRNA *brna)
@@ -2809,7 +2834,8 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a render layer");
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
parm = RNA_def_pointer(func, "layer", "SceneRenderLayer", "", "Timeline marker to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
/* use for render output and image save operator,
@@ -2901,7 +2927,6 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna)
#endif
-
#ifdef WITH_OPENJPEG
/* Jpeg 2000 */
prop = RNA_def_property(srna, "use_jpeg2k_ycc", PROP_BOOLEAN, PROP_NONE);
@@ -2923,7 +2948,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna)
/* Cineon and DPX */
prop = RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_CINEON_LOG);
+ RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_IMF_CINEON_FLAG_LOG);
RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
@@ -3388,16 +3413,16 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "xparts");
- RNA_def_property_range(prop, 1, 512);
- RNA_def_property_ui_text(prop, "Parts X", "Number of horizontal tiles to use while rendering");
+ prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tilex");
+ RNA_def_property_range(prop, 8, 10000);
+ RNA_def_property_ui_text(prop, "Tile X", "Horizontal tile size to use while rendering");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "parts_y", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "yparts");
- RNA_def_property_range(prop, 1, 512);
- RNA_def_property_ui_text(prop, "Parts Y", "Number of vertical tiles to use while rendering");
+ prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tiley");
+ RNA_def_property_range(prop, 8, 10000);
+ RNA_def_property_ui_text(prop, "Tile Y", "Vertical tile size to use while rendering");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE);
@@ -3613,14 +3638,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR);
RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "mblur_samples");
RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "blurfac");
@@ -3628,7 +3653,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.01, 2.0f, 1, 0);
RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
/* border */
prop = RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE);
@@ -3943,15 +3968,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_PREV);
RNA_def_property_ui_text(prop, "Sequencer OpenGL", "");
+#if 0 /* see R_SEQ_GL_REND comment */
prop = RNA_def_property(srna, "use_sequencer_gl_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_REND);
RNA_def_property_ui_text(prop, "Sequencer OpenGL", "");
-
+#endif
prop = RNA_def_property(srna, "sequencer_gl_preview", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "seq_prev_type");
RNA_def_property_enum_items(prop, viewport_shade_items);
RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "sequencer_gl_render", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "seq_rend_type");
@@ -4028,6 +4055,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE);
RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated");
+ /* persistent data */
+ prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA);
+ RNA_def_property_ui_text(prop, "Persistent Data", "Keep render data around for faster re-renders");
+ RNA_def_property_update(prop, 0, "rna_Scene_use_persistent_data_update");
+
/* Scene API */
RNA_api_scene_render(srna);
}
@@ -4119,7 +4152,8 @@ static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a timeline marker");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_TimeLine_clear");
RNA_def_function_ui_description(func, "Remove all timeline markers");
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index cdf7ac5e68f..63253153699 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -53,7 +53,7 @@
-void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
+static void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
{
scene->r.cfra = frame;
scene->r.subframe = subframe;
@@ -89,29 +89,29 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name
#include "../../collada/collada.h"
static void rna_Scene_collada_export(
- Scene *scene,
- const char *filepath,
- int apply_modifiers,
- int export_mesh_type,
-
- int selected,
- int include_children,
- int include_armatures,
- int deform_bones_only,
-
- int active_uv_only,
- int include_uv_textures,
- int include_material_textures,
- int use_texture_copies,
-
- int use_object_instantiation,
- int sort_by_name,
- int second_life)
+ Scene *scene,
+ const char *filepath,
+ int apply_modifiers,
+ int export_mesh_type,
+
+ int selected,
+ int include_children,
+ int include_armatures,
+ int deform_bones_only,
+
+ int active_uv_only,
+ int include_uv_textures,
+ int include_material_textures,
+ int use_texture_copies,
+
+ int use_object_instantiation,
+ int sort_by_name,
+ int second_life)
{
- collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
+ collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
include_children, include_armatures, deform_bones_only,
- active_uv_only, include_uv_textures, include_material_textures,
- use_texture_copies, use_object_instantiation, sort_by_name, second_life);
+ active_uv_only, include_uv_textures, include_material_textures,
+ use_texture_copies, use_object_instantiation, sort_by_name, second_life);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 58d676555c1..84e76fae896 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -60,6 +60,8 @@ static EnumPropertyItem particle_edit_hair_brush_items[] = {
#include "BKE_particle.h"
#include "BKE_depsgraph.h"
+#include "BLI_pbvh.h"
+
#include "ED_particle.h"
static EnumPropertyItem particle_edit_disconnected_hair_brush_items[] = {
@@ -206,6 +208,21 @@ static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNU
}
}
+static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+{
+ Object *ob = (scene->basact) ? scene->basact->object : NULL;
+
+ if (ob) {
+ Sculpt *sd = scene->toolsettings->sculpt;
+ ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE;
+
+ if (ob->sculpt->pbvh)
+ pbvh_show_diffuse_color_set(ob->sculpt->pbvh, ob->sculpt->show_diffuse_color);
+
+ WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
+ }
+}
+
#else
static void rna_def_paint(BlenderRNA *brna)
@@ -297,6 +314,12 @@ static void rna_def_sculpt(BlenderRNA *brna)
"Use only deformation modifiers (temporary disable all "
"constructive modifiers except multi-resolution)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update");
+
+ prop = RNA_def_property(srna, "show_diffuse_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SHOW_DIFFUSE);
+ RNA_def_property_ui_text(prop, "Show Diffuse Color",
+ "Show diffuse color of object and overlay sculpt mask on top of it");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update");
}
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index d8ca1aea5dd..c2fa64698e4 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -966,18 +966,20 @@ static SequenceModifierData *rna_Sequence_modifier_new(Sequence *seq, bContext *
}
}
-static void rna_Sequence_modifier_remove(Sequence *seq, bContext *C, ReportList *reports, SequenceModifierData *smd)
+static void rna_Sequence_modifier_remove(Sequence *seq, bContext *C, ReportList *reports, PointerRNA *smd_ptr)
{
+ SequenceModifierData *smd = smd_ptr->data;
Scene *scene = CTX_data_scene(C);
- if (BKE_sequence_modifier_remove(seq, smd)) {
- BKE_sequence_invalidate_cache_for_modifier(scene, seq);
-
- WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
- }
- else {
+ if (BKE_sequence_modifier_remove(seq, smd) == FALSE) {
BKE_report(reports, RPT_ERROR, "Modifier was not found in the stack");
+ return;
}
+
+ RNA_POINTER_INVALIDATE(smd_ptr);
+ BKE_sequence_invalidate_cache_for_modifier(scene, seq);
+
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
}
static void rna_Sequence_modifier_clear(Sequence *seq, bContext *C)
@@ -1267,7 +1269,8 @@ static void rna_def_sequence_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove an existing modifier from the sequence");
/* modifier to remove */
parm = RNA_def_pointer(func, "modifier", "SequenceModifier", "", "Modifier to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* clear all modifiers */
func = RNA_def_function(srna, "clear", "rna_Sequence_modifier_clear");
@@ -1685,6 +1688,16 @@ static void rna_def_effect_inputs(StructRNA *srna, int count)
#endif
}
+static void rna_def_color_management(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "strip->colorspace_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings");
+ RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
+}
+
static void rna_def_image(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1711,6 +1724,7 @@ static void rna_def_image(BlenderRNA *brna)
rna_def_filter_video(srna);
rna_def_proxy(srna);
rna_def_input(srna);
+ rna_def_color_management(srna);
}
static void rna_def_meta(BlenderRNA *brna)
@@ -1796,6 +1810,7 @@ static void rna_def_movie(BlenderRNA *brna)
rna_def_filter_video(srna);
rna_def_proxy(srna);
rna_def_input(srna);
+ rna_def_color_management(srna);
}
static void rna_def_movieclip(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index f63ef6c8d76..7602ec99c2b 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -89,6 +89,8 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start
if (file) {
strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
BLI_split_dirfile(file, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
+
+ BKE_sequence_init_colorspace(seq);
}
else {
strip->stripdata = NULL;
@@ -234,9 +236,10 @@ static Sequence *rna_Sequences_new_sound(ID *id, Editing *ed, Main *bmain, Repor
}
#else /* WITH_AUDASPACE */
static Sequence *rna_Sequences_new_sound(ID *UNUSED(id), Editing *UNUSED(ed), Main *UNUSED(bmain), ReportList *reports,
- const char *UNUSED(name), const char *UNUSED(file), int UNUSED(channel), int UNUSED(start_frame))
+ const char *UNUSED(name), const char *UNUSED(file), int UNUSED(channel),
+ int UNUSED(start_frame))
{
- BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support.");
+ BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support");
return NULL;
}
#endif /* WITH_AUDASPACE */
@@ -249,39 +252,37 @@ static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *repor
Scene *scene = (Scene *)id;
Sequence *seq;
struct SeqEffectHandle sh;
+ int num_inputs = BKE_sequence_effect_get_num_inputs(type);
- switch (BKE_sequence_effect_get_num_inputs(type)) {
+ switch (num_inputs) {
case 0:
if (end_frame <= start_frame) {
- BKE_report(reports, RPT_ERROR,
- "Sequences.new_effect: End frame not set");
+ BKE_report(reports, RPT_ERROR, "Sequences.new_effect: end frame not set");
return NULL;
}
break;
case 1:
if (seq1 == NULL) {
- BKE_report(reports, RPT_ERROR,
- "Sequences.new_effect: Effect takes 1 input sequence");
+ BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 1 input sequence");
return NULL;
}
break;
case 2:
if (seq1 == NULL || seq2 == NULL) {
- BKE_report(reports, RPT_ERROR,
- "Sequences.new_effect: Effect takes 2 input sequences");
+ BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 2 input sequences");
return NULL;
}
break;
case 3:
if (seq1 == NULL || seq2 == NULL || seq3 == NULL) {
- BKE_report(reports, RPT_ERROR,
- "Sequences.new_effect: Effect takes 3 input sequences");
+ BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 3 input sequences");
return NULL;
}
break;
default:
- BKE_report(reports, RPT_ERROR,
- "Sequences.new_effect: BKE_sequence_effect_get_num_inputs() > 3 (should never happen)");
+ BKE_reportf(reports, RPT_ERROR,
+ "Sequences.new_effect: effect expects more than 3 inputs (%d, should never happen!)",
+ num_inputs);
return NULL;
}
@@ -309,12 +310,18 @@ static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *repor
return seq;
}
-static void rna_Sequences_remove(ID *id, Editing *ed, Sequence *seq)
+static void rna_Sequences_remove(ID *id, Editing *ed, ReportList *reports, PointerRNA *seq_ptr)
{
+ Sequence *seq = seq_ptr->data;
Scene *scene = (Scene *)id;
- BLI_remlink(&ed->seqbase, seq);
+ if (BLI_remlink_safe(&ed->seqbase, seq) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "Sequence '%s' not in scene '%s'", seq->name + 2, scene->id.name + 2);
+ return;
+ }
+
BKE_sequence_free(scene, seq);
+ RNA_POINTER_INVALIDATE(seq_ptr);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
@@ -342,7 +349,7 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports,
StripElem *new_seq, *se;
if (seq->len == 1) {
- BKE_report(reports, RPT_ERROR, "SequenceElements.pop: can not pop the last element");
+ BKE_report(reports, RPT_ERROR, "SequenceElements.pop: cannot pop the last element");
return;
}
@@ -456,7 +463,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_clip", "rna_Sequences_new_clip");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new movie clip sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to add");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
@@ -472,8 +479,8 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_mask", "rna_Sequences_new_mask");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
- RNA_def_function_ui_description(func, "Add a new movie clip sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ RNA_def_function_ui_description(func, "Add a new mask sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to add");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
@@ -490,7 +497,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new scene sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to add");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
@@ -507,7 +514,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_image", "rna_Sequences_new_image");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new image sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to image");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -524,7 +531,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_movie", "rna_Sequences_new_movie");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new movie sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -540,8 +547,8 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_sound", "rna_Sequences_new_sound");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- RNA_def_function_ui_description(func, "Add a new movie clip sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ RNA_def_function_ui_description(func, "Add a new sound sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -558,7 +565,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new_effect", "rna_Sequences_new_effect");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new effect sequence");
- parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_enum(func, "type", seq_effect_items, 0, "Type",
"type for the new sequence");
@@ -569,21 +576,22 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "",
"The start frame for the new sequence", -MAXFRAME, MAXFRAME);
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_int(func, "end_frame", 0, -MAXFRAME, MAXFRAME, "",
- "The end frame for the new sequence", -MAXFRAME, MAXFRAME);
- parm = RNA_def_pointer(func, "seq1", "Sequence", "", "Sequence 1 for effect");
- parm = RNA_def_pointer(func, "seq2", "Sequence", "", "Sequence 2 for effect");
- parm = RNA_def_pointer(func, "seq3", "Sequence", "", "Sequence 3 for effect");
+ RNA_def_int(func, "end_frame", 0, -MAXFRAME, MAXFRAME, "",
+ "The end frame for the new sequence", -MAXFRAME, MAXFRAME);
+ RNA_def_pointer(func, "seq1", "Sequence", "", "Sequence 1 for effect");
+ RNA_def_pointer(func, "seq2", "Sequence", "", "Sequence 2 for effect");
+ RNA_def_pointer(func, "seq3", "Sequence", "", "Sequence 3 for effect");
/* return type */
parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Sequences_remove");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a Sequence");
parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Sequence to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index e8818248609..bdcda79583e 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -65,14 +65,20 @@ static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *p
DAG_scene_sort(bmain, scene);
}
+static void rna_Smoke_resetCache(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
+ if (settings->smd && settings->smd->domain)
+ settings->point_cache[0]->flag |= PTCACHE_OUTDATED;
+ DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+}
+
static void rna_Smoke_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
smokeModifier_reset(settings->smd);
-
- if (settings->smd && settings->smd->domain)
- settings->point_cache[0]->flag |= PTCACHE_OUTDATED;
+ rna_Smoke_resetCache(bmain, scene, ptr);
rna_Smoke_update(bmain, scene, ptr);
}
@@ -142,6 +148,30 @@ static void rna_SmokeModifier_density_get(PointerRNA *ptr, float *values)
memcpy(values, density, size * sizeof(float));
}
+static void rna_SmokeFlow_density_vgroup_get(PointerRNA *ptr, char *value)
+{
+ SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
+ rna_object_vgroup_name_index_get(ptr, value, flow->vgroup_density);
+}
+
+static int rna_SmokeFlow_density_vgroup_length(PointerRNA *ptr)
+{
+ SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
+ return rna_object_vgroup_name_index_length(ptr, flow->vgroup_density);
+}
+
+static void rna_SmokeFlow_density_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
+ rna_object_vgroup_name_index_set(ptr, value, &flow->vgroup_density);
+}
+
+static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value)
+{
+ SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
+ rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name));
+}
+
#else
static void rna_def_smoke_domain_settings(BlenderRNA *brna)
@@ -217,7 +247,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
RNA_def_property_ui_text(prop, "Density",
"How much density affects smoke motion (higher value results in faster rising smoke)");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "beta");
@@ -225,7 +255,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
RNA_def_property_ui_text(prop, "Heat",
"How much heat affects smoke motion (higher value results in faster rising smoke)");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "coll_group");
@@ -253,24 +283,24 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2);
RNA_def_property_ui_text(prop, "Strength", "Strength of noise");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "diss_speed");
RNA_def_property_range(prop, 1.0, 10000.0);
RNA_def_property_ui_range(prop, 1.0, 10000.0, 1, 0);
RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "use_dissolve_smoke", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE);
RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "use_dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG);
RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x ");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -297,21 +327,21 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "smooth_emitter", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGH_SMOOTH);
RNA_def_property_ui_text(prop, "Smooth Emitter", "Smooth emitted smoke to avoid blockiness");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "time_scale");
RNA_def_property_range(prop, 0.2, 1.5);
RNA_def_property_ui_range(prop, 0.2, 1.5, 0.02, 5);
RNA_def_property_ui_text(prop, "Time Scale", "Adjust simulation speed");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "vorticity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vorticity");
RNA_def_property_range(prop, 0.01, 4.0);
RNA_def_property_ui_range(prop, 0.01, 4.0, 0.02, 5);
RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
RNA_def_property_array(prop, 32);
@@ -321,25 +351,81 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_SmokeModifier_density_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Density", "Smoke density");
- prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dx");
+ prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "dx", "Cell Size");
+ RNA_def_property_ui_text(prop, "cell_size", "Cell Size");
- prop = RNA_def_property(srna, "start_point", PROP_FLOAT, PROP_XYZ);
+ prop = RNA_def_property(srna, "start_point", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */
RNA_def_property_float_sdna(prop, NULL, "p0");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "p0", "Start point");
- prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "scale");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "scale", "Domain scale factor");
-
- prop = RNA_def_property(srna, "domain_resolution", PROP_INT, PROP_XYZ);
+ prop = RNA_def_property(srna, "domain_resolution", PROP_INT, PROP_XYZ); /* can change each frame when using adaptive domain */
RNA_def_property_int_sdna(prop, NULL, "res");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "res", "Smoke Grid Resolution");
+
+ prop = RNA_def_property(srna, "burning_rate", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.01, 4.0);
+ RNA_def_property_ui_range(prop, 0.01, 2.0, 1.0, 5);
+ RNA_def_property_ui_text(prop, "Speed", "Speed of the burning reaction (use larger values for smaller flame)");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "flame_smoke", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, 8.0);
+ RNA_def_property_ui_range(prop, 0.0, 4.0, 1.0, 5);
+ RNA_def_property_ui_text(prop, "Smoke", "Amount of smoke created by burning fuel");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "flame_vorticity", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, 2.0);
+ RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
+ RNA_def_property_ui_text(prop, "Vorticity", "Additional vorticity for the flames");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "flame_ignition", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.5, 5.0);
+ RNA_def_property_ui_range(prop, 0.5, 2.5, 1.0, 5);
+ RNA_def_property_ui_text(prop, "Ignition", "Minimum temperature of flames");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "flame_max_temp", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 1.0, 10.0);
+ RNA_def_property_ui_range(prop, 1.0, 5.0, 1.0, 5);
+ RNA_def_property_ui_text(prop, "Maximum", "Maximum temperature of flames");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "flame_smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke emitted from burning fuel");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "use_adaptive_domain", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_ADAPTIVE_DOMAIN);
+ RNA_def_property_ui_text(prop, "Adaptive Domain", "Adapt simulation resolution and size to fluid");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "additional_res", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "adapt_res");
+ RNA_def_property_range(prop, 0, 512);
+ RNA_def_property_ui_range(prop, 0, 512, 2, 0);
+ RNA_def_property_ui_text(prop, "Additional", "Maximum number of additional cells");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "adapt_margin", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "adapt_margin");
+ RNA_def_property_range(prop, 2, 24);
+ RNA_def_property_ui_range(prop, 2, 24, 2, 0);
+ RNA_def_property_ui_text(prop, "Margin", "Margin added around fluid to minimize boundary interference");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.01, 0.5);
+ RNA_def_property_ui_range(prop, 0.01, 0.5, 1.0, 5);
+ RNA_def_property_ui_text(prop, "Threshold",
+ "Maximum amount of fluid cell can contain before it is considered empty");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
}
static void rna_def_smoke_flow_settings(BlenderRNA *brna)
@@ -347,6 +433,26 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem smoke_flow_types[] = {
+ {MOD_SMOKE_FLOW_TYPE_OUTFLOW, "OUTFLOW", 0, "Outflow", "Delete smoke from simulation"},
+ {MOD_SMOKE_FLOW_TYPE_SMOKE, "SMOKE", 0, "Smoke", "Add smoke"},
+ {MOD_SMOKE_FLOW_TYPE_SMOKEFIRE, "BOTH", 0, "Fire + Smoke", "Add fire and smoke"},
+ {MOD_SMOKE_FLOW_TYPE_FIRE, "FIRE", 0, "Fire", "Add fire"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem smoke_flow_sources[] = {
+ {MOD_SMOKE_FLOW_SOURCE_PARTICLES, "PARTICLES", ICON_PARTICLES, "Particle System", "Emit smoke from particles"},
+ {MOD_SMOKE_FLOW_SOURCE_MESH, "MESH", ICON_META_CUBE, "Mesh", "Emit smoke from mesh surface or volume"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem smoke_flow_texture_types[] = {
+ {MOD_SMOKE_FLOW_TEXTURE_MAP_AUTO, "AUTO", 0, "Generated", "Generated coordinates centered to flow object"},
+ {MOD_SMOKE_FLOW_TEXTURE_MAP_UV, "UV", 0, "UV", "Use UV layer for texture coordinates"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "SmokeFlowSettings", NULL);
RNA_def_struct_ui_text(srna, "Flow Settings", "Smoke flow settings");
RNA_def_struct_sdna(srna, "SmokeFlowSettings");
@@ -354,11 +460,23 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "density");
- RNA_def_property_range(prop, 0.001, 1);
- RNA_def_property_ui_range(prop, 0.001, 1.0, 1.0, 4);
+ RNA_def_property_range(prop, 0.0, 1);
+ RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 4);
RNA_def_property_ui_text(prop, "Density", "");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+ prop = RNA_def_property(srna, "smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "color");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "fuel_amount", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, 10);
+ RNA_def_property_ui_range(prop, 0.0, 5.0, 1.0, 4);
+ RNA_def_property_ui_text(prop, "Flame Rate", "");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
prop = RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "temp");
RNA_def_property_range(prop, -10, 10);
@@ -373,9 +491,16 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
RNA_def_property_update(prop, 0, "rna_Smoke_reset_dependancy");
- prop = RNA_def_property(srna, "use_outflow", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "type", MOD_SMOKE_FLOW_TYPE_OUTFLOW);
- RNA_def_property_ui_text(prop, "Outflow", "Delete smoke from simulation");
+ prop = RNA_def_property(srna, "smoke_flow_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, smoke_flow_types);
+ RNA_def_property_ui_text(prop, "Flow Type", "Change how flow affects the simulation");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "smoke_flow_source", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "source");
+ RNA_def_property_enum_items(prop, smoke_flow_sources);
+ RNA_def_property_ui_text(prop, "Source", "Change how smoke is emitted");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
prop = RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE);
@@ -385,14 +510,82 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "initial_velocity", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_INITVELOCITY);
- RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke inherits its velocity from the emitter particle");
+ RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke has some initial velocity when it is emitted");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vel_multi");
RNA_def_property_range(prop, -2.0, 2.0);
RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
- RNA_def_property_ui_text(prop, "Multiplier", "Multiplier to adjust velocity passed to smoke");
+ RNA_def_property_ui_text(prop, "Source", "Multiplier of source velocity passed to smoke");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "velocity_normal", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "vel_normal");
+ RNA_def_property_range(prop, -2.0, 2.0);
+ RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Normal", "Amount of normal directional velocity");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "velocity_random", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "vel_random");
+ RNA_def_property_range(prop, 0.0, 2.0);
+ RNA_def_property_ui_range(prop, 0.0, 2.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Random", "Amount of random velocity");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "volume_density", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_range(prop, 0.0, 1.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Volume", "Factor for smoke emitted from inside the mesh volume");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "surface_distance", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.5, 10.0);
+ RNA_def_property_ui_range(prop, 0.5, 5.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Surface", "Maximum distance from mesh surface to emit smoke");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "density_vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_SmokeFlow_density_vgroup_get",
+ "rna_SmokeFlow_density_vgroup_length",
+ "rna_SmokeFlow_density_vgroup_set");
+ RNA_def_property_ui_text(prop, "Vertex Group",
+ "Name of vertex group which determines surface emission rate");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_TEXTUREEMIT);
+ RNA_def_property_ui_text(prop, "Use Texture", "Use a texture to control emission strength");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "texture_map_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "texture_type");
+ RNA_def_property_enum_items(prop, smoke_flow_texture_types);
+ RNA_def_property_ui_text(prop, "Mapping", "Texture mapping type");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
+ RNA_def_property_ui_text(prop, "UV Map", "UV map name");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SmokeFlow_uvlayer_set");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "noise_texture", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Texture", "Texture that controls emission strength");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "texture_size", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.01, 10.0);
+ RNA_def_property_ui_range(prop, 0.1, 5.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Size", "Size of texture mapping");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+ prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, 200.0);
+ RNA_def_property_ui_range(prop, 0.0, 100.0, 0.05, 5);
+ RNA_def_property_ui_text(prop, "Offset", "Z-offset of texture mapping");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index ff5f4988cc1..962a92223eb 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -336,6 +336,15 @@ static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values)
copy_v3_v3(cursor, values);
}
+static float rna_View3D_GridScaleUnit_get(PointerRNA *ptr)
+{
+ View3D *v3d = (View3D *)(ptr->data);
+ bScreen *sc = (bScreen *)ptr->id.data;
+ Scene *scene = (Scene *)sc->scene;
+
+ return ED_view3d_grid_scale(scene, v3d, NULL);
+}
+
static void rna_SpaceView3D_layer_set(PointerRNA *ptr, const int *values)
{
View3D *v3d = (View3D *)(ptr->data);
@@ -949,15 +958,17 @@ static BGpic *rna_BackgroundImage_new(View3D *v3d)
return bgpic;
}
-static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic *bgpic)
+static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, PointerRNA *bgpic_ptr)
{
+ BGpic *bgpic = bgpic_ptr->data;
if (BLI_findindex(&v3d->bgpicbase, bgpic) == -1) {
- BKE_report(reports, RPT_ERROR, "BackgroundImage can't be removed");
- }
- else {
- ED_view3D_background_image_remove(v3d, bgpic);
- WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ BKE_report(reports, RPT_ERROR, "Background image cannot be removed");
}
+
+ ED_view3D_background_image_remove(v3d, bgpic);
+ RNA_POINTER_INVALIDATE(bgpic_ptr);
+
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d);
}
static void rna_BackgroundImage_clear(View3D *v3d)
@@ -1324,7 +1335,7 @@ static void rna_def_background_image(BlenderRNA *brna)
srna = RNA_def_struct(brna, "BackgroundImage", NULL);
RNA_def_struct_sdna(srna, "BGpic");
- RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3d View background");
+ RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3D View background");
prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "source");
@@ -1442,7 +1453,8 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove background image");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_BackgroundImage_clear");
RNA_def_function_ui_description(func, "Remove all background images");
@@ -1494,7 +1506,39 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Camera",
"Active camera used in this view (when unlocked from the scene's active camera)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
+
+ /* render border */
+ prop = RNA_def_property(srna, "use_render_border", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_BORDER);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Render Border",
+ "Use a user-defined border region within the frame size for rendered viewport");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "render_border_min_x", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "render_border.xmin");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Border Minimum X", "Minimum X value to for the render border");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "render_border_min_y", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "render_border.ymin");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Border Minimum Y", "Minimum Y value for the render border");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "render_border_max_x", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "render_border.xmax");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Border Maximum X", "Maximum X value for the render border");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "render_border_max_y", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "render_border.ymax");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Border Maximum Y", "Maximum Y value for the render border");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "lock_object", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_sdna(prop, NULL, "ob_centre");
@@ -1533,7 +1577,7 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "lens");
- RNA_def_property_ui_text(prop, "Lens", "Lens angle (mm) in perspective view");
+ RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle (mm)");
RNA_def_property_range(prop, 1.0f, 250.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -1571,7 +1615,12 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_int_default(prop, 10);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
+
+ prop = RNA_def_property(srna, "grid_scale_unit", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_float_funcs(prop, "rna_View3D_GridScaleUnit_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Grid Scale Unit", "Grid cell size scaled by scene unit system settings");
+
prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_FLOOR);
RNA_def_property_ui_text(prop, "Display Grid Floor", "Show the ground plane grid in perspective view");
@@ -2780,6 +2829,12 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_FILE_BLEND, 0);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ prop = RNA_def_property(srna, "use_filter_backup", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE_BACKUP);
+ RNA_def_property_ui_text(prop, "Filter BlenderBackup files", "Show .blend1, .blend2, etc. files");
+ RNA_def_property_ui_icon(prop, ICON_FILE_BACKUP, 0);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+
prop = RNA_def_property(srna, "use_filter_movie", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE);
RNA_def_property_ui_text(prop, "Filter Movies", "Show movie files");
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 45e3d15b9be..e77c5d13a6b 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -71,7 +71,7 @@ EnumPropertyItem texture_type_items[] = {
{TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""},
{TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", "Procedural - create a fractal noise texture"},
{TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", "Procedural - create cell-like patterns based on Worley noise"},
- {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3d texture based on volumetric data"},
+ {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3D texture based on volumetric data"},
{TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - wave generated bands or rings, with optional noise"},
{TEX_OCEAN, "OCEAN", ICON_TEXTURE, "Ocean", "Use a texture generated by an Ocean modifier"},
{0, NULL, 0, NULL, NULL}
@@ -1800,7 +1800,8 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna)
};
static EnumPropertyItem smoked_type_items[] = {
- {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Density", "Use smoke density as texture data"},
+ {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Smoke", "Use smoke density and color as texture data"},
+ {TEX_VD_SMOKEFLAME, "SMOKEFLAME", 0, "Flame", "Use flame temperature as texture data"},
{TEX_VD_SMOKEHEAT, "SMOKEHEAT", 0, "Heat", "Use smoke heat as texture data. Values from -2.0 to 2.0 are used"},
{TEX_VD_SMOKEVEL, "SMOKEVEL", 0, "Velocity", "Use smoke velocity as texture data"},
{0, NULL, 0, NULL, NULL}
diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c
index a2880510958..5be9d3a0dec 100644
--- a/source/blender/makesrna/intern/rna_texture_api.c
+++ b/source/blender/makesrna/intern/rna_texture_api.c
@@ -120,10 +120,10 @@ void RNA_api_environment_map(StructRNA *srna)
RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken");
- RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 0.0f, "File layout",
+ RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 1000.0f, "File layout",
"Flat array describing the X,Y position of each cube face in the "
"output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] "
- "(use -1 to skip a face)", 0.0f, 0.0f);
+ "(use -1 to skip a face)", 0.0f, 1000.0f);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 0c62a280935..4aefaf991d2 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -35,6 +35,7 @@
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -119,8 +120,7 @@ static void rna_tracking_active_object_index_range(PointerRNA *ptr, int *min, in
MovieClip *clip = (MovieClip *)ptr->id.data;
*min = 0;
- *max = clip->tracking.tot_object - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, clip->tracking.tot_object - 1);
}
static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr)
@@ -262,8 +262,7 @@ static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min
MovieClip *clip = (MovieClip *)ptr->id.data;
*min = 0;
- *max = clip->tracking.stabilization.tot_track - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, clip->tracking.stabilization.tot_track - 1);
}
static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
@@ -447,9 +446,15 @@ static MovieTrackingObject *rna_trackingObject_new(MovieTracking *tracking, cons
return object;
}
-static void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object)
+static void rna_trackingObject_remove(MovieTracking *tracking, ReportList *reports, PointerRNA *object_ptr)
{
- BKE_tracking_object_delete(tracking, object);
+ MovieTrackingObject *object = object_ptr->data;
+ if (BKE_tracking_object_delete(tracking, object) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "MovieTracking '%s' cannot be removed", object->name);
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(object_ptr);
WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL);
}
@@ -567,17 +572,21 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
"Limit speed of tracking to make visual feedback easier "
"(this does not affect the tracking quality)");
- /* keyframe_a */
- prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE);
+ /* reconstruction success_threshold */
+ prop = RNA_def_property(srna, "reconstruction_success_threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_int_sdna(prop, NULL, "keyframe1");
- RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization");
+ RNA_def_property_float_default(prop, 0.001f);
+ RNA_def_property_range(prop, 0, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Success Threshold",
+ "Threshold value of reconstruction error which is still considered successful");
- /* keyframe_b */
- prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE);
+ /* use fallback reconstruction */
+ prop = RNA_def_property(srna, "use_fallback_reconstruction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_int_sdna(prop, NULL, "keyframe2");
- RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization");
+ RNA_def_property_boolean_sdna(prop, NULL, "reconstruction_flag", TRACKING_USE_FALLBACK_RECONSTRUCTION);
+ RNA_def_property_ui_text(prop, "Use Fallback",
+ "Use fallback reconstruction algorithm in cases main reconstruction algorithm failed "
+ "(could give better solution with bad tracks)");
/* intrinsics refinement during bundle adjustment */
prop = RNA_def_property(srna, "refine_intrinsics", PROP_ENUM, PROP_NONE);
@@ -628,7 +637,8 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_tripod_solver", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "motion_flag", TRACKING_MOTION_TRIPOD);
- RNA_def_property_ui_text(prop, "Tripod Motion", "Use special solver to track a stable camera position, such as a tripod");
+ RNA_def_property_ui_text(prop, "Tripod Motion",
+ "Use special solver to track a stable camera position, such as a tripod");
/* default_limit_frames */
prop = RNA_def_property(srna, "default_frames_limit", PROP_INT, PROP_NONE);
@@ -668,7 +678,9 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
/* default_use_brute */
prop = RNA_def_property(srna, "use_default_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "default_algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK);
- RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking");
+ RNA_def_property_ui_text(prop, "Use Mask",
+ "Use a grease pencil datablock as a mask to use only specified areas of pattern "
+ "when tracking");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* default_use_normalization */
@@ -909,8 +921,8 @@ static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_int(func, "frame", 1, MINFRAME, MAXFRAME, "Frame",
"Frame number to find marker for", MINFRAME, MAXFRAME);
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_boolean(func, "exact", TRUE, "Exact",
- "Get marker at exact frame number rather than get estimated marker");
+ RNA_def_boolean(func, "exact", TRUE, "Exact",
+ "Get marker at exact frame number rather than get estimated marker");
parm = RNA_def_pointer(func, "marker", "MovieTrackingMarker", "", "Marker for specified frame");
RNA_def_function_return(func, parm);
@@ -1005,7 +1017,9 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
/* use_brute */
prop = RNA_def_property(srna, "use_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK);
- RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking");
+ RNA_def_property_ui_text(prop, "Use Mask",
+ "Use a grease pencil datablock as a mask to use only specified areas of pattern "
+ "when tracking");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* use_normalization */
@@ -1393,6 +1407,18 @@ static void rna_def_trackingObject(BlenderRNA *brna)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Scale", "Scale of object solution in camera space");
RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingObject_flushUpdate");
+
+ /* keyframe_a */
+ prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_int_sdna(prop, NULL, "keyframe1");
+ RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization");
+
+ /* keyframe_b */
+ prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_int_sdna(prop, NULL, "keyframe2");
+ RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization");
}
static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1416,8 +1442,11 @@ static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_trackingObject_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove tracking object from this movie clip");
- RNA_def_pointer(func, "object", "MovieTrackingObject", "", "Motion tracking object to be removed");
+ parm = RNA_def_pointer(func, "object", "MovieTrackingObject", "", "Motion tracking object to be removed");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* active object */
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
@@ -1437,7 +1466,8 @@ static void rna_def_trackingDopesheet(BlenderRNA *brna)
{TRACKING_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"},
{TRACKING_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"},
{TRACKING_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"},
- {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"},
+ {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error",
+ "Sort channels by average reprojection error of tracks after solve"},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 70d94bfc7ed..a0a9f6183af 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -85,7 +85,7 @@ static ARegionType *region_type_find(ReportList *reports, int space_type, int re
/* region type not found? abort */
if (art == NULL) {
- BKE_report(reports, RPT_ERROR, "Region not found in spacetype");
+ BKE_report(reports, RPT_ERROR, "Region not found in space type");
return NULL;
}
@@ -192,7 +192,7 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat
return NULL;
if (strlen(identifier) >= sizeof(dummypt.idname)) {
- BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d",
+ BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummypt.idname));
return NULL;
}
@@ -309,7 +309,7 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da
return NULL;
if (strlen(identifier) >= sizeof(dummyht.idname)) {
- BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d",
+ BKE_reportf(reports, RPT_ERROR, "Registering header class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummyht.idname));
return NULL;
}
@@ -438,7 +438,7 @@ static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data
return NULL;
if (strlen(identifier) >= sizeof(dummymt.idname)) {
- BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d",
+ BKE_reportf(reports, RPT_ERROR, "Registering menu class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummymt.idname));
return NULL;
}
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 006e1ad3903..548539e3395 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -236,41 +236,41 @@ void RNA_api_ui_layout(StructRNA *srna)
/* useful in C but not in python */
#if 0
- func= RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string");
+ func = RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string");
api_ui_item_op_common(func);
- parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
+ parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_string(func, "value", "", 0, "", "Enum property value");
+ parm = RNA_def_string(func, "value", "", 0, "", "Enum property value");
RNA_def_property_flag(parm, PROP_REQUIRED);
- func= RNA_def_function(srna, "operator_boolean", "uiItemBooleanO");
+ func = RNA_def_function(srna, "operator_boolean", "uiItemBooleanO");
api_ui_item_op_common(func);
- parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
+ parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with");
+ parm = RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with");
RNA_def_property_flag(parm, PROP_REQUIRED); */
- func= RNA_def_function(srna, "operator_int", "uiItemIntO");
+ func = RNA_def_function(srna, "operator_int", "uiItemIntO");
api_ui_item_op_common(func);
- parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
+ parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "",
+ parm = RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "",
"Value of the property to call the operator with", INT_MIN, INT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED); */
- func= RNA_def_function(srna, "operator_float", "uiItemFloatO");
+ func = RNA_def_function(srna, "operator_float", "uiItemFloatO");
api_ui_item_op_common(func);
- parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
+ parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "",
+ parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "",
"Value of the property to call the operator with", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED); */
- func= RNA_def_function(srna, "operator_string", "uiItemStringO");
+ func = RNA_def_function(srna, "operator_string", "uiItemStringO");
api_ui_item_op_common(func);
- parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
+ parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with");
+ parm = RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with");
RNA_def_property_flag(parm, PROP_REQUIRED);
#endif
@@ -390,7 +390,7 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
- func = RNA_def_function(srna, "template_color_wheel", "uiTemplateColorWheel");
+ func = RNA_def_function(srna, "template_color_picker", "uiTemplateColorPicker");
RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors");
api_ui_item_rna_common(func);
RNA_def_boolean(func, "value_slider", 0, "", "Display the value slider to the right of the color wheel");
@@ -439,7 +439,8 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_boolean(func, "compact", 0, "", "Use more compact layout");
func = RNA_def_function(srna, "template_list", "uiTemplateList");
- RNA_def_function_ui_description(func, "Item. A list widget to display data. e.g. vertexgroups");
+ RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups "
+ "(WARNING: only one per panel allowed!).");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 9c989121aa4..3e9f5b44a3d 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -24,9 +24,9 @@
* \ingroup RNA
*/
-
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -311,9 +311,16 @@ static bAddon *rna_userdef_addon_new(void)
return bext;
}
-static void rna_userdef_addon_remove(bAddon *bext)
+static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *bext_ptr)
{
+ bAddon *bext = bext_ptr->data;
+ if (BLI_findindex(&U.addons, bext) == -1) {
+ BKE_report(reports, RPT_ERROR, "Addon is no longer valid");
+ return;
+ }
+
BLI_freelinkN(&U.addons, bext);
+ RNA_POINTER_INVALIDATE(bext_ptr);
}
static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
@@ -388,7 +395,7 @@ static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), P
int a;
if (devices) {
- for (a = 0; devices[a].name; a++) {
+ for (a = 0; devices[a].identifier[0]; a++) {
tmp.value = devices[a].value;
tmp.identifier = devices[a].identifier;
tmp.name = devices[a].name;
@@ -410,6 +417,15 @@ static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), P
}
#endif
+#ifdef WITH_INTERNATIONAL
+static EnumPropertyItem *rna_lang_enum_properties_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), int *free)
+{
+ *free = 0; /* These items are handled by BLF code! */
+ return BLF_RNA_lang_enum_properties();
+}
+#endif
+
#else
static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
@@ -481,7 +497,7 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna)
/* (not used yet) */
#if 0
- prop= RNA_def_property(srna, "panelzoom", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "panelzoom", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.5, 2.0);
RNA_def_property_ui_text(prop, "Panel Zoom", "Default zoom level for panel areas");
#endif
@@ -754,6 +770,25 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
prop = RNA_def_property(srna, "icon_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast");
RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ /* axis */
+ prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "xaxis");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "X Axis", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "yaxis");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Y Axis", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "zaxis");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Z Axis", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
@@ -2510,7 +2545,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Sub Level Menu Open Delay",
"Time delay in 1/10 seconds before automatically opening sub level menus");
- prop = RNA_def_property(srna, "quit_dialog", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_quit_dialog", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_QUIT_PROMPT);
RNA_def_property_ui_text(prop, "Prompt Quit",
"Asks for confirmation when quitting through the window close button");
@@ -2745,6 +2780,11 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTAVAIL);
RNA_def_property_ui_text(prop, "Auto Keyframe Insert Available",
"Automatic keyframe insertion in available F-Curves");
+
+ prop = RNA_def_property(srna, "use_auto_keying_warning", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_NOWARNING);
+ RNA_def_property_ui_text(prop, "Show Auto Keying Warning",
+ "Show warning indicators when transforming objects and bones if auto keying is enabled");
/* keyframing settings */
prop = RNA_def_property(srna, "use_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE);
@@ -2778,7 +2818,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NONEGFRAMES);
RNA_def_property_ui_text(prop, "Allow Negative Frames",
"Current frame number can be manually set to a negative value");
-
+
/* fcurve opacity */
prop = RNA_def_property(srna, "fcurve_unselected_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "fcu_inactive_alpha");
@@ -2978,11 +3018,21 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem multi_sample_levels[] = {
+ {USER_MULTISAMPLE_NONE, "MULTISAMPLE_NONE", 0, "No MultiSample", "Do not use OpenGL MultiSample"},
+ {USER_MULTISAMPLE_2, "MULTISAMPLE_2", 0, "MultiSample: 2", "Use 2x OpenGL MultiSample (requires restart)"},
+ {USER_MULTISAMPLE_4, "MULTISAMPLE_4", 0, "MultiSample: 4", "Use 4x OpenGL MultiSample (requires restart)"},
+ {USER_MULTISAMPLE_8, "MULTISAMPLE_8", 0, "MultiSample: 8", "Use 8x OpenGL MultiSample (requires restart)"},
+ {USER_MULTISAMPLE_16, "MULTISAMPLE_16", 0, "MultiSample: 16", "Use 16x OpenGL MultiSample (requires restart)"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+#if 0
/* hardcoded here, could become dynamic somehow */
/* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */
/* if you edit here, please also edit the source/blender/blenfont/intern/blf_lang.c 's locales */
/* Note: As this list is in alphabetical order, and not defined order,
- * here is the highest define currently in use: 33 (Hebrew). */
+ * here is the highest define currently in use: 35 (Esperanto). */
static EnumPropertyItem language_items[] = {
{ 0, "", 0, N_("Nearly Done"), ""},
{ 0, "DEFAULT", 0, "Default (Default)", ""},
@@ -3000,31 +3050,39 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"},
{18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"},
{ 0, "", 0, N_("In Progress"), ""},
- {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"},
- {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"},
+/* {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"},*/ /* XXX Not active nor enough translated. */
+/* {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"},*/ /* XXX Not active nor enough translated. */
{16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"},
{11, "CZECH", 0, "Czech (Český)", "cs_CZ"},
{ 3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"},
- { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"},
+ {35, "ESPERANTO", 0, "Esperanto (Esperanto)", "eo"},
+ {34, "ESTONIAN", 0, "Estonian (Eestlane)", "et_EE"},
+/* { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"},*/ /* XXX Not active nor enough translated. */
{ 5, "GERMAN", 0, "German (Deutsch)", "de_DE"},
- {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"},
+/* {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"},*/ /* XXX Not active nor enough translated. */
/* using the utf8 flipped form of Hebrew (עִבְרִית)) */
{33, "HEBREW", 0, "Hebrew (תירִבְעִ)", "he_IL"},
{31, "HUNGARIAN", 0, "Hungarian (Magyar)", "hu_HU"},
{27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"},
{29, "KYRGYZ", 0, "Kyrgyz (Кыргыз тили)", "ky_KG"},
-/* {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, */ /* XXX No po's yet. */
- {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"},
+/* {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, */ /* XXX Not active nor enough translated. */
+/* {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"},*/ /* XXX Not active nor enough translated. */
/* using the utf8 flipped form of Persian (فارسی) */
{26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_IR"},
- {19, "POLISH", 0, "Polish (Polski)", "pl_PL"},
-/* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX No po's yet. */
+/* {19, "POLISH", 0, "Polish (Polski)", "pl_PL"},*/ /* XXX Not active nor enough translated. */
+/* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX Not active nor enough translated. */
{17, "SERBIAN", 0, "Serbian (Српски)", "sr_RS"},
{28, "SERBIAN_LATIN", 0, "Serbian Latin (Srpski latinica)", "sr_RS@latin"},
{ 7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"},
{30, "TURKISH", 0, "Turkish (Türkçe)", "tr_TR"},
{ 0, NULL, 0, NULL, NULL}
};
+#else
+ static EnumPropertyItem language_items[] = {
+ { 0, "DEFAULT", 0, "Default (Default)", ""},
+ { 0, NULL, 0, NULL, NULL}
+ };
+#endif
#ifdef WITH_CYCLES
static EnumPropertyItem compute_device_items[] = {
@@ -3067,6 +3125,9 @@ static void rna_def_userdef_system(BlenderRNA *brna)
prop = RNA_def_property(srna, "language", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, language_items);
+#ifdef WITH_INTERNATIONAL
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_lang_enum_properties_itemf");
+#endif
RNA_def_property_ui_text(prop, "Language", "Language used for translation");
RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update");
@@ -3110,6 +3171,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_enum_items(prop, color_picker_types);
RNA_def_property_enum_sdna(prop, NULL, "color_picker_type");
RNA_def_property_ui_text(prop, "Color Picker Type", "Different styles of displaying the color picker widget");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "use_preview_images", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ALLWINCODECS);
@@ -3259,6 +3321,12 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased");
RNA_def_property_update(prop, 0, "rna_userdef_text_update");
+ /* Full scene anti-aliasing */
+ prop = RNA_def_property(srna, "ogl_multisamples", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "ogl_multisamples");
+ RNA_def_property_enum_items(prop, multi_sample_levels);
+ RNA_def_property_ui_text(prop, "MultiSample", "Enable OpenGL multi-sampling, only for systems that support it, requires restart");
+
#ifdef WITH_CYCLES
prop = RNA_def_property(srna, "compute_device_type", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
@@ -3388,10 +3456,10 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_SHOW_GUIDE);
RNA_def_property_ui_text(prop, "Show Navigation Guide", "Display the center and axis during rotation");
/* TODO: update description when fly-mode visuals are in place ("projected position in fly mode")*/
-
+
/* 3D view */
prop = RNA_def_property(srna, "ndof_view_rotate_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "ndof_flag");
RNA_def_property_enum_items(prop, ndof_view_rotation_items);
RNA_def_property_ui_text(prop, "NDOF View Rotation", "Rotation style in the viewport");
@@ -3504,6 +3572,10 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_RECENT);
RNA_def_property_ui_text(prop, "Hide Recent Locations", "Hide recent locations in the file selector");
+ prop = RNA_def_property(srna, "hide_system_bookmarks", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_SYSTEM_BOOKMARKS);
+ RNA_def_property_ui_text(prop, "Hide System Bookmarks", "Hide system bookmarks in the file selector");
+
prop = RNA_def_property(srna, "show_thumbnails", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_THUMBNAILS);
RNA_def_property_ui_text(prop, "Show Thumbnails", "Open in thumbnail view for images and movies");
@@ -3619,10 +3691,11 @@ static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cpro
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_userdef_addon_remove");
- RNA_def_function_flag(func, FUNC_NO_SELF);
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove addon");
parm = RNA_def_pointer(func, "addon", "Addon", "", "Addon to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
void RNA_def_userdef(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index d8753f4ff43..e5f44644f7a 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -122,6 +122,7 @@ EnumPropertyItem event_timer_type_items[] = {
};
EnumPropertyItem event_ndof_type_items[] = {
+ {NDOF_MOTION, "NDOF_MOTION", 0, "Motion", ""},
/* buttons on all 3dconnexion devices */
{NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "Menu", ""},
{NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "Fit", ""},
@@ -622,13 +623,34 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
kmi->val = KM_NOTHING;
break;
case KMI_TYPE_NDOF:
- kmi->type = NDOF_BUTTON_MENU;
- kmi->val = KM_PRESS;
+ kmi->type = NDOF_MOTION;
+ kmi->val = KM_NOTHING;
break;
}
}
}
+/* assumes value to be an enum from event_type_items */
+/* function makes sure keymodifiers are only valid keys, ESC keeps it unaltered */
+static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value)
+{
+ wmKeyMapItem *kmi = ptr->data;
+
+ /* XXX, this should really be managed in an _itemf function,
+ * giving a list of valid enums, then silently changing them when they are set is not
+ * a good precedent, don't do this unless you have a good reason! */
+ if (value == ESCKEY) {
+ /* pass */
+ }
+ else if (value >= AKEY) {
+ kmi->keymodifier = value;
+ }
+ else {
+ kmi->keymodifier = 0;
+ }
+}
+
+
static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
int *UNUSED(free))
{
@@ -1062,7 +1084,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *
}
else {
BKE_reportf(reports, RPT_ERROR,
- "registering operator class: '%s', invalid bl_idname '%s', at position %d",
+ "Registering operator class: '%s', invalid bl_idname '%s', at position %d",
identifier, _operator_idname, i);
return NULL;
}
@@ -1071,7 +1093,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *
}
if (i > ((int)sizeof(dummyop.idname)) - 3) {
- BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', "
+ BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s', invalid bl_idname '%s', "
"is too long, maximum length is %d", identifier, _operator_idname,
(int)sizeof(dummyop.idname) - 3);
return NULL;
@@ -1079,7 +1101,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *
if (dot != 1) {
BKE_reportf(reports, RPT_ERROR,
- "registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
+ "Registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
identifier, _operator_idname);
return NULL;
}
@@ -1180,7 +1202,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, v
}
if (strlen(identifier) >= sizeof(dummyop.idname)) {
- BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d",
+ BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s' is too long, maximum length is %d",
identifier, (int)sizeof(dummyop.idname));
return NULL;
}
@@ -1230,24 +1252,30 @@ static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
{
wmOperator *data = (wmOperator *)(ptr->data);
char *str = (char *)data->type->idname;
- if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
- else assert(!"setting the bl_idname on a non-builtin operator");
+ if (!str[0])
+ BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_idname on a non-builtin operator");
}
static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
{
wmOperator *data = (wmOperator *)(ptr->data);
char *str = (char *)data->type->name;
- if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
- else assert(!"setting the bl_label on a non-builtin operator");
+ if (!str[0])
+ BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_label on a non-builtin operator");
}
static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
{
wmOperator *data = (wmOperator *)(ptr->data);
char *str = (char *)data->type->description;
- if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
- else assert(!"setting the bl_description on a non-builtin operator");
+ if (!str[0])
+ BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_description on a non-builtin operator");
}
static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -1404,7 +1432,7 @@ static void rna_def_operator_type_macro(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added");
RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
-/* prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */
+/* prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */
/* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
/* RNA_def_property_string_sdna(prop, NULL, "idname"); */
/* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */
@@ -1865,6 +1893,7 @@ static void rna_def_keyconfig(BlenderRNA *brna)
prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
RNA_def_property_enum_items(prop, event_type_items);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_wmKeyMapItem_keymodifier_set", NULL);
RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index d6979161cdc..b7895cc0e2d 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -153,6 +153,18 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, ReportList *reports
return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
}
+static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr)
+{
+ wmKeyMapItem *kmi = kmi_ptr->data;
+
+ if (WM_keymap_remove_item(km, kmi) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "KeyMapItem '%s' cannot be removed from '%s'", kmi->idname, km->idname);
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(kmi_ptr);
+}
+
static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, int modal)
{
if (modal == 0) {
@@ -178,6 +190,18 @@ static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char
return ot->modalkeymap;
}
+static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr)
+{
+ wmKeyConfig *keyconf = keyconf_ptr->data;
+
+ if (WM_keyconfig_remove(wm, keyconf) == FALSE) {
+ BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(keyconf_ptr);
+}
+
#else
#define WM_GEN_INVOKE_EVENT (1 << 0)
@@ -292,7 +316,7 @@ void RNA_api_operator(StructRNA *srna)
/* exec */
func = RNA_def_function(srna, "execute", NULL);
RNA_def_function_ui_description(func, "Execute the operator");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
@@ -303,7 +327,7 @@ void RNA_api_operator(StructRNA *srna)
/* check */
func = RNA_def_function(srna, "check", NULL);
RNA_def_function_ui_description(func, "Check the operator settings, return True to signal a change to redraw");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
@@ -313,7 +337,7 @@ void RNA_api_operator(StructRNA *srna)
/* invoke */
func = RNA_def_function(srna, "invoke", NULL);
RNA_def_function_ui_description(func, "Invoke the operator");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
parm = RNA_def_pointer(func, "event", "Event", "", "");
@@ -325,7 +349,7 @@ void RNA_api_operator(StructRNA *srna)
func = RNA_def_function(srna, "modal", NULL); /* same as invoke */
RNA_def_function_ui_description(func, "Modal operator function");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
parm = RNA_def_pointer(func, "event", "Event", "", "");
@@ -345,7 +369,7 @@ void RNA_api_operator(StructRNA *srna)
/* cancel */
func = RNA_def_function(srna, "cancel", NULL);
RNA_def_function_ui_description(func, "Called when the operator is canceled");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
@@ -464,9 +488,11 @@ void RNA_api_keymapitems(StructRNA *srna)
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
RNA_def_function_return(func, parm);
- func = RNA_def_function(srna, "remove", "WM_keymap_remove_item");
+ func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
parm = RNA_def_property(func, "id", PROP_INT, PROP_NONE);
@@ -516,10 +542,11 @@ void RNA_api_keyconfigs(StructRNA *srna)
parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration");
RNA_def_function_return(func, parm);
- func = RNA_def_function(srna, "remove", "WM_keyconfig_remove"); /* remove_keyconfig */
+ func = RNA_def_function(srna, "remove", "rna_KeyConfig_remove"); /* remove_keyconfig */
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
#endif
-
diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py
index e3359fbae59..0231e57fcfd 100755
--- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py
+++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py
@@ -130,11 +130,11 @@ def get_props_from_txt(input_filename):
line = line[1:]
# class
- [bclass, tail] = [x.strip() for x in line.split('.', 1)]
+ bclass, tail = [x.strip() for x in line.split('.', 1)]
# comment
if '*' in bclass:
- [comment, bclass] = [x.strip() for x in bclass.split('*', 1)]
+ comment, bclass = [x.strip() for x in bclass.split('*', 1)]
else:
comment= ''
@@ -144,18 +144,18 @@ def get_props_from_txt(input_filename):
continue
# from
- [bfrom, tail] = [x.strip() for x in tail.split('->', 1)]
+ bfrom, tail = [x.strip() for x in tail.split('->', 1)]
# to
- [bto, tail] = [x.strip() for x in tail.split(':', 1)]
+ bto, tail = [x.strip() for x in tail.split(':', 1)]
# type, description
try:
- [btype, description] = tail.split(None, 1)
+ btype, description = tail.split(None, 1)
# make life easy and strip quotes
description = description.replace("'", "").replace('"', "").replace("\\", "").strip()
except ValueError:
- [btype, description] = [tail,'NO DESCRIPTION']
+ btype, description = [tail,'NO DESCRIPTION']
# keyword-check
kwcheck = check_prefix(bto, btype)
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 83e7ea81ca5..3a7066ff41a 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -38,6 +38,7 @@ set(INC
../render/extern/include
../../../intern/elbeem/extern
../../../intern/guardedalloc
+ ../../../intern/opennl/extern
)
set(INC_SYS
@@ -64,6 +65,7 @@ set(SRC
intern/MOD_fluidsim_util.c
intern/MOD_hook.c
intern/MOD_lattice.c
+ intern/MOD_laplaciansmooth.c
intern/MOD_mask.c
intern/MOD_meshdeform.c
intern/MOD_mirror.c
@@ -117,13 +119,6 @@ if(WITH_MOD_REMESH)
)
endif()
-if(WITH_MOD_DECIMATE)
- add_definitions(-DWITH_MOD_DECIMATE)
- list(APPEND INC
- ../../../intern/decimation/extern
- )
-endif()
-
if(WITH_MOD_FLUID)
add_definitions(-DWITH_MOD_FLUID)
endif()
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index bf411c3b2fc..a4817ff775d 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -75,8 +75,9 @@ extern ModifierTypeInfo modifierType_WeightVGProximity;
extern ModifierTypeInfo modifierType_DynamicPaint;
extern ModifierTypeInfo modifierType_Remesh;
extern ModifierTypeInfo modifierType_Skin;
+extern ModifierTypeInfo modifierType_LaplacianSmooth;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);
-#endif //__MOD_MODIFIERTYPES_H__
+#endif /* __MOD_MODIFIERTYPES_H__ */
diff --git a/source/blender/modifiers/SConscript b/source/blender/modifiers/SConscript
index 2b506cce2cf..62fd9ba2de1 100644
--- a/source/blender/modifiers/SConscript
+++ b/source/blender/modifiers/SConscript
@@ -4,7 +4,7 @@ Import ('env')
sources = env.Glob('intern/*.c')
incs = '. ./intern'
-incs += ' #/intern/guardedalloc #/intern/decimation/extern #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include'
+incs += ' #/intern/guardedalloc #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include #/intern/opennl/extern'
incs += ' ../render/extern/include ../blenloader ../bmesh'
incs += ' ../include ../blenlib ../blenfont ../makesdna ../makesrna ../blenkernel ../blenkernel/intern'
incs += ' ../gpu'
@@ -20,9 +20,6 @@ if env['WITH_BF_REMESH']:
incs += ' #/intern/dualcon'
defs.append('WITH_MOD_REMESH')
-if env ['WITH_BF_DECIMATE']:
- defs.append('WITH_MOD_DECIMATE')
-
if env['WITH_BF_FLUID']:
defs.append('WITH_MOD_FLUID')
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index e6d86de45b4..7219038b087 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -135,13 +135,13 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
DerivedMesh *dm = derivedData;
- if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+ if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
@@ -158,14 +158,14 @@ static void deformVertsEM(
}
static void deformMatricesEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3],
float (*defMats)[3][3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
DerivedMesh *dm = derivedData;
- if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+ if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
amd->deformflag, NULL, amd->defgrp_name);
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 26682e30841..b9dd37ac50c 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -53,7 +53,8 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
-#include "BKE_tessmesh.h"
+
+#include "bmesh.h"
#include "depsgraph_private.h"
@@ -310,10 +311,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
int UNUSED(initFlags))
{
DerivedMesh *result;
- BMEditMesh *em = DM_to_editbmesh(dm, NULL, FALSE);
+ BMesh *bm = DM_to_bmesh(dm);
BMOperator first_dupe_op, dupe_op, old_dupe_op, weld_op;
BMVert **first_geom = NULL;
- int i, j, indexLen;
+ int i, j;
+ int index_len = -1; /* initialize to an invalid value */
/* offset matrix */
float offset[4][4];
float final_offset[4][4];
@@ -406,14 +408,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
* cleaner way to do this. One possibility: a "mirror" BMOp would
* certainly help by compressing it all into one top-level BMOp that
* executes a lot of second-level BMOps. */
- BMO_push(em->bm, NULL);
- bmesh_edit_begin(em->bm, 0);
+ BMO_push(bm, NULL);
+ bmesh_edit_begin(bm, 0);
if (amd->flags & MOD_ARR_MERGE)
- BMO_op_init(em->bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
+ BMO_op_init(bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"weld_verts");
- BMO_op_initf(em->bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
+ BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"duplicate geom=%avef");
first_dupe_op = dupe_op;
@@ -424,11 +426,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
BMOIter oiter;
if (j != 0) {
- BMO_op_initf(em->bm, &dupe_op,
+ BMO_op_initf(bm, &dupe_op,
(BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"duplicate geom=%s", &old_dupe_op, "newout");
}
- BMO_op_exec(em->bm, &dupe_op);
+ BMO_op_exec(bm, &dupe_op);
geom_slot = BMO_slot_get(&dupe_op, "geom");
newout_slot = BMO_slot_get(&dupe_op, "newout");
@@ -443,20 +445,23 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
}
/* apply transformation matrix */
- BMO_ITER (v, &oiter, em->bm, &dupe_op, "newout", BM_VERT) {
+ BMO_ITER (v, &oiter, bm, &dupe_op, "newout", BM_VERT) {
mul_m4_v3(offset, v->co);
}
if (amd->flags & MOD_ARR_MERGE) {
/*calculate merge mapping*/
if (j == 0) {
- indexMap = find_doubles_index_map(em->bm, &dupe_op,
- amd, &indexLen);
+ indexMap = find_doubles_index_map(bm, &dupe_op,
+ amd, &index_len);
}
#define _E(s, i) ((BMVert **)(s)->data.buf)[i]
- for (i = 0; i < indexLen; i++) {
+ /* ensure this is set */
+ BLI_assert(index_len != -1);
+
+ for (i = 0; i < index_len; i++) {
if (!indexMap[i]) continue;
/* merge v (from 'newout') into v2 (from old 'geom') */
@@ -465,11 +470,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
/* check in case the target vertex (v2) is already marked
* for merging */
- while ((v3 = BMO_slot_map_ptr_get(em->bm, &weld_op, "targetmap", v2))) {
+ while ((v3 = BMO_slot_map_ptr_get(bm, &weld_op, "targetmap", v2))) {
v2 = v3;
}
- BMO_slot_map_ptr_insert(em->bm, &weld_op, "targetmap", v, v2);
+ BMO_slot_map_ptr_insert(bm, &weld_op, "targetmap", v, v2);
}
#undef _E
@@ -481,7 +486,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
first_dupe_op = dupe_op;
if (j >= 2)
- BMO_op_finish(em->bm, &old_dupe_op);
+ BMO_op_finish(bm, &old_dupe_op);
old_dupe_op = dupe_op;
}
@@ -494,45 +499,44 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
* loop) the offset between first and last is different from
* dupe X to dupe X+1. */
- merge_first_last(em->bm, amd, &first_dupe_op, &dupe_op, &weld_op);
+ merge_first_last(bm, amd, &first_dupe_op, &dupe_op, &weld_op);
}
/* start capping */
if (start_cap || end_cap) {
- BM_mesh_elem_hflag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG, FALSE);
+ BM_mesh_elem_hflag_enable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE);
if (start_cap) {
float startoffset[4][4];
invert_m4_m4(startoffset, offset);
- bm_merge_dm_transform(em->bm, start_cap, startoffset, amd,
+ bm_merge_dm_transform(bm, start_cap, startoffset, amd,
&first_dupe_op, "geom", &weld_op);
}
if (end_cap) {
float endoffset[4][4];
mult_m4_m4m4(endoffset, offset, final_offset);
- bm_merge_dm_transform(em->bm, end_cap, endoffset, amd,
+ bm_merge_dm_transform(bm, end_cap, endoffset, amd,
&dupe_op, count == 1 ? "geom" : "newout", &weld_op);
}
}
/* done capping */
/* free remaining dupe operators */
- BMO_op_finish(em->bm, &first_dupe_op);
+ BMO_op_finish(bm, &first_dupe_op);
if (count > 2)
- BMO_op_finish(em->bm, &dupe_op);
+ BMO_op_finish(bm, &dupe_op);
/* run merge operator */
if (amd->flags & MOD_ARR_MERGE) {
- BMO_op_exec(em->bm, &weld_op);
- BMO_op_finish(em->bm, &weld_op);
+ BMO_op_exec(bm, &weld_op);
+ BMO_op_finish(bm, &weld_op);
}
/* Bump the stack level back down to match the adjustment up above */
- BMO_pop(em->bm);
+ BMO_pop(bm);
- BLI_assert(em->looptris == NULL);
- result = CDDM_from_BMEditMesh(em, NULL, FALSE, FALSE);
+ result = CDDM_from_bmesh(bm, FALSE);
if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) {
/* Update normals in case offset object has rotation. */
@@ -543,8 +547,8 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
CDDM_calc_normals(result);
}
- BMEdit_Free(em);
- MEM_freeN(em);
+ BM_mesh_free(bm);
+
if (indexMap)
MEM_freeN(indexMap);
if (first_geom)
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 638e91e22f1..3e3bcb73491 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -38,11 +38,11 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
-#include "BKE_tessmesh.h"
#include "BKE_mesh.h"
-
#include "BKE_bmesh.h" /* only for defines */
+#include "bmesh.h"
+
#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
@@ -88,6 +88,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
+// #define USE_BM_BEVEL_OP_AS_MOD
+
#ifdef USE_BM_BEVEL_OP_AS_MOD
#define EDGE_MARK 1
@@ -111,14 +113,12 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
{
DerivedMesh *result;
BMesh *bm;
- BMEditMesh *em;
BMIter iter;
BMEdge *e;
BevelModifierData *bmd = (BevelModifierData *) md;
- float threshold = cos((bmd->bevel_angle + 0.00001) * M_PI / 180.0);
+ float threshold = cos((bmd->bevel_angle + 0.00001f) * M_PI / 180.0f);
- em = DM_to_editbmesh(dm, NULL, FALSE);
- bm = em->bm;
+ bm = DM_to_bmesh(dm);
BM_mesh_normals_update(bm, FALSE);
BMO_push(bm, NULL);
@@ -148,10 +148,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
EDGE_MARK, bmd->value, (bmd->flags & BME_BEVEL_EVEN) != 0, (bmd->flags & BME_BEVEL_DIST) != 0);
BMO_pop(bm);
- BLI_assert(em->looptris == NULL);
- result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
- BMEdit_Free(em);
- MEM_freeN(em);
+ result = CDDM_from_bmesh(bm, TRUE);
+ BM_mesh_free(bm);
return result;
}
@@ -164,7 +162,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
- BMEditMesh *em;
+ BMesh *bm;
/*bDeformGroup *def;*/
int /*i,*/ options, defgrp_index = -1;
@@ -175,18 +173,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
#if 0
if ((options & BME_BEVEL_VWEIGHT) && bmd->defgrp_name[0]) {
defgrp_index = defgroup_name_index(ob, bmd->defgrp_name);
- if (defgrp_index < 0) {
+ if (defgrp_index == -1) {
options &= ~BME_BEVEL_VWEIGHT;
}
}
#endif
- em = DM_to_editbmesh(derivedData, NULL, FALSE);
- BME_bevel(em, bmd->value, bmd->res, options, defgrp_index, DEG2RADF(bmd->bevel_angle), NULL, FALSE);
- BLI_assert(em->looptris == NULL);
- result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
- BMEdit_Free(em);
- MEM_freeN(em);
+ bm = DM_to_bmesh(derivedData);
+ BME_bevel(bm, bmd->value, bmd->res, options, defgrp_index, DEG2RADF(bmd->bevel_angle), NULL);
+ result = CDDM_from_bmesh(bm, TRUE);
+ BM_mesh_free(bm);
/* until we allow for dirty normal flag, always calc,
* note: calculating on the CDDM is faster then the BMesh equivalent */
@@ -206,29 +202,29 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
ModifierTypeInfo modifierType_Bevel = {
- /* name */ "Bevel",
- /* structName */ "BevelModifierData",
- /* structSize */ sizeof(BevelModifierData),
- /* type */ eModifierTypeType_Constructive,
- /* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_SupportsEditmode |
- eModifierTypeFlag_EnableInEditmode,
-
- /* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ applyModifier,
- /* applyModifierEM */ applyModifierEM,
- /* initData */ initData,
- /* requiredDataMask */ requiredDataMask,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
- /* updateDepgraph */ NULL,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* name */ "Bevel",
+ /* structName */ "BevelModifierData",
+ /* structSize */ sizeof(BevelModifierData),
+ /* type */ eModifierTypeType_Constructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_SupportsEditmode |
+ eModifierTypeFlag_EnableInEditmode,
+
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ applyModifierEM,
+ /* initData */ initData,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ NULL,
+ /* isDisabled */ NULL,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 5c78a8efe23..0a48003fc81 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -167,7 +167,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (result)
return result;
else
- modifier_setError(md, "%s", TIP_("Can't execute boolean operation."));
+ modifier_setError(md, "Cannot execute boolean operation");
}
return derivedData;
@@ -192,28 +192,28 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(
ModifierTypeInfo modifierType_Boolean = {
- /* name */ "Boolean",
- /* structName */ "BooleanModifierData",
- /* structSize */ sizeof(BooleanModifierData),
- /* type */ eModifierTypeType_Nonconstructive,
- /* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_UsesPointCache,
-
- /* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ applyModifier,
- /* applyModifierEM */ NULL,
- /* initData */ NULL,
- /* requiredDataMask */ requiredDataMask,
- /* freeData */ NULL,
- /* isDisabled */ isDisabled,
- /* updateDepgraph */ updateDepgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* name */ "Boolean",
+ /* structName */ "BooleanModifierData",
+ /* structSize */ sizeof(BooleanModifierData),
+ /* type */ eModifierTypeType_Nonconstructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_UsesPointCache,
+
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ NULL,
+ /* initData */ NULL,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ NULL,
+ /* isDisabled */ isDisabled,
+ /* updateDepgraph */ updateDepgraph,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c
index bded11ddfa7..2ff93532d14 100644
--- a/source/blender/modifiers/intern/MOD_boolean_util.c
+++ b/source/blender/modifiers/intern/MOD_boolean_util.c
@@ -361,9 +361,9 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
/* create a new DerivedMesh */
result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements, 0, 0);
- CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX),
+ CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_ORIGINDEX),
CD_DEFAULT, face_it->num_elements);
- CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX),
+ CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_ORIGINDEX),
CD_DEFAULT, face_it->num_elements);
/* step through the vertex iterators: */
diff --git a/source/blender/modifiers/intern/MOD_boolean_util.h b/source/blender/modifiers/intern/MOD_boolean_util.h
index b996dc6d6ba..209db60f0c9 100644
--- a/source/blender/modifiers/intern/MOD_boolean_util.h
+++ b/source/blender/modifiers/intern/MOD_boolean_util.h
@@ -51,4 +51,4 @@ int NewBooleanMesh(struct Scene *scene, struct Base *base, struct Base *base_sel
struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob,
struct DerivedMesh *dm_select, struct Object *ob_select, int int_op_type);
-#endif // MOD_BOOLEAN_UTILS
+#endif /* MOD_BOOLEAN_UTILS */
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 121b0ee89e3..2105a6efd21 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -293,27 +293,27 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
ModifierTypeInfo modifierType_Build = {
- /* name */ "Build",
- /* structName */ "BuildModifierData",
- /* structSize */ sizeof(BuildModifierData),
- /* type */ eModifierTypeType_Nonconstructive,
- /* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_AcceptsCVs,
- /* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ applyModifier,
- /* applyModifierEM */ NULL,
- /* initData */ initData,
- /* requiredDataMask */ NULL,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
- /* updateDepgraph */ NULL,
- /* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* name */ "Build",
+ /* structName */ "BuildModifierData",
+ /* structSize */ sizeof(BuildModifierData),
+ /* type */ eModifierTypeType_Nonconstructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_AcceptsCVs,
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ NULL,
+ /* initData */ initData,
+ /* requiredDataMask */ NULL,
+ /* freeData */ NULL,
+ /* isDisabled */ NULL,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ dependsOnTime,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 8eb47f4066c..54f3efcc84c 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -180,7 +180,7 @@ static void freeData(ModifierData *md)
MEM_freeN(clmd->sim_parms);
}
if (clmd->coll_parms)
- MEM_freeN(clmd->coll_parms);
+ MEM_freeN(clmd->coll_parms);
BKE_ptcache_free_list(&clmd->ptcaches);
clmd->point_cache = NULL;
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 0ce4d74aebb..3ef6b9bfcb8 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -125,12 +125,12 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
- if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+ if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
deformVerts(md, ob, dm, vertexCos, numVerts, 0);
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index cb6681bfa68..dc29e59d549 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -32,10 +32,10 @@
* \ingroup modifiers
*/
-
-#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -44,12 +44,16 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
+#include "BKE_deform.h"
#include "BKE_particle.h"
#include "BKE_cdderivedmesh.h"
+#include "bmesh.h"
+
+// #define USE_TIMEIT
-#ifdef WITH_MOD_DECIMATE
-#include "LOD_decimation.h"
+#ifdef USE_TIMEIT
+# include "PIL_time.h"
#endif
#include "MOD_util.h"
@@ -59,6 +63,7 @@ static void initData(ModifierData *md)
DecimateModifierData *dmd = (DecimateModifierData *) md;
dmd->percent = 1.0;
+ dmd->angle = DEG2RADF(15.0f);
}
static void copyData(ModifierData *md, ModifierData *target)
@@ -67,146 +72,136 @@ static void copyData(ModifierData *md, ModifierData *target)
DecimateModifierData *tdmd = (DecimateModifierData *) target;
tdmd->percent = dmd->percent;
+ tdmd->iter = dmd->iter;
+ tdmd->angle = dmd->angle;
+ BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, sizeof(tdmd->defgrp_name));
+ tdmd->flag = dmd->flag;
+ tdmd->mode = dmd->mode;
}
-#ifdef WITH_MOD_DECIMATE
-static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
+static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+{
+ DecimateModifierData *dmd = (DecimateModifierData *) md;
+ CustomDataMask dataMask = 0;
+
+ /* ask for vertexgroups if we need them */
+ if (dmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
+
+ return dataMask;
+}
+
+static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DecimateModifierData *dmd = (DecimateModifierData *) md;
DerivedMesh *dm = derivedData, *result = NULL;
- MVert *mvert;
- MFace *mface;
- LOD_Decimation_Info lod;
- int totvert, totface;
- int a, numTris;
-
- DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
-
- mvert = dm->getVertArray(dm);
- mface = dm->getTessFaceArray(dm);
- totvert = dm->getNumVerts(dm);
- totface = dm->getNumTessFaces(dm);
-
- numTris = 0;
- for (a = 0; a < totface; a++) {
- MFace *mf = &mface[a];
- numTris++;
- if (mf->v4) numTris++;
- }
+ BMesh *bm;
- if (numTris < 3) {
- modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces (triangles)."));
- dm = CDDM_copy(dm);
- return dm;
- }
+ float *vweights = NULL;
- lod.vertex_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "vertices");
- lod.vertex_normal_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "normals");
- lod.triangle_index_buffer = MEM_mallocN(3 * sizeof(int) * numTris, "trias");
- lod.vertex_num = totvert;
- lod.face_num = numTris;
+#ifdef USE_TIMEIT
+ TIMEIT_START(decim);
+#endif
- for (a = 0; a < totvert; a++) {
- MVert *mv = &mvert[a];
- float *vbCo = &lod.vertex_buffer[a * 3];
- float *vbNo = &lod.vertex_normal_buffer[a * 3];
+ /* set up front so we dont show invalid info in the UI */
+ dmd->face_count = dm->getNumPolys(dm);
- copy_v3_v3(vbCo, mv->co);
- normal_short_to_float_v3(vbNo, mv->no);
+ switch (dmd->mode) {
+ case MOD_DECIM_MODE_COLLAPSE:
+ if (dmd->percent == 1.0f) {
+ return dm;
+ }
+ break;
+ case MOD_DECIM_MODE_UNSUBDIV:
+ if (dmd->iter == 0) {
+ return dm;
+ }
+ break;
+ case MOD_DECIM_MODE_DISSOLVE:
+ if (dmd->angle == 0.0f) {
+ return dm;
+ }
+ break;
}
- numTris = 0;
- for (a = 0; a < totface; a++) {
- MFace *mf = &mface[a];
- int *tri = &lod.triangle_index_buffer[3 * numTris++];
- tri[0] = mf->v1;
- tri[1] = mf->v2;
- tri[2] = mf->v3;
-
- if (mf->v4) {
- tri = &lod.triangle_index_buffer[3 * numTris++];
- tri[0] = mf->v1;
- tri[1] = mf->v3;
- tri[2] = mf->v4;
- }
+ if (dmd->face_count <= 3) {
+ modifier_setError(md, "Modifier requires more than 3 input faces");
+ return dm;
}
- dmd->faceCount = 0;
- if (LOD_LoadMesh(&lod) ) {
- if (LOD_PreprocessMesh(&lod) ) {
- /* we assume the decim_faces tells how much to reduce */
+ if (dmd->mode == MOD_DECIM_MODE_COLLAPSE) {
+ if (dmd->defgrp_name[0]) {
+ MDeformVert *dvert;
+ int defgrp_index;
- while (lod.face_num > numTris * dmd->percent) {
- if (LOD_CollapseEdge(&lod) == 0) break;
- }
+ modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index);
- if (lod.vertex_num > 2) {
- result = CDDM_new(lod.vertex_num, 0, lod.face_num, 0, 0);
- dmd->faceCount = lod.face_num;
- }
- else
- result = CDDM_new(lod.vertex_num, 0, 0, 0, 0);
-
- mvert = CDDM_get_verts(result);
- for (a = 0; a < lod.vertex_num; a++) {
- MVert *mv = &mvert[a];
- float *vbCo = &lod.vertex_buffer[a * 3];
-
- copy_v3_v3(mv->co, vbCo);
- }
+ if (dvert) {
+ const unsigned int vert_tot = dm->getNumVerts(dm);
+ unsigned int i;
+
+ vweights = MEM_mallocN(vert_tot * sizeof(float), __func__);
- if (lod.vertex_num > 2) {
- mface = CDDM_get_tessfaces(result);
- for (a = 0; a < lod.face_num; a++) {
- MFace *mf = &mface[a];
- int *tri = &lod.triangle_index_buffer[a * 3];
- mf->v1 = tri[0];
- mf->v2 = tri[1];
- mf->v3 = tri[2];
- test_index_face(mf, NULL, 0, 3);
+ if (dmd->flag & MOD_DECIM_FLAG_INVERT_VGROUP) {
+ for (i = 0; i < vert_tot; i++) {
+ vweights[i] = 1.0f - defvert_find_weight(&dvert[i], defgrp_index);
+ }
+ }
+ else {
+ for (i = 0; i < vert_tot; i++) {
+ vweights[i] = defvert_find_weight(&dvert[i], defgrp_index);
+ }
}
}
+ }
+ }
+
+ bm = DM_to_bmesh(dm);
- CDDM_calc_edges_tessface(result);
+ switch (dmd->mode) {
+ case MOD_DECIM_MODE_COLLAPSE:
+ {
+ const int do_triangulate = (dmd->flag & MOD_DECIM_FLAG_TRIANGULATE) != 0;
+ BM_mesh_decimate_collapse(bm, dmd->percent, vweights, do_triangulate);
+ break;
+ }
+ case MOD_DECIM_MODE_UNSUBDIV:
+ {
+ BM_mesh_decimate_unsubdivide(bm, dmd->iter);
+ break;
+ }
+ case MOD_DECIM_MODE_DISSOLVE:
+ {
+ const int do_dissolve_boundaries = (dmd->flag & MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS) != 0;
+ BM_mesh_decimate_dissolve(bm, dmd->angle, do_dissolve_boundaries);
+ break;
}
- else
- modifier_setError(md, "%s", TIP_("Out of memory."));
+ }
- LOD_FreeDecimationData(&lod);
+ if (vweights) {
+ MEM_freeN(vweights);
}
- else
- modifier_setError(md, "%s", TIP_("Non-manifold mesh as input."));
- MEM_freeN(lod.vertex_buffer);
- MEM_freeN(lod.vertex_normal_buffer);
- MEM_freeN(lod.triangle_index_buffer);
+ /* update for display only */
+ dmd->face_count = bm->totface;
+ result = CDDM_from_bmesh(bm, FALSE);
+ BM_mesh_free(bm);
- if (result) {
- CDDM_tessfaces_to_faces(result); /*builds ngon faces from tess (mface) faces*/
+#ifdef USE_TIMEIT
+ TIMEIT_END(decim);
+#endif
- return result;
- }
- else {
- return dm;
- }
-}
-#else // WITH_MOD_DECIMATE
-static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob),
- DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
-{
- return derivedData;
+ return result;
}
-#endif // WITH_MOD_DECIMATE
ModifierTypeInfo modifierType_Decimate = {
/* name */ "Decimate",
/* structName */ "DecimateModifierData",
/* structSize */ sizeof(DecimateModifierData),
/* type */ eModifierTypeType_Nonconstructive,
- /* flags */ eModifierTypeFlag_AcceptsMesh,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_AcceptsCVs,
/* copyData */ copyData,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
@@ -215,7 +210,7 @@ ModifierTypeInfo modifierType_Decimate = {
/* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
- /* requiredDataMask */ NULL,
+ /* requiredDataMask */ requiredDataMask,
/* freeData */ NULL,
/* isDisabled */ NULL,
/* updateDepgraph */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 7d7bfade9b7..80866a7c435 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -170,10 +170,10 @@ ModifierTypeInfo modifierType_DynamicPaint = {
/* structSize */ sizeof(DynamicPaintModifierData),
/* type */ eModifierTypeType_Constructive,
/* flags */ eModifierTypeFlag_AcceptsMesh |
-/* eModifierTypeFlag_SupportsMapping |*/
- eModifierTypeFlag_UsesPointCache |
- eModifierTypeFlag_Single |
- eModifierTypeFlag_UsesPreview,
+/* eModifierTypeFlag_SupportsMapping |*/
+ eModifierTypeFlag_UsesPointCache |
+ eModifierTypeFlag_Single |
+ eModifierTypeFlag_UsesPreview,
/* copyData */ copyData,
/* deformVerts */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index b1c3459bf51..21717d07fef 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -43,9 +43,10 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
-#include "BKE_tessmesh.h"
#include "BKE_mesh.h"
+#include "bmesh.h"
+
#include "DNA_object_types.h"
/* EdgeSplit */
@@ -61,15 +62,12 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
{
DerivedMesh *result;
BMesh *bm;
- BMEditMesh *em;
BMIter iter;
BMEdge *e;
float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f);
- em = DM_to_editbmesh(dm, NULL, FALSE);
- bm = em->bm;
+ bm = DM_to_bmesh(dm);
- BM_mesh_normals_update(bm, FALSE);
BMO_push(bm, NULL);
if (emd->flags & MOD_EDGESPLIT_FROMANGLE) {
@@ -110,10 +108,8 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
/* BM_mesh_validate(bm); */ /* for troubleshooting */
- BLI_assert(em->looptris == NULL);
- result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
- BMEdit_Free(em);
- MEM_freeN(em);
+ result = CDDM_from_bmesh(bm, TRUE);
+ BM_mesh_free(bm);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index b9593353288..1298d281de8 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -205,12 +205,13 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa
return df;
}
-#define SET_VERTS(a, b, c, d) { \
- v[0] = mf->v##a; uv[0] = a - 1; \
- v[1] = mf->v##b; uv[1] = b - 1; \
- v[2] = mf->v##c; uv[2] = c - 1; \
- v[3] = mf->v##d; uv[3] = d - 1; \
- } (void)0
+#define SET_VERTS(a, b, c, d) \
+ { \
+ v[0] = mf->v##a; uv[0] = a - 1; \
+ v[1] = mf->v##b; uv[1] = b - 1; \
+ v[2] = mf->v##c; uv[2] = c - 1; \
+ v[3] = mf->v##d; uv[3] = d - 1; \
+ } (void)0
#define GET_ES(v1, v2) edgecut_get(eh, v1, v2)
#define INT_UV(uvf, c0, c1) interp_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1], 0.5f)
@@ -669,8 +670,7 @@ static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
mv = CDDM_get_vert(splitdm, ed_v1);
- add_v3_v3(dupve->co, mv->co);
- mul_v3_fl(dupve->co, 0.5f);
+ mid_v3_v3v3(dupve->co, dupve->co, mv->co);
}
BLI_edgehashIterator_free(ehi);
@@ -813,7 +813,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
sim.psys = psmd->psys;
sim.psmd = psmd;
- /* timestep= psys_get_timestep(&sim); */
+ /* timestep = psys_get_timestep(&sim); */
cfra = BKE_scene_frame_get(scene);
@@ -861,7 +861,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
/* the final duplicated vertices */
explode = CDDM_from_template(dm, totdup, 0, totface - delface, 0, 0);
mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname);
- /*dupvert= CDDM_get_verts(explode);*/
+ /*dupvert = CDDM_get_verts(explode);*/
/* getting back to object space */
invert_m4_m4(imat, ob->obmat);
@@ -1039,26 +1039,26 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
ModifierTypeInfo modifierType_Explode = {
- /* name */ "Explode",
- /* structName */ "ExplodeModifierData",
- /* structSize */ sizeof(ExplodeModifierData),
- /* type */ eModifierTypeType_Constructive,
- /* flags */ eModifierTypeFlag_AcceptsMesh,
- /* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ applyModifier,
- /* applyModifierEM */ NULL,
- /* initData */ initData,
- /* requiredDataMask */ requiredDataMask,
- /* freeData */ freeData,
- /* isDisabled */ NULL,
- /* updateDepgraph */ NULL,
- /* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* name */ "Explode",
+ /* structName */ "ExplodeModifierData",
+ /* structSize */ sizeof(ExplodeModifierData),
+ /* type */ eModifierTypeType_Constructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh,
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ NULL,
+ /* initData */ initData,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ freeData,
+ /* isDisabled */ NULL,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ dependsOnTime,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 9acac6d00cd..47523286229 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -529,7 +529,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
fss = fluidmd->fss;
/* timescale not supported yet
- * clmd->sim_parms->timescale= timescale; */
+ * clmd->sim_parms->timescale = timescale; */
/* support reversing of baked fluid frames here */
if ((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) {
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
new file mode 100644
index 00000000000..6f6589d4d14
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -0,0 +1,703 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 by the Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Alexander Pinzon
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/modifiers/intern/MOD_laplaciansmooth.c
+ * \ingroup modifiers
+ */
+
+
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
+#include "BKE_displist.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+#include "BKE_object.h"
+#include "BKE_particle.h"
+#include "BKE_tessmesh.h"
+
+#include "MOD_modifiertypes.h"
+#include "MOD_util.h"
+
+#include "ONL_opennl.h"
+
+#define MOD_LAPLACIANSMOOTH_MAX_EDGE_PERCENTAGE 1.8f
+#define MOD_LAPLACIANSMOOTH_MIN_EDGE_PERCENTAGE 0.02f
+
+struct BLaplacianSystem {
+ float *eweights; /* Length weights per Edge */
+ float (*fweights)[3]; /* Cotangent weights per face */
+ float *ring_areas; /* Total area per ring*/
+ float *vlengths; /* Total sum of lengths(edges) per vertice*/
+ float *vweights; /* Total sum of weights per vertice*/
+ int numEdges; /* Number of edges*/
+ int numFaces; /* Number of faces*/
+ int numVerts; /* Number of verts*/
+ short *numNeFa; /* Number of neighboors faces around vertice*/
+ short *numNeEd; /* Number of neighboors Edges around vertice*/
+ short *zerola; /* Is zero area or length*/
+
+ /* Pointers to data*/
+ float (*vertexCos)[3];
+ MFace *mfaces;
+ MEdge *medges;
+ NLContext *context;
+
+ /*Data*/
+ float min_area;
+ float vert_centroid[3];
+};
+typedef struct BLaplacianSystem LaplacianSystem;
+
+static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md);
+static int is_disabled(ModifierData *md, int UNUSED(useRenderParams));
+static float compute_volume(float (*vertexCos)[3], MFace *mfaces, int numFaces);
+static float cotan_weight(float *v1, float *v2, float *v3);
+static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts);
+static void copy_data(ModifierData *md, ModifierData *target);
+static void delete_laplacian_system(LaplacianSystem *sys);
+static void delete_void_pointer(void *data);
+static void fill_laplacian_matrix(LaplacianSystem *sys);
+static void init_data(ModifierData *md);
+static void init_laplacian_matrix(LaplacianSystem *sys);
+static void memset_laplacian_system(LaplacianSystem *sys, int val);
+static void volume_preservation(LaplacianSystem *sys, float vini, float vend, short flag);
+static void validate_solution(LaplacianSystem *sys, short flag);
+
+static void delete_void_pointer(void *data)
+{
+ if (data) {
+ MEM_freeN(data);
+ data = NULL;
+ }
+}
+
+static void delete_laplacian_system(LaplacianSystem *sys)
+{
+ delete_void_pointer(sys->eweights);
+ delete_void_pointer(sys->fweights);
+ delete_void_pointer(sys->numNeEd);
+ delete_void_pointer(sys->numNeFa);
+ delete_void_pointer(sys->ring_areas);
+ delete_void_pointer(sys->vlengths);
+ delete_void_pointer(sys->vweights);
+ delete_void_pointer(sys->zerola);
+ if (sys->context) {
+ nlDeleteContext(sys->context);
+ }
+ sys->vertexCos = NULL;
+ sys->mfaces = NULL;
+ sys->medges = NULL;
+ MEM_freeN(sys);
+}
+
+static void memset_laplacian_system(LaplacianSystem *sys, int val)
+{
+ memset(sys->eweights, val, sizeof(float) * sys->numEdges);
+ memset(sys->fweights, val, sizeof(float) * sys->numFaces * 3);
+ memset(sys->numNeEd, val, sizeof(short) * sys->numVerts);
+ memset(sys->numNeFa, val, sizeof(short) * sys->numVerts);
+ memset(sys->ring_areas, val, sizeof(float) * sys->numVerts);
+ memset(sys->vlengths, val, sizeof(float) * sys->numVerts);
+ memset(sys->vweights, val, sizeof(float) * sys->numVerts);
+ memset(sys->zerola, val, sizeof(short) * sys->numVerts);
+}
+
+static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts)
+{
+ LaplacianSystem *sys;
+ sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem");
+ sys->numEdges = a_numEdges;
+ sys->numFaces = a_numFaces;
+ sys->numVerts = a_numVerts;
+
+ sys->eweights = MEM_callocN(sizeof(float) * sys->numEdges, "ModLaplSmoothEWeight");
+ if (!sys->eweights) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight");
+ if (!sys->fweights) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->numNeEd = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothNumNeEd");
+ if (!sys->numNeEd) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->numNeFa = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothNumNeFa");
+ if (!sys->numNeFa) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->ring_areas = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothRingAreas");
+ if (!sys->ring_areas) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->vlengths = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVlengths");
+ if (!sys->vlengths) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->vweights = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVweights");
+ if (!sys->vweights) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ sys->zerola = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothZeloa");
+ if (!sys->zerola) {
+ delete_laplacian_system(sys);
+ return NULL;
+ }
+
+ return sys;
+}
+
+static void init_data(ModifierData *md)
+{
+ LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md;
+ smd->lambda = 0.00001f;
+ smd->lambda_border = 0.00005f;
+ smd->repeat = 1;
+ smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION;
+ smd->defgrp_name[0] = '\0';
+}
+
+static void copy_data(ModifierData *md, ModifierData *target)
+{
+ LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md;
+ LaplacianSmoothModifierData *tsmd = (LaplacianSmoothModifierData *) target;
+
+ tsmd->lambda = smd->lambda;
+ tsmd->lambda_border = smd->lambda_border;
+ tsmd->repeat = smd->repeat;
+ tsmd->flag = smd->flag;
+ BLI_strncpy(tsmd->defgrp_name, smd->defgrp_name, sizeof(tsmd->defgrp_name));
+}
+
+static int is_disabled(ModifierData *md, int UNUSED(useRenderParams))
+{
+ LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md;
+ short flag;
+
+ flag = smd->flag & (MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z);
+
+ /* disable if modifier is off for X, Y and Z or if factor is 0 */
+ if (flag == 0) return 1;
+
+ return 0;
+}
+
+static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md)
+{
+ LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *)md;
+ CustomDataMask dataMask = 0;
+
+ /* ask for vertexgroups if we need them */
+ if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
+
+ return dataMask;
+}
+
+static float cotan_weight(float *v1, float *v2, float *v3)
+{
+ float a[3], b[3], c[3], clen;
+
+ sub_v3_v3v3(a, v2, v1);
+ sub_v3_v3v3(b, v3, v1);
+ cross_v3_v3v3(c, a, b);
+
+ clen = len_v3(c);
+
+ if (clen == 0.0f)
+ return 0.0f;
+
+ return dot_v3v3(a, b) / clen;
+}
+
+static float compute_volume(float (*vertexCos)[3], MFace *mfaces, int numFaces)
+{
+ float vol = 0.0f;
+ float x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
+ int i;
+ float *vf[4];
+ for (i = 0; i < numFaces; i++) {
+ vf[0] = vertexCos[mfaces[i].v1];
+ vf[1] = vertexCos[mfaces[i].v2];
+ vf[2] = vertexCos[mfaces[i].v3];
+
+ x1 = vf[0][0];
+ y1 = vf[0][1];
+ z1 = vf[0][2];
+
+ x2 = vf[1][0];
+ y2 = vf[1][1];
+ z2 = vf[1][2];
+
+ x3 = vf[2][0];
+ y3 = vf[2][1];
+ z3 = vf[2][2];
+
+
+ vol += (1.0f / 6.0f) * (x2 * y3 * z1 + x3 * y1 * z2 - x1 * y3 * z2 - x2 * y1 * z3 + x1 * y2 * z3 - x3 * y2 * z1);
+ if ((&mfaces[i])->v4) {
+ vf[3] = vertexCos[mfaces[i].v4];
+ x4 = vf[3][0];
+ y4 = vf[3][1];
+ z4 = vf[3][2];
+ vol += (1.0f / 6.0f) * (x1 * y3 * z4 - x1 * y4 * z3 - x3 * y1 * z4 + x3 * z1 * y4 + y1 * x4 * z3 - x4 * y3 * z1);
+ }
+ }
+ return fabsf(vol);
+}
+
+static void volume_preservation(LaplacianSystem *sys, float vini, float vend, short flag)
+{
+ float beta;
+ int i;
+
+ if (vend != 0.0f) {
+ beta = pow(vini / vend, 1.0f / 3.0f);
+ for (i = 0; i < sys->numVerts; i++) {
+ if (flag & MOD_LAPLACIANSMOOTH_X) {
+ sys->vertexCos[i][0] = (sys->vertexCos[i][0] - sys->vert_centroid[0]) * beta + sys->vert_centroid[0];
+ }
+ if (flag & MOD_LAPLACIANSMOOTH_Y) {
+ sys->vertexCos[i][1] = (sys->vertexCos[i][1] - sys->vert_centroid[1]) * beta + sys->vert_centroid[1];
+ }
+ if (flag & MOD_LAPLACIANSMOOTH_Z) {
+ sys->vertexCos[i][2] = (sys->vertexCos[i][2] - sys->vert_centroid[2]) * beta + sys->vert_centroid[2];
+ }
+
+ }
+ }
+}
+
+static void init_laplacian_matrix(LaplacianSystem *sys)
+{
+ float *v1, *v2, *v3, *v4;
+ float w1, w2, w3, w4;
+ float areaf;
+ int i, j;
+ unsigned int idv1, idv2, idv3, idv4, idv[4];
+ int has_4_vert;
+ for (i = 0; i < sys->numEdges; i++) {
+ idv1 = sys->medges[i].v1;
+ idv2 = sys->medges[i].v2;
+
+ v1 = sys->vertexCos[idv1];
+ v2 = sys->vertexCos[idv2];
+
+ sys->numNeEd[idv1] = sys->numNeEd[idv1] + 1;
+ sys->numNeEd[idv2] = sys->numNeEd[idv2] + 1;
+ w1 = len_v3v3(v1, v2);
+ if (w1 < sys->min_area) {
+ sys->zerola[idv1] = 1;
+ sys->zerola[idv2] = 1;
+ }
+ else {
+ w1 = 1.0f / w1;
+ }
+
+ sys->eweights[i] = w1;
+ }
+ for (i = 0; i < sys->numFaces; i++) {
+ has_4_vert = ((&sys->mfaces[i])->v4) ? 1 : 0;
+
+ idv1 = sys->mfaces[i].v1;
+ idv2 = sys->mfaces[i].v2;
+ idv3 = sys->mfaces[i].v3;
+ idv4 = has_4_vert ? sys->mfaces[i].v4 : 0;
+
+ sys->numNeFa[idv1] += 1;
+ sys->numNeFa[idv2] += 1;
+ sys->numNeFa[idv3] += 1;
+ if (has_4_vert) sys->numNeFa[idv4] += 1;
+
+ v1 = sys->vertexCos[idv1];
+ v2 = sys->vertexCos[idv2];
+ v3 = sys->vertexCos[idv3];
+ v4 = has_4_vert ? sys->vertexCos[idv4] : 0;
+
+ if (has_4_vert) {
+ areaf = area_quad_v3(v1, v2, v3, sys->vertexCos[sys->mfaces[i].v4]);
+ }
+ else {
+ areaf = area_tri_v3(v1, v2, v3);
+ }
+ if (fabsf(areaf) < sys->min_area) {
+ sys->zerola[idv1] = 1;
+ sys->zerola[idv2] = 1;
+ sys->zerola[idv3] = 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) {
+
+ idv[0] = idv1;
+ idv[1] = idv2;
+ idv[2] = idv3;
+ idv[3] = idv4;
+
+ for (j = 0; j < 4; j++) {
+ idv1 = idv[j];
+ idv2 = idv[(j + 1) % 4];
+ idv3 = idv[(j + 2) % 4];
+ idv4 = idv[(j + 3) % 4];
+
+ v1 = sys->vertexCos[idv1];
+ v2 = sys->vertexCos[idv2];
+ v3 = sys->vertexCos[idv3];
+ v4 = sys->vertexCos[idv4];
+
+ w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
+ w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
+ w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
+
+ sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f;
+ }
+ }
+ else {
+ w1 = cotan_weight(v1, v2, v3);
+ w2 = cotan_weight(v2, v3, v1);
+ w3 = cotan_weight(v3, v1, v2);
+
+ sys->fweights[i][0] = sys->fweights[i][0] + w1;
+ sys->fweights[i][1] = sys->fweights[i][1] + w2;
+ sys->fweights[i][2] = sys->fweights[i][2] + w3;
+
+ sys->vweights[idv1] = sys->vweights[idv1] + w2 + w3;
+ sys->vweights[idv2] = sys->vweights[idv2] + w1 + w3;
+ sys->vweights[idv3] = sys->vweights[idv3] + w1 + w2;
+ }
+ }
+ for (i = 0; i < sys->numEdges; i++) {
+ idv1 = sys->medges[i].v1;
+ idv2 = sys->medges[i].v2;
+ /* if is boundary, apply scale-dependent umbrella operator only with neighboors in boundary */
+ if (sys->numNeEd[idv1] != sys->numNeFa[idv1] && sys->numNeEd[idv2] != sys->numNeFa[idv2]) {
+ sys->vlengths[idv1] += sys->eweights[i];
+ sys->vlengths[idv2] += sys->eweights[i];
+ }
+ }
+
+}
+
+static void fill_laplacian_matrix(LaplacianSystem *sys)
+{
+ float *v1, *v2, *v3, *v4;
+ float w2, w3, w4;
+ int i, j;
+ int has_4_vert;
+ unsigned int idv1, idv2, idv3, idv4, idv[4];
+
+ for (i = 0; i < sys->numFaces; i++) {
+ idv1 = sys->mfaces[i].v1;
+ idv2 = sys->mfaces[i].v2;
+ idv3 = sys->mfaces[i].v3;
+ has_4_vert = ((&sys->mfaces[i])->v4) ? 1 : 0;
+
+ if (has_4_vert) {
+ idv[0] = sys->mfaces[i].v1;
+ idv[1] = sys->mfaces[i].v2;
+ idv[2] = sys->mfaces[i].v3;
+ idv[3] = sys->mfaces[i].v4;
+ for (j = 0; j < 4; j++) {
+ idv1 = idv[j];
+ idv2 = idv[(j + 1) % 4];
+ idv3 = idv[(j + 2) % 4];
+ idv4 = idv[(j + 3) % 4];
+
+ v1 = sys->vertexCos[idv1];
+ v2 = sys->vertexCos[idv2];
+ v3 = sys->vertexCos[idv3];
+ v4 = sys->vertexCos[idv4];
+
+ w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
+ w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
+ w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
+
+ w2 = w2 / 4.0f;
+ w3 = w3 / 4.0f;
+ w4 = w4 / 4.0f;
+
+ if (sys->numNeEd[idv1] == sys->numNeFa[idv1] && sys->zerola[idv1] == 0) {
+ nlMatrixAdd(idv1, idv2, w2 * sys->vweights[idv1]);
+ nlMatrixAdd(idv1, idv3, w3 * sys->vweights[idv1]);
+ nlMatrixAdd(idv1, idv4, w4 * sys->vweights[idv1]);
+ }
+ }
+ }
+ else {
+ /* Is ring if number of faces == number of edges around vertice*/
+ if (sys->numNeEd[idv1] == sys->numNeFa[idv1] && sys->zerola[idv1] == 0) {
+ nlMatrixAdd(idv1, idv2, sys->fweights[i][2] * sys->vweights[idv1]);
+ nlMatrixAdd(idv1, idv3, sys->fweights[i][1] * sys->vweights[idv1]);
+ }
+ if (sys->numNeEd[idv2] == sys->numNeFa[idv2] && sys->zerola[idv2] == 0) {
+ nlMatrixAdd(idv2, idv1, sys->fweights[i][2] * sys->vweights[idv2]);
+ nlMatrixAdd(idv2, idv3, sys->fweights[i][0] * sys->vweights[idv2]);
+ }
+ if (sys->numNeEd[idv3] == sys->numNeFa[idv3] && sys->zerola[idv3] == 0) {
+ nlMatrixAdd(idv3, idv1, sys->fweights[i][1] * sys->vweights[idv3]);
+ nlMatrixAdd(idv3, idv2, sys->fweights[i][0] * sys->vweights[idv3]);
+ }
+ }
+ }
+
+ for (i = 0; i < sys->numEdges; i++) {
+ idv1 = sys->medges[i].v1;
+ idv2 = sys->medges[i].v2;
+ /* Is boundary */
+ if (sys->numNeEd[idv1] != sys->numNeFa[idv1] &&
+ sys->numNeEd[idv2] != sys->numNeFa[idv2] &&
+ sys->zerola[idv1] == 0 &&
+ sys->zerola[idv2] == 0)
+ {
+ nlMatrixAdd(idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]);
+ nlMatrixAdd(idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]);
+ }
+ }
+}
+
+static void validate_solution(LaplacianSystem *sys, short flag)
+{
+ int i, idv1, idv2;
+ float leni, lene;
+ float vini, vend;
+ float *vi1, *vi2, ve1[3], ve2[3];
+ if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) {
+ vini = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces);
+ }
+ for (i = 0; i < sys->numEdges; i++) {
+ idv1 = sys->medges[i].v1;
+ idv2 = sys->medges[i].v2;
+ vi1 = sys->vertexCos[idv1];
+ vi2 = sys->vertexCos[idv2];
+ ve1[0] = nlGetVariable(0, idv1);
+ ve1[1] = nlGetVariable(1, idv1);
+ ve1[2] = nlGetVariable(2, idv1);
+ ve2[0] = nlGetVariable(0, idv2);
+ ve2[1] = nlGetVariable(1, idv2);
+ ve2[2] = nlGetVariable(2, idv2);
+ leni = len_v3v3(vi1, vi2);
+ lene = len_v3v3(ve1, ve2);
+ if (lene > leni * MOD_LAPLACIANSMOOTH_MAX_EDGE_PERCENTAGE || lene < leni * MOD_LAPLACIANSMOOTH_MIN_EDGE_PERCENTAGE) {
+ sys->zerola[idv1] = 1;
+ sys->zerola[idv2] = 1;
+ }
+ }
+ for (i = 0; i < sys->numVerts; i++) {
+ if (sys->zerola[i] == 0) {
+ if (flag & MOD_LAPLACIANSMOOTH_X) {
+ sys->vertexCos[i][0] = nlGetVariable(0, i);
+ }
+ if (flag & MOD_LAPLACIANSMOOTH_Y) {
+ sys->vertexCos[i][1] = nlGetVariable(1, i);
+ }
+ if (flag & MOD_LAPLACIANSMOOTH_Z) {
+ sys->vertexCos[i][2] = nlGetVariable(2, i);
+ }
+ }
+ }
+ if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) {
+ vend = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces);
+ volume_preservation(sys, vini, vend, flag);
+ }
+}
+
+static void laplaciansmoothModifier_do(
+ LaplacianSmoothModifierData *smd, Object *ob, DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts)
+{
+ LaplacianSystem *sys;
+ MDeformVert *dvert = NULL;
+ MDeformVert *dv = NULL;
+ float w, wpaint;
+ int i, iter;
+ int defgrp_index;
+
+ DM_ensure_tessface(dm);
+
+ sys = init_laplacian_system(dm->getNumEdges(dm), dm->getNumTessFaces(dm), numVerts);
+ if (!sys) {
+ return;
+ }
+
+ sys->mfaces = dm->getTessFaceArray(dm);
+ sys->medges = dm->getEdgeArray(dm);
+ sys->vertexCos = vertexCos;
+ sys->min_area = 0.00001f;
+ modifier_get_vgroup(ob, dm, smd->defgrp_name, &dvert, &defgrp_index);
+
+ sys->vert_centroid[0] = 0.0f;
+ sys->vert_centroid[1] = 0.0f;
+ sys->vert_centroid[2] = 0.0f;
+ for (iter = 0; iter < smd->repeat; iter++) {
+ memset_laplacian_system(sys, 0);
+ nlNewContext();
+ sys->context = nlGetCurrent();
+ nlSolverParameteri(NL_NB_VARIABLES, numVerts);
+ nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE);
+ nlSolverParameteri(NL_NB_ROWS, numVerts);
+ nlSolverParameteri(NL_NB_RIGHT_HAND_SIDES, 3);
+
+ init_laplacian_matrix(sys);
+
+ nlBegin(NL_SYSTEM);
+ for (i = 0; i < numVerts; i++) {
+ nlSetVariable(0, i, vertexCos[i][0]);
+ nlSetVariable(1, i, vertexCos[i][1]);
+ nlSetVariable(2, i, vertexCos[i][2]);
+ if (iter == 0) {
+ add_v3_v3(sys->vert_centroid, vertexCos[i]);
+ }
+ }
+ if (iter == 0 && numVerts > 0) {
+ mul_v3_fl(sys->vert_centroid, 1.0f / (float)numVerts);
+ }
+
+ nlBegin(NL_MATRIX);
+ dv = dvert;
+ for (i = 0; i < numVerts; i++) {
+ nlRightHandSideAdd(0, i, vertexCos[i][0]);
+ nlRightHandSideAdd(1, i, vertexCos[i][1]);
+ nlRightHandSideAdd(2, i, vertexCos[i][2]);
+ if (dv) {
+ wpaint = defvert_find_weight(dv, defgrp_index);
+ dv++;
+ }
+ else {
+ wpaint = 1.0f;
+ }
+
+ if (sys->zerola[i] == 0) {
+ w = sys->vweights[i] * sys->ring_areas[i];
+ sys->vweights[i] = (w == 0.0f) ? 0.0f : -smd->lambda * wpaint / (4.0f * w);
+ w = sys->vlengths[i];
+ sys->vlengths[i] = (w == 0.0f) ? 0.0f : -smd->lambda_border * wpaint * 2.0f / w;
+
+ if (sys->numNeEd[i] == sys->numNeFa[i]) {
+ nlMatrixAdd(i, i, 1.0f + smd->lambda * wpaint / (4.0f * sys->ring_areas[i]));
+ }
+ else {
+ nlMatrixAdd(i, i, 1.0f + smd->lambda_border * wpaint * 2.0f);
+ }
+ }
+ else {
+ nlMatrixAdd(i, i, 1.0f);
+ }
+ }
+
+ fill_laplacian_matrix(sys);
+
+ nlEnd(NL_MATRIX);
+ nlEnd(NL_SYSTEM);
+
+ if (nlSolveAdvanced(NULL, NL_TRUE)) {
+ validate_solution(sys, smd->flag);
+ }
+ nlDeleteContext(sys->context);
+ sys->context = NULL;
+ }
+ delete_laplacian_system(sys);
+
+}
+
+static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+{
+ DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0);
+
+ laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ob, dm,
+ vertexCos, numVerts);
+
+ if (dm != derivedData)
+ dm->release(dm);
+}
+
+static void deformVertsEM(
+ ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
+{
+ DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0);
+
+ laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ob, dm,
+ vertexCos, numVerts);
+
+ if (dm != derivedData)
+ dm->release(dm);
+}
+
+
+ModifierTypeInfo modifierType_LaplacianSmooth = {
+ /* name */ "Laplacian Smooth",
+ /* structName */ "LaplacianSmoothModifierData",
+ /* structSize */ sizeof(LaplacianSmoothModifierData),
+ /* type */ eModifierTypeType_OnlyDeform,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_SupportsEditmode,
+
+ /* copy_data */ copy_data,
+ /* deformVerts */ deformVerts,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ deformVertsEM,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ NULL,
+ /* applyModifierEM */ NULL,
+ /* initData */ init_data,
+ /* requiredDataMask */ required_data_mask,
+ /* freeData */ NULL,
+ /* isDisabled */ is_disabled,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
+ /* foreachObjectLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
+};
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index d64ccf750b2..a5c52c6c76a 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -122,12 +122,12 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
- if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+ if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
deformVerts(md, ob, dm, vertexCos, numVerts, 0);
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index ab7263a1b53..23ce8cdeb21 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -179,7 +179,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
/* verthash gives mapping from original vertex indices to the new indices (including selected matches only)
- * key=oldindex, value=newindex
+ * key = oldindex, value = newindex
*/
vertHash = BLI_ghash_int_new("mask vert gh");
@@ -226,11 +226,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
int defgrp_index = defgroup_name_index(ob, mmd->vgroup);
/* get dverts */
- if (defgrp_index >= 0)
+ if (defgrp_index != -1)
dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
/* if no vgroup (i.e. dverts) found, return the initial mesh */
- if ((defgrp_index < 0) || (dvert == NULL))
+ if ((defgrp_index == -1) || (dvert == NULL))
return dm;
/* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index f0bdf1bb737..f4d9b7270e6 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -218,7 +218,7 @@ static void meshdeformModifier_do(
}
if (!cagedm) {
- modifier_setError(md, "%s", TIP_("Can't get mesh from cage object."));
+ modifier_setError(md, "Cannot get mesh from cage object");
return;
}
@@ -246,17 +246,17 @@ static void meshdeformModifier_do(
totcagevert = cagedm->getNumVerts(cagedm);
if (mmd->totvert != totvert) {
- modifier_setError(md, TIP_("Verts changed from %d to %d."), mmd->totvert, totvert);
+ modifier_setError(md, "Verts changed from %d to %d", mmd->totvert, totvert);
cagedm->release(cagedm);
return;
}
else if (mmd->totcagevert != totcagevert) {
- modifier_setError(md, TIP_("Cage verts changed from %d to %d."), mmd->totcagevert, totcagevert);
+ modifier_setError(md, "Cage verts changed from %d to %d", mmd->totcagevert, totcagevert);
cagedm->release(cagedm);
return;
}
else if (mmd->bindcagecos == NULL) {
- modifier_setError(md, "%s", TIP_("Bind data missing."));
+ modifier_setError(md, "Bind data missing");
cagedm->release(cagedm);
return;
}
@@ -431,28 +431,28 @@ void modifier_mdef_compact_influences(ModifierData *md)
}
ModifierTypeInfo modifierType_MeshDeform = {
- /* name */ "MeshDeform",
- /* structName */ "MeshDeformModifierData",
- /* structSize */ sizeof(MeshDeformModifierData),
- /* type */ eModifierTypeType_OnlyDeform,
- /* flags */ eModifierTypeFlag_AcceptsCVs |
- eModifierTypeFlag_SupportsEditmode,
-
- /* copyData */ copyData,
- /* deformVerts */ deformVerts,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ deformVertsEM,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
- /* applyModifierEM */ NULL,
- /* initData */ initData,
- /* requiredDataMask */ requiredDataMask,
- /* freeData */ freeData,
- /* isDisabled */ isDisabled,
- /* updateDepgraph */ updateDepgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* name */ "MeshDeform",
+ /* structName */ "MeshDeformModifierData",
+ /* structSize */ sizeof(MeshDeformModifierData),
+ /* type */ eModifierTypeType_OnlyDeform,
+ /* flags */ eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_SupportsEditmode,
+
+ /* copyData */ copyData,
+ /* deformVerts */ deformVerts,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ deformVertsEM,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ NULL,
+ /* applyModifierEM */ NULL,
+ /* initData */ initData,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ freeData,
+ /* isDisabled */ isDisabled,
+ /* updateDepgraph */ updateDepgraph,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index febc4190fdf..83c678db7b3 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -43,7 +43,8 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
-#include "BKE_tessmesh.h"
+
+#include "bmesh.h"
#include "MEM_guardedalloc.h"
#include "depsgraph_private.h"
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 3bf8b9ffacc..564fa696c2a 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -33,17 +33,17 @@
#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
-#include "BKE_cdderivedmesh.h"
-#include "BKE_global.h"
-#include "BKE_modifier.h"
-#include "BKE_ocean.h"
-
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_math_inline.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_global.h"
+#include "BKE_modifier.h"
+#include "BKE_ocean.h"
+
#include "MOD_util.h"
#ifdef WITH_OCEANSIM
@@ -241,13 +241,13 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa
copy_v3_v3(max, mvert->co);
for (v = 1; v < totvert; v++, mvert++) {
- min[0] = minf(min[0], mvert->co[0]);
- min[1] = minf(min[1], mvert->co[1]);
- min[2] = minf(min[2], mvert->co[2]);
+ min[0] = min_ff(min[0], mvert->co[0]);
+ min[1] = min_ff(min[1], mvert->co[1]);
+ min[2] = min_ff(min[2], mvert->co[2]);
- max[0] = maxf(max[0], mvert->co[0]);
- max[1] = maxf(max[1], mvert->co[1]);
- max[2] = maxf(max[2], mvert->co[2]);
+ max[0] = max_ff(max[0], mvert->co[0]);
+ max[1] = max_ff(max[1], mvert->co[1]);
+ max[2] = max_ff(max[2], mvert->co[2]);
}
sub_v3_v3v3(delta, max, min);
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index e64e80efde3..4984682455a 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -81,6 +81,44 @@ static int dependsOnTime(ModifierData *UNUSED(md))
{
return 0;
}
+
+static int isDisabled(ModifierData *md, int useRenderParams)
+{
+ ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
+ ParticleSystem *psys;
+ ModifierData *ob_md;
+
+ if (!pimd->ob)
+ return TRUE;
+
+ psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
+ if (psys == NULL)
+ return TRUE;
+
+ /* If the psys modifier is disabled we cannot use its data.
+ * First look up the psys modifier from the object, then check if it is enabled.
+ */
+ for (ob_md = pimd->ob->modifiers.first; ob_md; ob_md = ob_md->next) {
+ if (ob_md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md;
+ if (psmd->psys == psys) {
+ int required_mode;
+
+ if (useRenderParams) required_mode = eModifierMode_Render;
+ else required_mode = eModifierMode_Realtime;
+
+ if (!modifier_isEnabled(md->scene, ob_md, required_mode))
+ return TRUE;
+
+ break;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+
static void updateDepgraph(ModifierData *md, DagForest *forest,
struct Scene *UNUSED(scene),
Object *UNUSED(ob),
@@ -363,32 +401,31 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE);
}
-
ModifierTypeInfo modifierType_ParticleInstance = {
- /* name */ "ParticleInstance",
- /* structName */ "ParticleInstanceModifierData",
- /* structSize */ sizeof(ParticleInstanceModifierData),
- /* type */ eModifierTypeType_Constructive,
- /* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_SupportsMapping |
- eModifierTypeFlag_SupportsEditmode |
- eModifierTypeFlag_EnableInEditmode,
-
- /* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ applyModifier,
- /* applyModifierEM */ applyModifierEM,
- /* initData */ initData,
- /* requiredDataMask */ NULL,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
- /* updateDepgraph */ updateDepgraph,
- /* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* name */ "ParticleInstance",
+ /* structName */ "ParticleInstanceModifierData",
+ /* structSize */ sizeof(ParticleInstanceModifierData),
+ /* type */ eModifierTypeType_Constructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_SupportsMapping |
+ eModifierTypeFlag_SupportsEditmode |
+ eModifierTypeFlag_EnableInEditmode,
+
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ applyModifierEM,
+ /* initData */ initData,
+ /* requiredDataMask */ NULL,
+ /* freeData */ NULL,
+ /* isDisabled */ isDisabled,
+ /* updateDepgraph */ updateDepgraph,
+ /* dependsOnTime */ dependsOnTime,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 254c02b7672..cd2ef5957cd 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -44,6 +44,7 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
+#include "BKE_scene.h"
#include "MOD_util.h"
@@ -130,6 +131,7 @@ static void deformVerts(ModifierData *md, Object *ob,
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
ParticleSystem *psys = NULL;
int needsFree = 0;
+ /* float cfra = BKE_scene_frame_get(md->scene); */ /* UNUSED */
if (ob->particlesystem.first)
psys = psmd->psys;
@@ -188,9 +190,11 @@ static void deformVerts(ModifierData *md, Object *ob,
psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm);
}
- psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(md->scene, ob, psys);
- psmd->flag |= eParticleSystemFlag_psys_updated;
+ if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {
+ psmd->flag &= ~eParticleSystemFlag_psys_updated;
+ particle_system_update(md->scene, ob, psys);
+ psmd->flag |= eParticleSystemFlag_psys_updated;
+ }
}
/* disabled particles in editmode for now, until support for proper derivedmesh
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index 2b55471be3d..746cad10a01 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -223,7 +223,7 @@ ModifierTypeInfo modifierType_Remesh = {
/* structSize */ sizeof(RemeshModifierData),
/* type */ eModifierTypeType_Nonconstructive,
/* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_AcceptsCVs |
eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
/* deformVerts */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index a94b4834d18..93b5e36e5a4 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -215,7 +215,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (totlen != 0.0f) {
float zero[3] = {0.0f, 0.0f, 0.0f};
- float cp[3];
+ float cp[3];
screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec);
}
else {
@@ -363,7 +363,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
*/
vert_connect = MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect");
- //vert_connect= (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */
+ //vert_connect = (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */
vc = vert_connect;
/* Copy Vert Locations */
@@ -475,7 +475,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/*printf("\t\tVERT: %i\n", lt_iter.v);*/
if (lt_iter.v_poin->flag) {
/*printf("\t\t\tBreaking Found end\n");*/
- //endpoints[0]= endpoints[1]= -1;
+ //endpoints[0] = endpoints[1] = -1;
ed_loop_closed = 1; /* circle */
break;
}
@@ -490,7 +490,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
screwvert_iter_step(&lt_iter);
if (!lt_iter.v_poin) {
/*printf("\t\t\tFound End Also Num %i\n", j);*/
- /*endpoints[j]= lt_iter.v_other;*/ /* other is still valid */
+ /*endpoints[j] = lt_iter.v_other;*/ /* other is still valid */
break;
}
}
@@ -732,7 +732,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
copy_v3_v3(mv_new->co, mv_new_base->co);
/* only need to set these if using non cleared memory */
- /*mv_new->mat_nr= mv_new->flag= 0;*/
+ /*mv_new->mat_nr = mv_new->flag = 0;*/
if (ltmd->ob_axis) {
sub_v3_v3(mv_new->co, mtx_tx[3]);
@@ -831,7 +831,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
/* close the loop*/
- if (close) {
+ if (close) {
if (do_flip) {
ml_new[3].v = i1;
ml_new[2].v = i2;
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 8ef86362edd..7fe8dc69790 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -122,6 +122,7 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
}
}
+
ModifierTypeInfo modifierType_ShapeKey = {
/* name */ "ShapeKey",
/* structName */ "ShapeKeyModifierData",
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 45cd33efea8..d3a03614d7c 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -163,30 +163,30 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
ModifierTypeInfo modifierType_Shrinkwrap = {
- /* name */ "Shrinkwrap",
- /* structName */ "ShrinkwrapModifierData",
- /* structSize */ sizeof(ShrinkwrapModifierData),
- /* type */ eModifierTypeType_OnlyDeform,
- /* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_AcceptsCVs |
- eModifierTypeFlag_SupportsEditmode |
- eModifierTypeFlag_EnableInEditmode,
-
- /* copyData */ copyData,
- /* deformVerts */ deformVerts,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ deformVertsEM,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
- /* applyModifierEM */ NULL,
- /* initData */ initData,
- /* requiredDataMask */ requiredDataMask,
- /* freeData */ NULL,
- /* isDisabled */ isDisabled,
- /* updateDepgraph */ updateDepgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* name */ "Shrinkwrap",
+ /* structName */ "ShrinkwrapModifierData",
+ /* structSize */ sizeof(ShrinkwrapModifierData),
+ /* type */ eModifierTypeType_OnlyDeform,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_SupportsEditmode |
+ eModifierTypeFlag_EnableInEditmode,
+
+ /* copyData */ copyData,
+ /* deformVerts */ deformVerts,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ deformVertsEM,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ NULL,
+ /* applyModifierEM */ NULL,
+ /* initData */ initData,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ NULL,
+ /* isDisabled */ isDisabled,
+ /* updateDepgraph */ updateDepgraph,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 44ebc76e4a1..5267c0d9ccb 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -161,7 +161,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
if (smd->limit[0] < 0.0f) smd->limit[0] = 0.0f;
if (smd->limit[0] > 1.0f) smd->limit[0] = 1.0f;
- smd->limit[0] = minf(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */
+ smd->limit[0] = min_ff(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */
/* Calculate matrixs do convert between coordinate spaces */
if (smd->origin) {
@@ -191,8 +191,8 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
if (transf) space_transform_apply(transf, tmp);
- lower = minf(lower, tmp[limit_axis]);
- upper = maxf(upper, tmp[limit_axis]);
+ lower = min_ff(lower, tmp[limit_axis]);
+ upper = max_ff(upper, tmp[limit_axis]);
}
@@ -200,7 +200,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
smd_limit[1] = lower + (upper - lower) * smd->limit[1];
smd_limit[0] = lower + (upper - lower) * smd->limit[0];
- smd_factor = smd->factor / maxf(FLT_EPSILON, smd_limit[1] - smd_limit[0]);
+ smd_factor = smd->factor / max_ff(FLT_EPSILON, smd_limit[1] - smd_limit[0]);
}
modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup);
@@ -353,9 +353,9 @@ ModifierTypeInfo modifierType_SimpleDeform = {
/* type */ eModifierTypeType_OnlyDeform,
/* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_AcceptsCVs |
- eModifierTypeFlag_SupportsEditmode |
- eModifierTypeFlag_EnableInEditmode,
+ eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_SupportsEditmode |
+ eModifierTypeFlag_EnableInEditmode,
/* copyData */ copyData,
/* deformVerts */ deformVerts,
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 222f13185ea..38ec0e8bb4c 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -77,7 +77,8 @@
#include "BKE_DerivedMesh.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_tessmesh.h"
+
+#include "bmesh.h"
#include "MOD_util.h"
@@ -143,6 +144,7 @@ static int is_quad_symmetric(BMVert *quad[4],
const SkinModifierData *smd)
{
const float threshold = 0.0001f;
+ const float threshold_squared = threshold * threshold;
int axis;
for (axis = 0; axis < 3; axis++) {
@@ -152,16 +154,16 @@ static int is_quad_symmetric(BMVert *quad[4],
copy_v3_v3(a, quad[0]->co);
a[axis] = -a[axis];
- if (len_v3v3(a, quad[1]->co) < threshold) {
+ if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) {
copy_v3_v3(a, quad[2]->co);
a[axis] = -a[axis];
- if (len_v3v3(a, quad[3]->co) < threshold)
+ if (len_squared_v3v3(a, quad[3]->co) < threshold_squared)
return 1;
}
- else if (len_v3v3(a, quad[3]->co) < threshold) {
+ else if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) {
copy_v3_v3(a, quad[2]->co);
a[axis] = -a[axis];
- if (len_v3v3(a, quad[1]->co) < threshold)
+ if (len_squared_v3v3(a, quad[1]->co) < threshold_squared)
return 1;
}
}
@@ -178,13 +180,13 @@ static int quad_crosses_symmetry_plane(BMVert *quad[4],
for (axis = 0; axis < 3; axis++) {
if (smd->symmetry_axes & (1 << axis)) {
- int i, left = 0, right = 0;
+ int i, left = FALSE, right = FALSE;
for (i = 0; i < 4; i++) {
- if (quad[i]->co[axis] < 0)
- left = 1;
- else if (quad[i]->co[axis] > 0)
- right = 1;
+ if (quad[i]->co[axis] < 0.0f)
+ left = TRUE;
+ else if (quad[i]->co[axis] > 0.0f)
+ right = TRUE;
if (left && right)
return TRUE;
@@ -355,7 +357,7 @@ static void merge_frame_corners(Frame **frames, int totframe)
BLI_assert(frames[i] != frames[k]);
side_b = frame_len(frames[k]);
- thresh = minf(side_a, side_b) / 2.0f;
+ thresh = min_ff(side_a, side_b) / 2.0f;
/* Compare with each corner of all other frames... */
for (l = 0; l < 4; l++) {
@@ -642,8 +644,8 @@ typedef struct {
} EdgeStackElem;
static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat,
- const MeshElemMap *emap, const MEdge *medge,
- const MVertSkin *vs, const MVert *mvert)
+ const MeshElemMap *emap, const MEdge *medge,
+ const MVertSkin *vs, const MVert *mvert)
{
EdgeStackElem stack_elem;
float axis[3], angle;
@@ -671,7 +673,7 @@ static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat,
/* If parent is a branch node, start a new edge chain */
if (parent_is_branch) {
calc_edge_mat(emat[e].mat, mvert[parent_v].co,
- mvert[v].co);
+ mvert[v].co);
}
else {
/* Build edge matrix guided by parent matrix */
@@ -695,11 +697,11 @@ static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat,
}
static EMat *build_edge_mats(const MVertSkin *vs,
- const MVert *mvert,
- int totvert,
+ const MVert *mvert,
+ int totvert,
const MEdge *medge,
- const MeshElemMap *emap,
- int totedge)
+ const MeshElemMap *emap,
+ int totedge)
{
BLI_Stack *stack;
EMat *emat;
@@ -957,12 +959,12 @@ static void add_poly(SkinOutput *so,
static void connect_frames(SkinOutput *so,
BMVert *frame1[4],
- BMVert *frame2[4])
+BMVert *frame2[4])
{
BMVert *q[4][4] = {{frame2[0], frame2[1], frame1[1], frame1[0]},
- {frame2[1], frame2[2], frame1[2], frame1[1]},
- {frame2[2], frame2[3], frame1[3], frame1[2]},
- {frame2[3], frame2[0], frame1[0], frame1[3]}};
+ {frame2[1], frame2[2], frame1[2], frame1[1]},
+ {frame2[2], frame2[3], frame1[3], frame1[2]},
+ {frame2[3], frame2[0], frame1[0], frame1[3]}};
float p[3], no[3];
int i, swap;
@@ -1352,24 +1354,6 @@ static void add_quad_from_tris(SkinOutput *so, BMEdge *e, BMFace *adj[2])
add_poly(so, quad[0], quad[1], quad[2], quad[3]);
}
-/* Returns the number of faces that are adjacent to both f1 and f2 */
-static int BM_face_share_face_count(BMFace *f1, BMFace *f2)
-{
- BMIter iter1, iter2;
- BMEdge *e;
- BMFace *f;
- int count = 0;
-
- 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_count(f, f2))
- count++;
- }
- }
-
- return count;
-}
-
static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
{
BMIter iter;
@@ -1422,7 +1406,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
}
}
- while (!BLI_heap_empty(heap)) {
+ while (!BLI_heap_is_empty(heap)) {
BMFace *adj[2];
e = BLI_heap_popmin(heap);
@@ -1432,7 +1416,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
* share a border with another face, output as a quad */
if (!BM_elem_flag_test(adj[0], BM_ELEM_TAG) &&
!BM_elem_flag_test(adj[1], BM_ELEM_TAG) &&
- !BM_face_share_face_count(adj[0], adj[1]))
+ !BM_face_share_face_check(adj[0], adj[1]))
{
add_quad_from_tris(so, e, adj);
BM_elem_flag_enable(adj[0], BM_ELEM_TAG);
@@ -1544,23 +1528,23 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes,
if (sn->flag & CAP_START) {
if (sn->flag & ROOT) {
add_poly(so,
- sn->frames[0].verts[0],
- sn->frames[0].verts[1],
- sn->frames[0].verts[2],
- sn->frames[0].verts[3]);
+ sn->frames[0].verts[0],
+ sn->frames[0].verts[1],
+ sn->frames[0].verts[2],
+ sn->frames[0].verts[3]);
}
else {
add_poly(so,
- sn->frames[0].verts[3],
- sn->frames[0].verts[2],
- sn->frames[0].verts[1],
- sn->frames[0].verts[0]);
+ sn->frames[0].verts[3],
+ sn->frames[0].verts[2],
+ sn->frames[0].verts[1],
+ sn->frames[0].verts[0]);
}
}
if (sn->flag & CAP_END) {
add_poly(so,
sn->frames[1].verts[0],
- sn->frames[1].verts[1],
+ sn->frames[1].verts[1],
sn->frames[1].verts[2],
sn->frames[1].verts[3]);
}
@@ -1770,7 +1754,6 @@ static void skin_set_orig_indices(DerivedMesh *dm)
static DerivedMesh *base_skin(DerivedMesh *origdm,
SkinModifierData *smd)
{
- BMEditMesh fake_em;
DerivedMesh *result;
MVertSkin *nodes;
BMesh *bm;
@@ -1807,8 +1790,7 @@ static DerivedMesh *base_skin(DerivedMesh *origdm,
if (!bm)
return NULL;
- fake_em.bm = bm;
- result = CDDM_from_BMEditMesh(&fake_em, NULL, FALSE, FALSE);
+ result = CDDM_from_bmesh(bm, FALSE);
BM_mesh_free(bm);
CDDM_calc_edges(result);
@@ -1861,7 +1843,7 @@ static void copyData(ModifierData *md, ModifierData *target)
static DerivedMesh *applyModifierEM(ModifierData *md,
Object *UNUSED(ob),
- BMEditMesh *UNUSED(em),
+ struct BMEditMesh *UNUSED(em),
DerivedMesh *dm)
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index b9b3b89e06d..4b2ce47b8d9 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -81,19 +81,31 @@ static void freeData(ModifierData *md)
smokeModifier_free(smd);
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
- float (*vertexCos)[3],
- int UNUSED(numVerts),
- ModifierApplyFlag UNUSED(flag))
+static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
{
- SmokeModifierData *smd = (SmokeModifierData *) md;
- DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos);
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ CustomDataMask dataMask = 0;
+
+ if (smd && (smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+ if (smd->flow->source == MOD_SMOKE_FLOW_SOURCE_MESH) {
+ /* vertex groups */
+ if (smd->flow->vgroup_density)
+ dataMask |= CD_MASK_MDEFORMVERT;
+ /* uv layer */
+ if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV)
+ dataMask |= CD_MASK_MTFACE;
+ }
+ }
+ return dataMask;
+}
- smokeModifier_do(smd, md->scene, ob, dm);
+static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
+ DerivedMesh *dm,
+ ModifierApplyFlag UNUSED(flag))
+{
+ SmokeModifierData *smd = (SmokeModifierData *) md;
- if (dm != derivedData)
- dm->release(dm);
+ return smokeModifier_do(smd, md->scene, ob, dm);
}
static int dependsOnTime(ModifierData *UNUSED(md))
@@ -102,11 +114,11 @@ static int dependsOnTime(ModifierData *UNUSED(md))
}
static void updateDepgraph(ModifierData *md, DagForest *forest,
- struct Scene *scene,
- Object *UNUSED(ob),
+ struct Scene *scene, struct Object *ob,
DagNode *obNode)
{
SmokeModifierData *smd = (SmokeModifierData *) md;
+ Base *base;
if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
if (smd->domain->fluid_group || smd->domain->coll_group) {
@@ -139,8 +151,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
}
}
else {
- Base *base = scene->base.first;
-
+ base = scene->base.first;
for (; base; base = base->next) {
SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(base->object, eModifierType_Smoke);
@@ -150,6 +161,14 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
}
}
}
+ /* add relation to all "smoke flow" force fields */
+ base = scene->base.first;
+ for (; base; base = base->next) {
+ if (base->object->pd && base->object->pd->forcefield == PFIELD_SMOKEFLOW && base->object->pd->f_source == ob) {
+ DagNode *node2 = dag_get_node(forest, base->object);
+ dag_add_relation(forest, obNode, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Source Object");
+ }
+ }
}
}
@@ -167,26 +186,30 @@ static void foreachIDLink(ModifierData *md, Object *ob,
walk(userData, ob, (ID **)&smd->domain->effector_weights->group);
}
}
+
+ if (smd->type == MOD_SMOKE_TYPE_FLOW && smd->flow) {
+ walk(userData, ob, (ID **)&smd->flow->noise_texture);
+ }
}
ModifierTypeInfo modifierType_Smoke = {
/* name */ "Smoke",
/* structName */ "SmokeModifierData",
/* structSize */ sizeof(SmokeModifierData),
- /* type */ eModifierTypeType_OnlyDeform,
+ /* type */ eModifierTypeType_Constructive,
/* flags */ eModifierTypeFlag_AcceptsMesh |
eModifierTypeFlag_UsesPointCache |
eModifierTypeFlag_Single,
/* copyData */ copyData,
- /* deformVerts */ deformVerts,
+ /* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
- /* requiredDataMask */ NULL,
+ /* requiredDataMask */ requiredDataMask,
/* freeData */ freeData,
/* isDisabled */ NULL,
/* updateDepgraph */ updateDepgraph,
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 545e2135344..1d35d8f55bf 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -250,7 +250,7 @@ ModifierTypeInfo modifierType_Smooth = {
/* structSize */ sizeof(SmoothModifierData),
/* type */ eModifierTypeType_OnlyDeform,
/* flags */ eModifierTypeFlag_AcceptsMesh |
- eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_AcceptsCVs |
eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 1df7d535c35..fbd3c084e70 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -207,9 +207,10 @@ BLI_INLINE void madd_v3v3short_fl(float r[3], const short a[3], const float f)
r[2] += (float)a[2] * f;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(
+ ModifierData *md, Object *ob,
+ DerivedMesh *dm,
+ ModifierApplyFlag UNUSED(flag))
{
int i;
DerivedMesh *result;
@@ -223,7 +224,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
const int numEdges = dm->getNumEdges(dm);
const int numFaces = dm->getNumPolys(dm);
int numLoops = 0, newLoops = 0, newFaces = 0, newEdges = 0;
- int j;
/* only use material offsets if we have 2 or more materials */
const short mat_nr_max = ob->totcol > 1 ? ob->totcol - 1 : 0;
@@ -292,9 +292,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
for (i = 0, mp = orig_mpoly; i < numFaces; i++, mp++) {
- MLoop *ml = orig_mloop + mp->loopstart;
unsigned int ml_v1;
unsigned int ml_v2;
+ int j;
+
+ ml = orig_mloop + mp->loopstart;
for (j = 0, ml_v1 = ml->v, ml_v2 = ml[mp->totloop - 1].v;
j < mp->totloop;
@@ -376,6 +378,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
for (i = 0; i < dm->numPolyData; i++, mp++) {
MLoop *ml2;
int e;
+ int j;
ml2 = mloop + mp->loopstart + dm->numLoopData;
for (j = 0; j < mp->totloop; j++) {
@@ -591,6 +594,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
int *origindex_edge;
int *orig_ed;
+ int j;
/* add faces & edges */
origindex_edge = result->getEdgeDataArray(result, CD_ORIGINDEX);
@@ -715,13 +719,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
for (i = 0; i < newEdges; i++, ed++) {
float nor_cpy[3];
short *nor_short;
- int j;
+ int k;
/* note, only the first vertex (lower half of the index) is calculated */
normalize_v3_v3(nor_cpy, edge_vert_nos[ed->v1]);
- for (j = 0; j < 2; j++) { /* loop over both verts of the edge */
- nor_short = mvert[*(&ed->v1 + j)].no;
+ for (k = 0; k < 2; k++) { /* loop over both verts of the edge */
+ nor_short = mvert[*(&ed->v1 + k)].no;
normal_short_to_float_v3(nor, nor_short);
add_v3_v3(nor, nor_cpy);
normalize_v3(nor);
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 1dbbe14e643..3b769a30994 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -199,7 +199,7 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (*
return dm;
if (ob->type == OB_MESH) {
- if (em) dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
+ if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob);
if (vertexCos) {
@@ -222,7 +222,7 @@ void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformV
*defgrp_index = defgroup_name_index(ob, name);
*dvert = NULL;
- if (*defgrp_index >= 0) {
+ if (*defgrp_index != -1) {
if (ob->type == OB_LATTICE)
*dvert = BKE_lattice_deform_verts_get(ob);
else if (dm)
@@ -277,5 +277,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(DynamicPaint);
INIT_TYPE(Remesh);
INIT_TYPE(Skin);
+ INIT_TYPE(LaplacianSmooth);
#undef INIT_TYPE
}
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index eadf7af553b..6f05c9a957a 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -42,10 +42,14 @@ struct TexResult;
void modifier_init_texture(struct Scene *scene, struct Tex *texture);
void get_texture_value(struct Tex *texture, float *tex_co, struct TexResult *texres);
-void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts);
+void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm,
+ float (*co)[3], float (*texco)[3], int numVerts);
void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
-struct DerivedMesh *get_cddm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3]);
-struct DerivedMesh *get_dm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int orco);
-void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index);
+struct DerivedMesh *get_cddm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm,
+ float (*vertexCos)[3]);
+struct DerivedMesh *get_dm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm,
+ float (*vertexCos)[3], int orco);
+void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm,
+ const char *name, struct MDeformVert **dvert, int *defgrp_index);
#endif /* __MOD_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 95f6ef60665..c2a62231529 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -238,7 +238,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
(fac = (wmd->falloff_radius - fac) / wmd->falloff_radius)))
{
/* skip if no vert group found */
- if (dvert && defgrp_index >= 0) {
+ if (dvert && defgrp_index != -1) {
dv = &dvert[i];
if (dv) {
@@ -337,7 +337,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
}
}
-static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData,
+static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
@@ -345,7 +345,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
if (use_dm) {
if (!derivedData)
- dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+ dm = CDDM_from_editbmesh(em, FALSE, FALSE);
}
deformVerts(md, ob, dm, vertexCos, numVerts, 0);
@@ -357,27 +357,27 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
ModifierTypeInfo modifierType_Warp = {
- /* name */ "Warp",
- /* structName */ "WarpModifierData",
- /* structSize */ sizeof(WarpModifierData),
- /* type */ eModifierTypeType_OnlyDeform,
- /* flags */ eModifierTypeFlag_AcceptsCVs |
- eModifierTypeFlag_SupportsEditmode,
- /* copyData */ copyData,
- /* deformVerts */ deformVerts,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ deformVertsEM,
- /* deformMatricesEM */ NULL,
- /* applyModifier */ 0,
- /* applyModifierEM */ 0,
- /* initData */ initData,
- /* requiredDataMask */ requiredDataMask,
- /* freeData */ freeData,
- /* isDisabled */ isDisabled,
- /* updateDepgraph */ updateDepgraph,
- /* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* name */ "Warp",
+ /* structName */ "WarpModifierData",
+ /* structSize */ sizeof(WarpModifierData),
+ /* type */ eModifierTypeType_OnlyDeform,
+ /* flags */ eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_SupportsEditmode,
+ /* copyData */ copyData,
+ /* deformVerts */ deformVerts,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ deformVertsEM,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ 0,
+ /* applyModifierEM */ 0,
+ /* initData */ initData,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ freeData,
+ /* isDisabled */ isDisabled,
+ /* updateDepgraph */ updateDepgraph,
+ /* dependsOnTime */ dependsOnTime,
+ /* dependsOnNormals */ NULL,
/* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ foreachTexLink,
+ /* foreachIDLink */ foreachIDLink,
+ /* foreachTexLink */ foreachTexLink,
};
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 440d2c157fe..b713f56a4c2 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -186,7 +186,7 @@ static void waveModifier_do(WaveModifierData *md,
const float falloff = wmd->falloff;
float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */
- if (wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH)
+ if ((wmd->flag & MOD_WAVE_NORM) && (ob->type == OB_MESH))
mvert = dm->getVertArray(dm);
if (wmd->objectcenter) {
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index ce6295e30cf..779ac6b5ecf 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -185,7 +185,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
float *org_w; /* Array original weights. */
float *new_w; /* Array new weights. */
int numVerts;
- int defgrp_idx;
+ int defgrp_index;
int i;
/* Flags. */
int do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0;
@@ -205,8 +205,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
return dm;
/* Get vgroup idx from its name. */
- defgrp_idx = defgroup_name_index(ob, wmd->defgrp_name);
- if (defgrp_idx < 0)
+ defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
+ if (defgrp_index == -1)
return dm;
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
@@ -228,7 +228,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
new_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, new_w");
dw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGEdit Modifier, dw");
for (i = 0; i < numVerts; i++) {
- dw[i] = defvert_find_index(&dvert[i], defgrp_idx);
+ dw[i] = defvert_find_index(&dvert[i], defgrp_index);
if (dw[i]) {
org_w[i] = new_w[i] = dw[i]->weight;
}
@@ -249,7 +249,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name);
/* Update/add/remove from vgroup. */
- weightvg_update_vg(dvert, defgrp_idx, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold,
+ weightvg_update_vg(dvert, defgrp_index, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold,
do_rem, wmd->rem_threshold);
/* If weight preview enabled... */
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 2961082b448..5883b176317 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -225,7 +225,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
MDeformVert *dvert = NULL;
MDeformWeight **dw1, **tdw1, **dw2, **tdw2;
int numVerts;
- int defgrp_idx, defgrp_idx2 = -1;
+ int defgrp_index, defgrp_index_other = -1;
float *org_w;
float *new_w;
int *tidx, *indices = NULL;
@@ -246,13 +246,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
return dm;
/* Get vgroup idx from its name. */
- defgrp_idx = defgroup_name_index(ob, wmd->defgrp_name_a);
- if (defgrp_idx < 0)
+ defgrp_index = defgroup_name_index(ob, wmd->defgrp_name_a);
+ if (defgrp_index == -1)
return dm;
/* Get seconf vgroup idx from its name, if given. */
if (wmd->defgrp_name_b[0] != (char)0) {
- defgrp_idx2 = defgroup_name_index(ob, wmd->defgrp_name_b);
- if (defgrp_idx2 < 0)
+ defgrp_index_other = defgroup_name_index(ob, wmd->defgrp_name_b);
+ if (defgrp_index_other == -1)
return dm;
}
@@ -277,10 +277,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
case MOD_WVG_SET_A:
/* All vertices in first vgroup. */
for (i = 0; i < numVerts; i++) {
- MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx);
+ MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_index);
if (dw) {
tdw1[numIdx] = dw;
- tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2);
+ tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_index_other);
tidx[numIdx++] = i;
}
}
@@ -288,9 +288,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
case MOD_WVG_SET_B:
/* All vertices in second vgroup. */
for (i = 0; i < numVerts; i++) {
- MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2);
+ MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_index_other);
if (dw) {
- tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx);
+ tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_index);
tdw2[numIdx] = dw;
tidx[numIdx++] = i;
}
@@ -299,8 +299,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
case MOD_WVG_SET_OR:
/* All vertices in one vgroup or the other. */
for (i = 0; i < numVerts; i++) {
- MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx);
- MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2);
+ MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_index);
+ MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_index_other);
if (adw || bdw) {
tdw1[numIdx] = adw;
tdw2[numIdx] = bdw;
@@ -311,8 +311,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
case MOD_WVG_SET_AND:
/* All vertices in both vgroups. */
for (i = 0; i < numVerts; i++) {
- MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx);
- MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2);
+ MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_index);
+ MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_index_other);
if (adw && bdw) {
tdw1[numIdx] = adw;
tdw2[numIdx] = bdw;
@@ -324,8 +324,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
default:
/* Use all vertices. */
for (i = 0; i < numVerts; i++) {
- tdw1[i] = defvert_find_index(&dvert[i], defgrp_idx);
- tdw2[i] = defvert_find_index(&dvert[i], defgrp_idx2);
+ tdw1[i] = defvert_find_index(&dvert[i], defgrp_index);
+ tdw2[i] = defvert_find_index(&dvert[i], defgrp_index_other);
}
numIdx = -1;
break;
@@ -377,7 +377,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
/* Update (add to) vgroup.
* XXX Depending on the MOD_WVG_SET_xxx option chosen, we might have to add vertices to vgroup.
*/
- weightvg_update_vg(dvert, defgrp_idx, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f);
+ weightvg_update_vg(dvert, defgrp_index, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f);
/* If weight preview enabled... */
#if 0 /* XXX Currently done in mod stack :/ */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 25a2a61d8e3..e936e571a5b 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -347,7 +347,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
int numVerts;
float (*v_cos)[3] = NULL; /* The vertices coordinates. */
Object *obr = NULL; /* Our target object. */
- int defgrp_idx;
+ int defgrp_index;
float *tw = NULL;
float *org_w = NULL;
float *new_w = NULL;
@@ -378,8 +378,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
return dm;
/* Get vgroup idx from its name. */
- defgrp_idx = defgroup_name_index(ob, wmd->defgrp_name);
- if (defgrp_idx < 0)
+ defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
+ if (defgrp_index == -1)
return dm;
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
@@ -394,7 +394,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
tw = MEM_mallocN(sizeof(float) * numVerts, "WeightVGProximity Modifier, tw");
tdw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGProximity Modifier, tdw");
for (i = 0; i < numVerts; i++) {
- MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_idx);
+ MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_index);
if (_dw) {
tidx[numIdx] = i;
tw[numIdx] = _dw->weight;
@@ -460,7 +460,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
else if (obr->type == OB_MESH) {
Mesh *me = (Mesh *)obr->data;
if (me->edit_btmesh)
- target_dm = CDDM_from_BMEditMesh(me->edit_btmesh, me, FALSE, FALSE);
+ target_dm = CDDM_from_editbmesh(me->edit_btmesh, FALSE, FALSE);
else
target_dm = CDDM_from_mesh(me, obr);
}
@@ -480,9 +480,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
for (i = 0; i < numIdx; i++) {
new_w[i] = dists_v ? dists_v[i] : FLT_MAX;
if (dists_e)
- new_w[i] = minf(dists_e[i], new_w[i]);
+ new_w[i] = min_ff(dists_e[i], new_w[i]);
if (dists_f)
- new_w[i] = minf(dists_f[i], new_w[i]);
+ new_w[i] = min_ff(dists_f[i], new_w[i]);
}
if (free_target_dm) target_dm->release(target_dm);
if (dists_v) MEM_freeN(dists_v);
@@ -509,7 +509,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name);
/* Update vgroup. Note we never add nor remove vertices from vgroup here. */
- weightvg_update_vg(dvert, defgrp_idx, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f);
+ weightvg_update_vg(dvert, defgrp_index, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f);
/* If weight preview enabled... */
#if 0 /* XXX Currently done in mod stack :/ */
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 08e0e7b0f93..7dca4d07b24 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -23,8 +23,12 @@
#
# ***** END GPL LICENSE BLOCK *****
-set(INC
+set(INC
.
+ composite
+ intern
+ shader
+ texture
../blenfont
../blenkernel
../blenlib
@@ -39,10 +43,6 @@ set(INC
set(INC_SYS
${GLEW_INCLUDE_PATH}
- intern
- composite
- shader
- texture
)
set(SRC
@@ -119,7 +119,8 @@ set(SRC
composite/nodes/node_composite_ellipsemask.c
composite/nodes/node_composite_switch.c
composite/nodes/node_composite_colorcorrection.c
-
+ composite/nodes/node_composite_pixelate.c
+
composite/node_composite_tree.c
composite/node_composite_util.c
@@ -144,34 +145,40 @@ set(SRC
shader/nodes/node_shader_valToRgb.c
shader/nodes/node_shader_value.c
shader/nodes/node_shader_vectMath.c
+ shader/nodes/node_shader_add_shader.c
+ shader/nodes/node_shader_ambient_occlusion.c
shader/nodes/node_shader_attribute.c
shader/nodes/node_shader_background.c
- # shader/nodes/node_shader_bsdf_anisotropic.c # XXX, why not included?
+ shader/nodes/node_shader_bsdf_anisotropic.c
shader/nodes/node_shader_bsdf_diffuse.c
- shader/nodes/node_shader_bsdf_glossy.c
shader/nodes/node_shader_bsdf_glass.c
+ shader/nodes/node_shader_bsdf_glossy.c
+ shader/nodes/node_shader_bsdf_refraction.c
shader/nodes/node_shader_bsdf_translucent.c
shader/nodes/node_shader_bsdf_transparent.c
shader/nodes/node_shader_bsdf_velvet.c
+ shader/nodes/node_shader_bump.c
shader/nodes/node_shader_emission.c
shader/nodes/node_shader_fresnel.c
- shader/nodes/node_shader_layer_weight.c
shader/nodes/node_shader_geometry.c
shader/nodes/node_shader_holdout.c
- shader/nodes/node_shader_volume_transparent.c
- shader/nodes/node_shader_volume_isotropic.c
- shader/nodes/node_shader_light_path.c
+ shader/nodes/node_shader_layer_weight.c
shader/nodes/node_shader_light_falloff.c
- shader/nodes/node_shader_object_info.c
- shader/nodes/node_shader_particle_info.c
+ shader/nodes/node_shader_light_path.c
shader/nodes/node_shader_mix_shader.c
- shader/nodes/node_shader_add_shader.c
+ shader/nodes/node_shader_normal_map.c
+ shader/nodes/node_shader_object_info.c
shader/nodes/node_shader_output_lamp.c
shader/nodes/node_shader_output_material.c
shader/nodes/node_shader_output_world.c
- shader/nodes/node_shader_tex_gradient.c
+ shader/nodes/node_shader_particle_info.c
+ shader/nodes/node_shader_script.c
+ shader/nodes/node_shader_tangent.c
+ shader/nodes/node_shader_tex_brick.c
+ shader/nodes/node_shader_tex_checker.c
shader/nodes/node_shader_tex_coord.c
shader/nodes/node_shader_tex_environment.c
+ shader/nodes/node_shader_tex_gradient.c
shader/nodes/node_shader_tex_image.c
shader/nodes/node_shader_tex_magic.c
shader/nodes/node_shader_tex_musgrave.c
@@ -179,8 +186,8 @@ set(SRC
shader/nodes/node_shader_tex_sky.c
shader/nodes/node_shader_tex_voronoi.c
shader/nodes/node_shader_tex_wave.c
- shader/nodes/node_shader_tex_checker.c
- shader/nodes/node_shader_tex_brick.c
+ shader/nodes/node_shader_volume_isotropic.c
+ shader/nodes/node_shader_volume_transparent.c
shader/node_shader_tree.c
shader/node_shader_util.c
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index bcef230e1d0..ee67ac88085 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -96,7 +96,7 @@ void register_node_type_cmp_combhsva(struct bNodeTreeType *ttype);
void register_node_type_cmp_sepyuva(struct bNodeTreeType *ttype);
void register_node_type_cmp_combyuva(struct bNodeTreeType *ttype);
void register_node_type_cmp_sepycca(struct bNodeTreeType *ttype);
-void register_node_type_cmp_combycca(struct bNodeTreeType *ttype);
+void register_node_type_cmp_combycca(struct bNodeTreeType *ttype);
void register_node_type_cmp_premulkey(struct bNodeTreeType *ttype);
void register_node_type_cmp_diff_matte(struct bNodeTreeType *ttype);
@@ -105,7 +105,7 @@ void register_node_type_cmp_chroma_matte(struct bNodeTreeType *ttype);
void register_node_type_cmp_color_matte(struct bNodeTreeType *ttype);
void register_node_type_cmp_channel_matte(struct bNodeTreeType *ttype);
void register_node_type_cmp_color_spill(struct bNodeTreeType *ttype);
-void register_node_type_cmp_luma_matte(struct bNodeTreeType *ttype);
+void register_node_type_cmp_luma_matte(struct bNodeTreeType *ttype);
void register_node_type_cmp_doubleedgemask(struct bNodeTreeType *ttype);
void register_node_type_cmp_keyingscreen(struct bNodeTreeType *ttype);
void register_node_type_cmp_keying(struct bNodeTreeType *ttype);
@@ -133,7 +133,7 @@ void register_node_type_cmp_ellipsemask(struct bNodeTreeType *ttype);
void register_node_type_cmp_bokehimage(struct bNodeTreeType *ttype);
void register_node_type_cmp_bokehblur(struct bNodeTreeType *ttype);
void register_node_type_cmp_switch(struct bNodeTreeType *ttype);
-
+void register_node_type_cmp_pixelate(struct bNodeTreeType *ttype);
void register_node_type_cmp_trackpos(struct bNodeTreeType *ttype);
#endif
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index 49428c06e5f..e402924c04f 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -80,14 +80,20 @@ void register_node_type_sh_fresnel(struct bNodeTreeType *ttype);
void register_node_type_sh_layer_weight(struct bNodeTreeType *ttype);
void register_node_type_sh_tex_coord(struct bNodeTreeType *ttype);
void register_node_type_sh_particle_info(struct bNodeTreeType *ttype);
+void register_node_type_sh_script(struct bNodeTreeType *ttype);
+void register_node_type_sh_normal_map(struct bNodeTreeType *ttype);
+void register_node_type_sh_tangent(struct bNodeTreeType *ttype);
+void register_node_type_sh_ambient_occlusion(struct bNodeTreeType *ttype);
void register_node_type_sh_background(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_diffuse(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_glossy(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_glass(struct bNodeTreeType *ttype);
+void register_node_type_sh_bsdf_refraction(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_translucent(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_transparent(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_velvet(struct bNodeTreeType *ttype);
+void register_node_type_sh_bsdf_anisotropic(struct bNodeTreeType *ttype);
void register_node_type_sh_emission(struct bNodeTreeType *ttype);
void register_node_type_sh_holdout(struct bNodeTreeType *ttype);
void register_node_type_sh_volume_transparent(struct bNodeTreeType *ttype);
@@ -109,6 +115,7 @@ void register_node_type_sh_tex_wave(struct bNodeTreeType *ttype);
void register_node_type_sh_tex_musgrave(struct bNodeTreeType *ttype);
void register_node_type_sh_tex_noise(struct bNodeTreeType *ttype);
void register_node_type_sh_tex_checker(struct bNodeTreeType *ttype);
+void register_node_type_sh_bump(struct bNodeTreeType *ttype);
#endif
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index f41be2bb7d9..b14f7c4e884 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -60,6 +60,7 @@ void node_socket_set_default_value_vector(void *default_value, PropertySubType s
void node_socket_set_default_value_rgba(void *default_value, float r, float g, float b, float a);
void node_socket_set_default_value_shader(void *default_value);
void node_socket_set_default_value_mesh(void *default_value);
+void node_socket_set_default_value_string(void *default_value, PropertySubType subtype, const char *value);
struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp);
struct bNodeSocket *node_add_output_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp);
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 0d86ada8026..9a7e587ff56 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -273,7 +273,7 @@ bNodeTreeType ntreeType_Composite = {
/* update */ update,
/* update_node */ update_node,
/* validate_link */ NULL,
- /* internal_connect */ node_internal_connect_default
+ /* update_internal_links */ node_update_internal_links_default
};
@@ -301,7 +301,7 @@ struct bNodeTreeExec *ntreeCompositBeginExecTree(bNodeTree *ntree, int use_tree_
for (node= exec->nodetree->nodes.first; node; node= node->next) {
/* initialize needed for groups */
- node->exec= 0;
+ node->exec= 0;
for (sock= node->outputs.first; sock; sock= sock->next) {
bNodeStack *ns= node_get_socket_stack(exec->stack, sock);
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index ad2d26d7c27..57eb99021f6 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -72,7 +72,7 @@ CompBuf *dupalloc_compbuf(CompBuf *cbuf)
dupbuf->xof= cbuf->xof;
dupbuf->yof= cbuf->yof;
- }
+ }
return dupbuf;
}
@@ -94,7 +94,7 @@ CompBuf *pass_on_compbuf(CompBuf *cbuf)
break;
lastbuf->next= dupbuf;
dupbuf->prev= lastbuf;
- }
+ }
return dupbuf;
}
@@ -213,53 +213,53 @@ void typecheck_compbuf_color(float *out, float *in, int outtype, int intype)
}
else if (outtype==CB_VEC2) {
if (intype==CB_VAL) {
- out[0]= in[0];
- out[1]= in[0];
+ out[0] = in[0];
+ out[1] = in[0];
}
else if (intype==CB_VEC3) {
- out[0]= in[0];
- out[1]= in[1];
+ out[0] = in[0];
+ out[1] = in[1];
}
else if (intype==CB_RGBA) {
- out[0]= in[0];
- out[1]= in[1];
+ out[0] = in[0];
+ out[1] = in[1];
}
}
else if (outtype==CB_VEC3) {
if (intype==CB_VAL) {
- out[0]= in[0];
- out[1]= in[0];
- out[2]= in[0];
+ out[0] = in[0];
+ out[1] = in[0];
+ out[2] = in[0];
}
else if (intype==CB_VEC2) {
- out[0]= in[0];
- out[1]= in[1];
- out[2]= 0.0f;
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = 0.0f;
}
else if (intype==CB_RGBA) {
- out[0]= in[0];
- out[1]= in[1];
- out[2]= in[2];
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
}
}
else if (outtype==CB_RGBA) {
if (intype==CB_VAL) {
- out[0]= in[0];
- out[1]= in[0];
- out[2]= in[0];
- out[3]= 1.0f;
+ out[0] = in[0];
+ out[1] = in[0];
+ out[2] = in[0];
+ out[3] = 1.0f;
}
else if (intype==CB_VEC2) {
- out[0]= in[0];
- out[1]= in[1];
- out[2]= 0.0f;
- out[3]= 1.0f;
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = 0.0f;
+ out[3] = 1.0f;
}
else if (intype==CB_VEC3) {
- out[0]= in[0];
- out[1]= in[1];
- out[2]= in[2];
- out[3]= 1.0f;
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = 1.0f;
}
}
}
@@ -307,69 +307,69 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type)
else if (type==CB_VEC2) {
if (inbuf->type==CB_VAL) {
for (; x>0; x--, outrf+= 2, inrf+= 1) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[0];
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[0];
}
}
else if (inbuf->type==CB_VEC3) {
for (; x>0; x--, outrf+= 2, inrf+= 3) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[1];
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[1];
}
}
else if (inbuf->type==CB_RGBA) {
for (; x>0; x--, outrf+= 2, inrf+= 4) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[1];
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[1];
}
}
}
else if (type==CB_VEC3) {
if (inbuf->type==CB_VAL) {
for (; x>0; x--, outrf+= 3, inrf+= 1) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[0];
- outrf[2]= inrf[0];
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[0];
+ outrf[2] = inrf[0];
}
}
else if (inbuf->type==CB_VEC2) {
for (; x>0; x--, outrf+= 3, inrf+= 2) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[1];
- outrf[2]= 0.0f;
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[1];
+ outrf[2] = 0.0f;
}
}
else if (inbuf->type==CB_RGBA) {
for (; x>0; x--, outrf+= 3, inrf+= 4) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[1];
- outrf[2]= inrf[2];
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[1];
+ outrf[2] = inrf[2];
}
}
}
else if (type==CB_RGBA) {
if (inbuf->type==CB_VAL) {
for (; x>0; x--, outrf+= 4, inrf+= 1) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[0];
- outrf[2]= inrf[0];
- outrf[3]= 1.0f;
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[0];
+ outrf[2] = inrf[0];
+ outrf[3] = 1.0f;
}
}
else if (inbuf->type==CB_VEC2) {
for (; x>0; x--, outrf+= 4, inrf+= 2) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[1];
- outrf[2]= 0.0f;
- outrf[3]= 1.0f;
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[1];
+ outrf[2] = 0.0f;
+ outrf[3] = 1.0f;
}
}
else if (inbuf->type==CB_VEC3) {
for (; x>0; x--, outrf+= 4, inrf+= 3) {
- outrf[0]= inrf[0];
- outrf[1]= inrf[1];
- outrf[2]= inrf[2];
- outrf[3]= 1.0f;
+ outrf[0] = inrf[0];
+ outrf[1] = inrf[1];
+ outrf[2] = inrf[2];
+ outrf[3] = 1.0f;
}
}
}
@@ -387,7 +387,7 @@ float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y,
return use;
}
else {
- static float col[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+ static float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* map coords */
x-= cbuf->xof;
@@ -707,18 +707,18 @@ void do_copy_rgba(bNode *UNUSED(node), float *out, float *in)
void do_copy_rgb(bNode *UNUSED(node), float *out, float *in)
{
copy_v3_v3(out, in);
- out[3]= 1.0f;
+ out[3] = 1.0f;
}
void do_copy_value(bNode *UNUSED(node), float *out, float *in)
{
- out[0]= in[0];
+ out[0] = in[0];
}
void do_copy_a_rgba(bNode *UNUSED(node), float *out, float *in, float *fac)
{
copy_v3_v3(out, in);
- out[3]= *fac;
+ out[3] = *fac;
}
/* only accepts RGBA buffers */
@@ -732,16 +732,16 @@ void gamma_correct_compbuf(CompBuf *img, int inversed)
drect= img->rect;
if (inversed) {
for (x=img->x*img->y; x>0; x--, drect+=4) {
- if (drect[0]>0.0f) drect[0]= sqrt(drect[0]); else drect[0]= 0.0f;
- if (drect[1]>0.0f) drect[1]= sqrt(drect[1]); else drect[1]= 0.0f;
- if (drect[2]>0.0f) drect[2]= sqrt(drect[2]); else drect[2]= 0.0f;
+ if (drect[0]>0.0f) drect[0] = sqrt(drect[0]); else drect[0] = 0.0f;
+ if (drect[1]>0.0f) drect[1] = sqrt(drect[1]); else drect[1] = 0.0f;
+ if (drect[2]>0.0f) drect[2] = sqrt(drect[2]); else drect[2] = 0.0f;
}
}
else {
for (x=img->x*img->y; x>0; x--, drect+=4) {
- if (drect[0]>0.0f) drect[0]*= drect[0]; else drect[0]= 0.0f;
- if (drect[1]>0.0f) drect[1]*= drect[1]; else drect[1]= 0.0f;
- if (drect[2]>0.0f) drect[2]*= drect[2]; else drect[2]= 0.0f;
+ if (drect[0]>0.0f) drect[0]*= drect[0]; else drect[0] = 0.0f;
+ if (drect[1]>0.0f) drect[1]*= drect[1]; else drect[1] = 0.0f;
+ if (drect[2]>0.0f) drect[2]*= drect[2]; else drect[2] = 0.0f;
}
}
}
@@ -757,9 +757,9 @@ void premul_compbuf(CompBuf *img, int inversed)
if (inversed) {
for (x=img->x*img->y; x>0; x--, drect+=4) {
if (fabsf(drect[3]) < 1e-5f) {
- drect[0]= 0.0f;
- drect[1]= 0.0f;
- drect[2]= 0.0f;
+ drect[0] = 0.0f;
+ drect[1] = 0.0f;
+ drect[2] = 0.0f;
}
else {
drect[0] /= drect[3];
diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c
index 86eb0aa2c83..72c2204d8c5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c
+++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c
@@ -32,13 +32,13 @@
#include "node_composite_util.h"
/* **************** ALPHAOVER ******************** */
-static bNodeSocketTemplate cmp_node_alphaover_in[]= {
+static bNodeSocketTemplate cmp_node_alphaover_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_alphaover_out[]= {
+static bNodeSocketTemplate cmp_node_alphaover_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -48,7 +48,7 @@ static bNodeSocketTemplate cmp_node_alphaover_out[]= {
static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, float *over, float *fac)
{
- /* Zero alpha values should still permit an add of RGB data */
+ /* Zero alpha values should still permit an add of RGB data */
if (over[3]<0.0f) {
copy_v4_v4(out, src);
}
@@ -58,11 +58,11 @@ static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, flo
else {
float mul= 1.0f - fac[0]*over[3];
- out[0]= (mul*src[0]) + fac[0]*over[0];
- out[1]= (mul*src[1]) + fac[0]*over[1];
- out[2]= (mul*src[2]) + fac[0]*over[2];
- out[3]= (mul*src[3]) + fac[0]*over[3];
- }
+ out[0] = (mul*src[0]) + fac[0]*over[0];
+ out[1] = (mul*src[1]) + fac[0]*over[1];
+ out[2] = (mul*src[2]) + fac[0]*over[2];
+ out[3] = (mul*src[3]) + fac[0]*over[3];
+ }
}
/* result will be still premul, but the over part is premulled */
@@ -79,10 +79,10 @@ static void do_alphaover_key(bNode *UNUSED(node), float *out, float *src, float
float premul= fac[0]*over[3];
float mul= 1.0f - premul;
- out[0]= (mul*src[0]) + premul*over[0];
- out[1]= (mul*src[1]) + premul*over[1];
- out[2]= (mul*src[2]) + premul*over[2];
- out[3]= (mul*src[3]) + fac[0]*over[3];
+ out[0] = (mul*src[0]) + premul*over[0];
+ out[1] = (mul*src[1]) + premul*over[1];
+ out[2] = (mul*src[2]) + premul*over[2];
+ out[3] = (mul*src[3]) + fac[0]*over[3];
}
}
@@ -102,10 +102,10 @@ static void do_alphaover_mixed(bNode *node, float *out, float *src, float *over,
float premul= fac[0]*addfac;
float mul= 1.0f - fac[0]*over[3];
- out[0]= (mul*src[0]) + premul*over[0];
- out[1]= (mul*src[1]) + premul*over[1];
- out[2]= (mul*src[2]) + premul*over[2];
- out[3]= (mul*src[3]) + fac[0]*over[3];
+ out[0] = (mul*src[0]) + premul*over[0];
+ out[1] = (mul*src[1]) + premul*over[1];
+ out[2] = (mul*src[2]) + premul*over[2];
+ out[3] = (mul*src[3]) + fac[0]*over[3];
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
index e05ef1ea5a5..7674ace42a3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
@@ -33,14 +33,14 @@
/* **************** BILATERALBLUR ******************** */
static bNodeSocketTemplate cmp_node_bilateralblur_in[] = {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f},
- { -1, 0, "" }
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { -1, 0, "" }
};
static bNodeSocketTemplate cmp_node_bilateralblur_out[] = {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
#ifdef WITH_COMPOSITOR_LEGACY
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
index c5697679f90..8324b77b2d1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
@@ -37,7 +37,7 @@
/* **************** Bokeh image Tools ******************** */
-static bNodeSocketTemplate cmp_node_bokehimage_out[]= {
+static bNodeSocketTemplate cmp_node_bokehimage_out[] = {
{ SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.c b/source/blender/nodes/composite/nodes/node_composite_boxmask.c
index 1ba522c0e5f..d3c6b2ccef0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_boxmask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.c
@@ -1,6 +1,4 @@
/*
- * $Id: CMP_math.c 36271 2011-04-21 13:11:51Z campbellbarton $
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -35,15 +33,15 @@
#include "../node_composite_util.h"
/* **************** SCALAR MATH ******************** */
-static bNodeSocketTemplate cmp_node_boxmask_in[]= {
+static bNodeSocketTemplate cmp_node_boxmask_in[] = {
{ SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_boxmask_out[]= {
+static bNodeSocketTemplate cmp_node_boxmask_out[] = {
{ SOCK_FLOAT, 0, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+ { -1, 0, "" }
};
static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c
index 2b8a394d6f2..ecf572f59c7 100644
--- a/source/blender/nodes/composite/nodes/node_composite_brightness.c
+++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c
@@ -36,13 +36,13 @@
/* **************** Brigh and contrsast ******************** */
-static bNodeSocketTemplate cmp_node_brightcontrast_in[]= {
+static bNodeSocketTemplate cmp_node_brightcontrast_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_brightcontrast_out[]= {
+static bNodeSocketTemplate cmp_node_brightcontrast_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -72,7 +72,7 @@ static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, fl
b = a * (brightness + delta);
}
- for (c=0; c<3; c++) {
+ for (c=0; c<3; c++) {
i = in[c];
v = a*i + b;
out[c] = v;
diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
index 06b77de463b..40dbbbb8dca 100644
--- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
@@ -34,12 +34,12 @@
/* ******************* Channel Matte Node ********************************* */
-static bNodeSocketTemplate cmp_node_channel_matte_in[]={
+static bNodeSocketTemplate cmp_node_channel_matte_in[] ={
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_channel_matte_out[]={
+static bNodeSocketTemplate cmp_node_channel_matte_out[] ={
{SOCK_RGBA, 0, N_("Image")},
{SOCK_FLOAT, 0, N_("Matte")},
{-1, 0, ""}
@@ -71,7 +71,7 @@ static void do_normalized_ycca_to_rgba2(bNode *UNUSED(node), float *out, float *
static void do_channel_matte(bNode *node, float *out, float *in)
{
NodeChroma *c=(NodeChroma *)node->storage;
- float alpha=0.0;
+ float alpha=0.0;
switch (c->algorithm) {
case 0: { /* Alpha=key_channel-limit channel */
diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
index 55ee1b090bb..f343f806d57 100644
--- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
@@ -33,13 +33,13 @@
#include "node_composite_util.h"
/* ******************* Chroma Key ********************************************************** */
-static bNodeSocketTemplate cmp_node_chroma_in[]={
+static bNodeSocketTemplate cmp_node_chroma_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, 1, N_("Key Color"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_chroma_out[]={
+static bNodeSocketTemplate cmp_node_chroma_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{SOCK_FLOAT, 0, N_("Matte")},
{-1, 0, ""}
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c
index 37fb29811ba..07a6647d976 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c
@@ -33,13 +33,13 @@
#include "node_composite_util.h"
/* ******************* Color Key ********************************************************** */
-static bNodeSocketTemplate cmp_node_color_in[]={
+static bNodeSocketTemplate cmp_node_color_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, 1, N_("Key Color"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_color_out[]={
+static bNodeSocketTemplate cmp_node_color_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{SOCK_FLOAT, 0, N_("Matte")},
{-1, 0, ""}
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c
index c4120ab22c6..44a5ac9e968 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c
@@ -29,26 +29,25 @@
* \ingroup cmpnodes
*/
-
-
#include "node_composite_util.h"
-#define AVG(a, b) ((a + b) / 2)
-
/* ******************* Color Spill Supression ********************************* */
-static bNodeSocketTemplate cmp_node_color_spill_in[]={
+static bNodeSocketTemplate cmp_node_color_spill_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_color_spill_out[]={
+static bNodeSocketTemplate cmp_node_color_spill_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{-1, 0, ""}
};
#ifdef WITH_COMPOSITOR_LEGACY
+#define AVG(a, b) ((a + b) / 2)
+
+
static void do_simple_spillmap_red(bNode *node, float* out, float *in)
{
NodeColorspill *ncs;
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
index a9f930f9cf2..e9d26ebebbc 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
@@ -35,13 +35,13 @@
/* ******************* Color Balance ********************************* */
-static bNodeSocketTemplate cmp_node_colorbalance_in[]={
+static bNodeSocketTemplate cmp_node_colorbalance_in[] = {
{SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_colorbalance_out[]={
+static bNodeSocketTemplate cmp_node_colorbalance_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{-1, 0, ""}
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
index ce43b2f0f2b..526f8472992 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
@@ -36,13 +36,13 @@
/* ******************* Color Balance ********************************* */
-static bNodeSocketTemplate cmp_node_colorcorrection_in[]={
+static bNodeSocketTemplate cmp_node_colorcorrection_in[] = {
{ SOCK_RGBA,1,N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Mask"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ -1,0,""}
};
-static bNodeSocketTemplate cmp_node_colorcorrection_out[]={
+static bNodeSocketTemplate cmp_node_colorcorrection_out[] = {
{ SOCK_RGBA,0,N_("Image")},
{ -1,0,""}
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c
index 2596248d696..10b81cdaaa0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.c
+++ b/source/blender/nodes/composite/nodes/node_composite_common.c
@@ -231,153 +231,3 @@ void register_node_type_cmp_group(bNodeTreeType *ttype)
nodeRegisterType(ttype, &ntype);
}
-
-#ifdef WITH_COMPOSITOR_LEGACY
-
-/**** FOR LOOP ****/
-
-#if 0 /* XXX loop nodes don't work nicely with current trees */
-/* Move the results from the previous iteration back to the input sockets. */
-static void loop_iteration_reset(bNodeTree *ngroup, bNodeStack *gstack)
-{
- bNodeSocket *gin, *gout;
- bNodeStack *nsin, *nsout;
-
- gin = ngroup->inputs.first;
- gout = ngroup->outputs.first;
-
- while (gin && gout) {
- /* skip static (non-looping) sockets */
- while (gin && !(gin->flag & SOCK_DYNAMIC))
- gin=gin->next;
- while (gout && !(gout->flag & SOCK_DYNAMIC))
- gout=gout->next;
-
- if (gin && gout) {
- nsin = node_get_socket_stack(gstack, gin);
- nsout = node_get_socket_stack(gstack, gout);
-
- move_stack(nsin, nsout);
-
- gin=gin->next;
- gout=gout->next;
- }
- }
-}
-
-static void forloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out)
-{
- bNodeTreeExec *exec= (bNodeTreeExec *)nodedata;
- int totiterations= (int)in[0]->vec[0];
- bNodeSocket *sock;
- bNodeStack *ns;
- int iteration;
-
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode=exec->nodetree->nodes.first; inode; inode=inode->next)
- inode->need_exec = 1;
- }
-
- /* "Iteration" socket */
- sock = exec->nodetree->inputs.first;
- ns = node_get_socket_stack(exec->stack, sock);
-
- group_copy_inputs(node, in, exec->stack);
- for (iteration=0; iteration < totiterations; ++iteration) {
- /* first input contains current iteration counter */
- ns->vec[0] = (float)iteration;
-
- if (iteration > 0)
- loop_iteration_reset(exec->nodetree, exec->stack);
- ntreeExecNodes(exec, data, thread);
- group_free_internal(exec);
- }
- group_move_outputs(node, out, exec->stack);
-}
-
-void register_node_type_cmp_forloop(bNodeTreeType *ttype)
-{
- static bNodeType ntype;
-
- node_type_base(ttype, &ntype, NODE_FORLOOP, "For", NODE_CLASS_GROUP, NODE_OPTIONS);
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 200);
- node_type_label(&ntype, node_group_label);
- node_type_init(&ntype, node_forloop_init);
- node_type_valid(&ntype, node_group_valid);
- node_type_template(&ntype, node_forloop_template);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_tree(&ntype, node_forloop_init_tree, node_loop_update_tree);
- node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear);
- node_type_exec_new(&ntype, group_initexec, group_freeexec, forloop_execute);
-
- nodeRegisterType(ttype, &ntype);
-}
-#endif
-
-
-/**** WHILE LOOP ****/
-
-#if 0 /* XXX loop nodes don't work nicely with current trees */
-static void whileloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out)
-{
- bNodeTreeExec *exec= (bNodeTreeExec *)nodedata;
- int condition= (in[0]->vec[0] > 0.0f);
- bNodeSocket *sock;
- bNodeStack *ns;
- int iteration;
-
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode=exec->nodetree->nodes.first; inode; inode=inode->next)
- inode->need_exec = 1;
- }
-
- /* "Condition" socket */
- sock = exec->nodetree->outputs.first;
- ns = node_get_socket_stack(exec->stack, sock);
-
- iteration = 0;
- group_copy_inputs(node, in, exec->stack);
- while (condition && iteration < node->custom1) {
- if (iteration > 0)
- loop_iteration_reset(exec->nodetree, exec->stack);
- ntreeExecNodes(exec, data, thread);
- group_free_internal(exec);
-
-// PRINT_BUFFERS(exec);
-
- condition = (ns->vec[0] > 0.0f);
- ++iteration;
- }
- group_move_outputs(node, out, exec->stack);
-}
-
-void register_node_type_cmp_whileloop(bNodeTreeType *ttype)
-{
- static bNodeType ntype;
-
- node_type_base(ttype, &ntype, NODE_WHILELOOP, "While", NODE_CLASS_GROUP, NODE_OPTIONS);
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 200);
- node_type_label(&ntype, node_group_label);
- node_type_init(&ntype, node_whileloop_init);
- node_type_valid(&ntype, node_group_valid);
- node_type_template(&ntype, node_whileloop_template);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_tree(&ntype, node_whileloop_init_tree, node_loop_update_tree);
- node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear);
- node_type_exec_new(&ntype, group_initexec, group_freeexec, whileloop_execute);
-
- nodeRegisterType(ttype, &ntype);
-}
-#endif
-
-#endif /* WITH_COMPOSITOR_LEGACY */
diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c
index dadc863873d..cb932b6a8de 100644
--- a/source/blender/nodes/composite/nodes/node_composite_composite.c
+++ b/source/blender/nodes/composite/nodes/node_composite_composite.c
@@ -32,7 +32,7 @@
#include "node_composite_util.h"
/* **************** COMPOSITE ******************** */
-static bNodeSocketTemplate cmp_node_composite_in[]= {
+static bNodeSocketTemplate cmp_node_composite_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Z"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
@@ -110,7 +110,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype)
#endif
/* Do not allow muting for this node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c
index 9b1483d95cf..ad51fae1998 100644
--- a/source/blender/nodes/composite/nodes/node_composite_crop.c
+++ b/source/blender/nodes/composite/nodes/node_composite_crop.c
@@ -34,11 +34,11 @@
/* **************** Crop ******************** */
-static bNodeSocketTemplate cmp_node_crop_in[]= {
+static bNodeSocketTemplate cmp_node_crop_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_crop_out[]= {
+static bNodeSocketTemplate cmp_node_crop_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -82,7 +82,7 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack
outputrect.ymin=MIN2(ntxy->y1, ntxy->y2);
if (node->custom1) {
- /* this option crops the image size too */
+ /* this option crops the image size too */
stackbuf= get_cropped_compbuf(&outputrect, cbuf->rect, cbuf->x, cbuf->y, cbuf->type);
}
else {
diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c
index 1948709ec84..a1999ec8887 100644
--- a/source/blender/nodes/composite/nodes/node_composite_curves.c
+++ b/source/blender/nodes/composite/nodes/node_composite_curves.c
@@ -36,7 +36,7 @@
/* **************** CURVE Time ******************** */
/* custom1 = sfra, custom2 = efra */
-static bNodeSocketTemplate cmp_node_time_out[]= {
+static bNodeSocketTemplate cmp_node_time_out[] = {
{ SOCK_FLOAT, 0, N_("Fac")},
{ -1, 0, "" }
};
@@ -55,7 +55,7 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack *
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
- out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f);
+ out[0]->vec[0] = CLAMPIS(fac, 0.0f, 1.0f);
}
#endif /* WITH_COMPOSITOR_LEGACY */
@@ -86,12 +86,12 @@ void register_node_type_cmp_curve_time(bNodeTreeType *ttype)
/* **************** CURVE VEC ******************** */
-static bNodeSocketTemplate cmp_node_curve_vec_in[]= {
+static bNodeSocketTemplate cmp_node_curve_vec_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_curve_vec_out[]= {
+static bNodeSocketTemplate cmp_node_curve_vec_out[] = {
{ SOCK_VECTOR, 0, N_("Vector")},
{ -1, 0, "" }
};
@@ -132,7 +132,7 @@ void register_node_type_cmp_curve_vec(bNodeTreeType *ttype)
/* **************** CURVE RGB ******************** */
-static bNodeSocketTemplate cmp_node_curve_rgb_in[]= {
+static bNodeSocketTemplate cmp_node_curve_rgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Black Level"), 0.0f, 0.0f, 0.0f, 1.0f},
@@ -140,7 +140,7 @@ static bNodeSocketTemplate cmp_node_curve_rgb_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_curve_rgb_out[]= {
+static bNodeSocketTemplate cmp_node_curve_rgb_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -151,7 +151,7 @@ static void do_curves(bNode *node, float *out, float *in)
{
curvemapping_initialize(node->storage);
curvemapping_evaluate_premulRGBF(node->storage, out, in);
- out[3]= in[3];
+ out[3] = in[3];
}
static void do_curves_fac(bNode *node, float *out, float *in, float *fac)
@@ -166,11 +166,11 @@ static void do_curves_fac(bNode *node, float *out, float *in, float *fac)
else {
float col[4], mfac= 1.0f-*fac;
curvemapping_evaluate_premulRGBF(node->storage, col, in);
- out[0]= mfac*in[0] + *fac*col[0];
- out[1]= mfac*in[1] + *fac*col[1];
- out[2]= mfac*in[2] + *fac*col[2];
+ out[0] = mfac*in[0] + *fac*col[0];
+ out[1] = mfac*in[1] + *fac*col[1];
+ out[2] = mfac*in[2] + *fac*col[2];
}
- out[3]= in[3];
+ out[3] = in[3];
}
static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c
index 1a9852264bf..27ce0f7c4a7 100644
--- a/source/blender/nodes/composite/nodes/node_composite_defocus.c
+++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c
@@ -34,12 +34,12 @@
#include <limits.h>
/* ************ qdn: Defocus node ****************** */
-static bNodeSocketTemplate cmp_node_defocus_in[]= {
+static bNodeSocketTemplate cmp_node_defocus_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_defocus_out[]= {
+static bNodeSocketTemplate cmp_node_defocus_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -338,7 +338,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
// fast blur...
// bug #6656 part 1, probably when previous node_composite.c was split into separate files, it was not properly updated
// to include recent cvs commits (well, at least not defocus node), so this part was missing...
- wt = minf(nqd->maxblur, aperture * 128.0f);
+ wt = min_ff(nqd->maxblur, aperture * 128.0f);
IIR_gauss_single(crad, wt);
IIR_gauss_single(wts, wt);
@@ -589,8 +589,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
// n-agonal
int ov, nv;
float mind, maxd, lwt;
- ys = maxi((int)floor(bkh_b[2] * ct_crad + y), 0);
- ye = mini((int)ceil(bkh_b[3] * ct_crad + y), new->y - 1);
+ ys = max_ii((int)floor(bkh_b[2] * ct_crad + y), 0);
+ ye = min_ii((int)ceil(bkh_b[3] * ct_crad + y), new->y - 1);
for (sy=ys; sy<=ye; sy++) {
float fxs = 1e10f, fxe = -1e10f;
float yf = (sy - y)/ct_crad;
@@ -861,7 +861,7 @@ static void node_composit_exec_defocus(void *UNUSED(data), bNode *node, bNodeSta
if (node->exec & NODE_BREAK) {
free_compbuf(new);
new= NULL;
- }
+ }
out[0]->data = new;
if (zbuf_use && (zbuf_use != zbuf)) free_compbuf(zbuf_use);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.c b/source/blender/nodes/composite/nodes/node_composite_despeckle.c
index 21b703dc9a8..9d47e4bc276 100644
--- a/source/blender/nodes/composite/nodes/node_composite_despeckle.c
+++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.c
@@ -32,12 +32,12 @@
#include "node_composite_util.h"
/* **************** FILTER ******************** */
-static bNodeSocketTemplate cmp_node_despeckle_in[]= {
+static bNodeSocketTemplate cmp_node_despeckle_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_despeckle_out[]= {
+static bNodeSocketTemplate cmp_node_despeckle_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c
index ed43baef420..014b72d3c60 100644
--- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c
@@ -33,13 +33,13 @@
#include "node_composite_util.h"
/* ******************* channel Difference Matte ********************************* */
-static bNodeSocketTemplate cmp_node_diff_matte_in[]={
+static bNodeSocketTemplate cmp_node_diff_matte_in[] = {
{SOCK_RGBA, 1, N_("Image 1"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, 1, N_("Image 2"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_diff_matte_out[]={
+static bNodeSocketTemplate cmp_node_diff_matte_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{SOCK_FLOAT, 0, N_("Matte")},
{-1, 0, ""}
@@ -76,7 +76,7 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float *
}
/*only change if more transparent than either image */
- maxInputAlpha=maxf(inColor1[3], inColor2[3]);
+ maxInputAlpha=max_ff(inColor1[3], inColor2[3]);
if (alpha < maxInputAlpha) {
/*clamp*/
if (alpha < 0.0f) alpha = 0.0f;
diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c
index f53c64b990a..9787c9f7145 100644
--- a/source/blender/nodes/composite/nodes/node_composite_dilate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c
@@ -54,28 +54,28 @@ static void morpho_dilate(CompBuf *cbuf)
for (y = 0; y < cbuf->y; y++) {
for (x = 0; x < cbuf->x - 1; x++) {
p = rectf + cbuf->x * y + x;
- *p = maxf(*p, *(p + 1));
+ *p = max_ff(*p, *(p + 1));
}
}
for (y = 0; y < cbuf->y; y++) {
for (x = cbuf->x - 1; x >= 1; x--) {
p = rectf + cbuf->x * y + x;
- *p = maxf(*p, *(p - 1));
+ *p = max_ff(*p, *(p - 1));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = 0; y < cbuf->y - 1; y++) {
p = rectf + cbuf->x * y + x;
- *p = maxf(*p, *(p + cbuf->x));
+ *p = max_ff(*p, *(p + cbuf->x));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = cbuf->y - 1; y >= 1; y--) {
p = rectf + cbuf->x * y + x;
- *p = maxf(*p, *(p - cbuf->x));
+ *p = max_ff(*p, *(p - cbuf->x));
}
}
}
@@ -88,28 +88,28 @@ static void morpho_erode(CompBuf *cbuf)
for (y = 0; y < cbuf->y; y++) {
for (x = 0; x < cbuf->x - 1; x++) {
p = rectf + cbuf->x * y + x;
- *p = minf(*p, *(p + 1));
+ *p = min_ff(*p, *(p + 1));
}
}
for (y = 0; y < cbuf->y; y++) {
for (x = cbuf->x - 1; x >= 1; x--) {
p = rectf + cbuf->x * y + x;
- *p = minf(*p, *(p - 1));
+ *p = min_ff(*p, *(p - 1));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = 0; y < cbuf->y - 1; y++) {
p = rectf + cbuf->x * y + x;
- *p = minf(*p, *(p + cbuf->x));
+ *p = min_ff(*p, *(p + cbuf->x));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = cbuf->y - 1; y >= 1; y--) {
p = rectf + cbuf->x * y + x;
- *p = minf(*p, *(p - cbuf->x));
+ *p = min_ff(*p, *(p - cbuf->x));
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c
index 51ccc2a4d39..c07ad0a0c97 100644
--- a/source/blender/nodes/composite/nodes/node_composite_displace.c
+++ b/source/blender/nodes/composite/nodes/node_composite_displace.c
@@ -35,14 +35,14 @@
/* **************** Displace ******************** */
-static bNodeSocketTemplate cmp_node_displace_in[]= {
+static bNodeSocketTemplate cmp_node_displace_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_VECTOR, 1, N_("Vector"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_TRANSLATION},
{ SOCK_FLOAT, 1, N_("X Scale"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Y Scale"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f, PROP_FACTOR},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_displace_out[]= {
+static bNodeSocketTemplate cmp_node_displace_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -113,8 +113,8 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf *
dxt = p_dx - d_dx;
dyt = p_dy - d_dy;
- dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x;
- dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y;
+ dxt = signf(dxt)*max_ff(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x;
+ dyt = signf(dyt)*max_ff(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y;
ibuf_sample(ibuf, u, v, dxt, dyt, col);
qd_setPixel(stackbuf, x, y, col);
diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c
index 7a101ff43b5..7e605865cd2 100644
--- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c
@@ -33,13 +33,13 @@
#include "node_composite_util.h"
/* ******************* channel Distance Matte ********************************* */
-static bNodeSocketTemplate cmp_node_distance_matte_in[]={
+static bNodeSocketTemplate cmp_node_distance_matte_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, 1, N_("Key Color"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_distance_matte_out[]={
+static bNodeSocketTemplate cmp_node_distance_matte_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{SOCK_FLOAT, 0, N_("Matte")},
{-1, 0, ""}
@@ -159,9 +159,9 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac
workbuf=dupalloc_compbuf(inbuf);
/*use the input color*/
- c->key[0]= in[1]->vec[0];
- c->key[1]= in[1]->vec[1];
- c->key[2]= in[1]->vec[2];
+ c->key[0] = in[1]->vec[0];
+ c->key[1] = in[1]->vec[1];
+ c->key[2] = in[1]->vec[2];
/* work in RGB color space */
if (c->channel == 1) {
diff --git a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c
index 63a54efea74..3c1e3ee443e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c
@@ -32,12 +32,12 @@
/* **************** Double Edge Mask ******************** */
-static bNodeSocketTemplate cmp_node_doubleedgemask_in[]= {
+static bNodeSocketTemplate cmp_node_doubleedgemask_in[] = {
{ SOCK_FLOAT, 1, "Inner Mask", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, // inner mask socket definition
{ SOCK_FLOAT, 1, "Outer Mask", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, // outer mask socket definition
{ -1, 0, "" } // input socket array terminator
};
-static bNodeSocketTemplate cmp_node_doubleedgemask_out[]= {
+static bNodeSocketTemplate cmp_node_doubleedgemask_out[] = {
{ SOCK_FLOAT, 0, "Mask"}, // output socket definition
{ -1, 0, "" } // output socket array terminator
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
index a97322a17c0..761b0b13f11 100644
--- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
@@ -1,6 +1,4 @@
/*
- * $Id: CMP_math.c 36271 2011-04-21 13:11:51Z campbellbarton $
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -35,15 +33,15 @@
#include "../node_composite_util.h"
/* **************** SCALAR MATH ******************** */
-static bNodeSocketTemplate cmp_node_ellipsemask_in[]= {
+static bNodeSocketTemplate cmp_node_ellipsemask_in[] = {
{ SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_ellipsemask_out[]= {
+static bNodeSocketTemplate cmp_node_ellipsemask_out[] = {
{ SOCK_FLOAT, 0, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+ { -1, 0, "" }
};
static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c
index 0b12c03682b..a27116ab077 100644
--- a/source/blender/nodes/composite/nodes/node_composite_filter.c
+++ b/source/blender/nodes/composite/nodes/node_composite_filter.c
@@ -33,12 +33,12 @@
#include "node_composite_util.h"
/* **************** FILTER ******************** */
-static bNodeSocketTemplate cmp_node_filter_in[]= {
+static bNodeSocketTemplate cmp_node_filter_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_filter_out[]= {
+static bNodeSocketTemplate cmp_node_filter_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -73,10 +73,10 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac)
for (c=0; c<3; c++) {
f1= filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8];
f2= filter[0]*row1[0] + filter[3]*row1[4] + filter[6]*row1[8] + filter[1]*row2[0] + filter[4]*row2[4] + filter[7]*row2[8] + filter[2]*row3[0] + filter[5]*row3[4] + filter[8]*row3[8];
- fp[0]= mfac*row2[4] + fac*sqrt(f1*f1 + f2*f2);
+ fp[0] = mfac*row2[4] + fac*sqrt(f1*f1 + f2*f2);
fp++; row1++; row2++; row3++;
}
- fp[0]= row2[4];
+ fp[0] = row2[4];
/* no alpha... will clear it completely */
fp++; row1++; row2++; row3++;
}
@@ -87,7 +87,7 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac)
for (x=2; x<rowlen; x++) {
f1= filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2];
f2= filter[0]*row1[0] + filter[3]*row1[1] + filter[6]*row1[2] + filter[1]*row2[0] + filter[4]*row2[1] + filter[7]*row2[2] + filter[2]*row3[0] + filter[5]*row3[1] + filter[8]*row3[2];
- fp[0]= mfac*row2[1] + fac*sqrt(f1*f1 + f2*f2);
+ fp[0] = mfac*row2[1] + fac*sqrt(f1*f1 + f2*f2);
fp++; row1++; row2++; row3++;
}
}
@@ -116,28 +116,28 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac)
fp= out->rect + pixlen*(y)*rowlen;
if (pixlen==1) {
- fp[0]= row2[0];
+ fp[0] = row2[0];
fp+= 1;
for (x=2; x<rowlen; x++) {
- fp[0]= mfac*row2[1] + fac*(filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]);
+ fp[0] = mfac*row2[1] + fac*(filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]);
fp++; row1++; row2++; row3++;
}
- fp[0]= row2[1];
+ fp[0] = row2[1];
}
else if (pixlen==2) {
- fp[0]= row2[0];
- fp[1]= row2[1];
+ fp[0] = row2[0];
+ fp[1] = row2[1];
fp+= 2;
for (x=2; x<rowlen; x++) {
for (c=0; c<2; c++) {
- fp[0]= mfac*row2[2] + fac*(filter[0]*row1[0] + filter[1]*row1[2] + filter[2]*row1[4] + filter[3]*row2[0] + filter[4]*row2[2] + filter[5]*row2[4] + filter[6]*row3[0] + filter[7]*row3[2] + filter[8]*row3[4]);
+ fp[0] = mfac*row2[2] + fac*(filter[0]*row1[0] + filter[1]*row1[2] + filter[2]*row1[4] + filter[3]*row2[0] + filter[4]*row2[2] + filter[5]*row2[4] + filter[6]*row3[0] + filter[7]*row3[2] + filter[8]*row3[4]);
fp++; row1++; row2++; row3++;
}
}
- fp[0]= row2[2];
- fp[1]= row2[3];
+ fp[0] = row2[2];
+ fp[1] = row2[3];
}
else if (pixlen==3) {
copy_v3_v3(fp, row2);
@@ -145,7 +145,7 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac)
for (x=2; x<rowlen; x++) {
for (c=0; c<3; c++) {
- fp[0]= mfac*row2[3] + fac*(filter[0]*row1[0] + filter[1]*row1[3] + filter[2]*row1[6] + filter[3]*row2[0] + filter[4]*row2[3] + filter[5]*row2[6] + filter[6]*row3[0] + filter[7]*row3[3] + filter[8]*row3[6]);
+ fp[0] = mfac*row2[3] + fac*(filter[0]*row1[0] + filter[1]*row1[3] + filter[2]*row1[6] + filter[3]*row2[0] + filter[4]*row2[3] + filter[5]*row2[6] + filter[6]*row3[0] + filter[7]*row3[3] + filter[8]*row3[6]);
fp++; row1++; row2++; row3++;
}
}
@@ -157,7 +157,7 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac)
for (x=2; x<rowlen; x++) {
for (c=0; c<4; c++) {
- fp[0]= mfac*row2[4] + fac*(filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]);
+ fp[0] = mfac*row2[4] + fac*(filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]);
fp++; row1++; row2++; row3++;
}
}
@@ -169,13 +169,13 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac)
static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- static float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
- float sharp[9]= {-1, -1, -1, -1, 9, -1, -1, -1, -1};
- float laplace[9]= {-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f};
- float sobel[9]= {1, 2, 1, 0, 0, 0, -1, -2, -1};
- float prewitt[9]= {1, 1, 1, 0, 0, 0, -1, -1, -1};
- float kirsch[9]= {5, 5, 5, -3, -3, -3, -2, -2, -2};
- float shadow[9]= {1, 2, 1, 0, 1, 0, -1, -2, -1};
+ static float soft[9] = {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
+ float sharp[9] = {-1, -1, -1, -1, 9, -1, -1, -1, -1};
+ float laplace[9] = {-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f};
+ float sobel[9] = {1, 2, 1, 0, 0, 0, -1, -2, -1};
+ float prewitt[9] = {1, 1, 1, 0, 0, 0, -1, -1, -1};
+ float kirsch[9] = {5, 5, 5, -3, -3, -3, -2, -2, -2};
+ float shadow[9] = {1, 2, 1, 0, 1, 0, -1, -2, -1};
if (out[0]->hasoutput==0) return;
diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c
index 147e7591af7..4aa98d173e7 100644
--- a/source/blender/nodes/composite/nodes/node_composite_flip.c
+++ b/source/blender/nodes/composite/nodes/node_composite_flip.c
@@ -33,12 +33,12 @@
#include "node_composite_util.h"
/* **************** Flip ******************** */
-static bNodeSocketTemplate cmp_node_flip_in[]= {
+static bNodeSocketTemplate cmp_node_flip_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_flip_out[]= {
+static bNodeSocketTemplate cmp_node_flip_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -75,7 +75,7 @@ static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack
outfp += (src_width-1)*src_pix;
for (x=0; x<src_width; x++) {
for (i=0; i<src_pix; i++) {
- outfp[i]= srcfp[i];
+ outfp[i] = srcfp[i];
}
outfp -= src_pix;
srcfp += src_pix;
diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c
index 87155478035..b8c99894301 100644
--- a/source/blender/nodes/composite/nodes/node_composite_gamma.c
+++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c
@@ -35,12 +35,12 @@
/* **************** Gamma Tools ******************** */
-static bNodeSocketTemplate cmp_node_gamma_in[]= {
+static bNodeSocketTemplate cmp_node_gamma_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Gamma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_gamma_out[]= {
+static bNodeSocketTemplate cmp_node_gamma_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c
index 7d6c0cb1a29..950d8a56f58 100644
--- a/source/blender/nodes/composite/nodes/node_composite_glare.c
+++ b/source/blender/nodes/composite/nodes/node_composite_glare.c
@@ -32,11 +32,11 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_glare_in[]= {
+static bNodeSocketTemplate cmp_node_glare_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_glare_out[]= {
+static bNodeSocketTemplate cmp_node_glare_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c
index c8784ceedb7..d52e3d01a32 100644
--- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c
+++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c
@@ -34,12 +34,12 @@
/* **************** Hue Saturation ******************** */
-static bNodeSocketTemplate cmp_node_hue_sat_in[]= {
+static bNodeSocketTemplate cmp_node_hue_sat_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_hue_sat_out[]= {
+static bNodeSocketTemplate cmp_node_hue_sat_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -60,10 +60,10 @@ static void do_hue_sat_fac(bNode *node, float *out, float *in, float *fac)
hsv[2]*= nhs->val;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
- out[0]= mfac*in[0] + *fac*col[0];
- out[1]= mfac*in[1] + *fac*col[1];
- out[2]= mfac*in[2] + *fac*col[2];
- out[3]= in[3];
+ out[0] = mfac*in[0] + *fac*col[0];
+ out[1] = mfac*in[1] + *fac*col[1];
+ out[2] = mfac*in[2] + *fac*col[2];
+ out[3] = in[3];
}
else {
copy_v4_v4(out, in);
@@ -89,7 +89,7 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta
out[0]->data= stackbuf;
- /* get rid of intermediary cbuf if it's extra */
+ /* get rid of intermediary cbuf if it's extra */
if (stackbuf!=cbuf)
free_compbuf(cbuf);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c
index 42077cd5c06..f751dbea8d2 100644
--- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c
+++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c
@@ -32,13 +32,13 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_huecorrect_in[]= {
+static bNodeSocketTemplate cmp_node_huecorrect_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_huecorrect_out[]= {
+static bNodeSocketTemplate cmp_node_huecorrect_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -71,7 +71,7 @@ static void do_huecorrect(bNode *node, float *out, float *in)
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2);
- out[3]= in[3];
+ out[3] = in[3];
}
static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac)
@@ -101,10 +101,10 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac)
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
- out[0]= mfac*in[0] + *fac*rgb[0];
- out[1]= mfac*in[1] + *fac*rgb[1];
- out[2]= mfac*in[2] + *fac*rgb[2];
- out[3]= in[3];
+ out[0] = mfac*in[0] + *fac*rgb[0];
+ out[1] = mfac*in[1] + *fac*rgb[1];
+ out[2] = mfac*in[2] + *fac*rgb[2];
+ out[3] = in[3];
}
static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c
index 31a3a765ebe..ef0c5021192 100644
--- a/source/blender/nodes/composite/nodes/node_composite_idMask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c
@@ -35,11 +35,11 @@
/* **************** ID Mask ******************** */
-static bNodeSocketTemplate cmp_node_idmask_in[]= {
+static bNodeSocketTemplate cmp_node_idmask_in[] = {
{ SOCK_FLOAT, 1, N_("ID value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_idmask_out[]= {
+static bNodeSocketTemplate cmp_node_idmask_out[] = {
{ SOCK_FLOAT, 0, N_("Alpha")},
{ -1, 0, "" }
};
@@ -56,14 +56,14 @@ static void do_idmask(CompBuf *stackbuf, CompBuf *cbuf, float idnr)
rect= cbuf->rect;
for (x= cbuf->x*cbuf->y - 1; x>=0; x--)
if (rect[x]==idnr)
- abuf[x]= 255;
+ abuf[x] = 255;
antialias_tagbuf(cbuf->x, cbuf->y, abuf);
rect= stackbuf->rect;
for (x= cbuf->x*cbuf->y - 1; x>=0; x--)
if (abuf[x]>1)
- rect[x]= (1.0f/255.0f)*(float)abuf[x];
+ rect[x] = (1.0f/255.0f)*(float)abuf[x];
MEM_freeN(abuf);
}
@@ -78,7 +78,7 @@ static void do_idmask_fsa(CompBuf *stackbuf, CompBuf *cbuf, float idnr)
rs= stackbuf->rect;
for (x= cbuf->x*cbuf->y - 1; x>=0; x--)
if (rect[x]==idnr)
- rs[x]= 1.0f;
+ rs[x] = 1.0f;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 9f3874560ac..150382c1f8f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -34,7 +34,7 @@
/* **************** IMAGE (and RenderResult, multilayer image) ******************** */
-static bNodeSocketTemplate cmp_node_rlayers_out[]= {
+static bNodeSocketTemplate cmp_node_rlayers_out[] = {
{ SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Z"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
@@ -505,7 +505,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE
generate_preview(data, node, stackbuf);
}
}
- }
+ }
}
#endif /* WITH_COMPOSITOR_LEGACY */
diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c
index b0e656b173b..2db6e42f603 100644
--- a/source/blender/nodes/composite/nodes/node_composite_invert.c
+++ b/source/blender/nodes/composite/nodes/node_composite_invert.c
@@ -32,15 +32,15 @@
#include "node_composite_util.h"
/* **************** INVERT ******************** */
-static bNodeSocketTemplate cmp_node_invert_in[]= {
- { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_invert_in[] = {
+ { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_invert_out[]= {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_invert_out[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
};
#ifdef WITH_COMPOSITOR_LEGACY
diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
index e16b7e5d885..96e905827cb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
+++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
@@ -96,21 +96,24 @@ static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keying
int j;
zero_v3(site->color);
- for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
- if (pattern_ibuf->rect_float) {
- add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
- }
- else {
- unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
- site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
- site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
- site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ if (pattern_ibuf) {
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
}
- }
- mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
- IMB_freeImBuf(pattern_ibuf);
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+ }
site->co[0] = marker->pos[0] * screenbuf->x;
site->co[1] = marker->pos[1] * screenbuf->y;
diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c
index a4983cce8b8..c3f64f0eacb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c
+++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c
@@ -32,13 +32,13 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_lensdist_in[]= {
+static bNodeSocketTemplate cmp_node_lensdist_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Distort"), 0.f, 0.f, 0.f, 0.f, -0.999f, 1.f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Dispersion"), 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_lensdist_out[]= {
+static bNodeSocketTemplate cmp_node_lensdist_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -74,7 +74,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb
qd_getPixelLerpChan(tsrc, (u*dst->x - kr) - 0.5f, v*dst->y - 0.5f, 2, colp[x]+2);
/* set alpha */
- colp[x][3]= 1.0f;
+ colp[x][3] = 1.0f;
}
}
free_compbuf(tsrc);
@@ -159,7 +159,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb
if (db) colp[x][2] = 2.f*tc[2] / (float)db;
/* set alpha */
- colp[x][3]= 1.0f;
+ colp[x][3] = 1.0f;
}
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c
index 601516c5bb0..57d94d6cb4d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_levels.c
+++ b/source/blender/nodes/composite/nodes/node_composite_levels.c
@@ -34,12 +34,12 @@
/* **************** LEVELS ******************** */
-static bNodeSocketTemplate cmp_node_view_levels_in[]= {
+static bNodeSocketTemplate cmp_node_view_levels_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_view_levels_out[]={
+static bNodeSocketTemplate cmp_node_view_levels_out[] = {
{SOCK_FLOAT, 0, N_("Mean")},
{SOCK_FLOAT, 0, N_("Std Dev")},
{-1, 0, ""}
@@ -101,7 +101,7 @@ static void fill_bins(bNode *node, CompBuf* in, int* bins)
bins[ivalue]+=1;
} /*end if alpha */
}
- }
+ }
}
static float brightness_mean(bNode *node, CompBuf* in)
@@ -275,8 +275,8 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack *
if (in[0]->hasinput==0) return;
if (in[0]->data==NULL) return;
- histogram=alloc_compbuf(256, 256, CB_RGBA, 1);
- cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
+ histogram=alloc_compbuf(256, 256, CB_RGBA, 1);
+ cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
/*initalize bins*/
for (x=0; x<256; x++) {
@@ -300,9 +300,9 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack *
#endif
if (out[0]->hasoutput)
- out[0]->vec[0]= mean;
+ out[0]->vec[0] = mean;
if (out[1]->hasoutput)
- out[1]->vec[0]= std_dev;
+ out[1]->vec[0] = std_dev;
generate_preview(data, node, histogram);
diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c
index 61cd4493f39..ed232933139 100644
--- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c
@@ -34,12 +34,12 @@
/* ******************* Luma Matte Node ********************************* */
-static bNodeSocketTemplate cmp_node_luma_matte_in[]={
+static bNodeSocketTemplate cmp_node_luma_matte_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}
};
-static bNodeSocketTemplate cmp_node_luma_matte_out[]={
+static bNodeSocketTemplate cmp_node_luma_matte_out[] = {
{SOCK_RGBA, 0, N_("Image")},
{SOCK_FLOAT, 0, N_("Matte")},
{-1, 0, ""}
diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c
index 04d2eaff4f4..40092a84367 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c
@@ -34,12 +34,12 @@
/* **************** Map UV ******************** */
-static bNodeSocketTemplate cmp_node_mapuv_in[]= {
+static bNodeSocketTemplate cmp_node_mapuv_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_VECTOR, 1, N_("UV"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_mapuv_out[]= {
+static bNodeSocketTemplate cmp_node_mapuv_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -135,7 +135,7 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr
}
}
- IMB_freeImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c
index be69c11b35f..677d5bd5013 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c
@@ -33,11 +33,11 @@
#include "node_composite_util.h"
/* **************** MAP VALUE ******************** */
-static bNodeSocketTemplate cmp_node_map_value_in[]= {
+static bNodeSocketTemplate cmp_node_map_value_in[] = {
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_map_value_out[]= {
+static bNodeSocketTemplate cmp_node_map_value_out[] = {
{ SOCK_FLOAT, 0, N_("Value")},
{ -1, 0, "" }
};
@@ -48,13 +48,13 @@ static void do_map_value(bNode *node, float *out, float *src)
{
TexMapping *texmap= node->storage;
- out[0]= (src[0] + texmap->loc[0])*texmap->size[0];
+ out[0] = (src[0] + texmap->loc[0])*texmap->size[0];
if (texmap->flag & TEXMAP_CLIP_MIN)
if (out[0]<texmap->min[0])
- out[0]= texmap->min[0];
+ out[0] = texmap->min[0];
if (texmap->flag & TEXMAP_CLIP_MAX)
if (out[0]>texmap->max[0])
- out[0]= texmap->max[0];
+ out[0] = texmap->max[0];
}
static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c
index 1bddfe0852a..5bc67adf5fb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_math.c
+++ b/source/blender/nodes/composite/nodes/node_composite_math.c
@@ -33,15 +33,15 @@
#include "node_composite_util.h"
/* **************** SCALAR MATH ******************** */
-static bNodeSocketTemplate cmp_node_math_in[]= {
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_math_in[] = {
+ { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_math_out[]= {
- { SOCK_FLOAT, 0, N_("Value")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_math_out[] = {
+ { SOCK_FLOAT, 0, N_("Value")},
+ { -1, 0, "" }
};
#ifdef WITH_COMPOSITOR_LEGACY
@@ -50,63 +50,64 @@ static void do_math(bNode *node, float *out, float *in, float *in2)
{
switch (node->custom1) {
case 0: /* Add */
- out[0]= in[0] + in2[0];
+ out[0] = in[0] + in2[0];
break;
case 1: /* Subtract */
- out[0]= in[0] - in2[0];
+ out[0] = in[0] - in2[0];
break;
case 2: /* Multiply */
- out[0]= in[0] * in2[0];
+ out[0] = in[0] * in2[0];
break;
case 3: /* Divide */
{
if (in2[0]==0) /* We don't want to divide by zero. */
- out[0]= 0.0;
+ out[0] = 0.0;
else
- out[0]= in[0] / in2[0];
+ out[0] = in[0] / in2[0];
}
break;
case 4: /* Sine */
- out[0]= sin(in[0]);
+ out[0] = sin(in[0]);
break;
case 5: /* Cosine */
- out[0]= cos(in[0]);
+ out[0] = cos(in[0]);
break;
case 6: /* Tangent */
- out[0]= tan(in[0]);
+ out[0] = tan(in[0]);
break;
case 7: /* Arc-Sine */
{
/* Can't do the impossible... */
if (in[0] <= 1 && in[0] >= -1 )
- out[0]= asin(in[0]);
+ out[0] = asin(in[0]);
else
- out[0]= 0.0;
+ out[0] = 0.0;
}
break;
case 8: /* Arc-Cosine */
{
/* Can't do the impossible... */
if ( in[0] <= 1 && in[0] >= -1 )
- out[0]= acos(in[0]);
+ out[0] = acos(in[0]);
else
- out[0]= 0.0;
+ out[0] = 0.0;
}
break;
case 9: /* Arc-Tangent */
- out[0]= atan(in[0]);
+ out[0] = atan(in[0]);
break;
case 10: /* Power */
{
/* Only raise negative numbers by full integers */
if ( in[0] >= 0 ) {
- out[0]= pow(in[0], in2[0]);
+ out[0] = pow(in[0], in2[0]);
}
else {
- float y_mod_1 = fmod(in2[0], 1);
+ float y_mod_1 = fabsf(fmodf(in2[0], 1.0f));
+
/* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
- out[0]= powf(in[0], floorf(in2[0] + 0.5f));
+ out[0] = powf(in[0], floorf(in2[0] + 0.5f));
}
else {
out[0] = 0.0f;
@@ -118,50 +119,50 @@ static void do_math(bNode *node, float *out, float *in, float *in2)
{
/* Don't want any imaginary numbers... */
if ( in[0] > 0 && in2[0] > 0 )
- out[0]= log(in[0]) / log(in2[0]);
+ out[0] = log(in[0]) / log(in2[0]);
else
- out[0]= 0.0;
+ out[0] = 0.0;
}
break;
case 12: /* Minimum */
{
if ( in[0] < in2[0] )
- out[0]= in[0];
+ out[0] = in[0];
else
- out[0]= in2[0];
+ out[0] = in2[0];
}
break;
case 13: /* Maximum */
{
if ( in[0] > in2[0] )
- out[0]= in[0];
+ out[0] = in[0];
else
- out[0]= in2[0];
+ out[0] = in2[0];
}
break;
case 14: /* Round */
{
/* round by the second value */
if ( in2[0] != 0.0f )
- out[0]= floorf(in[0] / in2[0] + 0.5f) * in2[0];
+ out[0] = floorf(in[0] / in2[0] + 0.5f) * in2[0];
else
- out[0]= floorf(in[0] + 0.5f);
+ out[0] = floorf(in[0] + 0.5f);
}
break;
case 15: /* Less Than */
{
if ( in[0] < in2[0] )
- out[0]= 1.0f;
+ out[0] = 1.0f;
else
- out[0]= 0.0f;
+ out[0] = 0.0f;
}
break;
case 16: /* Greater Than */
{
if ( in[0] > in2[0] )
- out[0]= 1.0f;
+ out[0] = 1.0f;
else
- out[0]= 0.0f;
+ out[0] = 0.0f;
}
break;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c
index e2c9a5abcb1..5d3ee480612 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c
@@ -32,13 +32,13 @@
#include "node_composite_util.h"
/* **************** MIX RGB ******************** */
-static bNodeSocketTemplate cmp_node_mix_rgb_in[]= {
+static bNodeSocketTemplate cmp_node_mix_rgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_mix_rgb_out[]= {
+static bNodeSocketTemplate cmp_node_mix_rgb_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -55,7 +55,7 @@ static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *f
else
ramp_blend(node->custom1, col, fac[0], in2);
copy_v3_v3(out, col);
- out[3]= in1[3];
+ out[3] = in1[3];
}
static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c
index 6f1e86e2760..93fd7ca1c1b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_normal.c
+++ b/source/blender/nodes/composite/nodes/node_composite_normal.c
@@ -34,12 +34,12 @@
/* **************** NORMAL ******************** */
-static bNodeSocketTemplate cmp_node_normal_in[]= {
+static bNodeSocketTemplate cmp_node_normal_in[] = {
{ SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_normal_out[]= {
+static bNodeSocketTemplate cmp_node_normal_out[] = {
{ SOCK_VECTOR, 0, N_("Normal")},
{ SOCK_FLOAT, 0, N_("Dot")},
{ -1, 0, "" }
@@ -53,7 +53,7 @@ static void do_normal(bNode *node, float *out, float *in)
float *nor= ((bNodeSocketValueVector*)sock->default_value)->value;
/* render normals point inside... the widget points outside */
- out[0]= -dot_v3v3(nor, in);
+ out[0] = -dot_v3v3(nor, in);
}
/* generates normal, does dot product */
@@ -68,7 +68,7 @@ static void node_composit_exec_normal(void *UNUSED(data), bNode *node, bNodeStac
if (in[0]->data==NULL) {
copy_v3_v3(out[0]->vec, nor);
/* render normals point inside... the widget points outside */
- out[1]->vec[0]= -dot_v3v3(out[0]->vec, in[0]->vec);
+ out[1]->vec[0] = -dot_v3v3(out[0]->vec, in[0]->vec);
}
else if (out[1]->hasoutput) {
/* make output size of input image */
diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c
index 1d2312d8280..19b543dce5d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_normalize.c
+++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c
@@ -34,11 +34,11 @@
/* **************** NORMALIZE single channel, useful for Z buffer ******************** */
-static bNodeSocketTemplate cmp_node_normalize_in[]= {
+static bNodeSocketTemplate cmp_node_normalize_in[] = {
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_normalize_out[]= {
+static bNodeSocketTemplate cmp_node_normalize_out[] = {
{ SOCK_FLOAT, 0, N_("Value")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_pixelate.c b/source/blender/nodes/composite/nodes/node_composite_pixelate.c
new file mode 100644
index 00000000000..5eac4867a23
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_pixelate.c
@@ -0,0 +1,57 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Jeroen Bakker
+ * Monique Dewanchand
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_pixelate.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "node_composite_util.h"
+
+
+/* **************** Pixelate ******************** */
+
+static bNodeSocketTemplate cmp_node_pixelate_in[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { -1, 0, "" }
+};
+static bNodeSocketTemplate cmp_node_pixelate_out[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
+};
+
+void register_node_type_cmp_pixelate(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_PIXELATE, "Pixelate", NODE_CLASS_OP_FILTER, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_pixelate_in, cmp_node_pixelate_out);
+ node_type_size(&ntype, 130, 100, 130);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c
index d791983b069..7f7b7692b02 100644
--- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c
+++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c
@@ -35,11 +35,11 @@
/* **************** Premul and Key Alpha Convert ******************** */
-static bNodeSocketTemplate cmp_node_premulkey_in[]= {
+static bNodeSocketTemplate cmp_node_premulkey_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_premulkey_out[]= {
+static bNodeSocketTemplate cmp_node_premulkey_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c
index 65c1dcdb7bb..54fba650783 100644
--- a/source/blender/nodes/composite/nodes/node_composite_rgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c
@@ -34,7 +34,7 @@
/* **************** RGB ******************** */
-static bNodeSocketTemplate cmp_node_rgb_out[]= {
+static bNodeSocketTemplate cmp_node_rgb_out[] = {
{ SOCK_RGBA, 0, N_("RGBA"), 0.5f, 0.5f, 0.5f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c
index 8968fd5fb3a..9a76764b97e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_rotate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c
@@ -34,12 +34,12 @@
/* **************** Rotate ******************** */
-static bNodeSocketTemplate cmp_node_rotate_in[]= {
+static bNodeSocketTemplate cmp_node_rotate_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Degr"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_ANGLE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_rotate_out[]= {
+static bNodeSocketTemplate cmp_node_rotate_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c
index ebc18cd19eb..f1a75493718 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c
@@ -34,11 +34,11 @@
/* **************** SEPARATE HSVA ******************** */
-static bNodeSocketTemplate cmp_node_sephsva_in[]= {
+static bNodeSocketTemplate cmp_node_sephsva_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_sephsva_out[]= {
+static bNodeSocketTemplate cmp_node_sephsva_out[] = {
{ SOCK_FLOAT, 0, N_("H")},
{ SOCK_FLOAT, 0, N_("S")},
{ SOCK_FLOAT, 0, N_("V")},
@@ -54,10 +54,10 @@ static void do_sephsva(bNode *UNUSED(node), float *out, float *in)
rgb_to_hsv(in[0], in[1], in[2], &h, &s, &v);
- out[0]= h;
- out[1]= s;
- out[2]= v;
- out[3]= in[3];
+ out[0] = h;
+ out[1] = s;
+ out[2] = v;
+ out[3] = in[3];
}
static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
@@ -97,7 +97,7 @@ static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeSta
/*not used anymore */
if (cbuf2!=cbuf)
free_compbuf(cbuf2);
- free_compbuf(cbuf);
+ free_compbuf(cbuf);
}
}
@@ -126,7 +126,7 @@ static bNodeSocketTemplate cmp_node_combhsva_in[] = {
{ SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_combhsva_out[]= {
+static bNodeSocketTemplate cmp_node_combhsva_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c
index 0c989ed3fc6..83b2c731020 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c
@@ -33,11 +33,11 @@
#include "node_composite_util.h"
/* **************** SEPARATE RGBA ******************** */
-static bNodeSocketTemplate cmp_node_seprgba_in[]= {
+static bNodeSocketTemplate cmp_node_seprgba_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_seprgba_out[]= {
+static bNodeSocketTemplate cmp_node_seprgba_out[] = {
{ SOCK_FLOAT, 0, N_("R")},
{ SOCK_FLOAT, 0, N_("G")},
{ SOCK_FLOAT, 0, N_("B")},
@@ -98,14 +98,14 @@ void register_node_type_cmp_seprgba(bNodeTreeType *ttype)
/* **************** COMBINE RGBA ******************** */
-static bNodeSocketTemplate cmp_node_combrgba_in[]= {
+static bNodeSocketTemplate cmp_node_combrgba_in[] = {
{ SOCK_FLOAT, 1, N_("R"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("G"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("B"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_combrgba_out[]= {
+static bNodeSocketTemplate cmp_node_combrgba_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -150,7 +150,7 @@ static void node_composit_exec_combrgba(void *UNUSED(data), bNode *node, bNodeSt
do_combrgba, CB_VAL, CB_VAL, CB_VAL, CB_VAL);
out[0]->data= stackbuf;
- }
+ }
}
#endif /* WITH_COMPOSITOR_LEGACY */
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
index ccae7cfe57f..982d674708c 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
@@ -34,11 +34,11 @@
/* **************** SEPARATE YCCA ******************** */
-static bNodeSocketTemplate cmp_node_sepycca_in[]= {
+static bNodeSocketTemplate cmp_node_sepycca_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_sepycca_out[]= {
+static bNodeSocketTemplate cmp_node_sepycca_out[] = {
{ SOCK_FLOAT, 0, N_("Y")},
{ SOCK_FLOAT, 0, N_("Cb")},
{ SOCK_FLOAT, 0, N_("Cr")},
@@ -55,10 +55,10 @@ static void do_sepycca_601(bNode *UNUSED(node), float *out, float *in)
rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_ITU_BT601);
/*divided by 255 to normalize for viewing in */
- out[0]= y/255.0f;
- out[1]= cb/255.0f;
- out[2]= cr/255.0f;
- out[3]= in[3];
+ out[0] = y/255.0f;
+ out[1] = cb/255.0f;
+ out[2] = cr/255.0f;
+ out[3] = in[3];
}
static void do_sepycca_709(bNode *UNUSED(node), float *out, float *in)
@@ -68,10 +68,10 @@ static void do_sepycca_709(bNode *UNUSED(node), float *out, float *in)
rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_ITU_BT709);
/*divided by 255 to normalize for viewing in */
- out[0]= y/255.0f;
- out[1]= cb/255.0f;
- out[2]= cr/255.0f;
- out[3]= in[3];
+ out[0] = y/255.0f;
+ out[1] = cb/255.0f;
+ out[2] = cr/255.0f;
+ out[3] = in[3];
}
static void do_sepycca_jfif(bNode *UNUSED(node), float *out, float *in)
@@ -81,10 +81,10 @@ static void do_sepycca_jfif(bNode *UNUSED(node), float *out, float *in)
rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_JFIF_0_255);
/*divided by 255 to normalize for viewing in */
- out[0]= y/255.0f;
- out[1]= cb/255.0f;
- out[2]= cr/255.0f;
- out[3]= in[3];
+ out[0] = y/255.0f;
+ out[1] = cb/255.0f;
+ out[2] = cr/255.0f;
+ out[3] = in[3];
}
static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
@@ -167,14 +167,14 @@ void register_node_type_cmp_sepycca(bNodeTreeType *ttype)
/* **************** COMBINE YCCA ******************** */
-static bNodeSocketTemplate cmp_node_combycca_in[]= {
+static bNodeSocketTemplate cmp_node_combycca_in[] = {
{ SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Cb"), 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Cr"), 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_combycca_out[]= {
+static bNodeSocketTemplate cmp_node_combycca_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
@@ -296,7 +296,7 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt
}
out[0]->data= stackbuf;
- }
+ }
}
#endif /* WITH_COMPOSITOR_LEGACY */
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
index 9b8c805b0f0..0a9575971b4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
@@ -34,11 +34,11 @@
/* **************** SEPARATE YUVA ******************** */
-static bNodeSocketTemplate cmp_node_sepyuva_in[]= {
+static bNodeSocketTemplate cmp_node_sepyuva_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_sepyuva_out[]= {
+static bNodeSocketTemplate cmp_node_sepyuva_out[] = {
{ SOCK_FLOAT, 0, N_("Y")},
{ SOCK_FLOAT, 0, N_("U")},
{ SOCK_FLOAT, 0, N_("V")},
@@ -54,10 +54,10 @@ static void do_sepyuva(bNode *UNUSED(node), float *out, float *in)
rgb_to_yuv(in[0], in[1], in[2], &y, &u, &v);
- out[0]= y;
- out[1]= u;
- out[2]= v;
- out[3]= in[3];
+ out[0] = y;
+ out[1] = u;
+ out[2] = v;
+ out[3] = in[3];
}
static void node_composit_exec_sepyuva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
@@ -121,14 +121,14 @@ void register_node_type_cmp_sepyuva(bNodeTreeType *ttype)
/* **************** COMBINE YUVA ******************** */
-static bNodeSocketTemplate cmp_node_combyuva_in[]= {
+static bNodeSocketTemplate cmp_node_combyuva_in[] = {
{ SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("U"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("V"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_combyuva_out[]= {
+static bNodeSocketTemplate cmp_node_combyuva_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c
index 503815b74a0..59c104869fe 100644
--- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c
+++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c
@@ -33,12 +33,12 @@
#include "node_composite_util.h"
/* **************** SET ALPHA ******************** */
-static bNodeSocketTemplate cmp_node_setalpha_in[]= {
+static bNodeSocketTemplate cmp_node_setalpha_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_setalpha_out[]= {
+static bNodeSocketTemplate cmp_node_setalpha_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
index f6811f526f7..73cf039c6df 100644
--- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
@@ -33,7 +33,7 @@
#include "node_composite_util.h"
/* **************** SPLIT VIEWER ******************** */
-static bNodeSocketTemplate cmp_node_splitviewer_in[]= {
+static bNodeSocketTemplate cmp_node_splitviewer_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
@@ -167,7 +167,7 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype)
#endif
/* Do not allow muting for this node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
index fdf0b38e844..1787e075a14 100644
--- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
+++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
@@ -35,12 +35,12 @@
/* **************** Translate ******************** */
-static bNodeSocketTemplate cmp_node_stabilize2d_in[]= {
+static bNodeSocketTemplate cmp_node_stabilize2d_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_stabilize2d_out[]= {
+static bNodeSocketTemplate cmp_node_stabilize2d_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.c b/source/blender/nodes/composite/nodes/node_composite_switch.c
index 258fac18c11..7f9127c969f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switch.c
+++ b/source/blender/nodes/composite/nodes/node_composite_switch.c
@@ -34,13 +34,13 @@
#include "../node_composite_util.h"
/* **************** MIX RGB ******************** */
-static bNodeSocketTemplate cmp_node_switch_in[]= {
+static bNodeSocketTemplate cmp_node_switch_in[] = {
{ SOCK_RGBA, 1, N_("Off"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, N_("On"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_switch_out[]= {
+static bNodeSocketTemplate cmp_node_switch_out[] = {
{ SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c
index 3fedccd7d12..b6518c48638 100644
--- a/source/blender/nodes/composite/nodes/node_composite_texture.c
+++ b/source/blender/nodes/composite/nodes/node_composite_texture.c
@@ -33,12 +33,12 @@
#include "node_composite_util.h"
/* **************** TEXTURE ******************** */
-static bNodeSocketTemplate cmp_node_texture_in[]= {
+static bNodeSocketTemplate cmp_node_texture_in[] = {
{ SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_TRANSLATION},
{ SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 1.0f, -10.0f, 10.0f, PROP_XYZ},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_texture_out[]= {
+static bNodeSocketTemplate cmp_node_texture_out[] = {
{ SOCK_FLOAT, 0, N_("Value")},
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
@@ -51,28 +51,28 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco)
{
bNode *node= cbuf->node;
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float vec[3], *size, nor[3]={0.0f, 0.0f, 0.0f}, col[4];
+ float vec[3], *size, nor[3] = {0.0f, 0.0f, 0.0f}, col[4];
int retval, type= cbuf->procedural_type;
size= cbuf->procedural_size;
- vec[0]= size[0]*(xco + cbuf->procedural_offset[0]);
- vec[1]= size[1]*(yco + cbuf->procedural_offset[1]);
- vec[2]= size[2]*cbuf->procedural_offset[2];
+ vec[0] = size[0]*(xco + cbuf->procedural_offset[0]);
+ vec[1] = size[1]*(yco + cbuf->procedural_offset[1]);
+ vec[2] = size[2]*cbuf->procedural_offset[2];
retval= multitex_ext((Tex *)node->id, vec, NULL, NULL, 0, &texres);
if (type==CB_VAL) {
if (texres.talpha)
- col[0]= texres.ta;
+ col[0] = texres.ta;
else
- col[0]= texres.tin;
+ col[0] = texres.tin;
}
else if (type==CB_RGBA) {
if (texres.talpha)
- col[3]= texres.ta;
+ col[3] = texres.ta;
else
- col[3]= texres.tin;
+ col[3] = texres.tin;
if ((retval & TEX_RGB)) {
copy_v3_v3(col, &texres.tr);
@@ -81,7 +81,7 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco)
copy_v3_fl(col, col[3]);
}
}
- else {
+ else {
copy_v3_v3(col, nor);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
index 5e4efe2f3b1..00b1a5514dc 100644
--- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c
+++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
@@ -32,11 +32,11 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_tonemap_in[]= {
+static bNodeSocketTemplate cmp_node_tonemap_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_tonemap_out[]= {
+static bNodeSocketTemplate cmp_node_tonemap_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c
index 649902ff908..1c2963a2f08 100644
--- a/source/blender/nodes/composite/nodes/node_composite_translate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_translate.c
@@ -35,13 +35,13 @@
/* **************** Translate ******************** */
-static bNodeSocketTemplate cmp_node_translate_in[]= {
+static bNodeSocketTemplate cmp_node_translate_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("X"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_translate_out[]= {
+static bNodeSocketTemplate cmp_node_translate_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
index 87a776c7bea..5c111998b18 100644
--- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
@@ -34,11 +34,11 @@
/* **************** VALTORGB ******************** */
-static bNodeSocketTemplate cmp_node_valtorgb_in[]= {
+static bNodeSocketTemplate cmp_node_valtorgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_valtorgb_out[]= {
+static bNodeSocketTemplate cmp_node_valtorgb_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ SOCK_FLOAT, 0, N_("Alpha")},
{ -1, 0, "" }
@@ -106,11 +106,11 @@ void register_node_type_cmp_valtorgb(bNodeTreeType *ttype)
/* **************** RGBTOBW ******************** */
-static bNodeSocketTemplate cmp_node_rgbtobw_in[]= {
+static bNodeSocketTemplate cmp_node_rgbtobw_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_rgbtobw_out[]= {
+static bNodeSocketTemplate cmp_node_rgbtobw_out[] = {
{ SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_value.c b/source/blender/nodes/composite/nodes/node_composite_value.c
index 63ab4fcb58f..2c65fe6be19 100644
--- a/source/blender/nodes/composite/nodes/node_composite_value.c
+++ b/source/blender/nodes/composite/nodes/node_composite_value.c
@@ -33,7 +33,7 @@
#include "node_composite_util.h"
/* **************** VALUE ******************** */
-static bNodeSocketTemplate cmp_node_value_out[]= {
+static bNodeSocketTemplate cmp_node_value_out[] = {
/* XXX value nodes use the output sockets for buttons, so we need explicit limits here! */
{ SOCK_FLOAT, 0, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
{ -1, 0, "" }
@@ -56,7 +56,7 @@ static void node_composit_exec_value(void *UNUSED(data), bNode *node, bNodeStack
bNodeSocket *sock= node->outputs.first;
float val= ((bNodeSocketValueFloat*)sock->default_value)->value;
- out[0]->vec[0]= val;
+ out[0]->vec[0] = val;
}
#endif /* WITH_COMPOSITOR_LEGACY */
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c
index 6321b1def4d..938f75cf3f5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -149,7 +149,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype)
node_type_exec(&ntype, node_composit_exec_viewer);
#endif
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c
index 3decbe8d230..8e639aaa357 100644
--- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c
+++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c
@@ -35,14 +35,14 @@
/* **************** Z COMBINE ******************** */
/* lazy coder note: node->custom2 is abused to send signal */
-static bNodeSocketTemplate cmp_node_zcombine_in[]= {
+static bNodeSocketTemplate cmp_node_zcombine_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE},
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_zcombine_out[]= {
+static bNodeSocketTemplate cmp_node_zcombine_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ SOCK_FLOAT, 0, N_("Z")},
{ -1, 0, "" }
@@ -60,10 +60,10 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float *
// use alpha in combine operation
alpha= src1[3];
malpha= 1.0f - alpha;
- out[0]= malpha*src2[0] + alpha*src1[0];
- out[1]= malpha*src2[1] + alpha*src1[1];
- out[2]= malpha*src2[2] + alpha*src1[2];
- out[3]= malpha*src2[3] + alpha*src1[3];
+ out[0] = malpha*src2[0] + alpha*src1[0];
+ out[1] = malpha*src2[1] + alpha*src1[1];
+ out[2] = malpha*src2[2] + alpha*src1[2];
+ out[3] = malpha*src2[3] + alpha*src1[3];
}
else {
// do combination based solely on z value
@@ -75,10 +75,10 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float *
// use alpha in combine operation
alpha= src2[3];
malpha= 1.0f - alpha;
- out[0]= malpha*src1[0] + alpha*src2[0];
- out[1]= malpha*src1[1] + alpha*src2[1];
- out[2]= malpha*src1[2] + alpha*src2[2];
- out[3]= malpha*src1[3] + alpha*src2[3];
+ out[0] = malpha*src1[0] + alpha*src2[0];
+ out[1] = malpha*src1[1] + alpha*src2[1];
+ out[2] = malpha*src1[2] + alpha*src2[2];
+ out[3] = malpha*src1[3] + alpha*src2[3];
}
else {
// do combination based solely on z value
@@ -111,20 +111,20 @@ static void do_zcombine_add(bNode *node, float *out, float *col1, float *col2, f
malpha= 1.0f - alpha;
- out[0]= malpha*col1[0] + alpha*col2[0];
- out[1]= malpha*col1[1] + alpha*col2[1];
- out[2]= malpha*col1[2] + alpha*col2[2];
- out[3]= malpha*col1[3] + alpha*col2[3];
+ out[0] = malpha*col1[0] + alpha*col2[0];
+ out[1] = malpha*col1[1] + alpha*col2[1];
+ out[2] = malpha*col1[2] + alpha*col2[2];
+ out[3] = malpha*col1[3] + alpha*col2[3];
}
else {
alpha= col1[3];
malpha= 1.0f - alpha;
- out[0]= malpha*col2[0] + alpha*col1[0];
- out[1]= malpha*col2[1] + alpha*col1[1];
- out[2]= malpha*col2[2] + alpha*col1[2];
- out[3]= malpha*col2[3] + alpha*col1[3];
+ out[0] = malpha*col2[0] + alpha*col1[0];
+ out[1] = malpha*col2[1] + alpha*col1[1];
+ out[2] = malpha*col2[2] + alpha*col1[2];
+ out[3] = malpha*col2[3] + alpha*col1[3];
}
}
else {
@@ -132,10 +132,10 @@ static void do_zcombine_add(bNode *node, float *out, float *col1, float *col2, f
alpha = *acol;
malpha= 1.0f - alpha;
- out[0]= malpha*col1[0] + alpha*col2[0];
- out[1]= malpha*col1[1] + alpha*col2[1];
- out[2]= malpha*col1[2] + alpha*col2[2];
- out[3]= malpha*col1[3] + alpha*col2[3];
+ out[0] = malpha*col1[0] + alpha*col2[0];
+ out[1] = malpha*col1[1] + alpha*col2[1];
+ out[2] = malpha*col1[2] + alpha*col2[2];
+ out[3] = malpha*col1[3] + alpha*col2[3];
}
}
@@ -202,8 +202,8 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in
aabuf= MEM_mallocN(cbuf->x*cbuf->y, "aa buf");
fp= mbuf->rect;
for (x= cbuf->x*cbuf->y-1; x>=0; x--)
- if (fp[x]==0.0f) aabuf[x]= 0;
- else aabuf[x]= 255;
+ if (fp[x]==0.0f) aabuf[x] = 0;
+ else aabuf[x] = 255;
antialias_tagbuf(cbuf->x, cbuf->y, aabuf);
@@ -211,7 +211,7 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in
fp= mbuf->rect;
for (x= cbuf->x*cbuf->y-1; x>=0; x--)
if (aabuf[x]>1)
- fp[x]= (1.0f/255.0f)*(float)aabuf[x];
+ fp[x] = (1.0f/255.0f)*(float)aabuf[x];
composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[2]->data, in[2]->vec, mbuf, NULL,
do_zcombine_add, CB_RGBA, CB_RGBA, CB_VAL);
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 301dea22c17..86ef8a14c12 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -92,7 +92,7 @@ bNodeSocket *node_group_add_extern_socket(bNodeTree *UNUSED(ntree), ListBase *lb
sock->new_sock = NULL;
/* group sockets are dynamically added */
- sock->flag |= SOCK_DYNAMIC;
+ sock->flag |= SOCK_DYNAMIC|SOCK_COLLAPSED;
sock->own_index = gsock->own_index;
sock->groupsock = gsock;
@@ -115,7 +115,7 @@ bNodeSocket *node_group_add_socket(bNodeTree *ngroup, const char *name, int type
BLI_strncpy(gsock->name, name, sizeof(gsock->name));
gsock->type = type;
/* group sockets are dynamically added */
- gsock->flag |= SOCK_DYNAMIC;
+ gsock->flag |= SOCK_DYNAMIC|SOCK_COLLAPSED;
gsock->next = gsock->prev = NULL;
gsock->new_sock = NULL;
@@ -354,168 +354,6 @@ static void UNUSED_FUNCTION(node_group_link)(bNodeTree *ntree, bNodeSocket *sock
node_group_expose_socket(ntree, sock, in_out);
}
-/**** For Loop ****/
-
-/* Essentially a group node with slightly different behavior.
- * The internal tree is executed several times, with each output being re-used
- * as an input in the next iteration. For this purpose, input and output socket
- * lists are kept identical!
- */
-
-bNodeTemplate node_forloop_template(bNode *node)
-{
- bNodeTemplate ntemp;
- ntemp.type = NODE_FORLOOP;
- ntemp.ngroup = (bNodeTree*)node->id;
- return ntemp;
-}
-
-void node_forloop_init(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp)
-{
- bNodeSocket *sock;
-
- node->id = (ID*)ntemp->ngroup;
-
- sock = nodeAddSocket(ntree, node, SOCK_IN, "Iterations", SOCK_FLOAT);
- node_socket_set_default_value_float(sock->default_value, PROP_UNSIGNED, 1, 0, 10000);
-
- /* NB: group socket input/output roles are inverted internally!
- * Group "inputs" work as outputs in links and vice versa.
- */
- if (ntemp->ngroup) {
- bNodeSocket *gsock;
- for (gsock=ntemp->ngroup->inputs.first; gsock; gsock=gsock->next)
- node_group_add_extern_socket(ntree, &node->inputs, SOCK_IN, gsock);
- for (gsock=ntemp->ngroup->outputs.first; gsock; gsock=gsock->next)
- node_group_add_extern_socket(ntree, &node->outputs, SOCK_OUT, gsock);
- }
-}
-
-void node_forloop_init_tree(bNodeTree *ntree)
-{
- bNodeSocket *sock;
- sock = node_group_add_socket(ntree, "Iteration", SOCK_FLOAT, SOCK_IN);
- sock->flag |= SOCK_INTERNAL;
-}
-
-static void loop_sync(bNodeTree *ntree, int sync_in_out)
-{
- bNodeSocket *sock, *sync, *nsync, *mirror;
- ListBase *sync_lb;
-
- if (sync_in_out==SOCK_IN) {
- sock = ntree->outputs.first;
-
- sync = ntree->inputs.first;
- sync_lb = &ntree->inputs;
- }
- else {
- sock = ntree->inputs.first;
-
- sync = ntree->outputs.first;
- sync_lb = &ntree->outputs;
- }
-
- /* NB: the sock->storage pointer is used here directly to store the own_index int
- * out the mirrored socket counterpart!
- */
-
- while (sock) {
- /* skip static and internal sockets on the sync side (preserves socket order!) */
- while (sync && ((sync->flag & SOCK_INTERNAL) || !(sync->flag & SOCK_DYNAMIC)))
- sync = sync->next;
-
- if (sync && !(sync->flag & SOCK_INTERNAL) && (sync->flag & SOCK_DYNAMIC)) {
- if (sock->storage==NULL) {
- /* if mirror index is 0, the sockets is newly added and a new mirror must be created. */
- mirror = node_group_expose_socket(ntree, sock, sync_in_out);
- /* store the mirror index */
- sock->storage = SET_INT_IN_POINTER(mirror->own_index);
- mirror->storage = SET_INT_IN_POINTER(sock->own_index);
- /* move mirror to the right place */
- BLI_remlink(sync_lb, mirror);
- if (sync)
- BLI_insertlinkbefore(sync_lb, sync, mirror);
- else
- BLI_addtail(sync_lb, mirror);
- }
- else {
- /* look up the mirror socket */
- for (mirror=sync; mirror; mirror=mirror->next)
- if (mirror->own_index == GET_INT_FROM_POINTER(sock->storage))
- break;
- /* make sure the name is the same (only for identification by user, no deeper meaning) */
- BLI_strncpy(mirror->name, sock->name, sizeof(mirror->name));
- /* fix the socket order if necessary */
- if (mirror != sync) {
- BLI_remlink(sync_lb, mirror);
- BLI_insertlinkbefore(sync_lb, sync, mirror);
- }
- else
- sync = sync->next;
- }
- }
-
- sock = sock->next;
- }
-
- /* remaining sockets in sync_lb are leftovers from deleted sockets, remove them */
- while (sync) {
- nsync = sync->next;
- if (!(sync->flag & SOCK_INTERNAL) && (sync->flag & SOCK_DYNAMIC))
- node_group_remove_socket(ntree, sync, sync_in_out);
- sync = nsync;
- }
-}
-
-void node_loop_update_tree(bNodeTree *ngroup)
-{
- /* make sure inputs & outputs are identical */
- if (ngroup->update & NTREE_UPDATE_GROUP_IN)
- loop_sync(ngroup, SOCK_OUT);
- if (ngroup->update & NTREE_UPDATE_GROUP_OUT)
- loop_sync(ngroup, SOCK_IN);
-}
-
-void node_whileloop_init(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp)
-{
- bNodeSocket *sock;
-
- node->id = (ID*)ntemp->ngroup;
-
- sock = nodeAddSocket(ntree, node, SOCK_IN, "Condition", SOCK_FLOAT);
- node_socket_set_default_value_float(sock->default_value, PROP_NONE, 1, 0, 1);
-
- /* max iterations */
- node->custom1 = 10000;
-
- /* NB: group socket input/output roles are inverted internally!
- * Group "inputs" work as outputs in links and vice versa.
- */
- if (ntemp->ngroup) {
- bNodeSocket *gsock;
- for (gsock=ntemp->ngroup->inputs.first; gsock; gsock=gsock->next)
- node_group_add_extern_socket(ntree, &node->inputs, SOCK_IN, gsock);
- for (gsock=ntemp->ngroup->outputs.first; gsock; gsock=gsock->next)
- node_group_add_extern_socket(ntree, &node->outputs, SOCK_OUT, gsock);
- }
-}
-
-void node_whileloop_init_tree(bNodeTree *ntree)
-{
- bNodeSocket *sock;
- sock = node_group_add_socket(ntree, "Condition", SOCK_FLOAT, SOCK_OUT);
- sock->flag |= SOCK_INTERNAL;
-}
-
-bNodeTemplate node_whileloop_template(bNode *node)
-{
- bNodeTemplate ntemp;
- ntemp.type = NODE_WHILELOOP;
- ntemp.ngroup = (bNodeTree*)node->id;
- return ntemp;
-}
-
/**** FRAME ****/
static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
@@ -547,16 +385,13 @@ void register_node_type_frame(bNodeTreeType *ttype)
/* **************** REROUTE ******************** */
/* simple, only a single input and output here */
-static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
+static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node)
{
bNodeLink *link;
- ListBase ret;
-
- ret.first = ret.last = NULL;
/* Security check! */
if (!ntree)
- return ret;
+ return;
link = MEM_callocN(sizeof(bNodeLink), "internal node link");
link->fromnode = node;
@@ -565,9 +400,7 @@ static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
link->tosock = node->outputs.first;
/* internal link is always valid */
link->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, link);
-
- return ret;
+ BLI_addtail(&node->internal_links, link);
}
static void node_reroute_init(bNodeTree *ntree, bNode *node, bNodeTemplate *UNUSED(ntemp))
@@ -586,7 +419,7 @@ void register_node_type_reroute(bNodeTreeType *ttype)
node_type_base(ttype, ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0);
node_type_init(ntype, node_reroute_init);
- node_type_internal_connect(ntype, node_reroute_internal_connect);
+ node_type_internal_links(ntype, node_reroute_update_internal_links);
ntype->needs_free = 1;
nodeRegisterType(ttype, ntype);
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index 00f72469b0f..9e04a9e05f8 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -38,18 +38,8 @@
struct bNodeTree;
void node_group_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
-void node_forloop_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
-void node_whileloop_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
-
-void node_forloop_init_tree(struct bNodeTree *ntree);
-void node_whileloop_init_tree(struct bNodeTree *ntree);
-
const char *node_group_label(struct bNode *node);
-
struct bNodeTemplate node_group_template(struct bNode *node);
-struct bNodeTemplate node_forloop_template(struct bNode *node);
-struct bNodeTemplate node_whileloop_template(struct bNode *node);
-
int node_group_valid(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
@@ -57,8 +47,6 @@ struct bNodeTree *node_group_edit_get(struct bNode *node);
struct bNodeTree *node_group_edit_set(struct bNode *node, int edit);
void node_group_edit_clear(bNode *node);
-void node_loop_update_tree(struct bNodeTree *ngroup);
-
void ntree_update_reroute_nodes(struct bNodeTree *ntree);
#endif
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index d01ef2e2d52..3cc7ebf9337 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -69,7 +69,7 @@ void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack
}
}
-void node_init_input_index(bNodeSocket *sock, int *index)
+static void node_init_input_index(bNodeSocket *sock, int *index)
{
if (sock->link && sock->link->fromsock) {
sock->stack_index = sock->link->fromsock->stack_index;
@@ -79,16 +79,31 @@ void node_init_input_index(bNodeSocket *sock, int *index)
}
}
-void node_init_output_index(bNodeSocket *sock, int *index)
+static void node_init_output_index(bNodeSocket *sock, int *index, ListBase *internal_links)
{
- sock->stack_index = (*index)++;
+ if (internal_links) {
+ bNodeLink *link;
+ /* copy the stack index from internally connected input to skip the node */
+ for (link = internal_links->first; link; link = link->next) {
+ if (link->tosock == sock) {
+ sock->stack_index = link->fromsock->stack_index;
+ break;
+ }
+ }
+ /* if not internally connected, assign a new stack index anyway to avoid bad stack access */
+ if (!link)
+ sock->stack_index = (*index)++;
+ }
+ else {
+ sock->stack_index = (*index)++;
+ }
}
/* basic preparation of socket stacks */
static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeSocket *sock)
{
bNodeStack *ns = node_get_socket_stack(stack, sock);
- float null_value[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+ float null_value[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* don't mess with remote socket stacks, these are initialized by other nodes! */
if (sock->link)
@@ -133,7 +148,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
bNodeExec *nodeexec;
bNodeSocket *sock, *gsock;
bNodeStack *ns;
- int index= 0;
+ int index;
bNode **nodelist;
int totnodes, n;
@@ -148,10 +163,11 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
/* backpointer to node tree */
exec->nodetree = ntree;
+ /* set stack indices */
+ index = 0;
/* group inputs essentially work as outputs */
for (gsock=ntree->inputs.first; gsock; gsock = gsock->next)
- node_init_output_index(gsock, &index);
- /* set stack indexes */
+ node_init_output_index(gsock, &index, NULL);
for (n=0; n < totnodes; ++n) {
node = nodelist[n];
@@ -160,8 +176,15 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
/* init node socket stack indexes */
for (sock=node->inputs.first; sock; sock=sock->next)
node_init_input_index(sock, &index);
- for (sock=node->outputs.first; sock; sock=sock->next)
- node_init_output_index(sock, &index);
+
+ if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
+ for (sock=node->outputs.first; sock; sock=sock->next)
+ node_init_output_index(sock, &index, &node->internal_links);
+ }
+ else {
+ for (sock=node->outputs.first; sock; sock=sock->next)
+ node_init_output_index(sock, &index, NULL);
+ }
}
/* group outputs essentially work as inputs */
for (gsock=ntree->outputs.first; gsock; gsock = gsock->next)
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 1003206e96a..e985795de71 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -73,8 +73,6 @@ typedef struct bNodeThreadStack {
struct bNodeStack *node_get_socket_stack(struct bNodeStack *stack, struct bNodeSocket *sock);
void node_get_stack(struct bNode *node, struct bNodeStack *stack, struct bNodeStack **in, struct bNodeStack **out);
-void node_init_input_index(struct bNodeSocket *sock, int *index);
-void node_init_output_index(struct bNodeSocket *sock, int *index);
struct bNodeTreeExec *ntree_exec_begin(struct bNodeTree *ntree);
void ntree_exec_end(struct bNodeTreeExec *exec);
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index 8b393dd740a..0335d295fba 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -41,6 +41,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_DerivedMesh.h"
#include "BKE_node.h"
@@ -157,6 +158,20 @@ static bNodeSocketType node_socket_type_mesh = {
/* buttonfunc */ NULL,
};
+/****************** STRING ******************/
+
+static bNodeSocketType node_socket_type_string = {
+ /* type */ SOCK_STRING,
+ /* ui_name */ "String",
+ /* ui_description */ "String",
+ /* ui_icon */ 0,
+ /* ui_color */ {255, 255, 255, 255},
+
+ /* value_structname */ "bNodeSocketValueString",
+ /* value_structsize */ sizeof(bNodeSocketValueString),
+
+ /* buttonfunc */ NULL,
+};
void node_socket_type_init(bNodeSocketType *types[])
{
@@ -169,6 +184,7 @@ void node_socket_type_init(bNodeSocketType *types[])
INIT_TYPE(boolean);
INIT_TYPE(shader);
INIT_TYPE(mesh);
+ INIT_TYPE(string);
#undef INIT_TYPE
}
@@ -218,6 +234,9 @@ void node_socket_init_default_value(int type, void *default_value)
case SOCK_MESH:
node_socket_set_default_value_mesh(default_value);
break;
+ case SOCK_STRING:
+ node_socket_set_default_value_string(default_value, PROP_NONE, (char *)"");
+ break;
}
}
@@ -265,6 +284,13 @@ void node_socket_set_default_value_rgba(void *default_value, float r, float g, f
val->value[3] = a;
}
+void node_socket_set_default_value_string(void *default_value, PropertySubType subtype, const char *value)
+{
+ bNodeSocketValueString *val = default_value;
+ val->subtype = subtype;
+ BLI_strncpy(val->value, value, 1024);//FILE_MAX
+}
+
void node_socket_set_default_value_shader(void *UNUSED(default_value))
{
}
@@ -282,12 +308,14 @@ void node_socket_copy_default_value(int type, void *to_default_value, void *from
bNodeSocketValueBoolean *frombool= (bNodeSocketValueBoolean*)from_default_value;
bNodeSocketValueVector *fromvector= (bNodeSocketValueVector*)from_default_value;
bNodeSocketValueRGBA *fromrgba= (bNodeSocketValueRGBA*)from_default_value;
+ bNodeSocketValueString *fromstring= (bNodeSocketValueString*)from_default_value;
bNodeSocketValueFloat *tofloat= (bNodeSocketValueFloat*)to_default_value;
bNodeSocketValueInt *toint= (bNodeSocketValueInt*)to_default_value;
bNodeSocketValueBoolean *tobool= (bNodeSocketValueBoolean*)to_default_value;
bNodeSocketValueVector *tovector= (bNodeSocketValueVector*)to_default_value;
bNodeSocketValueRGBA *torgba= (bNodeSocketValueRGBA*)to_default_value;
+ bNodeSocketValueString *tostring= (bNodeSocketValueString*)to_default_value;
switch (type) {
case SOCK_FLOAT:
@@ -305,6 +333,9 @@ void node_socket_copy_default_value(int type, void *to_default_value, void *from
case SOCK_RGBA:
*torgba = *fromrgba;
break;
+ case SOCK_STRING:
+ *tostring = *fromstring;
+ break;
}
}
@@ -470,6 +501,9 @@ struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct
case SOCK_MESH:
node_socket_set_default_value_mesh(sock->default_value);
break;
+ case SOCK_STRING:
+ node_socket_set_default_value_string(sock->default_value, stemp->subtype, (char *)"");
+ break;
}
return sock;
@@ -490,39 +524,39 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in
break;
}
if (sock) {
- sock->type= stemp->type; /* in future, read this from tydefs! */
- if (stemp->limit==0) sock->limit= 0xFFF;
- else sock->limit= stemp->limit;
+ sock->type = stemp->type; /* in future, read this from tydefs! */
+ if (stemp->limit == 0) sock->limit= 0xFFF;
+ else sock->limit = stemp->limit;
sock->flag |= stemp->flag;
/* Copy the property range and subtype parameters in case the template changed.
* NOT copying the actual value here, only button behavior changes!
*/
switch (sock->type) {
- case SOCK_FLOAT:
+ case SOCK_FLOAT:
{
bNodeSocketValueFloat *dval= sock->default_value;
dval->min = stemp->min;
dval->max = stemp->max;
dval->subtype = stemp->subtype;
+ break;
}
- break;
- case SOCK_INT:
+ case SOCK_INT:
{
bNodeSocketValueInt *dval= sock->default_value;
dval->min = stemp->min;
dval->max = stemp->max;
dval->subtype = stemp->subtype;
+ break;
}
- break;
- case SOCK_VECTOR:
+ case SOCK_VECTOR:
{
bNodeSocketValueVector *dval= sock->default_value;
dval->min = stemp->min;
dval->max = stemp->max;
dval->subtype = stemp->subtype;
+ break;
}
- break;
}
BLI_remlink(socklist, sock);
@@ -600,7 +634,9 @@ void node_verify_socket_templates(bNodeTree *ntree, bNode *node)
* This also prevents group node sockets from being removed, without the need to explicitly
* check the node type here.
*/
- if (ntype && ((ntype->inputs && ntype->inputs[0].type>=0) || (ntype->outputs && ntype->outputs[0].type>=0))) {
+ if (ntype && ((ntype->inputs && ntype->inputs[0].type >= 0) ||
+ (ntype->outputs && ntype->outputs[0].type >= 0)))
+ {
verify_socket_template_list(ntree, node, SOCK_IN, &node->inputs, ntype->inputs);
verify_socket_template_list(ntree, node, SOCK_OUT, &node->outputs, ntype->outputs);
}
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index 27258c45fe5..09e6ddd18a5 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -65,12 +65,12 @@ void node_free_standard_storage(bNode *node)
void node_copy_curves(bNode *orig_node, bNode *new_node)
{
- new_node->storage= curvemapping_copy(orig_node->storage);
+ new_node->storage = curvemapping_copy(orig_node->storage);
}
void node_copy_standard_storage(bNode *orig_node, bNode *new_node)
{
- new_node->storage= MEM_dupallocN(orig_node->storage);
+ new_node->storage = MEM_dupallocN(orig_node->storage);
}
void *node_initexec_curves(bNode *node)
@@ -109,18 +109,15 @@ const char *node_filter_label(bNode *node)
return IFACE_(name);
}
-ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
+void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
{
- ListBase ret;
bNodeSocket *fromsock_first=NULL, *tosock_first=NULL; /* used for fallback link if no other reconnections are found */
int datatype;
int num_links_in = 0, num_links_out = 0, num_reconnect = 0;
- ret.first = ret.last = NULL;
-
/* Security check! */
if (!ntree)
- return ret;
+ return;
for (datatype=0; datatype < NUM_SOCKET_TYPES; ++datatype) {
bNodeSocket *fromsock, *tosock;
@@ -170,7 +167,7 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
ilink->tosock = tosock;
/* internal link is always valid */
ilink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, ilink);
+ BLI_addtail(&node->internal_links, ilink);
++num_reconnect;
}
@@ -188,8 +185,6 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
ilink->tosock = tosock_first;
/* internal link is always valid */
ilink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, ilink);
+ BLI_addtail(&node->internal_links, ilink);
}
-
- return ret;
}
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index 95104df5fed..3134baa283c 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -62,7 +62,7 @@ const char *node_math_label(struct bNode *node);
const char *node_vect_math_label(struct bNode *node);
const char *node_filter_label(struct bNode *node);
-ListBase node_internal_connect_default(struct bNodeTree *ntree, struct bNode *node);
+void node_update_internal_links_default(struct bNodeTree *ntree, struct bNode *node);
#endif
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index ad907c317f8..b7dc83d7d79 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -87,10 +87,11 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f
func(calldata, NODE_CLASS_SHADER, N_("Shader"));
func(calldata, NODE_CLASS_TEXTURE, N_("Texture"));
}
-
+
func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
+ func(calldata, NODE_CLASS_SCRIPT, N_("Script"));
func(calldata, NODE_CLASS_GROUP, N_("Group"));
func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
}
@@ -153,7 +154,7 @@ bNodeTreeType ntreeType_Shader = {
/* update */ update,
/* update_node */ NULL,
/* validate_link */ NULL,
- /* internal_connect */ node_internal_connect_default
+ /* update_internal_links */ node_update_internal_links_default
};
/* GPU material from shader nodes */
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 56704b981be..6130fe72af3 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -50,9 +50,9 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
}
else if (type_in==SOCK_VECTOR) {
if (ns->sockettype==SOCK_FLOAT) {
- in[0]= from[0];
- in[1]= from[0];
- in[2]= from[0];
+ in[0] = from[0];
+ in[1] = from[0];
+ in[2] = from[0];
}
else {
copy_v3_v3(in, from);
@@ -63,14 +63,14 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
copy_v4_v4(in, from);
}
else if (ns->sockettype==SOCK_FLOAT) {
- in[0]= from[0];
- in[1]= from[0];
- in[2]= from[0];
- in[3]= 1.0f;
+ in[0] = from[0];
+ in[1] = from[0];
+ in[2] = from[0];
+ in[3] = 1.0f;
}
else {
copy_v3_v3(in, from);
- in[3]= 1.0f;
+ in[3] = 1.0f;
}
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.c b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
index ee8513a4119..ec868b2cc38 100644
--- a/source/blender/nodes/shader/nodes/node_shader_add_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
@@ -29,13 +29,13 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_add_shader_in[]= {
+static bNodeSocketTemplate sh_node_add_shader_in[] = {
{ SOCK_SHADER, 1, N_("Shader")},
{ SOCK_SHADER, 1, N_("Shader")},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_add_shader_out[]= {
+static bNodeSocketTemplate sh_node_add_shader_out[] = {
{ SOCK_SHADER, 0, N_("Shader")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
new file mode 100644
index 00000000000..7dfefc9ece0
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -0,0 +1,63 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_ambient_occlusion_in[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_ambient_occlusion_out[] = {
+ { SOCK_SHADER, 0, N_("AO")},
+ { -1, 0, "" }
+};
+
+static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "node_ambient_occlusion", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_ambient_occlusion(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_AMBIENT_OCCLUSION, "Ambient Occlusion", NODE_CLASS_SHADER, 0);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_ambient_occlusion_in, sh_node_ambient_occlusion_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_init(&ntype, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, node_shader_gpu_ambient_occlusion);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 9c65323337e..9b2ed2f14f0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_attribute_out[]= {
+static bNodeSocketTemplate sh_node_attribute_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ SOCK_VECTOR, 0, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
diff --git a/source/blender/nodes/shader/nodes/node_shader_background.c b/source/blender/nodes/shader/nodes/node_shader_background.c
index 7d13c359a2b..d82c513540c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_background.c
+++ b/source/blender/nodes/shader/nodes/node_shader_background.c
@@ -29,13 +29,13 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_background_in[]= {
+static bNodeSocketTemplate sh_node_background_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_background_out[]= {
+static bNodeSocketTemplate sh_node_background_out[] = {
{ SOCK_SHADER, 0, N_("Background")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c
index 2735553cdad..9c23a29cae9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_brightness.c
+++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c
@@ -31,14 +31,14 @@
/* **************** Brigh and contrsast ******************** */
-static bNodeSocketTemplate sh_node_brightcontrast_in[]= {
+static bNodeSocketTemplate sh_node_brightcontrast_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_brightcontrast_out[]= {
+static bNodeSocketTemplate sh_node_brightcontrast_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
index 9157728b546..71780e9316e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -29,21 +29,27 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Roughness U"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Roughness V"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Anisotropy"), 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+ { SOCK_VECTOR, 1, N_("Tangent"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_anisotropic_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_anisotropic_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_anisotropic", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+ if (!in[3].link)
+ in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_anisotropic", in, out);
}
/* node type definition */
@@ -51,7 +57,7 @@ void register_node_type_sh_bsdf_anisotropic(bNodeTreeType *ttype)
{
static bNodeType ntype;
- node_type_base(ttype, &ntype, SH_NODE_BSDF_ANISOTROPIC, "Glossy Anisotropic BSDF", NODE_CLASS_SHADER, 0);
+ node_type_base(ttype, &ntype, SH_NODE_BSDF_ANISOTROPIC, "Anisotropic BSDF", NODE_CLASS_SHADER, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bsdf_anisotropic_in, sh_node_bsdf_anisotropic_out);
node_type_size(&ntype, 150, 60, 200);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
index d2e2db3e78a..ad9f197afb8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
@@ -29,20 +29,24 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_diffuse_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_diffuse_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_diffuse_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_diffuse_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_diffuse", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+ if (!in[2].link)
+ in[2].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_diffuse", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index 8ff0ad57742..9e188092570 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -29,21 +29,25 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_glass_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_glass_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_glass_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_glass_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_glass", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+ if (!in[3].link)
+ in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_glass", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index d28b3454f02..5e32930b707 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -29,21 +29,24 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_glossy_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_glossy_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_glossy_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_glossy_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
{
- /* todo: is incoming vector normalized? */
- return GPU_stack_link(mat, "node_bsdf_glossy", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+ if (!in[2].link)
+ in[2].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_glossy", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
new file mode 100644
index 00000000000..99e66e39002
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -0,0 +1,68 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_refraction_in[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_refraction_out[] = {
+ { SOCK_SHADER, 0, N_("BSDF")},
+ { -1, 0, "" }
+};
+
+static int node_shader_gpu_bsdf_refraction(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ if (!in[3].link)
+ in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_refraction", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_refraction(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_bsdf_refraction_in, sh_node_bsdf_refraction_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_init(&ntype, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, node_shader_gpu_bsdf_refraction);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
index a3ba3ac7ff3..3c7084886b7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
@@ -29,19 +29,23 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_translucent_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_translucent_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_translucent_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_translucent_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_translucent", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+ if (!in[1].link)
+ in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_translucent", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
index 8c945abdd0d..7fb452ad78d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
@@ -29,12 +29,12 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_transparent_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_transparent_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_transparent_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_transparent_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
index 04a1c1b32df..a4d25d42d4e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
@@ -29,20 +29,24 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_bsdf_velvet_in[]= {
+static bNodeSocketTemplate sh_node_bsdf_velvet_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Sigma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_bsdf_velvet_out[]= {
+static bNodeSocketTemplate sh_node_bsdf_velvet_out[] = {
{ SOCK_SHADER, 0, N_("BSDF")},
{ -1, 0, "" }
};
static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_velvet", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+ if (!in[2].link)
+ in[2].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_velvet", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c
new file mode 100644
index 00000000000..b0605f9b248
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_bump.c
@@ -0,0 +1,68 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/shader/nodes/node_shader_bump.c
+ * \ingroup shdnodes
+ */
+
+
+
+#include "node_shader_util.h"
+
+
+/* **************** BUMP ******************** */
+static bNodeSocketTemplate sh_node_bump_in[] = {
+ { SOCK_FLOAT, 1, "Strength", 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+ { SOCK_FLOAT, 1, "Height", 1.0f, 1.0f, 1.0f, 1.0f, -1000.0f, 1000.0f, PROP_NONE, SOCK_HIDE_VALUE},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_bump_out[] = {
+ { SOCK_VECTOR, 0, "Normal"},
+ { -1, 0, "" }
+};
+
+static int gpu_shader_bump(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "node_bump", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_bump(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_BUMP, "Bump", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_bump_in, sh_node_bump_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_storage(&ntype, "BumpNode", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, gpu_shader_bump);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c
index 17cec8196e8..fd36a94516e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_camera.c
+++ b/source/blender/nodes/shader/nodes/node_shader_camera.c
@@ -33,7 +33,7 @@
#include "node_shader_util.h"
/* **************** CAMERA INFO ******************** */
-static bNodeSocketTemplate sh_node_camera_out[]= {
+static bNodeSocketTemplate sh_node_camera_out[] = {
{ SOCK_VECTOR, 0, N_("View Vector")},
{ SOCK_FLOAT, 0, N_("View Z Depth")},
{ SOCK_FLOAT, 0, N_("View Distance")},
@@ -47,8 +47,8 @@ static void node_shader_exec_camera(void *data, bNode *UNUSED(node), bNodeStack
ShadeInput *shi= ((ShaderCallData *)data)->shi; /* Data we need for shading. */
copy_v3_v3(out[0]->vec, shi->co); /* get view vector */
- out[1]->vec[0]= fabs(shi->co[2]); /* get view z-depth */
- out[2]->vec[0]= normalize_v3(out[0]->vec); /* get view distance */
+ out[1]->vec[0] = fabs(shi->co[2]); /* get view z-depth */
+ out[2]->vec[0] = normalize_v3(out[0]->vec); /* get view distance */
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index df369482a2e..688d77d8350 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -204,128 +204,3 @@ void register_node_type_sh_group(bNodeTreeType *ttype)
nodeRegisterType(ttype, &ntype);
}
-
-
-/**** FOR LOOP ****/
-
-#if 0 /* XXX loop nodes don't work nicely with current trees */
-static void forloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out)
-{
- bNodeTreeExec *exec= (bNodeTreeExec*)nodedata;
- bNodeThreadStack *nts;
- int iterations= (int)in[0]->vec[0];
- bNodeSocket *sock;
- bNodeStack *ns;
- int iteration;
-
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode=exec->nodetree->nodes.first; inode; inode=inode->next)
- inode->need_exec = 1;
- }
-
- nts = ntreeGetThreadStack(exec, thread);
-
- /* "Iteration" socket */
- sock = exec->nodetree->inputs.first;
- ns = node_get_socket_stack(nts->stack, sock);
-
-// group_copy_inputs(node, in, nts->stack);
- for (iteration=0; iteration < iterations; ++iteration) {
- /* first input contains current iteration counter */
- ns->vec[0] = (float)iteration;
- ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f;
-
-// if (iteration > 0)
-// loop_init_iteration(exec->nodetree, nts->stack);
-// ntreeExecThreadNodes(exec, nts, data, thread);
- }
-// loop_copy_outputs(node, in, out, exec->stack);
-
- ntreeReleaseThreadStack(nts);
-}
-
-void register_node_type_sh_forloop(bNodeTreeType *ttype)
-{
- static bNodeType ntype;
-
- node_type_base(ttype, &ntype, NODE_FORLOOP, "For", NODE_CLASS_GROUP, NODE_OPTIONS);
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 200);
- node_type_label(&ntype, node_group_label);
- node_type_init(&ntype, node_forloop_init);
- node_type_valid(&ntype, node_group_valid);
- node_type_template(&ntype, node_forloop_template);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_tree(&ntype, node_forloop_init_tree, node_loop_update_tree);
- node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear);
- node_type_exec_new(&ntype, group_initexec, group_freeexec, forloop_execute);
-
- nodeRegisterType(ttype, &ntype);
-}
-#endif
-
-/**** WHILE LOOP ****/
-
-#if 0 /* XXX loop nodes don't work nicely with current trees */
-static void whileloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out)
-{
- bNodeTreeExec *exec= (bNodeTreeExec*)nodedata;
- bNodeThreadStack *nts;
- int condition= (in[0]->vec[0] > 0.0f);
- bNodeSocket *sock;
- bNodeStack *ns;
- int iteration;
-
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode=exec->nodetree->nodes.first; inode; inode=inode->next)
- inode->need_exec = 1;
- }
-
- nts = ntreeGetThreadStack(exec, thread);
-
- /* "Condition" socket */
- sock = exec->nodetree->outputs.first;
- ns = node_get_socket_stack(nts->stack, sock);
-
- iteration = 0;
-// group_copy_inputs(node, in, nts->stack);
- while (condition && iteration < node->custom1) {
-// if (iteration > 0)
-// loop_init_iteration(exec->nodetree, nts->stack);
-// ntreeExecThreadNodes(exec, nts, data, thread);
-
- condition = (ns->vec[0] > 0.0f);
- ++iteration;
- }
-// loop_copy_outputs(node, in, out, exec->stack);
-
- ntreeReleaseThreadStack(nts);
-}
-
-void register_node_type_sh_whileloop(bNodeTreeType *ttype)
-{
- static bNodeType ntype;
-
- node_type_base(ttype, &ntype, NODE_WHILELOOP, "While", NODE_CLASS_GROUP, NODE_OPTIONS);
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 200);
- node_type_label(&ntype, node_group_label);
- node_type_init(&ntype, node_whileloop_init);
- node_type_valid(&ntype, node_group_valid);
- node_type_template(&ntype, node_whileloop_template);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_tree(&ntype, node_whileloop_init_tree, node_loop_update_tree);
- node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear);
- node_type_exec_new(&ntype, group_initexec, group_freeexec, whileloop_execute);
-
- nodeRegisterType(ttype, &ntype);
-}
-#endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index 83cb1d33628..9fa654c9740 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -34,13 +34,13 @@
/* **************** CURVE VEC ******************** */
-static bNodeSocketTemplate sh_node_curve_vec_in[]= {
+static bNodeSocketTemplate sh_node_curve_vec_in[] = {
{ SOCK_FLOAT, 0, N_("Fac"), 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_curve_vec_out[]= {
+static bNodeSocketTemplate sh_node_curve_vec_out[] = {
{ SOCK_VECTOR, 0, N_("Vector")},
{ -1, 0, "" }
};
@@ -88,13 +88,13 @@ void register_node_type_sh_curve_vec(bNodeTreeType *ttype)
/* **************** CURVE RGB ******************** */
-static bNodeSocketTemplate sh_node_curve_rgb_in[]= {
+static bNodeSocketTemplate sh_node_curve_rgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_curve_rgb_out[]= {
+static bNodeSocketTemplate sh_node_curve_rgb_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c
index 4854d887592..0c4cb7ed51c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_emission.c
+++ b/source/blender/nodes/shader/nodes/node_shader_emission.c
@@ -29,13 +29,13 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_emission_in[]= {
+static bNodeSocketTemplate sh_node_emission_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_emission_out[]= {
+static bNodeSocketTemplate sh_node_emission_out[] = {
{ SOCK_SHADER, 0, N_("Emission")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
index 610a2149011..80913e6b07a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
@@ -28,12 +28,12 @@
#include "../node_shader_util.h"
/* **************** Fresnel ******************** */
-static bNodeSocketTemplate sh_node_fresnel_in[]= {
+static bNodeSocketTemplate sh_node_fresnel_in[] = {
{ SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_fresnel_out[]= {
+static bNodeSocketTemplate sh_node_fresnel_out[] = {
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c
index 526868f73d3..c49554c44be 100644
--- a/source/blender/nodes/shader/nodes/node_shader_gamma.c
+++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c
@@ -30,13 +30,13 @@
/* **************** Gamma Tools ******************** */
-static bNodeSocketTemplate sh_node_gamma_in[]= {
+static bNodeSocketTemplate sh_node_gamma_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Gamma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_gamma_out[]= {
+static bNodeSocketTemplate sh_node_gamma_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c
index f23158ab5d4..eb3d462d616 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geom.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geom.c
@@ -37,7 +37,7 @@
/* **************** GEOMETRY ******************** */
/* output socket type definition */
-static bNodeSocketTemplate sh_node_geom_out[]= {
+static bNodeSocketTemplate sh_node_geom_out[] = {
{ SOCK_VECTOR, 0, N_("Global")},
{ SOCK_VECTOR, 0, N_("Local")},
{ SOCK_VECTOR, 0, N_("View")},
@@ -92,12 +92,12 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i
}
copy_v3_v3(out[GEOM_OUT_VCOL]->vec, scol->col);
- out[GEOM_OUT_VCOL]->vec[3]= scol->col[3];
- out[GEOM_OUT_VCOL_ALPHA]->vec[0]= scol->col[3];
+ out[GEOM_OUT_VCOL]->vec[3] = scol->col[3];
+ out[GEOM_OUT_VCOL_ALPHA]->vec[0] = scol->col[3];
}
else {
memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
- out[GEOM_OUT_VCOL_ALPHA]->vec[0]= 1.0f;
+ out[GEOM_OUT_VCOL_ALPHA]->vec[0] = 1.0f;
}
if (shi->osatex) {
@@ -116,7 +116,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i
}
/* front/back, normal flipping was stored */
- out[GEOM_OUT_FRONTBACK]->vec[0]= (shi->flippednor)? 0.0f: 1.0f;
+ out[GEOM_OUT_FRONTBACK]->vec[0] = (shi->flippednor)? 0.0f: 1.0f;
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
index 2ebd93218d6..acef885d2d4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geometry.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_geometry_out[]= {
+static bNodeSocketTemplate sh_node_geometry_out[] = {
{ SOCK_VECTOR, 0, N_("Position"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 0, N_("Tangent"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.c
index dbd4ed8ab67..18ad4994c9b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_holdout.c
+++ b/source/blender/nodes/shader/nodes/node_shader_holdout.c
@@ -29,11 +29,11 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_holdout_in[]= {
+static bNodeSocketTemplate sh_node_holdout_in[] = {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_holdout_out[]= {
+static bNodeSocketTemplate sh_node_holdout_out[] = {
{ SOCK_SHADER, 0, N_("Holdout")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
index b07650e33c0..b635ad1edd9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
@@ -34,7 +34,7 @@
/* **************** Hue Saturation ******************** */
-static bNodeSocketTemplate sh_node_hue_sat_in[]= {
+static bNodeSocketTemplate sh_node_hue_sat_in[] = {
{ SOCK_FLOAT, 1, N_("Hue"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
{ SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR},
@@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_hue_sat_in[]= {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_hue_sat_out[]= {
+static bNodeSocketTemplate sh_node_hue_sat_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
@@ -60,9 +60,9 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float *hue, float *s
hsv[2]*= *val;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
- out[0]= mfac*in[0] + *fac*col[0];
- out[1]= mfac*in[1] + *fac*col[1];
- out[2]= mfac*in[2] + *fac*col[2];
+ out[0] = mfac*in[0] + *fac*col[0];
+ out[1] = mfac*in[1] + *fac*col[1];
+ out[2] = mfac*in[2] + *fac*col[2];
}
else {
copy_v4_v4(out, in);
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c
index ef592a7e2ec..2ea858f4e34 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.c
@@ -35,15 +35,15 @@
/* **************** INVERT ******************** */
-static bNodeSocketTemplate sh_node_invert_in[]= {
- { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_invert_in[] = {
+ { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_invert_out[]= {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_invert_out[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
};
static void node_shader_exec_invert(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in,
diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
index 6eacea10b5b..3058483ebef 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
@@ -29,12 +29,12 @@
/* **************** Layer Weight ******************** */
-static bNodeSocketTemplate sh_node_layer_weight_in[]= {
+static bNodeSocketTemplate sh_node_layer_weight_in[] = {
{ SOCK_FLOAT, 1, N_("Blend"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_layer_weight_out[]= {
+static bNodeSocketTemplate sh_node_layer_weight_out[] = {
{ SOCK_FLOAT, 0, N_("Fresnel"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Facing"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
index aab5fa8060d..2dec244ae3a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
@@ -29,7 +29,7 @@
/* **************** INPUT ********************* */
-static bNodeSocketTemplate sh_node_light_falloff_in[]= {
+static bNodeSocketTemplate sh_node_light_falloff_in[] = {
{ SOCK_FLOAT, 0, N_("Strength"), 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
{ SOCK_FLOAT, 0, N_("Smooth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
@@ -37,7 +37,7 @@ static bNodeSocketTemplate sh_node_light_falloff_in[]= {
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_light_falloff_out[]= {
+static bNodeSocketTemplate sh_node_light_falloff_out[] = {
{ SOCK_FLOAT, 0, N_("Quadratic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Linear"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Constant"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.c
index 264b1390688..b4a3d4e01e1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_path.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_light_path_out[]= {
+static bNodeSocketTemplate sh_node_light_path_out[] = {
{ SOCK_FLOAT, 0, N_("Is Camera Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Is Shadow Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Is Diffuse Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 4508f66543e..cedd3a4910c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -33,12 +33,12 @@
#include "node_shader_util.h"
/* **************** MAPPING ******************** */
-static bNodeSocketTemplate sh_node_mapping_in[]= {
+static bNodeSocketTemplate sh_node_mapping_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_mapping_out[]= {
+static bNodeSocketTemplate sh_node_mapping_out[] = {
{ SOCK_VECTOR, 0, N_("Vector")},
{ -1, 0, "" }
};
@@ -55,14 +55,14 @@ static void node_shader_exec_mapping(void *UNUSED(data), bNode *node, bNodeStack
mul_m4_v3(texmap->mat, vec);
if (texmap->flag & TEXMAP_CLIP_MIN) {
- if (vec[0]<texmap->min[0]) vec[0]= texmap->min[0];
- if (vec[1]<texmap->min[1]) vec[1]= texmap->min[1];
- if (vec[2]<texmap->min[2]) vec[2]= texmap->min[2];
+ if (vec[0]<texmap->min[0]) vec[0] = texmap->min[0];
+ if (vec[1]<texmap->min[1]) vec[1] = texmap->min[1];
+ if (vec[2]<texmap->min[2]) vec[2] = texmap->min[2];
}
if (texmap->flag & TEXMAP_CLIP_MAX) {
- if (vec[0]>texmap->max[0]) vec[0]= texmap->max[0];
- if (vec[1]>texmap->max[1]) vec[1]= texmap->max[1];
- if (vec[2]>texmap->max[2]) vec[2]= texmap->max[2];
+ if (vec[0]>texmap->max[0]) vec[0] = texmap->max[0];
+ if (vec[1]>texmap->max[1]) vec[1] = texmap->max[1];
+ if (vec[2]>texmap->max[2]) vec[2] = texmap->max[2];
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c
index 57865e072e7..bccf6d349cf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_material.c
@@ -34,7 +34,7 @@
/* **************** MATERIAL ******************** */
-static bNodeSocketTemplate sh_node_material_in[]= {
+static bNodeSocketTemplate sh_node_material_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Refl"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
@@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_material_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_material_out[]= {
+static bNodeSocketTemplate sh_node_material_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ SOCK_FLOAT, 0, N_("Alpha")},
{ SOCK_VECTOR, 0, N_("Normal")},
@@ -51,7 +51,7 @@ static bNodeSocketTemplate sh_node_material_out[]= {
/* **************** EXTENDED MATERIAL ******************** */
-static bNodeSocketTemplate sh_node_material_ext_in[]= {
+static bNodeSocketTemplate sh_node_material_ext_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Refl"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
@@ -66,7 +66,7 @@ static bNodeSocketTemplate sh_node_material_ext_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_material_ext_out[]= {
+static bNodeSocketTemplate sh_node_material_ext_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ SOCK_FLOAT, 0, N_("Alpha")},
{ SOCK_VECTOR, 0, N_("Normal")},
@@ -84,7 +84,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
ShaderCallData *shcd= data;
float col[4];
bNodeSocket *sock;
- char hasinput[NUM_MAT_IN]= {'\0'};
+ char hasinput[NUM_MAT_IN] = {'\0'};
int i;
/* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
@@ -139,7 +139,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
if (hasinput[MAT_IN_ALPHA])
nodestack_get_vec(&shi->alpha, SOCK_FLOAT, in[MAT_IN_ALPHA]);
if (hasinput[MAT_IN_TRANSLUCENCY])
- nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]);
+ nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]);
}
shi->nodes= 1; /* temp hack to prevent trashadow recursion */
@@ -157,20 +157,20 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
copy_v3_v3(col, shrnode.spec);
}
else
- col[0]= col[1]= col[2]= 0.0f;
+ col[0] = col[1] = col[2] = 0.0f;
- col[3]= shrnode.alpha;
+ col[3] = shrnode.alpha;
if (shi->do_preview)
nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage);
copy_v3_v3(out[MAT_OUT_COLOR]->vec, col);
- out[MAT_OUT_ALPHA]->vec[0]= shrnode.alpha;
+ out[MAT_OUT_ALPHA]->vec[0] = shrnode.alpha;
if (node->custom1 & SH_NODE_MAT_NEG) {
- shi->vn[0]= -shi->vn[0];
- shi->vn[1]= -shi->vn[1];
- shi->vn[2]= -shi->vn[2];
+ shi->vn[0] = -shi->vn[0];
+ shi->vn[1] = -shi->vn[1];
+ shi->vn[2] = -shi->vn[2];
}
copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn);
@@ -222,7 +222,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in,
GPUShadeInput shi;
GPUShadeResult shr;
bNodeSocket *sock;
- char hasinput[NUM_MAT_IN]= {'\0'};
+ char hasinput[NUM_MAT_IN] = {'\0'};
int i;
/* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index c112ae1d448..0b71a3f13b4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -34,61 +34,61 @@
/* **************** SCALAR MATH ******************** */
-static bNodeSocketTemplate sh_node_math_in[]= {
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_math_in[] = {
+ { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_math_out[]= {
- { SOCK_FLOAT, 0, N_("Value")},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_math_out[] = {
+ { SOCK_FLOAT, 0, N_("Value")},
+ { -1, 0, "" }
};
static void node_shader_exec_math(void *UNUSED(data), bNode *node, bNodeStack **in,
bNodeStack **out)
{
- switch (node->custom1) {
+ switch (node->custom1) {
case 0: /* Add */
- out[0]->vec[0]= in[0]->vec[0] + in[1]->vec[0];
+ out[0]->vec[0] = in[0]->vec[0] + in[1]->vec[0];
break;
case 1: /* Subtract */
- out[0]->vec[0]= in[0]->vec[0] - in[1]->vec[0];
+ out[0]->vec[0] = in[0]->vec[0] - in[1]->vec[0];
break;
case 2: /* Multiply */
- out[0]->vec[0]= in[0]->vec[0] * in[1]->vec[0];
+ out[0]->vec[0] = in[0]->vec[0] * in[1]->vec[0];
break;
case 3: /* Divide */
{
if (in[1]->vec[0]==0) /* We don't want to divide by zero. */
- out[0]->vec[0]= 0.0;
+ out[0]->vec[0] = 0.0;
else
- out[0]->vec[0]= in[0]->vec[0] / in[1]->vec[0];
+ out[0]->vec[0] = in[0]->vec[0] / in[1]->vec[0];
}
break;
case 4: /* Sine */
{
if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
- out[0]->vec[0]= sin(in[0]->vec[0]);
+ out[0]->vec[0] = sin(in[0]->vec[0]);
else
- out[0]->vec[0]= sin(in[1]->vec[0]);
+ out[0]->vec[0] = sin(in[1]->vec[0]);
}
break;
case 5: /* Cosine */
{
- if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
- out[0]->vec[0]= cos(in[0]->vec[0]);
+ if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ out[0]->vec[0] = cos(in[0]->vec[0]);
else
- out[0]->vec[0]= cos(in[1]->vec[0]);
+ out[0]->vec[0] = cos(in[1]->vec[0]);
}
break;
case 6: /* Tangent */
{
- if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
- out[0]->vec[0]= tan(in[0]->vec[0]);
+ if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ out[0]->vec[0] = tan(in[0]->vec[0]);
else
- out[0]->vec[0]= tan(in[1]->vec[0]);
+ out[0]->vec[0] = tan(in[1]->vec[0]);
}
break;
case 7: /* Arc-Sine */
@@ -96,16 +96,16 @@ bNodeStack **out)
if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
/* Can't do the impossible... */
if ( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 )
- out[0]->vec[0]= asin(in[0]->vec[0]);
+ out[0]->vec[0] = asin(in[0]->vec[0]);
else
- out[0]->vec[0]= 0.0;
+ out[0]->vec[0] = 0.0;
}
else {
/* Can't do the impossible... */
if ( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 )
- out[0]->vec[0]= asin(in[1]->vec[0]);
+ out[0]->vec[0] = asin(in[1]->vec[0]);
else
- out[0]->vec[0]= 0.0;
+ out[0]->vec[0] = 0.0;
}
}
break;
@@ -114,86 +114,97 @@ bNodeStack **out)
if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
/* Can't do the impossible... */
if ( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 )
- out[0]->vec[0]= acos(in[0]->vec[0]);
+ out[0]->vec[0] = acos(in[0]->vec[0]);
else
- out[0]->vec[0]= 0.0;
+ out[0]->vec[0] = 0.0;
}
else {
/* Can't do the impossible... */
if ( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 )
- out[0]->vec[0]= acos(in[1]->vec[0]);
+ out[0]->vec[0] = acos(in[1]->vec[0]);
else
- out[0]->vec[0]= 0.0;
+ out[0]->vec[0] = 0.0;
}
}
break;
case 9: /* Arc-Tangent */
{
if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
- out[0]->vec[0]= atan(in[0]->vec[0]);
+ out[0]->vec[0] = atan(in[0]->vec[0]);
else
- out[0]->vec[0]= atan(in[1]->vec[0]);
+ out[0]->vec[0] = atan(in[1]->vec[0]);
}
break;
case 10: /* Power */
{
- /* Don't want any imaginary numbers... */
- if ( in[0]->vec[0] >= 0 )
- out[0]->vec[0]= pow(in[0]->vec[0], in[1]->vec[0]);
- else
- out[0]->vec[0]= 0.0;
+ /* Only raise negative numbers by full integers */
+ if ( in[0]->vec[0] >= 0 ) {
+ out[0]->vec[0] = pow(in[0]->vec[0], in[1]->vec[0]);
+ }
+ else {
+ float y_mod_1 = fabsf(fmodf(in[1]->vec[0], 1.0f));
+
+ /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
+ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
+ out[0]->vec[0] = powf(in[0]->vec[0], floorf(in[1]->vec[0] + 0.5f));
+ }
+ else {
+ out[0]->vec[0] = 0.0f;
+ }
+ }
+
}
break;
case 11: /* Logarithm */
{
/* Don't want any imaginary numbers... */
if ( in[0]->vec[0] > 0 && in[1]->vec[0] > 0 )
- out[0]->vec[0]= log(in[0]->vec[0]) / log(in[1]->vec[0]);
+ out[0]->vec[0] = log(in[0]->vec[0]) / log(in[1]->vec[0]);
else
- out[0]->vec[0]= 0.0;
+ out[0]->vec[0] = 0.0;
}
break;
case 12: /* Minimum */
{
if ( in[0]->vec[0] < in[1]->vec[0] )
- out[0]->vec[0]= in[0]->vec[0];
+ out[0]->vec[0] = in[0]->vec[0];
else
- out[0]->vec[0]= in[1]->vec[0];
+ out[0]->vec[0] = in[1]->vec[0];
}
break;
case 13: /* Maximum */
{
if ( in[0]->vec[0] > in[1]->vec[0] )
- out[0]->vec[0]= in[0]->vec[0];
+ out[0]->vec[0] = in[0]->vec[0];
else
- out[0]->vec[0]= in[1]->vec[0];
+ out[0]->vec[0] = in[1]->vec[0];
}
break;
case 14: /* Round */
{
if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
- out[0]->vec[0]= (in[0]->vec[0]<0)?(int)(in[0]->vec[0] - 0.5f):(int)(in[0]->vec[0] + 0.5f);
+ out[0]->vec[0] = (in[0]->vec[0]<0)?(int)(in[0]->vec[0] - 0.5f):(int)(in[0]->vec[0] + 0.5f);
else
- out[0]->vec[0]= (in[1]->vec[0]<0)?(int)(in[1]->vec[0] - 0.5f):(int)(in[1]->vec[0] + 0.5f);
+ out[0]->vec[0] = (in[1]->vec[0]<0)?(int)(in[1]->vec[0] - 0.5f):(int)(in[1]->vec[0] + 0.5f);
}
break;
case 15: /* Less Than */
{
if ( in[0]->vec[0] < in[1]->vec[0] )
- out[0]->vec[0]= 1.0f;
+ out[0]->vec[0] = 1.0f;
else
- out[0]->vec[0]= 0.0f;
+ out[0]->vec[0] = 0.0f;
}
break;
case 16: /* Greater Than */
{
if ( in[0]->vec[0] > in[1]->vec[0] )
- out[0]->vec[0]= 1.0f;
+ out[0]->vec[0] = 1.0f;
else
- out[0]->vec[0]= 0.0f;
+ out[0]->vec[0] = 0.0f;
}
break;
- }
+ }
}
static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
@@ -214,8 +225,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUN
case 13:
case 15:
case 16:
- GPU_stack_link(mat, names[node->custom1], NULL, out,
- GPU_socket(&in[0]), GPU_socket(&in[1]));
+ GPU_stack_link(mat, names[node->custom1], in, out);
break;
case 4:
case 5:
@@ -224,10 +234,20 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUN
case 8:
case 9:
case 14:
- if (in[0].hasinput || !in[1].hasinput)
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[0]));
- else
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[1]));
+ if (in[0].hasinput || !in[1].hasinput) {
+ /* use only first item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[0], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
+ else {
+ /* use only second item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[1], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
break;
default:
return 0;
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index 53c1387ca1a..18dcc8f7fef 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -33,13 +33,13 @@
#include "node_shader_util.h"
/* **************** MIX RGB ******************** */
-static bNodeSocketTemplate sh_node_mix_rgb_in[]= {
+static bNodeSocketTemplate sh_node_mix_rgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f},
{ SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_mix_rgb_out[]= {
+static bNodeSocketTemplate sh_node_mix_rgb_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
index 80ee1a8499d..039e63a4dea 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
@@ -29,14 +29,14 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_mix_shader_in[]= {
+static bNodeSocketTemplate sh_node_mix_shader_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_SHADER, 1, N_("Shader")},
{ SOCK_SHADER, 1, N_("Shader")},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_mix_shader_out[]= {
+static bNodeSocketTemplate sh_node_mix_shader_out[] = {
{ SOCK_SHADER, 0, N_("Shader")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index bb0a85417d9..98a56c85279 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -33,12 +33,12 @@
#include "node_shader_util.h"
/* **************** NORMAL ******************** */
-static bNodeSocketTemplate sh_node_normal_in[]= {
+static bNodeSocketTemplate sh_node_normal_in[] = {
{ SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_normal_out[]= {
+static bNodeSocketTemplate sh_node_normal_out[] = {
{ SOCK_VECTOR, 0, N_("Normal")},
{ SOCK_FLOAT, 0, N_("Dot")},
{ -1, 0, "" }
@@ -68,7 +68,7 @@ static void node_shader_exec_normal(void *UNUSED(data), bNode *node, bNodeStack
copy_v3_v3(out[0]->vec, ((bNodeSocketValueVector*)sock->default_value)->value);
/* render normals point inside... the widget points outside */
- out[1]->vec[0]= -dot_v3v3(out[0]->vec, vec);
+ out[1]->vec[0] = -dot_v3v3(out[0]->vec, vec);
}
static int gpu_shader_normal(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
new file mode 100644
index 00000000000..ee83699abdb
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -0,0 +1,70 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_normal_map_in[] = {
+ { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+ { SOCK_RGBA, 0, N_("Color"), 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_normal_map_out[] = {
+ { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeShaderNormalMap *attr = MEM_callocN(sizeof(NodeShaderNormalMap), "NodeShaderNormalMap");
+ node->storage = attr;
+}
+
+static int gpu_shader_normal_map(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "node_normal_map", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_normal_map(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_normal_map_in, sh_node_normal_map_out);
+ node_type_size(&ntype, 250, 60, 250);
+ node_type_init(&ntype, node_shader_init_normal_map);
+ node_type_storage(&ntype, "NodeShaderNormalMap", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, gpu_shader_normal_map);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c
index 1cafa01ecec..ef283004d46 100644
--- a/source/blender/nodes/shader/nodes/node_shader_object_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_object_info_out[]= {
+static bNodeSocketTemplate sh_node_object_info_out[] = {
{ SOCK_VECTOR, 0, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Object Index"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Material Index"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c
index 4434054abae..6f7f900aecd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output.c
@@ -33,7 +33,7 @@
#include "node_shader_util.h"
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_output_in[]= {
+static bNodeSocketTemplate sh_node_output_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ -1, 0, "" }
@@ -62,7 +62,7 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN
// copy_v3_v3(shr->nor, in[3]->vec);
}
- }
+ }
}
static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
@@ -92,7 +92,7 @@ void register_node_type_sh_output(bNodeTreeType *ttype)
node_type_gpu(&ntype, gpu_shader_output);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
index eb7208302fe..ce406a8f5a1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_output_lamp_in[]= {
+static bNodeSocketTemplate sh_node_output_lamp_in[] = {
{ SOCK_SHADER, 1, N_("Surface"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
@@ -49,7 +49,7 @@ void register_node_type_sh_output_lamp(bNodeTreeType *ttype)
node_type_gpu(&ntype, NULL);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index e81744c44bd..f185e13010b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_output_material_in[]= {
+static bNodeSocketTemplate sh_node_output_material_in[] = {
{ SOCK_SHADER, 1, N_("Surface")},
{ SOCK_SHADER, 1, N_("Volume")},
{ SOCK_FLOAT, 1, N_("Displacement"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
@@ -62,7 +62,7 @@ void register_node_type_sh_output_material(bNodeTreeType *ttype)
node_type_gpu(&ntype, node_shader_gpu_output_material);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
index 3a931c2af53..953197ab2cd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_world.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_output_world_in[]= {
+static bNodeSocketTemplate sh_node_output_world_in[] = {
{ SOCK_SHADER, 1, N_("Surface"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_SHADER, 1, N_("Volume"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
@@ -50,7 +50,7 @@ void register_node_type_sh_output_world(bNodeTreeType *ttype)
node_type_gpu(&ntype, NULL);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index ddfcb9476f4..c7e31d117cc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -28,18 +28,18 @@
#include "../node_shader_util.h"
static bNodeSocketTemplate outputs[] = {
- { SOCK_FLOAT, 0, "Index" },
- { SOCK_FLOAT, 0, "Age" },
- { SOCK_FLOAT, 0, "Lifetime" },
- { SOCK_VECTOR, 0, "Location" },
- #if 0 /* quaternion sockets not yet supported */
- { SOCK_QUATERNION, 0, "Rotation" },
- #endif
- { SOCK_FLOAT, 0, "Size" },
- { SOCK_VECTOR, 0, "Velocity" },
- { SOCK_VECTOR, 0, "Angular Velocity" },
- { -1, 0, "" }
-};
+ { SOCK_FLOAT, 0, "Index" },
+ { SOCK_FLOAT, 0, "Age" },
+ { SOCK_FLOAT, 0, "Lifetime" },
+ { SOCK_VECTOR, 0, "Location" },
+#if 0 /* quaternion sockets not yet supported */
+ { SOCK_QUATERNION, 0, "Rotation" },
+#endif
+ { SOCK_FLOAT, 0, "Size" },
+ { SOCK_VECTOR, 0, "Velocity" },
+ { SOCK_VECTOR, 0, "Angular Velocity" },
+ { -1, 0, "" }
+ };
/* node type definition */
void register_node_type_sh_particle_info(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c
index 5a19c61fe92..f37ff1d511b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_rgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c
@@ -33,7 +33,7 @@
#include "node_shader_util.h"
/* **************** RGB ******************** */
-static bNodeSocketTemplate sh_node_rgb_out[]= {
+static bNodeSocketTemplate sh_node_rgb_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c
new file mode 100644
index 00000000000..b5563658a64
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_script.c
@@ -0,0 +1,86 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/shader/nodes/node_shader_script.c
+ * \ingroup shdnodes
+ */
+
+#include "BKE_idprop.h"
+
+#include "node_shader_util.h"
+
+/* **************** Script ******************** */
+
+static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeShaderScript *nss = MEM_callocN(sizeof(NodeShaderScript), "shader script node");
+ node->storage = nss;
+}
+
+static void node_free_script(bNode *node)
+{
+ NodeShaderScript *nss = node->storage;
+
+ if (nss) {
+ if (nss->bytecode) {
+ MEM_freeN(nss->bytecode);
+ }
+
+ if (nss->prop) {
+ IDP_FreeProperty(nss->prop);
+ MEM_freeN(nss->prop);
+ }
+
+ MEM_freeN(nss);
+ }
+}
+
+static void node_copy_script(bNode *orig_node, bNode *new_node)
+{
+ NodeShaderScript *orig_nss = orig_node->storage;
+ NodeShaderScript *new_nss = MEM_dupallocN(orig_nss);
+
+ if (orig_nss->bytecode)
+ new_nss->bytecode = MEM_dupallocN(orig_nss->bytecode);
+
+ if (orig_nss->prop)
+ new_nss->prop = IDP_CopyProperty(orig_nss->prop);
+
+ new_node->storage = new_nss;
+}
+
+void register_node_type_sh_script(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_SCRIPT, "Script", NODE_CLASS_SCRIPT, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_init(&ntype, init);
+ node_type_storage(&ntype, "NodeShaderScript", node_free_script, node_copy_script);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
index 55f37b666e7..70fba161de9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
@@ -33,11 +33,11 @@
#include "node_shader_util.h"
/* **************** SEPARATE RGBA ******************** */
-static bNodeSocketTemplate sh_node_seprgb_in[]= {
+static bNodeSocketTemplate sh_node_seprgb_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_seprgb_out[]= {
+static bNodeSocketTemplate sh_node_seprgb_out[] = {
{ SOCK_FLOAT, 0, N_("R")},
{ SOCK_FLOAT, 0, N_("G")},
{ SOCK_FLOAT, 0, N_("B")},
@@ -73,13 +73,13 @@ void register_node_type_sh_seprgb(bNodeTreeType *ttype)
/* **************** COMBINE RGB ******************** */
-static bNodeSocketTemplate sh_node_combrgb_in[]= {
+static bNodeSocketTemplate sh_node_combrgb_in[] = {
{ SOCK_FLOAT, 1, N_("R"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
{ SOCK_FLOAT, 1, N_("G"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
{ SOCK_FLOAT, 1, N_("B"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_combrgb_out[]= {
+static bNodeSocketTemplate sh_node_combrgb_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
index adab396be02..8073f4b01d2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c
+++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
@@ -33,20 +33,19 @@
#include "node_shader_util.h"
/* **************** VALUE SQUEEZE ******************** */
-static bNodeSocketTemplate sh_node_squeeze_in[]= {
- { SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Center"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_squeeze_in[] = {
+ { SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, N_("Center"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_squeeze_out[]= {
- { SOCK_FLOAT, 0, N_("Value")},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_squeeze_out[] = {
+ { SOCK_FLOAT, 0, N_("Value")},
+ { -1, 0, "" }
};
-static void node_shader_exec_squeeze(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in,
-bNodeStack **out)
+static void node_shader_exec_squeeze(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out)
{
float vec[3];
@@ -54,7 +53,7 @@ bNodeStack **out)
nodestack_get_vec(vec+1, SOCK_FLOAT, in[1]);
nodestack_get_vec(vec+2, SOCK_FLOAT, in[2]);
- out[0]->vec[0] = 1.0f / (1.0f + pow(M_E, -((vec[0] - vec[2]) * vec[1])));
+ out[0]->vec[0] = 1.0f / (1.0f + powf(M_E, -((vec[0] - vec[2]) * vec[1])));
}
static int gpu_shader_squeeze(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
new file mode 100644
index 00000000000..6c0d6d7cd9f
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -0,0 +1,60 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tangent_out[] = {
+ { SOCK_VECTOR, 0, N_("Tangent"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_shader_init_tangent(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeShaderTangent *attr = MEM_callocN(sizeof(NodeShaderTangent), "NodeShaderTangent");
+ attr->axis = SHD_TANGENT_AXIS_Z;
+ node->storage = attr;
+}
+
+/* node type definition */
+void register_node_type_sh_tangent(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, NULL, sh_node_tangent_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_init(&ntype, node_shader_init_tangent);
+ node_type_storage(&ntype, "NodeShaderTangent", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, NULL);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
index 11f7fb94ae0..66bf0267586 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_brick_in[]= {
+static bNodeSocketTemplate sh_node_tex_brick_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_RGBA, 1, N_("Color1"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Color2"), 0.2f, 0.2f, 0.2f, 1.0f, 0.0f, 1.0f},
@@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_tex_brick_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_brick_out[]= {
+static bNodeSocketTemplate sh_node_tex_brick_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
index 0c1e7dcb995..8a2ae2d40dc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
@@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_checker_in[]= {
+static bNodeSocketTemplate sh_node_tex_checker_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_RGBA, 1, N_("Color1"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Color2"), 0.2f, 0.2f, 0.2f, 1.0f, 0.0f, 1.0f},
@@ -37,7 +37,7 @@ static bNodeSocketTemplate sh_node_tex_checker_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_checker_out[]= {
+static bNodeSocketTemplate sh_node_tex_checker_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
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 62b1cabd491..dd717874951 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
@@ -31,7 +31,7 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_coord_out[]= {
+static bNodeSocketTemplate sh_node_tex_coord_out[] = {
{ SOCK_VECTOR, 0, N_("Generated"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 0, N_("UV"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index ace0f0c8774..abe8e0190c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -27,14 +27,16 @@
#include "../node_shader_util.h"
+#include "IMB_colormanagement.h"
+
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_environment_in[]= {
+static bNodeSocketTemplate sh_node_tex_environment_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_environment_out[]= {
+static bNodeSocketTemplate sh_node_tex_environment_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
@@ -59,7 +61,8 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod
Image *ima= (Image*)node->id;
ImageUser *iuser= NULL;
NodeTexImage *tex = node->storage;
- int ncd = tex->color_space == SHD_COLORSPACE_NONE;
+ int isdata = tex->color_space == SHD_COLORSPACE_NONE;
+ int ret;
if (!ima)
return GPU_stack_link(mat, "node_tex_environment_empty", in, out);
@@ -69,10 +72,18 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod
node_shader_gpu_tex_mapping(mat, node, in, out);
- if (out[0].link && GPU_material_do_color_management(mat))
- GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ ret = GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, isdata));
+
+ if (ret) {
+ ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser);
+ if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
+ GPU_material_do_color_management(mat))
+ {
+ GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ }
+ }
- return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, ncd));
+ return ret;
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
index a7f869155fa..0802ecdea1d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
@@ -29,12 +29,12 @@
/* **************** BLEND ******************** */
-static bNodeSocketTemplate sh_node_tex_gradient_in[]= {
+static bNodeSocketTemplate sh_node_tex_gradient_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_gradient_out[]= {
+static bNodeSocketTemplate sh_node_tex_gradient_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
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 d6c757222b9..9b17f76bd47 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -27,14 +27,16 @@
#include "../node_shader_util.h"
+#include "IMB_colormanagement.h"
+
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_image_in[]= {
+static bNodeSocketTemplate sh_node_tex_image_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_image_out[]= {
+static bNodeSocketTemplate sh_node_tex_image_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
@@ -59,7 +61,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack
Image *ima= (Image*)node->id;
ImageUser *iuser= NULL;
NodeTexImage *tex = node->storage;
- int ncd = tex->color_space == SHD_COLORSPACE_NONE;
+ int isdata = tex->color_space == SHD_COLORSPACE_NONE;
+ int ret;
if (!ima)
return GPU_stack_link(mat, "node_tex_image_empty", in, out);
@@ -69,10 +72,18 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack
node_shader_gpu_tex_mapping(mat, node, in, out);
- if (out[0].link && GPU_material_do_color_management(mat))
- GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ ret = GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+
+ if (ret) {
+ ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser);
+ if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
+ GPU_material_do_color_management(mat))
+ {
+ GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ }
+ }
- return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, ncd));
+ return ret;
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
index b9f1b5c1d21..86feabbcc2b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
@@ -29,14 +29,14 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_magic_in[]= {
+static bNodeSocketTemplate sh_node_tex_magic_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, N_("Distortion"), 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_magic_out[]= {
+static bNodeSocketTemplate sh_node_tex_magic_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
index 60b4f65f0b4..cd4b5743e14 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
@@ -29,7 +29,7 @@
/* **************** MUSGRAVE ******************** */
-static bNodeSocketTemplate sh_node_tex_musgrave_in[]= {
+static bNodeSocketTemplate sh_node_tex_musgrave_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, N_("Detail"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f},
@@ -40,7 +40,7 @@ static bNodeSocketTemplate sh_node_tex_musgrave_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_musgrave_out[]= {
+static bNodeSocketTemplate sh_node_tex_musgrave_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
index bd049300048..18788f9e72c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
@@ -29,7 +29,7 @@
/* **************** NOISE ******************** */
-static bNodeSocketTemplate sh_node_tex_noise_in[]= {
+static bNodeSocketTemplate sh_node_tex_noise_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, N_("Detail"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f},
@@ -37,7 +37,7 @@ static bNodeSocketTemplate sh_node_tex_noise_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_noise_out[]= {
+static bNodeSocketTemplate sh_node_tex_noise_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 977d689ace6..7a1b853a7f4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -29,12 +29,12 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_tex_sky_in[]= {
+static bNodeSocketTemplate sh_node_tex_sky_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_sky_out[]= {
+static bNodeSocketTemplate sh_node_tex_sky_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
index 22baa3853ac..d4cc24687b3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
@@ -29,13 +29,13 @@
/* **************** VORONOI ******************** */
-static bNodeSocketTemplate sh_node_tex_voronoi_in[]= {
+static bNodeSocketTemplate sh_node_tex_voronoi_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_voronoi_out[]= {
+static bNodeSocketTemplate sh_node_tex_voronoi_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
index 8a099521ee9..8b23de0310c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
@@ -29,7 +29,7 @@
/* **************** WAVE ******************** */
-static bNodeSocketTemplate sh_node_tex_wave_in[]= {
+static bNodeSocketTemplate sh_node_tex_wave_in[] = {
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, N_("Distortion"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
@@ -38,7 +38,7 @@ static bNodeSocketTemplate sh_node_tex_wave_in[]= {
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_tex_wave_out[]= {
+static bNodeSocketTemplate sh_node_tex_wave_out[] = {
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c
index 73c3b846fe3..6d1b3ff6dba 100644
--- a/source/blender/nodes/shader/nodes/node_shader_texture.c
+++ b/source/blender/nodes/shader/nodes/node_shader_texture.c
@@ -32,14 +32,16 @@
#include "DNA_texture_types.h"
+#include "IMB_colormanagement.h"
+
#include "node_shader_util.h"
/* **************** TEXTURE ******************** */
-static bNodeSocketTemplate sh_node_texture_in[]= {
+static bNodeSocketTemplate sh_node_texture_in[] = {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, /* no limit */
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_texture_out[]= {
+static bNodeSocketTemplate sh_node_texture_out[] = {
{ SOCK_FLOAT, 0, N_("Value")},
{ SOCK_RGBA, 0, N_("Color")},
{ SOCK_VECTOR, 0, N_("Normal")},
@@ -52,7 +54,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
ShadeInput *shi= ((ShaderCallData *)data)->shi;
TexResult texres;
bNodeSocket *sock_vector= node->inputs.first;
- float vec[3], nor[3]={0.0f, 0.0f, 0.0f};
+ float vec[3], nor[3] = {0.0f, 0.0f, 0.0f};
int retval;
short which_output = node->custom1;
@@ -76,8 +78,8 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
float *fp= in[0]->data;
float dxt[3], dyt[3];
- dxt[0]= fp[0]; dxt[1]= dxt[2]= 0.0f;
- dyt[0]= fp[1]; dyt[1]= dyt[2]= 0.0f;
+ dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f;
+ dyt[0] = fp[1]; dyt[1] = dyt[2] = 0.0f;
retval= multitex_nodes((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output, NULL, NULL);
}
else
@@ -96,9 +98,9 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
/* intensity and color need some handling */
if (texres.talpha)
- out[0]->vec[0]= texres.ta;
+ out[0]->vec[0] = texres.ta;
else
- out[0]->vec[0]= texres.tin;
+ out[0]->vec[0] = texres.tin;
if ((retval & TEX_RGB) == 0) {
copy_v3_fl(out[1]->vec, out[0]->vec[0]);
@@ -122,8 +124,19 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G
Tex *tex = (Tex*)node->id;
if (tex && tex->type == TEX_IMAGE && tex->ima) {
- GPUNodeLink *texlink = GPU_image(tex->ima, NULL, FALSE);
- return GPU_stack_link(mat, "texture_image", in, out, texlink);
+ GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, FALSE);
+ int ret = GPU_stack_link(mat, "texture_image", in, out, texlink);
+
+ if (ret) {
+ ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
+ if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) ==0 &&
+ GPU_material_do_color_management(mat))
+ {
+ GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link);
+ }
+ }
+
+ return ret;
}
else
return 0;
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
index d3094200f83..182487d343e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
@@ -33,11 +33,11 @@
#include "node_shader_util.h"
/* **************** VALTORGB ******************** */
-static bNodeSocketTemplate sh_node_valtorgb_in[]= {
+static bNodeSocketTemplate sh_node_valtorgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_valtorgb_out[]= {
+static bNodeSocketTemplate sh_node_valtorgb_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ SOCK_FLOAT, 0, N_("Alpha")},
{ -1, 0, "" }
@@ -53,7 +53,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeStac
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
do_colorband(node->storage, fac, out[0]->vec);
- out[1]->vec[0]= out[0]->vec[3];
+ out[1]->vec[0] = out[0]->vec[3];
}
}
@@ -89,11 +89,11 @@ void register_node_type_sh_valtorgb(bNodeTreeType *ttype)
/* **************** RGBTOBW ******************** */
-static bNodeSocketTemplate sh_node_rgbtobw_in[]= {
+static bNodeSocketTemplate sh_node_rgbtobw_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_rgbtobw_out[]= {
+static bNodeSocketTemplate sh_node_rgbtobw_out[] = {
{ SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c
index 8a6c3c87e0d..a3d1e5afec2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.c
+++ b/source/blender/nodes/shader/nodes/node_shader_value.c
@@ -33,7 +33,7 @@
#include "node_shader_util.h"
/* **************** VALUE ******************** */
-static bNodeSocketTemplate sh_node_value_out[]= {
+static bNodeSocketTemplate sh_node_value_out[] = {
/* XXX value nodes use the output sockets for buttons, so we need explicit limits here! */
{ SOCK_FLOAT, 0, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
{ -1, 0, "" }
@@ -54,7 +54,7 @@ static void node_shader_exec_value(void *UNUSED(data), bNode *node, bNodeStack *
bNodeSocket *sock= node->outputs.first;
float val= ((bNodeSocketValueFloat*)sock->default_value)->value;
- out[0]->vec[0]= val;
+ out[0]->vec[0] = val;
}
static int gpu_shader_value(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index 007366c6082..3e00421ddf0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -35,16 +35,16 @@
/* **************** VECTOR MATH ******************** */
-static bNodeSocketTemplate sh_node_vect_math_in[]= {
- { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
- { -1, 0, "" }
+static bNodeSocketTemplate sh_node_vect_math_in[] = {
+ { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_vect_math_out[]= {
- { SOCK_VECTOR, 0, N_("Vector")},
+static bNodeSocketTemplate sh_node_vect_math_out[] = {
+ { SOCK_VECTOR, 0, N_("Vector")},
{ SOCK_FLOAT, 0, N_("Value")},
- { -1, 0, "" }
+ { -1, 0, "" }
};
static void node_shader_exec_vect_math(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
@@ -55,46 +55,46 @@ static void node_shader_exec_vect_math(void *UNUSED(data), bNode *node, bNodeSta
nodestack_get_vec(vec2, SOCK_VECTOR, in[1]);
if (node->custom1 == 0) { /* Add */
- out[0]->vec[0]= vec1[0] + vec2[0];
- out[0]->vec[1]= vec1[1] + vec2[1];
- out[0]->vec[2]= vec1[2] + vec2[2];
+ out[0]->vec[0] = vec1[0] + vec2[0];
+ out[0]->vec[1] = vec1[1] + vec2[1];
+ out[0]->vec[2] = vec1[2] + vec2[2];
- out[1]->vec[0]= (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3;
+ out[1]->vec[0] = (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3;
}
else if (node->custom1 == 1) { /* Subtract */
- out[0]->vec[0]= vec1[0] - vec2[0];
- out[0]->vec[1]= vec1[1] - vec2[1];
- out[0]->vec[2]= vec1[2] - vec2[2];
+ out[0]->vec[0] = vec1[0] - vec2[0];
+ out[0]->vec[1] = vec1[1] - vec2[1];
+ out[0]->vec[2] = vec1[2] - vec2[2];
- out[1]->vec[0]= (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3;
+ out[1]->vec[0] = (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3;
}
else if (node->custom1 == 2) { /* Average */
- out[0]->vec[0]= vec1[0] + vec2[0];
- out[0]->vec[1]= vec1[1] + vec2[1];
- out[0]->vec[2]= vec1[2] + vec2[2];
+ out[0]->vec[0] = vec1[0] + vec2[0];
+ out[0]->vec[1] = vec1[1] + vec2[1];
+ out[0]->vec[2] = vec1[2] + vec2[2];
out[1]->vec[0] = normalize_v3(out[0]->vec );
}
else if (node->custom1 == 3) { /* Dot product */
- out[1]->vec[0]= (vec1[0] * vec2[0]) + (vec1[1] * vec2[1]) + (vec1[2] * vec2[2]);
+ out[1]->vec[0] = (vec1[0] * vec2[0]) + (vec1[1] * vec2[1]) + (vec1[2] * vec2[2]);
}
else if (node->custom1 == 4) { /* Cross product */
- out[0]->vec[0]= (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]);
- out[0]->vec[1]= (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]);
- out[0]->vec[2]= (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]);
+ out[0]->vec[0] = (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]);
+ out[0]->vec[1] = (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]);
+ out[0]->vec[2] = (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]);
out[1]->vec[0] = normalize_v3(out[0]->vec );
}
else if (node->custom1 == 5) { /* Normalize */
if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
- out[0]->vec[0]= vec1[0];
- out[0]->vec[1]= vec1[1];
- out[0]->vec[2]= vec1[2];
+ out[0]->vec[0] = vec1[0];
+ out[0]->vec[1] = vec1[1];
+ out[0]->vec[2] = vec1[2];
}
else {
- out[0]->vec[0]= vec2[0];
- out[0]->vec[1]= vec2[1];
- out[0]->vec[2]= vec2[2];
+ out[0]->vec[0] = vec2[0];
+ out[0]->vec[1] = vec2[1];
+ out[0]->vec[2] = vec2[2];
}
out[1]->vec[0] = normalize_v3(out[0]->vec );
@@ -114,14 +114,23 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in,
case 2:
case 3:
case 4:
- GPU_stack_link(mat, names[node->custom1], NULL, out,
- GPU_socket(&in[0]), GPU_socket(&in[1]));
+ GPU_stack_link(mat, names[node->custom1], in, out);
break;
case 5:
- if (in[0].hasinput || !in[1].hasinput)
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[0]));
- else
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[1]));
+ if (in[0].hasinput || !in[1].hasinput) {
+ /* use only first item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[0], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
+ else {
+ /* use only second item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[1], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
break;
default:
return 0;
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c b/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c
index 366f50ab4fc..5451eb303cc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c
@@ -29,13 +29,13 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_volume_isotropic_in[]= {
+static bNodeSocketTemplate sh_node_volume_isotropic_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_volume_isotropic_out[]= {
+static bNodeSocketTemplate sh_node_volume_isotropic_out[] = {
{ SOCK_SHADER, 0, N_("Volume")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c b/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c
index 9d48f613d34..ad7d7fceda3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c
@@ -29,13 +29,13 @@
/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_volume_transparent_in[]= {
+static bNodeSocketTemplate sh_node_volume_transparent_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate sh_node_volume_transparent_out[]= {
+static bNodeSocketTemplate sh_node_volume_transparent_out[] = {
{ SOCK_SHADER, 0, N_("Volume")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 9656d93f1b0..ba94531c259 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -134,7 +134,7 @@ bNodeTreeType ntreeType_Texture = {
/* update */ update,
/* update_node */ NULL,
/* validate_link */ NULL,
- /* internal_connect */ node_internal_connect_default
+ /* update_internal_links */ node_update_internal_links_default
};
int ntreeTexTagAnimated(bNodeTree *ntree)
@@ -240,19 +240,19 @@ void ntreeTexEndExecTree(bNodeTreeExec *exec, int use_tree_data)
}
int ntreeTexExecTree(
- bNodeTree *nodes,
- TexResult *texres,
- float *co,
- float *dxt, float *dyt,
- int osatex,
- short thread,
- Tex *UNUSED(tex),
- short which_output,
- int cfra,
- int preview,
- ShadeInput *shi,
- MTex *mtex
-) {
+ bNodeTree *nodes,
+ TexResult *texres,
+ float co[3],
+ float dxt[3], float dyt[3],
+ int osatex,
+ const short thread,
+ Tex *UNUSED(tex),
+ short which_output,
+ int cfra,
+ int preview,
+ ShadeInput *shi,
+ MTex *mtex)
+{
TexCallData data;
float *nor = texres->nor;
int retval = TEX_INT;
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 5e58b74ac3a..06473d800d0 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -29,7 +29,7 @@
* \ingroup nodes
*/
-
+
/*
* HOW TEXTURE NODES WORK
*
@@ -112,13 +112,13 @@ void params_from_cdata(TexParams *out, TexCallData *in)
out->mtex = in->mtex;
}
-void tex_do_preview(bNode *node, float *co, float *col)
+void tex_do_preview(bNode *node, const float coord[2], const float col[4])
{
- bNodePreview *preview= node->preview;
+ bNodePreview *preview = node->preview;
if (preview) {
- int xs= ((co[0] + 1.0f)*0.5f)*preview->xsize;
- int ys= ((co[1] + 1.0f)*0.5f)*preview->ysize;
+ int xs = ((coord[0] + 1.0f) * 0.5f) * preview->xsize;
+ int ys = ((coord[1] + 1.0f) * 0.5f) * preview->ysize;
nodeAddToPreview(node, col, xs, ys, 0); /* 0 = no color management */
}
@@ -132,19 +132,19 @@ void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexC
dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
else
dg = out->data;
-
- dg->cdata= cdata;
+
+ dg->cdata = cdata;
dg->fn = texfn;
dg->node = node;
- memcpy(dg->in, in, MAX_SOCKET * sizeof(bNodeStack*));
+ memcpy(dg->in, in, MAX_SOCKET * sizeof(bNodeStack *));
dg->type = out->sockettype;
}
void ntreeTexCheckCyclics(struct bNodeTree *ntree)
{
bNode *node;
- for (node= ntree->nodes.first; node; node= node->next) {
-
+ for (node = ntree->nodes.first; node; node = node->next) {
+
if (node->type == TEX_NODE_TEXTURE && node->id) {
/* custom2 stops the node from rendering */
if (node->custom1) {
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index e938e6fc419..16dbc2f7bfb 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -79,8 +79,10 @@
typedef struct TexCallData {
TexResult *target;
+ /* all float[3] */
float *co;
float *dxt, *dyt;
+
int osatex;
char do_preview;
short thread;
@@ -94,7 +96,7 @@ typedef struct TexCallData {
typedef struct TexParams {
float *co;
float *dxt, *dyt;
- float *previewco;
+ const float *previewco;
int cfra;
int osatex;
@@ -119,7 +121,7 @@ void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread);
float tex_input_value(bNodeStack *in, TexParams *params, short thread);
void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *data);
-void tex_do_preview(bNode *node, float *coord, float *col);
+void tex_do_preview(bNode *node, const float coord[2], const float col[4]);
void params_from_cdata(TexParams *out, TexCallData *in);
diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c
index 9e557705b3f..4c2d276b902 100644
--- a/source/blender/nodes/texture/nodes/node_texture_at.c
+++ b/source/blender/nodes/texture/nodes/node_texture_at.c
@@ -33,12 +33,12 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Texture"), 0.0f, 0.0f, 0.0f, 1.0f },
{ SOCK_VECTOR, 1, N_("Coordinates"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Texture") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c
index f6259962529..b4f81f08e43 100644
--- a/source/blender/nodes/texture/nodes/node_texture_bricks.c
+++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c
@@ -35,7 +35,7 @@
#include <math.h>
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f },
{ SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f },
{ SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f },
@@ -45,7 +45,7 @@ static bNodeSocketTemplate inputs[]= {
{ SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
@@ -66,7 +66,7 @@ static float noise(int n) /* fast integer noise */
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- float *co = p->co;
+ const float *co = p->co;
float x = co[0];
float y = co[1];
diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c
index cd9c3170cf7..1f653d1f7b9 100644
--- a/source/blender/nodes/texture/nodes/node_texture_checker.c
+++ b/source/blender/nodes/texture/nodes/node_texture_checker.c
@@ -34,13 +34,13 @@
#include "NOD_texture.h"
#include <math.h>
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f },
{ SOCK_RGBA, 1, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f },
{ SOCK_FLOAT, 1, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Color") },
{ -1, 0, "" }
};
@@ -62,7 +62,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
}
else {
tex_input_rgba(out, in[1], p, thread);
- }
+ }
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 1eaf9b2b0fe..41bfd0ae00a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -148,128 +148,3 @@ void register_node_type_tex_group(bNodeTreeType *ttype)
nodeRegisterType(ttype, &ntype);
}
-
-
-/**** FOR LOOP ****/
-
-#if 0 /* XXX loop nodes don't work nicely with current trees */
-static void forloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out)
-{
- bNodeTreeExec *exec= (bNodeTreeExec*)nodedata;
- bNodeThreadStack *nts;
- int iterations= (int)in[0]->vec[0];
- bNodeSocket *sock;
- bNodeStack *ns;
- int iteration;
-
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode=exec->nodetree->nodes.first; inode; inode=inode->next)
- inode->need_exec = 1;
- }
-
- nts = ntreeGetThreadStack(exec, thread);
-
- /* "Iteration" socket */
- sock = exec->nodetree->inputs.first;
- ns = node_get_socket_stack(nts->stack, sock);
-
-// group_copy_inputs(node, in, nts->stack);
- for (iteration=0; iteration < iterations; ++iteration) {
- /* first input contains current iteration counter */
- ns->vec[0] = (float)iteration;
- ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f;
-
-// if (iteration > 0)
-// loop_init_iteration(exec->nodetree, nts->stack);
-// ntreeExecThreadNodes(exec, nts, data, thread);
- }
-// loop_copy_outputs(node, in, out, exec->stack);
-
- ntreeReleaseThreadStack(nts);
-}
-
-void register_node_type_tex_forloop(bNodeTreeType *ttype)
-{
- static bNodeType ntype;
-
- node_type_base(ttype, &ntype, NODE_FORLOOP, "For", NODE_CLASS_GROUP, NODE_OPTIONS);
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 200);
- node_type_label(&ntype, node_group_label);
- node_type_init(&ntype, node_forloop_init);
- node_type_valid(&ntype, node_group_valid);
- node_type_template(&ntype, node_forloop_template);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_tree(&ntype, node_forloop_init_tree, node_loop_update_tree);
- node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear);
- node_type_exec_new(&ntype, group_initexec, group_freeexec, forloop_execute);
-
- nodeRegisterType(ttype, &ntype);
-}
-#endif
-
-/**** WHILE LOOP ****/
-
-#if 0 /* XXX loop nodes don't work nicely with current trees */
-static void whileloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out)
-{
- bNodeTreeExec *exec= (bNodeTreeExec*)nodedata;
- bNodeThreadStack *nts;
- int condition= (in[0]->vec[0] > 0.0f);
- bNodeSocket *sock;
- bNodeStack *ns;
- int iteration;
-
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode=exec->nodetree->nodes.first; inode; inode=inode->next)
- inode->need_exec = 1;
- }
-
- nts = ntreeGetThreadStack(exec, thread);
-
- /* "Condition" socket */
- sock = exec->nodetree->outputs.first;
- ns = node_get_socket_stack(nts->stack, sock);
-
- iteration = 0;
-// group_copy_inputs(node, in, nts->stack);
- while (condition && iteration < node->custom1) {
-// if (iteration > 0)
-// loop_init_iteration(exec->nodetree, nts->stack);
-// ntreeExecThreadNodes(exec, nts, data, thread);
-
- condition = (ns->vec[0] > 0.0f);
- ++iteration;
- }
-// loop_copy_outputs(node, in, out, exec->stack);
-
- ntreeReleaseThreadStack(nts);
-}
-
-void register_node_type_tex_whileloop(bNodeTreeType *ttype)
-{
- static bNodeType ntype;
-
- node_type_base(ttype, &ntype, NODE_WHILELOOP, "While", NODE_CLASS_GROUP, NODE_OPTIONS);
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 200);
- node_type_label(&ntype, node_group_label);
- node_type_init(&ntype, node_whileloop_init);
- node_type_valid(&ntype, node_group_valid);
- node_type_template(&ntype, node_whileloop_template);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_tree(&ntype, node_whileloop_init_tree, node_loop_update_tree);
- node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear);
- node_type_exec_new(&ntype, group_initexec, group_freeexec, whileloop_execute);
-
- nodeRegisterType(ttype, &ntype);
-}
-#endif
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index 77521190590..25da4f19e52 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.c
@@ -33,14 +33,14 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_FLOAT, 1, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Color") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c
index 2add5c820eb..971520ebc38 100644
--- a/source/blender/nodes/texture/nodes/node_texture_coord.c
+++ b/source/blender/nodes/texture/nodes/node_texture_coord.c
@@ -33,7 +33,7 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_VECTOR, 0, N_("Coordinates") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index 6ccb5e1e83f..5980f938938 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -36,7 +36,7 @@
/* **************** CURVE Time ******************** */
/* custom1 = sfra, custom2 = efra */
-static bNodeSocketTemplate time_outputs[]= {
+static bNodeSocketTemplate time_outputs[] = {
{ SOCK_FLOAT, 0, N_("Value") },
{ -1, 0, "" }
};
@@ -83,12 +83,12 @@ void register_node_type_tex_curve_time(bNodeTreeType *ttype)
}
/* **************** CURVE RGB ******************** */
-static bNodeSocketTemplate rgb_inputs[]= {
+static bNodeSocketTemplate rgb_inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate rgb_outputs[]= {
+static bNodeSocketTemplate rgb_outputs[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c
index eae34e2ce47..a2875c31d9e 100644
--- a/source/blender/nodes/texture/nodes/node_texture_decompose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c
@@ -34,11 +34,11 @@
#include "NOD_texture.h"
#include <math.h>
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_FLOAT, 0, N_("Red") },
{ SOCK_FLOAT, 0, N_("Green") },
{ SOCK_FLOAT, 0, N_("Blue") },
diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c
index 29f08a0ded0..8c3b1555d5d 100644
--- a/source/blender/nodes/texture/nodes/node_texture_distance.c
+++ b/source/blender/nodes/texture/nodes/node_texture_distance.c
@@ -35,13 +35,13 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_VECTOR, 1, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
{ SOCK_VECTOR, 1, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_FLOAT, 0, N_("Value") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
index 6863eab9150..b5e9969a830 100644
--- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
+++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
@@ -34,7 +34,7 @@
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_FLOAT, 1, N_("Hue"), 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, PROP_NONE },
{ SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR },
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR },
@@ -42,7 +42,7 @@ static bNodeSocketTemplate inputs[]= {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Color") },
{ -1, 0, "" }
};
@@ -56,14 +56,14 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
hsv[0]+= (hue - 0.5f);
if (hsv[0]>1.0f) hsv[0]-=1.0f; else if (hsv[0]<0.0f) hsv[0]+= 1.0f;
hsv[1]*= sat;
- if (hsv[1]>1.0f) hsv[1]= 1.0f; else if (hsv[1]<0.0f) hsv[1]= 0.0f;
+ if (hsv[1]>1.0f) hsv[1] = 1.0f; else if (hsv[1]<0.0f) hsv[1] = 0.0f;
hsv[2]*= val;
- if (hsv[2]>1.0f) hsv[2]= 1.0f; else if (hsv[2]<0.0f) hsv[2]= 0.0f;
+ if (hsv[2]>1.0f) hsv[2] = 1.0f; else if (hsv[2]<0.0f) hsv[2] = 0.0f;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
- out[0]= mfac*in[0] + fac*col[0];
- out[1]= mfac*in[1] + fac*col[1];
- out[2]= mfac*in[2] + fac*col[2];
+ out[0] = mfac*in[0] + fac*col[0];
+ out[1] = mfac*in[1] + fac*col[1];
+ out[2] = mfac*in[2] + fac*col[2];
}
else {
copy_v4_v4(out, in);
diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index 7ce91c37295..f3fdaf0bb64 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -33,7 +33,7 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c
index 0339c3f0cf2..9c2963d2dc2 100644
--- a/source/blender/nodes/texture/nodes/node_texture_invert.c
+++ b/source/blender/nodes/texture/nodes/node_texture_invert.c
@@ -34,14 +34,14 @@
#include "NOD_texture.h"
/* **************** INVERT ******************** */
-static bNodeSocketTemplate inputs[]= {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate inputs[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" }
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 36e9cac0827..95d70ccc7d6 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -35,15 +35,15 @@
/* **************** SCALAR MATH ******************** */
-static bNodeSocketTemplate inputs[]= {
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
- { -1, 0, "" }
+static bNodeSocketTemplate inputs[] = {
+ { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
- { SOCK_FLOAT, 0, N_("Value")},
- { -1, 0, "" }
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_FLOAT, 0, N_("Value")},
+ { -1, 0, "" }
};
static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
@@ -112,7 +112,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
{
/* Only raise negative numbers by full integers */
if ( in0 >= 0 ) {
- out[0]= pow(in0, in1);
+ out[0] = pow(in0, in1);
}
else {
float y_mod_1 = fmod(in1, 1);
@@ -178,7 +178,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
fprintf(stderr,
"%s:%d: unhandeld value in switch statement: %d\n",
__FILE__, __LINE__, node->custom1);
- }
+ }
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
index bf6cb7a3262..fe04854c734 100644
--- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
@@ -34,13 +34,13 @@
#include "NOD_texture.h"
/* **************** MIX RGB ******************** */
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_FLOAT, 1, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR },
{ SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f },
{ SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Color") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index ce22bc00a55..2f5efe8c45e 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -34,7 +34,7 @@
#include "NOD_texture.h"
/* **************** COMPOSITE ******************** */
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION},
{ -1, 0, "" }
@@ -65,7 +65,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o
tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
- target->talpha = 1;
+ target->talpha = TRUE;
if (target->nor) {
if (in[1] && in[1]->hasinput)
@@ -170,7 +170,7 @@ void register_node_type_tex_output(bNodeTreeType *ttype)
node_type_exec(&ntype, exec);
/* Do not allow muting output. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index 102f6e1c428..8876d98b9b2 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -40,12 +40,12 @@
*/
-static bNodeSocketTemplate outputs_both[]= {
+static bNodeSocketTemplate outputs_both[] = {
{ SOCK_RGBA, 0, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f },
{ SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs_color_only[]= {
+static bNodeSocketTemplate outputs_color_only[] = {
{ SOCK_RGBA, 0, N_("Color") },
{ -1, 0, "" }
};
@@ -57,7 +57,7 @@ static bNodeSocketTemplate outputs_color_only[]= {
{ SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f }
/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */
-static void do_proc(float *result, TexParams *p, float *col1, float *col2, char is_normal, Tex *tex, short thread)
+static void do_proc(float *result, TexParams *p, const float col1[4], const float col2[4], char is_normal, Tex *tex, const short thread)
{
TexResult texres;
int textype;
@@ -69,7 +69,7 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char
texres.nor = NULL;
textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex,
- &texres, thread, 0, p->shi, p->mtex);
+ &texres, thread, 0, p->shi, p->mtex);
if (is_normal)
return;
@@ -83,7 +83,7 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char
}
}
-typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, short thread);
+typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, const short thread);
static void texfn(
float *result,
@@ -138,7 +138,7 @@ static int count_outputs(bNode *node)
/* --- VORONOI -- */
-static bNodeSocketTemplate voronoi_inputs[]= {
+static bNodeSocketTemplate voronoi_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("W1"), 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
{ SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
@@ -163,7 +163,7 @@ static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short th
ProcDef(voronoi)
/* --- BLEND -- */
-static bNodeSocketTemplate blend_inputs[]= {
+static bNodeSocketTemplate blend_inputs[] = {
COMMON_INPUTS,
{ -1, 0, "" }
};
@@ -171,7 +171,7 @@ ProcNoInputs(blend)
ProcDef(blend)
/* -- MAGIC -- */
-static bNodeSocketTemplate magic_inputs[]= {
+static bNodeSocketTemplate magic_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
{ -1, 0, "" }
@@ -183,7 +183,7 @@ static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thre
ProcDef(magic)
/* --- MARBLE --- */
-static bNodeSocketTemplate marble_inputs[]= {
+static bNodeSocketTemplate marble_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
@@ -197,7 +197,7 @@ static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thr
ProcDef(marble)
/* --- CLOUDS --- */
-static bNodeSocketTemplate clouds_inputs[]= {
+static bNodeSocketTemplate clouds_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ -1, 0, "" }
@@ -209,7 +209,7 @@ static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thr
ProcDef(clouds)
/* --- DISTORTED NOISE --- */
-static bNodeSocketTemplate distnoise_inputs[]= {
+static bNodeSocketTemplate distnoise_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Distortion"), 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f, PROP_UNSIGNED },
@@ -223,7 +223,7 @@ static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short
ProcDef(distnoise)
/* --- WOOD --- */
-static bNodeSocketTemplate wood_inputs[]= {
+static bNodeSocketTemplate wood_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
@@ -237,7 +237,7 @@ static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short threa
ProcDef(wood)
/* --- MUSGRAVE --- */
-static bNodeSocketTemplate musgrave_inputs[]= {
+static bNodeSocketTemplate musgrave_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED },
@@ -258,7 +258,7 @@ static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short t
ProcDef(musgrave)
/* --- NOISE --- */
-static bNodeSocketTemplate noise_inputs[]= {
+static bNodeSocketTemplate noise_inputs[] = {
COMMON_INPUTS,
{ -1, 0, "" }
};
@@ -266,7 +266,7 @@ ProcNoInputs(noise)
ProcDef(noise)
/* --- STUCCI --- */
-static bNodeSocketTemplate stucci_inputs[]= {
+static bNodeSocketTemplate stucci_inputs[] = {
COMMON_INPUTS,
{ SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
{ SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c
index a7832c8c180..1b1d57044a3 100644
--- a/source/blender/nodes/texture/nodes/node_texture_rotate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c
@@ -35,19 +35,19 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, N_("Turns"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
{ SOCK_VECTOR, 1, N_("Axis"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION },
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" }
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
};
-static void rotate(float new_co[3], float a, float ax[3], float co[3])
+static void rotate(float new_co[3], float a, float ax[3], const float co[3])
{
float para[3];
float perp[3];
diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c
index 130a21ba84d..56562724fb9 100644
--- a/source/blender/nodes/texture/nodes/node_texture_scale.c
+++ b/source/blender/nodes/texture/nodes/node_texture_scale.c
@@ -33,15 +33,15 @@
#include <math.h>
#include "node_texture_util.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f },
{ SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 0.0f, -10.0f, 10.0f, PROP_XYZ },
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" }
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c
index 4832f19f2c7..cc7367a7632 100644
--- a/source/blender/nodes/texture/nodes/node_texture_texture.c
+++ b/source/blender/nodes/texture/nodes/node_texture_texture.c
@@ -35,13 +35,13 @@
#include "RE_shader_ext.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f },
{ SOCK_RGBA, 1, N_("Color2"), 0.0f, 0.0f, 0.0f, 1.0f },
{ -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
+static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Color") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c
index 85f857ca2be..a95cb00a47d 100644
--- a/source/blender/nodes/texture/nodes/node_texture_translate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_translate.c
@@ -34,15 +34,15 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION },
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" }
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_RGBA, 0, N_("Color")},
+ { -1, 0, "" }
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c
index 2d107b87578..bbfc1fa616b 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.c
@@ -33,23 +33,23 @@
#include "node_texture_util.h"
#include "NOD_texture.h"
-static bNodeSocketTemplate inputs[]= {
+static bNodeSocketTemplate inputs[] = {
{ SOCK_FLOAT, 1, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE },
{ SOCK_FLOAT, 1, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED },
- { -1, 0, "" }
+ { -1, 0, "" }
};
-static bNodeSocketTemplate outputs[]= {
- { SOCK_VECTOR, 0, N_("Normal") },
- { -1, 0, "" }
+static bNodeSocketTemplate outputs[] = {
+ { SOCK_VECTOR, 0, N_("Normal") },
+ { -1, 0, "" }
};
static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
float new_co[3];
- float *co = p->co;
+ const float *co = p->co;
- float nabla = tex_input_value(in[1], p, thread);
+ float nabla = tex_input_value(in[1], p, thread);
float val;
float nor[3];
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
index 515613509f6..78635453fc1 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
@@ -34,11 +34,11 @@
#include "NOD_texture.h"
/* **************** VALTORGB ******************** */
-static bNodeSocketTemplate valtorgb_in[]= {
+static bNodeSocketTemplate valtorgb_in[] = {
{ SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ -1, 0, "" }
};
-static bNodeSocketTemplate valtorgb_out[]= {
+static bNodeSocketTemplate valtorgb_out[] = {
{ SOCK_RGBA, 0, N_("Color")},
{ -1, 0, "" }
};
@@ -77,11 +77,11 @@ void register_node_type_tex_valtorgb(bNodeTreeType *ttype)
}
/* **************** RGBTOBW ******************** */
-static bNodeSocketTemplate rgbtobw_in[]= {
+static bNodeSocketTemplate rgbtobw_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate rgbtobw_out[]= {
+static bNodeSocketTemplate rgbtobw_out[] = {
{ SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c
index bc31bef59d8..5cb8d8c438c 100644
--- a/source/blender/nodes/texture/nodes/node_texture_viewer.c
+++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c
@@ -66,7 +66,7 @@ void register_node_type_tex_viewer(bNodeTreeType *ttype)
node_type_exec(&ntype, exec);
/* Do not allow muting viewer node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/opencl/CMakeLists.txt b/source/blender/opencl/CMakeLists.txt
index 20dcf33d363..b3c76db1bca 100644
--- a/source/blender/opencl/CMakeLists.txt
+++ b/source/blender/opencl/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 14444 2008-04-16 22:40:48Z hos $
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 83a40ecc068..9bd45d2b759 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -80,6 +80,7 @@ int BPY_button_exec(struct bContext *C, const char *expr, double *value, const
int BPY_string_exec(struct bContext *C, const char *expr);
void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */
+void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr);
int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result);
void BPY_context_set(struct bContext *C);
void BPY_context_update(struct bContext *C);
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index fd5fa63647b..2cae10101d1 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -645,7 +645,7 @@ static PyGetSetDef bpy_bmface_getseters[] = {
static PyGetSetDef bpy_bmloop_getseters[] = {
/* generic */
- // flags are available but not used for loops.
+ /* flags are available but not used for loops. */
// {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
// {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN},
{(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG},
diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h
index 947e66bf24e..df5231a4b1b 100644
--- a/source/blender/python/bmesh/bmesh_py_types.h
+++ b/source/blender/python/bmesh/bmesh_py_types.h
@@ -116,7 +116,7 @@ typedef struct BPy_BMElemSeq {
/* if this is a sequence on an existing element,
* loops of faces for eg.
- * If this veriable is set, it will be used */
+ * If this variable is set, it will be used */
/* we hold a reference to this.
* check in case the owner becomes invalid on access */
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 0391839c763..1fea12d105c 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -1079,7 +1079,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
ret = -1;
}
else {
- BLI_strncpy(mstring->s, tmp_val, MIN2(PyBytes_Size(py_value), sizeof(mstring->s)));
+ BLI_strncpy(mstring->s, tmp_val, min_ii(PyBytes_Size(py_value), sizeof(mstring->s)));
}
break;
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index 85095596a4e..2ff731559d1 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -387,7 +387,7 @@ void BPy_BM_init_types_select(void)
BPy_BMEditSelSeq_Type.tp_name = "BMEditSelSeq";
BPy_BMEditSelIter_Type.tp_name = "BMEditSelIter";
- BPy_BMEditSelSeq_Type.tp_doc = NULL; // todo
+ BPy_BMEditSelSeq_Type.tp_doc = NULL; /* todo */
BPy_BMEditSelIter_Type.tp_doc = NULL;
BPy_BMEditSelSeq_Type.tp_repr = (reprfunc)NULL;
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 45b767c6eda..a10bfef2a8d 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -520,7 +520,7 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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) {
@@ -556,7 +556,7 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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)
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index b9ef4b056ad..ad97ceb68d4 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -1,4 +1,4 @@
-/*
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -56,6 +56,7 @@ static ListBase bpy_import_main_list;
static PyMethodDef bpy_import_meth;
static PyMethodDef bpy_reload_meth;
+static PyObject *imp_reload_orig = NULL;
/* 'builtins' is most likely PyEval_GetBuiltins() */
void bpy_import_init(PyObject *builtins)
@@ -69,7 +70,13 @@ void bpy_import_init(PyObject *builtins)
* XXX, use import hooks */
mod = PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
if (mod) {
- PyDict_SetItemString(PyModule_GetDict(mod), "reload", item = PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
+ PyObject *mod_dict = PyModule_GetDict(mod);
+
+ /* blender owns the function */
+ imp_reload_orig = PyDict_GetItemString(mod_dict, "reload");
+ Py_INCREF(imp_reload_orig);
+
+ PyDict_SetItemString(mod_dict, "reload", item = PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
Py_DECREF(mod);
}
else {
@@ -309,7 +316,12 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
int found = 0;
/* try reimporting from file */
- newmodule = PyImport_ReloadModule(module);
+
+ /* in Py3.3 this just calls imp.reload() which we overwrite, causing recursive calls */
+ //newmodule = PyImport_ReloadModule(module);
+
+ newmodule = PyObject_CallFunctionObjArgs(imp_reload_orig, module, NULL);
+
if (newmodule)
return newmodule;
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 06b6192a091..529b2e708ad 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -43,43 +43,39 @@
#include "py_capi_utils.h"
#endif
-extern PyTypeObject BPy_IDArray_Type;
-extern PyTypeObject BPy_IDGroup_Iter_Type;
-extern PyTypeObject BPy_IDGroup_Type;
-
/*********************** ID Property Main Wrapper Stuff ***************/
/* ----------------------------------------------------------------------------
* static conversion functions to avoid duplicate code, no type checking.
*/
-static PyObject *idprop_py_from_idp_string(IDProperty *prop)
+static PyObject *idprop_py_from_idp_string(const IDProperty *prop)
{
if (prop->subtype == IDP_STRING_SUB_BYTE) {
- return PyBytes_FromStringAndSize(IDP_Array(prop), prop->len);
+ return PyBytes_FromStringAndSize(IDP_String(prop), prop->len);
}
else {
#ifdef USE_STRING_COERCE
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
#else
- return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len - 1);
+ return PyUnicode_FromStringAndSize(IDP_String(prop), prop->len - 1);
#endif
}
}
-static PyObject *idprop_py_from_idp_int(IDProperty *prop)
+static PyObject *idprop_py_from_idp_int(const IDProperty *prop)
{
- return PyLong_FromLong((long)prop->data.val);
+ return PyLong_FromLong((long)IDP_Int(prop));
}
-static PyObject *idprop_py_from_idp_float(IDProperty *prop)
+static PyObject *idprop_py_from_idp_float(const IDProperty *prop)
{
- return PyFloat_FromDouble((double)(*(float *)(&prop->data.val)));
+ return PyFloat_FromDouble((double)IDP_Float(prop));
}
-static PyObject *idprop_py_from_idp_double(IDProperty *prop)
+static PyObject *idprop_py_from_idp_double(const IDProperty *prop)
{
- return PyFloat_FromDouble((*(double *)(&prop->data.val)));
+ return PyFloat_FromDouble(IDP_Double(prop));
}
static PyObject *idprop_py_from_idp_group(ID *id, IDProperty *prop, IDProperty *parent)
@@ -193,7 +189,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
PyErr_SetString(PyExc_TypeError, "expected an int type");
return -1;
}
- prop->data.val = ivalue;
+ IDP_Int(prop) = ivalue;
break;
}
case IDP_FLOAT:
@@ -203,7 +199,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
PyErr_SetString(PyExc_TypeError, "expected a float");
return -1;
}
- *(float *)&self->prop->data.val = fvalue;
+ IDP_Float(self->prop) = fvalue;
break;
}
case IDP_DOUBLE:
@@ -213,7 +209,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
PyErr_SetString(PyExc_TypeError, "expected a float");
return -1;
}
- *(double *)&self->prop->data.val = dvalue;
+ IDP_Double(self->prop) = dvalue;
break;
}
default:
@@ -300,40 +296,34 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
}
/* returns NULL on success, error string on failure */
-static int idp_sequence_type(PyObject *seq)
+static int idp_sequence_type(PyObject *seq_fast)
{
PyObject *item;
int type = IDP_INT;
- Py_ssize_t i, len = PySequence_Size(seq);
+ Py_ssize_t i, len = PySequence_Fast_GET_SIZE(seq_fast);
for (i = 0; i < len; i++) {
- item = PySequence_GetItem(seq, i);
+ item = PySequence_Fast_GET_ITEM(seq_fast, i);
if (PyFloat_Check(item)) {
if (type == IDP_IDPARRAY) { /* mixed dict/int */
- Py_DECREF(item);
return -1;
}
type = IDP_DOUBLE;
}
else if (PyLong_Check(item)) {
if (type == IDP_IDPARRAY) { /* mixed dict/int */
- Py_DECREF(item);
return -1;
}
}
else if (PyMapping_Check(item)) {
if (i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */
- Py_DECREF(item);
return -1;
}
type = IDP_IDPARRAY;
}
else {
- Py_XDECREF(item);
return -1;
}
-
- Py_DECREF(item);
}
return type;
@@ -386,48 +376,61 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
//prop->subtype = IDP_STRING_SUB_BYTE;
}
else if (PySequence_Check(ob)) {
+ PyObject *ob_seq_fast = PySequence_Fast(ob, "py -> idprop");
PyObject *item;
int i;
- if ((val.array.type = idp_sequence_type(ob)) == -1)
+ if (ob_seq_fast == NULL) {
+ PyErr_Print();
+ PyErr_Clear();
+ return "error converting the sequence";
+ }
+
+ if ((val.array.type = idp_sequence_type(ob_seq_fast)) == -1) {
+ Py_DECREF(ob_seq_fast);
return "only floats, ints and dicts are allowed in ID property arrays";
+ }
/* validate sequence and derive type.
* we assume IDP_INT unless we hit a float
* number; then we assume it's */
- val.array.len = PySequence_Size(ob);
+ val.array.len = PySequence_Fast_GET_SIZE(ob_seq_fast);
switch (val.array.type) {
case IDP_DOUBLE:
prop = IDP_New(IDP_ARRAY, &val, name);
for (i = 0; i < val.array.len; i++) {
- item = PySequence_GetItem(ob, i);
+ item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
((double *)IDP_Array(prop))[i] = (float)PyFloat_AsDouble(item);
- Py_DECREF(item);
}
break;
case IDP_INT:
prop = IDP_New(IDP_ARRAY, &val, name);
for (i = 0; i < val.array.len; i++) {
- item = PySequence_GetItem(ob, i);
+ item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
((int *)IDP_Array(prop))[i] = (int)PyLong_AsSsize_t(item);
- Py_DECREF(item);
}
break;
case IDP_IDPARRAY:
prop = IDP_NewIDPArray(name);
for (i = 0; i < val.array.len; i++) {
const char *error;
- item = PySequence_GetItem(ob, i);
+ item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
error = BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item);
- Py_DECREF(item);
- if (error)
+ if (error) {
+ Py_DECREF(ob_seq_fast);
return error;
+ }
}
break;
+ default:
+ Py_DECREF(ob_seq_fast);
+ return "internal error with idp array.type";
}
+
+ Py_DECREF(ob_seq_fast);
}
else if (PyMapping_Check(ob)) {
PyObject *keys, *vals, *key, *pval;
@@ -471,7 +474,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
if (group->type == IDP_IDPARRAY) {
IDP_AppendArray(group, prop);
- // IDP_FreeProperty(item); // IDP_AppendArray does a shallow copy (memcpy), only free memory
+ // IDP_FreeProperty(item); /* IDP_AppendArray does a shallow copy (memcpy), only free memory */
MEM_freeN(prop);
}
else {
@@ -802,17 +805,28 @@ static PyObject *BPy_IDGroup_Update(BPy_IDProperty *self, PyObject *value)
PyObject *pkey, *pval;
Py_ssize_t i = 0;
- if (!PyDict_Check(value)) {
+ if (BPy_IDGroup_Check(value)) {
+ BPy_IDProperty *other = (BPy_IDProperty *)value;
+ if (UNLIKELY(self->prop == other->prop)) {
+ Py_RETURN_NONE;
+ }
+
+ /* XXX, possible one is inside the other */
+ IDP_MergeGroup(self->prop, other->prop, TRUE);
+ }
+ else if (PyDict_Check(value)) {
+ while (PyDict_Next(value, &i, &pkey, &pval)) {
+ BPy_IDGroup_Map_SetItem(self, pkey, pval);
+ if (PyErr_Occurred()) return NULL;
+ }
+ }
+ else {
PyErr_Format(PyExc_TypeError,
- "expected a dict not a %.200s",
+ "expected a dict or an IDPropertyGroup type, not a %.200s",
Py_TYPE(value)->tp_name);
return NULL;
}
- while (PyDict_Next(value, &i, &pkey, &pval)) {
- BPy_IDGroup_Map_SetItem(self, pkey, pval);
- if (PyErr_Occurred()) return NULL;
- }
Py_RETURN_NONE;
}
@@ -1173,7 +1187,7 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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) {
@@ -1208,7 +1222,7 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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)
@@ -1416,15 +1430,15 @@ void IDProp_Init_Types(void)
/* --- */
static struct PyModuleDef IDProp_types_module_def = {
- PyModuleDef_HEAD_INIT,
- "idprop.types", /* m_name */
- NULL, /* m_doc */
- 0, /* m_size */
- NULL, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL, /* m_free */
+ PyModuleDef_HEAD_INIT,
+ "idprop.types", /* m_name */
+ NULL, /* m_doc */
+ 0, /* m_size */
+ NULL, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
};
static PyObject *BPyInit_idprop_types(void)
@@ -1483,3 +1497,40 @@ PyObject *BPyInit_idprop(void)
return mod;
}
+
+
+#ifdef DEBUG
+/* -------------------------------------------------------------------- */
+/* debug only function */
+
+void IDP_spit(IDProperty *prop)
+{
+ if (prop) {
+ PyGILState_STATE gilstate;
+ int use_gil = TRUE; /* !PYC_INTERPRETER_ACTIVE; */
+ PyObject *ret_dict;
+ PyObject *ret_str;
+
+ if (use_gil) {
+ gilstate = PyGILState_Ensure();
+ }
+
+ /* to_dict() */
+ ret_dict = BPy_IDGroup_MapDataToPy(prop);
+ ret_str = PyObject_Repr(ret_dict);
+ Py_DECREF(ret_dict);
+
+ printf("IDProperty: %s\n", _PyUnicode_AsString(ret_str));
+
+ Py_DECREF(ret_str);
+
+ if (use_gil) {
+ PyGILState_Release(gilstate);
+ }
+ }
+ else {
+ printf("IDProperty: <NIL>\n");
+ }
+}
+
+#endif
diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h
index 99e291f69c0..cb82676c4d9 100644
--- a/source/blender/python/generic/idprop_py_api.h
+++ b/source/blender/python/generic/idprop_py_api.h
@@ -32,6 +32,17 @@ struct ID;
struct IDProperty;
struct BPy_IDGroup_Iter;
+extern PyTypeObject BPy_IDArray_Type;
+extern PyTypeObject BPy_IDGroup_Iter_Type;
+extern PyTypeObject BPy_IDGroup_Type;
+
+#define BPy_IDArray_Check(v) (PyObject_TypeCheck(v, &BPy_IDArray_Type))
+#define BPy_IDArray_CheckExact(v) (Py_TYPE(v) == &BPy_IDArray_Type)
+#define BPy_IDGroup_Iter_Check(v) (PyObject_TypeCheck(v, &BPy_IDGroup_Iter_Type))
+#define BPy_IDGroup_Iter_CheckExact(v) (Py_TYPE(v) == &BPy_IDGroup_Iter_Type)
+#define BPy_IDGroup_Check(v) (PyObject_TypeCheck(v, &BPy_IDGroup_Type))
+#define BPy_IDGroup_CheckExact(v) (Py_TYPE(v) == &BPy_IDGroup_Type)
+
typedef struct BPy_IDProperty {
PyObject_VAR_HEAD
struct ID *id; /* can be NULL */
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 9492c8384dc..b8537a1359f 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -504,7 +504,7 @@ void PyC_SetHomePath(const char *py_path_bundle)
* but current Python lib (release 3.1.1) doesn't handle these correctly */
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");
+ \nThis may make python import function fail\n");
#endif
@@ -542,7 +542,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
if (fp) {
PyGILState_STATE gilstate = PyGILState_Ensure();
- va_list vargs;
+ va_list vargs;
int *sizes = PyMem_MALLOC(sizeof(int) * (n / 2));
int i;
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 481cfb17c7a..935a5f9030b 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -69,4 +69,4 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int
int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix);
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
-#endif // __PY_CAPI_UTILS_H__
+#endif /* __PY_CAPI_UTILS_H__ */
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index 604166eed3c..61c49027d9a 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -30,12 +30,12 @@ set(INC
../../blenlib
../../blenloader
../../editors/include
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
- ../../gpu
- ../../../../intern/guardedalloc
../../../../intern/cycles/blender
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 3bf44e43c56..3ed662f41d7 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -32,6 +32,9 @@
#include <Python.h>
+#include "RNA_types.h"
+#include "RNA_access.h"
+
#include "bpy.h"
#include "bpy_util.h"
#include "bpy_rna.h"
@@ -49,8 +52,6 @@
#include "BKE_global.h" /* XXX, G.main only */
#include "BKE_blender.h"
-#include "RNA_access.h"
-
#include "MEM_guardedalloc.h"
/* external util modules */
@@ -278,7 +279,7 @@ void BPy_init_modules(void)
bpy_import_test("bpy_types");
PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
bpy_import_test("bpy_types");
- PyModule_AddObject(mod, "props", BPY_rna_props());
+ PyModule_AddObject(mod, "props", BPY_rna_props());
/* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
PyModule_AddObject(mod, "ops", BPY_operator_module());
PyModule_AddObject(mod, "app", BPY_app_struct());
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index ccce0d8c5ae..a8aa7269b72 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -242,6 +242,7 @@ static PyGetSetDef bpy_app_getsets[] = {
{(char *)"debug_ffmpeg", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_FFMPEG},
{(char *)"debug_python", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_PYTHON},
{(char *)"debug_events", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_EVENTS},
+ {(char *)"debug_handlers", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_HANDLERS},
{(char *)"debug_wm", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_WM},
{(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL},
diff --git a/source/blender/python/intern/bpy_app.h b/source/blender/python/intern/bpy_app.h
index 5bf36f04ba0..226bf44a493 100644
--- a/source/blender/python/intern/bpy_app.h
+++ b/source/blender/python/intern/bpy_app.h
@@ -29,4 +29,4 @@
PyObject *BPY_app_struct(void);
-#endif // __BPY_APP_H__
+#endif /* __BPY_APP_H__ */
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.h b/source/blender/python/intern/bpy_app_ffmpeg.h
index cadbb021d31..26d6e13f8f4 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.h
+++ b/source/blender/python/intern/bpy_app_ffmpeg.h
@@ -29,4 +29,4 @@
PyObject *BPY_app_ffmpeg_struct(void);
-#endif // __BPY_APP_FFMPEG_H__
+#endif /* __BPY_APP_FFMPEG_H__ */
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 4d7f2080bbc..90a0444ceae 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -284,7 +284,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
if (PyList_GET_SIZE(cb_list) > 0) {
PyGILState_STATE gilstate = PyGILState_Ensure();
- PyObject *args = PyTuple_New(1); // save python creating each call
+ PyObject *args = PyTuple_New(1); /* save python creating each call */
PyObject *func;
PyObject *ret;
Py_ssize_t pos;
diff --git a/source/blender/python/intern/bpy_app_handlers.h b/source/blender/python/intern/bpy_app_handlers.h
index 1f1eaf04a8b..40ca43909ed 100644
--- a/source/blender/python/intern/bpy_app_handlers.h
+++ b/source/blender/python/intern/bpy_app_handlers.h
@@ -29,4 +29,4 @@
PyObject *BPY_app_handlers_struct(void);
-#endif // __BPY_APP_HANDLERS_H__
+#endif /* __BPY_APP_HANDLERS_H__ */
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index de23b3bf109..9a79616c23b 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -280,7 +280,7 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
}
-#if 0 // slow, with this can avoid all Py_CompileString above.
+#if 0 /* slow, with this can avoid all Py_CompileString above. */
/* execute expression to get a value */
retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars);
#else
diff --git a/source/blender/python/intern/bpy_driver.h b/source/blender/python/intern/bpy_driver.h
index 6d1696d6cdc..1fccec7e1b2 100644
--- a/source/blender/python/intern/bpy_driver.h
+++ b/source/blender/python/intern/bpy_driver.h
@@ -36,4 +36,4 @@ extern PyObject *bpy_pydriver_Dict;
float BPY_driver_exec(struct ChannelDriver *driver, const float evaltime);
void BPY_driver_reset(void);
-#endif // __BPY_DRIVER_H__
+#endif /* __BPY_DRIVER_H__ */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index b628f42e759..94cbee383ea 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -69,7 +69,7 @@
#include "BPY_extern.h"
-#include "../generic/bpy_internal_import.h" // our own imports
+#include "../generic/bpy_internal_import.h" /* our own imports */
#include "../generic/py_capi_utils.h"
/* inittab initialization functions */
@@ -180,10 +180,10 @@ void BPY_text_free_code(Text *text)
void BPY_modules_update(bContext *C)
{
-#if 0 // slow, this runs all the time poll, draw etc 100's of time a sec.
+#if 0 /* slow, this runs all the time poll, draw etc 100's of time a sec. */
PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
PyModule_AddObject(mod, "data", BPY_rna_module());
- PyModule_AddObject(mod, "types", BPY_rna_types()); // atm this does not need updating
+ PyModule_AddObject(mod, "types", BPY_rna_types()); /* atm this does not need updating */
#endif
/* refreshes the main struct */
@@ -268,7 +268,7 @@ void BPY_python_start(int argc, const char **argv)
Py_Initialize();
- // PySys_SetArgv(argc, argv); // broken in py3, not a huge deal
+ // PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
/* sigh, why do python guys not have a (char **) version anymore? */
{
int i;
@@ -510,6 +510,18 @@ void BPY_DECREF(void *pyob_ptr)
PyGILState_Release(gilstate);
}
+void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr)
+{
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ const int do_invalidate = (Py_REFCNT((PyObject *)pyob_ptr) > 1);
+ Py_DECREF((PyObject *)pyob_ptr);
+ if (do_invalidate) {
+ pyrna_invalidate(pyob_ptr);
+ }
+ PyGILState_Release(gilstate);
+}
+
+
/* return -1 on error, else 0 */
int BPY_button_exec(bContext *C, const char *expr, double *value, const short verbose)
{
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index bb116017f6b..bd033736865 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -75,9 +75,10 @@ static EnumPropertyItem property_flag_enum_items[] = {
static EnumPropertyItem property_subtype_string_items[] = {
{PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""},
{PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""},
- {PROP_FILENAME, "FILENAME", 0, "Filename", ""},
+ {PROP_FILENAME, "FILE_NAME", 0, "Filename", ""},
{PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""},
{PROP_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+ {PROP_PASSWORD, "PASSWORD", 0, "Password", 0},
{PROP_NONE, "NONE", 0, "None", ""},
{0, NULL, 0, NULL, NULL}};
@@ -260,7 +261,7 @@ static int bpy_prop_callback_check(PyObject *py_func, int argcount)
static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_cb)
{
/* assume this is already checked for type and arg length */
- if (update_cb) {
+ if (update_cb && update_cb != Py_None) {
PyObject **py_data = MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, __func__);
RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb);
py_data[BPY_DATA_CB_SLOT_UPDATE] = update_cb;
@@ -309,35 +310,38 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
/* terse macros for error checks shared between all funcs cant use function
* calls because of static strings passed to pyrna_set_to_enum_bitfield */
#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \
- if (id_len >= MAX_IDPROP_NAME) { \
+ if (UNLIKELY(id_len >= MAX_IDPROP_NAME)) { \
PyErr_Format(PyExc_TypeError, \
#_func"(): '%.200s' too long, max length is %d", \
id, MAX_IDPROP_NAME - 1); \
return NULL; \
} \
- if (RNA_def_property_free_identifier(srna, id) == -1) { \
+ if (UNLIKELY(RNA_def_property_free_identifier(srna, id) == -1)) { \
PyErr_Format(PyExc_TypeError, \
#_func"(): '%s' is defined as a non-dynamic type", \
id); \
return NULL; \
} \
- if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \
+ if (UNLIKELY(pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \
pyopts, \
&opts, \
- #_func"(options={ ...}):")) \
+ #_func"(options={ ...}):"))) \
{ \
return NULL; \
} (void)0
#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \
BPY_PROPDEF_CHECK(_func, _property_flag_items); \
- if (pysubtype && RNA_enum_value_from_id(_subtype, \
+ if (UNLIKELY(pysubtype && RNA_enum_value_from_id(_subtype, \
pysubtype, \
- &subtype) == 0) \
+ &subtype) == 0)) \
{ \
+ const char *enum_str = BPy_enum_as_string(_subtype); \
PyErr_Format(PyExc_TypeError, \
- #_func"(subtype='%s'): invalid subtype", \
- pysubtype); \
+ #_func"(subtype='%s'): " \
+ "subtype not found in (%s)", \
+ pysubtype, enum_str); \
+ MEM_freeN((void *)enum_str); \
return NULL; \
} (void)0
@@ -921,7 +925,7 @@ BPY_PROPDEF_NAME_DOC
BPY_PROPDEF_DESC_DOC
" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'LIBRARY_EDITABLE'].\n"
" :type options: set\n"
-" :arg subtype: Enumerator in ['FILE_PATH', 'DIR_PATH', 'FILENAME', 'NONE'].\n"
+" :arg subtype: Enumerator in ['FILE_PATH', 'DIR_PATH', 'FILE_NAME', 'NONE'].\n"
" :type subtype: string\n"
BPY_PROPDEF_UPDATE_DOC
);
@@ -1511,7 +1515,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
args = PyTuple_New(0);
ret = BPy_RemoveProperty(self, args, kw);
Py_DECREF(args);
- return ret;
+ return ret;
}
else if (PyTuple_GET_SIZE(args) > 1) {
PyErr_SetString(PyExc_ValueError, "all args must be keywords");
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 00c1f5cfe6c..eaaced416fe 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -119,13 +119,10 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self)
return -1;
}
-#if defined(USE_PYRNA_INVALIDATE_GC) || defined(USE_PYRNA_INVALIDATE_WEAKREF)
-static void pyrna_invalidate(BPy_DummyPointerRNA *self)
+void pyrna_invalidate(BPy_DummyPointerRNA *self)
{
- self->ptr.type = NULL; /* this is checked for validity */
- self->ptr.id.data = NULL; /* should not be needed but prevent bad pointer access, just in case */
+ RNA_POINTER_INVALIDATE(&self->ptr);
}
-#endif
#ifdef USE_PYRNA_INVALIDATE_GC
#define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g) + 1))
@@ -337,7 +334,7 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
}
return FALSE;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
#ifdef USE_PEDANTIC_WRITE
@@ -350,7 +347,7 @@ void pyrna_write_set(int val)
{
rna_disallow_writes = !val;
}
-#else // USE_PEDANTIC_WRITE
+#else /* USE_PEDANTIC_WRITE */
int pyrna_write_check(void)
{
return TRUE;
@@ -359,7 +356,7 @@ void pyrna_write_set(int UNUSED(val))
{
/* nothing */
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self);
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self);
@@ -426,7 +423,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
return -1;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError,
@@ -490,7 +487,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
return -1;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError,
@@ -547,7 +544,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
return -1;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError,
@@ -588,7 +585,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_
return order_fallback;
}
-#endif // USE_MATHUTILS
+#endif /* USE_MATHUTILS */
/* note that PROP_NONE is included as a vector subtype. this is because its handy to
* have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4. */
@@ -672,7 +669,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA *prop_eul_order = NULL;
short order = pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ);
- ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA
+ ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); /* TODO, get order from RNA */
RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul);
}
else {
@@ -698,7 +695,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
case PROP_COLOR_GAMMA:
if (len == 3) { /* color */
if (is_thick) {
- ret = Color_CreatePyObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
+ ret = Color_CreatePyObject(NULL, Py_NEW, NULL);
RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
}
else {
@@ -722,10 +719,10 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
}
}
-#else // USE_MATHUTILS
+#else /* USE_MATHUTILS */
(void)ptr;
(void)prop;
-#endif // USE_MATHUTILS
+#endif /* USE_MATHUTILS */
return ret;
}
@@ -834,7 +831,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
const char *name;
if (!PYRNA_STRUCT_IS_VALID(self)) {
- return PyUnicode_FromFormat("<bpy_struct, %.200s dead>",
+ return PyUnicode_FromFormat("<bpy_struct, %.200s invalid>",
Py_TYPE(self)->tp_name);
}
@@ -1302,7 +1299,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
val, RNA_struct_identifier(ptr->type),
ptr_name, RNA_property_identifier(prop));
-#if 0 // gives python decoding errors while generating docs :(
+#if 0 /* gives python decoding errors while generating docs :( */
char error_str[256];
BLI_snprintf(error_str, sizeof(error_str),
"RNA Warning: Current value \"%d\" "
@@ -1371,14 +1368,14 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
else {
ret = PyUnicode_FromStringAndSize(buf, buf_len);
}
-#else // USE_STRING_COERCE
+#else /* USE_STRING_COERCE */
if (subtype == PROP_BYTESTRING) {
ret = PyBytes_FromStringAndSize(buf, buf_len);
}
else {
ret = PyUnicode_FromStringAndSize(buf, buf_len);
}
-#endif // USE_STRING_COERCE
+#endif /* USE_STRING_COERCE */
if (buf_fixed != buf) {
MEM_freeN((void *)buf);
}
@@ -1635,12 +1632,12 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
if (subtype == PROP_TRANSLATE) {
param = IFACE_(param);
}
-#endif // WITH_INTERNATIONAL
+#endif /* WITH_INTERNATIONAL */
}
-#else // USE_STRING_COERCE
+#else /* USE_STRING_COERCE */
param = _PyUnicode_AsString(value);
-#endif // USE_STRING_COERCE
+#endif /* USE_STRING_COERCE */
if (param == NULL) {
if (PyUnicode_Check(value)) {
@@ -1668,7 +1665,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
}
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
-#endif // USE_STRING_COERCE
+#endif /* USE_STRING_COERCE */
}
break;
}
@@ -1778,10 +1775,21 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
if (data) {
if (flag & PROP_RNAPTR) {
- if (value == Py_None)
- memset(data, 0, sizeof(PointerRNA));
- else
- *((PointerRNA *)data) = param->ptr;
+ if (flag & PROP_THICK_WRAP) {
+ if (value == Py_None)
+ memset(data, 0, sizeof(PointerRNA));
+ else
+ *((PointerRNA *)data) = param->ptr;
+ }
+ 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)
+ *((void **)data) = NULL;
+ else
+ *((PointerRNA **)data) = &param->ptr;
+ }
}
else if (value == Py_None) {
*((void **)data) = NULL;
@@ -1995,7 +2003,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
return ret;
}
-//---------------sequence-------------------------------------------
+/* ---------------sequence------------------------------------------- */
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
{
PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self);
@@ -2604,7 +2612,7 @@ 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((void *)key, len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -2772,7 +2780,7 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *
int len = RNA_property_array_length(&self->ptr, self->prop);
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)key, len, &start, &stop, &step, &slicelength) < 0) {
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
ret = -1;
}
else if (slicelength <= 0) {
@@ -2982,7 +2990,7 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje
if (rna_disallow_writes && rna_id_write_error(&self->ptr, key)) {
return -1;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
if (group == NULL) {
PyErr_SetString(PyExc_TypeError, "bpy_struct[key] = val: id properties not supported for this type");
@@ -3441,7 +3449,7 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
return ret;
}
-//---------------getattr--------------------------------------------
+/* ---------------getattr-------------------------------------------- */
static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
{
const char *name = _PyUnicode_AsString(pyname);
@@ -3455,7 +3463,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __getattr__ must be a string");
ret = NULL;
}
- else if (name[0] == '_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups
+ else if (name[0] == '_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
/* annoying exception, maybe we need to have different types for this... */
if ((strcmp(name, "__getitem__") == 0 || strcmp(name, "__setitem__") == 0) && !RNA_struct_idprops_check(self->ptr.type)) {
PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type");
@@ -3565,7 +3573,7 @@ static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
}
#endif
-//--------------- setattr-------------------------------------------
+/* --------------- setattr------------------------------------------- */
static int pyrna_is_deferred_prop(const PyObject *value)
{
return PyTuple_CheckExact(value) &&
@@ -3678,7 +3686,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
return -1;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
if (name == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
@@ -3829,7 +3837,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
#endif
}
-//--------------- setattr-------------------------------------------
+/* --------------- setattr------------------------------------------- */
static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pyname, PyObject *value)
{
const char *name = _PyUnicode_AsString(pyname);
@@ -3840,7 +3848,7 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
return -1;
}
-#endif // USE_PEDANTIC_WRITE
+#endif /* USE_PEDANTIC_WRITE */
if (name == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
@@ -3868,6 +3876,12 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
{
PointerRNA r_ptr;
+#ifdef USE_PEDANTIC_WRITE
+ if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+ return NULL;
+ }
+#endif /* USE_PEDANTIC_WRITE */
+
RNA_property_collection_add(&self->ptr, self->prop, &r_ptr);
if (!r_ptr.data) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.add(): not supported for this collection");
@@ -3882,6 +3896,12 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb
{
int key = PyLong_AsLong(value);
+#ifdef USE_PEDANTIC_WRITE
+ if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+ return NULL;
+ }
+#endif /* USE_PEDANTIC_WRITE */
+
if (key == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.remove(): expected one int argument");
return NULL;
@@ -3897,6 +3917,12 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb
static PyObject *pyrna_prop_collection_idprop_clear(BPy_PropertyRNA *self)
{
+#ifdef USE_PEDANTIC_WRITE
+ if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+ return NULL;
+ }
+#endif /* USE_PEDANTIC_WRITE */
+
RNA_property_collection_clear(&self->ptr, self->prop);
Py_RETURN_NONE;
@@ -3906,6 +3932,12 @@ static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObje
{
int key = 0, pos = 0;
+#ifdef USE_PEDANTIC_WRITE
+ if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+ return NULL;
+ }
+#endif /* USE_PEDANTIC_WRITE */
+
if (!PyArg_ParseTuple(args, "ii", &key, &pos)) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.move(): expected two ints as arguments");
return NULL;
@@ -4275,7 +4307,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args,
foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed);
*size = RNA_raw_type_sizeof(*raw_type);
-#if 0 // works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks
+#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */
if ((*attr_tot) < 1)
*attr_tot = 1;
@@ -4617,7 +4649,7 @@ static struct PyMethodDef pyrna_prop_collection_methods[] = {
static struct PyMethodDef pyrna_prop_collection_idprop_methods[] = {
{"add", (PyCFunction)pyrna_prop_collection_idprop_add, METH_NOARGS, NULL},
{"remove", (PyCFunction)pyrna_prop_collection_idprop_remove, METH_O, NULL},
- {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, NULL},
+ {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, NULL},
{"move", (PyCFunction)pyrna_prop_collection_idprop_move, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
@@ -5564,7 +5596,7 @@ PyTypeObject pyrna_prop_collection_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
- NULL, /* subclassed */ /* tp_repr */
+ NULL, /* subclassed */ /* tp_repr */
/* Method suites for standard classes */
@@ -5598,7 +5630,7 @@ PyTypeObject pyrna_prop_collection_Type = {
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
- NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
+ NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
#ifdef USE_WEAKREFS
@@ -5683,7 +5715,7 @@ static PyTypeObject pyrna_prop_collection_idprop_Type = {
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
- NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
+ NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
#ifdef USE_WEAKREFS
@@ -5830,7 +5862,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
- NULL, /* subclassed */ /* tp_repr */
+ NULL, /* subclassed */ /* tp_repr */
/* Method suites for standard classes */
@@ -5868,7 +5900,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = {
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
- NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
+ NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
#ifdef USE_WEAKREFS
@@ -6044,8 +6076,8 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
fprintf(stderr, "%s: failed to find 'bpy_types' module\n", __func__);
return NULL;
}
- bpy_types_dict = PyModule_GetDict(bpy_types); // borrow
- Py_DECREF(bpy_types); // fairly safe to assume the dict is kept
+ bpy_types_dict = PyModule_GetDict(bpy_types); /* borrow */
+ Py_DECREF(bpy_types); /* fairly safe to assume the dict is kept */
}
newclass = PyDict_GetItemString(bpy_types_dict, idname);
@@ -6134,7 +6166,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
/* srna owns one, and the other is owned by the caller */
pyrna_subtype_set_rna(newclass, srna);
- // XXX, adding this back segfaults blender on load.
+ /* XXX, adding this back segfaults blender on load. */
// Py_DECREF(newclass); /* let srna own */
}
else {
@@ -6291,7 +6323,7 @@ int pyrna_id_FromPyObject(PyObject *obj, ID **id)
void BPY_rna_init(void)
{
-#ifdef USE_MATHUTILS // register mathutils callbacks, ok to run more then once.
+#ifdef USE_MATHUTILS /* register mathutils callbacks, ok to run more then once. */
mathutils_rna_array_cb_index = Mathutils_RegisterCallback(&mathutils_rna_array_cb);
mathutils_rna_matrix_cb_index = Mathutils_RegisterCallback(&mathutils_rna_matrix_cb);
#endif
@@ -6375,7 +6407,7 @@ PyObject *BPY_rna_doc(void)
/* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a different type
* the self->ptr and self->prop are always set to the "structs" collection */
-//---------------getattr--------------------------------------------
+/* ---------------getattr-------------------------------------------- */
static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname)
{
PointerRNA newptr;
@@ -6750,7 +6782,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
PyObject *base_class = RNA_struct_py_type_get(srna);
PyObject *item;
int i, flag, arg_count, func_arg_count;
- const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; // __name__
+ 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)
@@ -6919,11 +6951,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
#ifdef USE_PEDANTIC_WRITE
const int is_operator = RNA_struct_is_a(ptr->type, &RNA_Operator);
- const char *func_id = RNA_function_identifier(func);
+ // const char *func_id = RNA_function_identifier(func); /* UNUSED */
/* testing, for correctness, not operator and not draw function */
- const short is_readonly = ((strncmp("draw", func_id, 4) == 0) || /* draw or draw_header */
- /*strstr("render", func_id) ||*/
- !is_operator);
+ const short is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE);
#endif
py_class = RNA_struct_py_type_get(ptr->type);
@@ -7211,10 +7241,10 @@ static void bpy_class_free(void *pyob_ptr)
gilstate = PyGILState_Ensure();
- // breaks re-registering classes
+ /* breaks re-registering classes */
// PyDict_Clear(((PyTypeObject *)self)->tp_dict);
- //
- // remove the rna attribute instead.
+
+ /* remove the rna attribute instead. */
PyDict_DelItem(((PyTypeObject *)self)->tp_dict, bpy_intern_str_bl_rna);
if (PyErr_Occurred())
PyErr_Clear();
@@ -7279,7 +7309,7 @@ void pyrna_free_types(void)
void *py_ptr = RNA_struct_py_type_get(srna);
if (py_ptr) {
-#if 0 // XXX - should be able to do this but makes python crash on exit
+#if 0 /* XXX - should be able to do this but makes python crash on exit */
bpy_class_free(py_ptr);
#endif
RNA_struct_py_type_set(srna, NULL);
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 1fb4b116872..880ef4c2185 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -207,6 +207,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
int pyrna_write_check(void);
void pyrna_write_set(int val);
+void pyrna_invalidate(BPy_DummyPointerRNA *self);
int pyrna_struct_validity_check(BPy_StructRNA *pysrna);
int pyrna_prop_validity_check(BPy_PropertyRNA *self);
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 70815d9f8bf..e66d8f05309 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -30,6 +30,8 @@
#include "RNA_types.h"
+#include "BLI_utildefines.h"
+
#include "bpy_rna.h"
#include "BKE_global.h"
#include "MEM_guardedalloc.h"
@@ -664,7 +666,8 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
len = RNA_property_multi_array_length(ptr, prop, arraydim);
if (index >= len || index < 0) {
/* this shouldn't happen because higher level funcs must check for invalid index */
- if (G.debug & G_DEBUG_PYTHON) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len);
+ if (G.debug & G_DEBUG_PYTHON)
+ printf("%s: invalid index %d for array with length=%d\n", __func__, index, len);
PyErr_SetString(PyExc_IndexError, "out of range");
return NULL;
diff --git a/source/blender/python/intern/bpy_traceback.h b/source/blender/python/intern/bpy_traceback.h
index 575f9824379..9ac49c370e4 100644
--- a/source/blender/python/intern/bpy_traceback.h
+++ b/source/blender/python/intern/bpy_traceback.h
@@ -28,4 +28,4 @@
void python_script_error_jump(const char *filepath, int *lineno, int *offset);
-#endif // __BPY_TRACEBACK_H__
+#endif /* __BPY_TRACEBACK_H__ */
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index 53d0e10a01e..b7994eeccdc 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -35,6 +35,8 @@
#include "BKE_report.h"
#include "BKE_context.h"
+#include "BLF_translation.h"
+
#include "../generic/py_capi_utils.h"
static bContext *__py_context = NULL;
@@ -79,7 +81,7 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const short
short BPy_errors_to_report(ReportList *reports)
{
PyObject *pystring;
- PyObject *pystring_format = NULL; // workaround, see below
+ PyObject *pystring_format = NULL; /* workaround, see below */
char *cstring;
const char *filename;
@@ -98,7 +100,7 @@ short BPy_errors_to_report(ReportList *reports)
pystring = PyC_ExceptionBuffer();
if (pystring == NULL) {
- BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert");
+ BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert");
return 0;
}
@@ -108,17 +110,18 @@ short BPy_errors_to_report(ReportList *reports)
cstring = _PyUnicode_AsString(pystring);
-#if 0 // ARG!. workaround for a bug in blenders use of vsnprintf
- BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno);
+#if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */
+ BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", cstring, filename, lineno);
#else
- pystring_format = PyUnicode_FromFormat("%s\nlocation:%s:%d\n", cstring, filename, lineno);
+ pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno);
cstring = _PyUnicode_AsString(pystring_format);
BKE_report(reports, RPT_ERROR, cstring);
#endif
-
- fprintf(stderr, "%s\nlocation:%s:%d\n", cstring, filename, lineno); // not exactly needed. just for testing
-
+
+ /* not exactly needed. just for testing */
+ fprintf(stderr, TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno);
+
Py_DECREF(pystring);
- Py_DECREF(pystring_format); // workaround
+ Py_DECREF(pystring_format); /* workaround */
return 1;
}
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index 63660b06813..6aa50cf88de 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -24,15 +24,20 @@
* \ingroup pythonintern
*/
-
#ifndef __BPY_UTIL_H__
#define __BPY_UTIL_H__
#if PY_VERSION_HEX < 0x03020000
-#error "Python 3.2 or greater is required, you'll need to update your python."
+# error "Python 3.2 or greater is required, you'll need to update your python."
#endif
-#include "RNA_types.h" /* for EnumPropertyItem only */
+#if PY_VERSION_HEX < 0x03030000
+# ifdef _MSC_VER
+# pragma message("Python 3.2 will be deprecated soon, upgrade to Python 3.3.")
+# else
+# warning "Python 3.2 will be deprecated soon, upgrade to Python 3.3."
+# endif
+#endif
struct EnumPropertyItem;
struct ReportList;
@@ -51,4 +56,5 @@ void BPy_SetContext(struct bContext *C);
extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate);
extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate);
-#endif
+
+#endif /* __BPY_UTIL_H__ */
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index c08165f9850..a4a4010005a 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -276,12 +276,12 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
}
-//----------------------------------MATRIX FUNCTIONS--------------------
+/* ----------------------------------MATRIX FUNCTIONS-------------------- */
/* Utility functions */
-// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon
+/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c
index 8b5e39fbd27..f16b488f9d0 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -35,8 +35,8 @@
#define COLOR_SIZE 3
-//----------------------------------mathutils.Color() -------------------
-//makes a new color for you to play with
+/* ----------------------------------mathutils.Color() ------------------- */
+/* makes a new color for you to play with */
static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
float col[3] = {0.0f, 0.0f, 0.0f};
@@ -64,7 +64,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return Color_CreatePyObject(col, Py_NEW, type);
}
-//-----------------------------METHODS----------------------------
+/* -----------------------------METHODS---------------------------- */
/* note: BaseMath_ReadCallback must be called beforehand */
static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits)
@@ -113,8 +113,8 @@ static PyObject *Color_deepcopy(ColorObject *self, PyObject *args)
return Color_copy(self);
}
-//----------------------------print object (internal)--------------
-//print the object to screen
+/* ----------------------------print object (internal)-------------- */
+/* print the object to screen */
static PyObject *Color_repr(ColorObject *self)
{
@@ -146,8 +146,8 @@ static PyObject *Color_str(ColorObject *self)
return mathutils_dynstr_to_py(ds); /* frees ds */
}
-//------------------------tp_richcmpr
-//returns -1 exception, 0 false, 1 true
+/* ------------------------tp_richcmpr */
+/* returns -1 exception, 0 false, 1 true */
static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
{
PyObject *res;
@@ -184,15 +184,15 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
return Py_INCREF(res), res;
}
-//---------------------SEQUENCE PROTOCOLS------------------------
-//----------------------------len(object)------------------------
-//sequence length
+/* ---------------------SEQUENCE PROTOCOLS------------------------ */
+/* ----------------------------len(object)------------------------ */
+/* sequence length */
static int Color_len(ColorObject *UNUSED(self))
{
return COLOR_SIZE;
}
-//----------------------------object[]---------------------------
-//sequence accessor (get)
+/* ----------------------------object[]--------------------------- */
+/* sequence accessor (get) */
static PyObject *Color_item(ColorObject *self, int i)
{
if (i < 0) i = COLOR_SIZE - i;
@@ -210,13 +210,13 @@ static PyObject *Color_item(ColorObject *self, int i)
return PyFloat_FromDouble(self->col[i]);
}
-//----------------------------object[]-------------------------
-//sequence accessor (set)
+/* ----------------------------object[]------------------------- */
+/* sequence accessor (set) */
static int Color_ass_item(ColorObject *self, int i, PyObject *value)
{
float f = PyFloat_AsDouble(value);
- if (f == -1 && PyErr_Occurred()) { // parsed item not a number
+ if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"color[item] = x: "
"argument not a number");
@@ -238,8 +238,8 @@ static int Color_ass_item(ColorObject *self, int i, PyObject *value)
return 0;
}
-//----------------------------object[z:y]------------------------
-//sequence slice (get)
+/* ----------------------------object[z:y]------------------------ */
+/* sequence slice (get) */
static PyObject *Color_slice(ColorObject *self, int begin, int end)
{
PyObject *tuple;
@@ -260,8 +260,8 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end)
return tuple;
}
-//----------------------------object[z:y]------------------------
-//sequence slice (set)
+/* ----------------------------object[z:y]------------------------ */
+/* sequence slice (set) */
static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
{
int i, size;
@@ -306,7 +306,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -342,7 +342,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
@@ -361,7 +361,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
}
}
-//-----------------PROTCOL DECLARATIONS--------------------------
+/* -----------------PROTCOL DECLARATIONS-------------------------- */
static PySequenceMethods Color_SeqMethods = {
(lenfunc) Color_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
@@ -792,7 +792,7 @@ static PyGetSetDef Color_getseters[] = {
};
-//-----------------------METHOD DEFINITIONS ----------------------
+/* -----------------------METHOD DEFINITIONS ---------------------- */
static struct PyMethodDef Color_methods[] = {
{"copy", (PyCFunction) Color_copy, METH_NOARGS, Color_copy_doc},
{"__copy__", (PyCFunction) Color_copy, METH_NOARGS, Color_copy_doc},
@@ -800,65 +800,65 @@ static struct PyMethodDef Color_methods[] = {
{NULL, NULL, 0, NULL}
};
-//------------------PY_OBECT DEFINITION--------------------------
+/* ------------------PY_OBECT DEFINITION-------------------------- */
PyDoc_STRVAR(color_doc,
"This object gives access to Colors in Blender."
);
PyTypeObject color_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "Color", //tp_name
- sizeof(ColorObject), //tp_basicsize
- 0, //tp_itemsize
- (destructor)BaseMathObject_dealloc, //tp_dealloc
- NULL, //tp_print
- NULL, //tp_getattr
- NULL, //tp_setattr
- NULL, //tp_compare
- (reprfunc) Color_repr, //tp_repr
- &Color_NumMethods, //tp_as_number
- &Color_SeqMethods, //tp_as_sequence
- &Color_AsMapping, //tp_as_mapping
- NULL, //tp_hash
- NULL, //tp_call
- (reprfunc) Color_str, //tp_str
- NULL, //tp_getattro
- NULL, //tp_setattro
- NULL, //tp_as_buffer
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
- color_doc, //tp_doc
- (traverseproc)BaseMathObject_traverse, //tp_traverse
- (inquiry)BaseMathObject_clear, //tp_clear
- (richcmpfunc)Color_richcmpr, //tp_richcompare
- 0, //tp_weaklistoffset
- NULL, //tp_iter
- NULL, //tp_iternext
- Color_methods, //tp_methods
- NULL, //tp_members
- Color_getseters, //tp_getset
- NULL, //tp_base
- NULL, //tp_dict
- NULL, //tp_descr_get
- NULL, //tp_descr_set
- 0, //tp_dictoffset
- NULL, //tp_init
- NULL, //tp_alloc
- Color_new, //tp_new
- NULL, //tp_free
- NULL, //tp_is_gc
- NULL, //tp_bases
- NULL, //tp_mro
- NULL, //tp_cache
- NULL, //tp_subclasses
- NULL, //tp_weaklist
- NULL //tp_del
+ "Color", /* tp_name */
+ sizeof(ColorObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)BaseMathObject_dealloc, /* tp_dealloc */
+ NULL, /* tp_print */
+ NULL, /* tp_getattr */
+ NULL, /* tp_setattr */
+ NULL, /* tp_compare */
+ (reprfunc) Color_repr, /* tp_repr */
+ &Color_NumMethods, /* tp_as_number */
+ &Color_SeqMethods, /* tp_as_sequence */
+ &Color_AsMapping, /* tp_as_mapping */
+ NULL, /* tp_hash */
+ NULL, /* tp_call */
+ (reprfunc) Color_str, /* tp_str */
+ NULL, /* tp_getattro */
+ NULL, /* tp_setattro */
+ NULL, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ color_doc, /* tp_doc */
+ (traverseproc)BaseMathObject_traverse, /* tp_traverse */
+ (inquiry)BaseMathObject_clear, /* tp_clear */
+ (richcmpfunc)Color_richcmpr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ NULL, /* tp_iter */
+ NULL, /* tp_iternext */
+ Color_methods, /* tp_methods */
+ NULL, /* tp_members */
+ Color_getseters, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ NULL, /* tp_descr_get */
+ NULL, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ NULL, /* tp_init */
+ NULL, /* tp_alloc */
+ Color_new, /* tp_new */
+ NULL, /* tp_free */
+ NULL, /* tp_is_gc */
+ NULL, /* tp_bases */
+ NULL, /* tp_mro */
+ NULL, /* tp_cache */
+ NULL, /* tp_subclasses */
+ NULL, /* tp_weaklist */
+ NULL /* tp_del */
};
-//------------------------Color_CreatePyObject (internal)-------------
-//creates a new color object
+/* ------------------------Color_CreatePyObject (internal)------------- */
+/* creates a new color object */
/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
* (i.e. it was allocated elsewhere by MEM_mallocN())
* pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
* (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type)
+PyObject *Color_CreatePyObject(float col[3], int type, PyTypeObject *base_type)
{
ColorObject *self;
diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h
index eff09c25a99..1c75766c2a9 100644
--- a/source/blender/python/mathutils/mathutils_Color.h
+++ b/source/blender/python/mathutils/mathutils_Color.h
@@ -46,8 +46,8 @@ typedef struct {
* be stored in py_data) or be a wrapper for data allocated through
* blender (stored in blend_data). This is an either/or struct not both*/
-//prototypes
-PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type);
+/* prototypes */
+PyObject *Color_CreatePyObject(float col[3], int type, PyTypeObject *base_type);
PyObject *Color_CreatePyObject_cb(PyObject *cb_user,
unsigned char cb_type, unsigned char cb_subtype);
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index 468ef3788c1..829d3ee27e1 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -39,8 +39,8 @@
#define EULER_SIZE 3
-//----------------------------------mathutils.Euler() -------------------
-//makes a new euler for you to play with
+/* ----------------------------------mathutils.Euler() ------------------- */
+/* makes a new euler for you to play with */
static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *seq = NULL;
@@ -122,8 +122,8 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits)
return ret;
}
-//-----------------------------METHODS----------------------------
-//return a quaternion representation of the euler
+/* -----------------------------METHODS----------------------------
+ * return a quaternion representation of the euler */
PyDoc_STRVAR(Euler_to_quaternion_doc,
".. method:: to_quaternion()\n"
@@ -145,7 +145,7 @@ static PyObject *Euler_to_quaternion(EulerObject *self)
return Quaternion_CreatePyObject(quat, Py_NEW, NULL);
}
-//return a matrix representation of the euler
+/* return a matrix representation of the euler */
PyDoc_STRVAR(Euler_to_matrix_doc,
".. method:: to_matrix()\n"
"\n"
@@ -277,8 +277,8 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value)
Py_RETURN_NONE;
}
-//----------------------------Euler.rotate()-----------------------
-// return a copy of the euler
+/* ----------------------------Euler.rotate()-----------------------
+ * return a copy of the euler */
PyDoc_STRVAR(Euler_copy_doc,
".. function:: copy()\n"
@@ -305,8 +305,8 @@ static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args)
return Euler_copy(self);
}
-//----------------------------print object (internal)--------------
-//print the object to screen
+/* ----------------------------print object (internal)--------------
+ * print the object to screen */
static PyObject *Euler_repr(EulerObject *self)
{
@@ -374,15 +374,15 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op)
return Py_INCREF(res), res;
}
-//---------------------SEQUENCE PROTOCOLS------------------------
-//----------------------------len(object)------------------------
-//sequence length
+/* ---------------------SEQUENCE PROTOCOLS------------------------ */
+/* ----------------------------len(object)------------------------ */
+/* sequence length */
static int Euler_len(EulerObject *UNUSED(self))
{
return EULER_SIZE;
}
-//----------------------------object[]---------------------------
-//sequence accessor (get)
+/* ----------------------------object[]--------------------------- */
+/* sequence accessor (get) */
static PyObject *Euler_item(EulerObject *self, int i)
{
if (i < 0) i = EULER_SIZE - i;
@@ -400,13 +400,13 @@ static PyObject *Euler_item(EulerObject *self, int i)
return PyFloat_FromDouble(self->eul[i]);
}
-//----------------------------object[]-------------------------
-//sequence accessor (set)
+/* ----------------------------object[]------------------------- */
+/* sequence accessor (set) */
static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
{
float f = PyFloat_AsDouble(value);
- if (f == -1 && PyErr_Occurred()) { // parsed item not a number
+ if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
"euler[attribute] = x: "
"argument not a number");
@@ -429,8 +429,8 @@ static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
return 0;
}
-//----------------------------object[z:y]------------------------
-//sequence slice (get)
+/* ----------------------------object[z:y]------------------------ */
+/* sequence slice (get) */
static PyObject *Euler_slice(EulerObject *self, int begin, int end)
{
PyObject *tuple;
@@ -451,8 +451,8 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end)
return tuple;
}
-//----------------------------object[z:y]------------------------
-//sequence slice (set)
+/* ----------------------------object[z:y]------------------------ */
+/* sequence slice (set) */
static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
{
int i, size;
@@ -497,7 +497,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -534,7 +534,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
@@ -553,7 +553,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
}
}
-//-----------------PROTCOL DECLARATIONS--------------------------
+/* -----------------PROTCOL DECLARATIONS-------------------------- */
static PySequenceMethods Euler_SeqMethods = {
(lenfunc) Euler_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
@@ -629,7 +629,7 @@ static PyGetSetDef Euler_getseters[] = {
};
-//-----------------------METHOD DEFINITIONS ----------------------
+/* -----------------------METHOD DEFINITIONS ---------------------- */
static struct PyMethodDef Euler_methods[] = {
{"zero", (PyCFunction) Euler_zero, METH_NOARGS, Euler_zero_doc},
{"to_matrix", (PyCFunction) Euler_to_matrix, METH_NOARGS, Euler_to_matrix_doc},
@@ -643,60 +643,60 @@ static struct PyMethodDef Euler_methods[] = {
{NULL, NULL, 0, NULL}
};
-//------------------PY_OBECT DEFINITION--------------------------
+/* ------------------PY_OBECT DEFINITION-------------------------- */
PyDoc_STRVAR(euler_doc,
"This object gives access to Eulers in Blender."
);
PyTypeObject euler_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "Euler", //tp_name
- sizeof(EulerObject), //tp_basicsize
- 0, //tp_itemsize
- (destructor)BaseMathObject_dealloc, //tp_dealloc
- NULL, //tp_print
- NULL, //tp_getattr
- NULL, //tp_setattr
- NULL, //tp_compare
- (reprfunc) Euler_repr, //tp_repr
- NULL, //tp_as_number
- &Euler_SeqMethods, //tp_as_sequence
- &Euler_AsMapping, //tp_as_mapping
- NULL, //tp_hash
- NULL, //tp_call
- (reprfunc) Euler_str, //tp_str
- NULL, //tp_getattro
- NULL, //tp_setattro
- NULL, //tp_as_buffer
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
- euler_doc, //tp_doc
- (traverseproc)BaseMathObject_traverse, //tp_traverse
- (inquiry)BaseMathObject_clear, //tp_clear
- (richcmpfunc)Euler_richcmpr, //tp_richcompare
- 0, //tp_weaklistoffset
- NULL, //tp_iter
- NULL, //tp_iternext
- Euler_methods, //tp_methods
- NULL, //tp_members
- Euler_getseters, //tp_getset
- NULL, //tp_base
- NULL, //tp_dict
- NULL, //tp_descr_get
- NULL, //tp_descr_set
- 0, //tp_dictoffset
- NULL, //tp_init
- NULL, //tp_alloc
- Euler_new, //tp_new
- NULL, //tp_free
- NULL, //tp_is_gc
- NULL, //tp_bases
- NULL, //tp_mro
- NULL, //tp_cache
- NULL, //tp_subclasses
- NULL, //tp_weaklist
- NULL //tp_del
+ "Euler", /* tp_name */
+ sizeof(EulerObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)BaseMathObject_dealloc, /* tp_dealloc */
+ NULL, /* tp_print */
+ NULL, /* tp_getattr */
+ NULL, /* tp_setattr */
+ NULL, /* tp_compare */
+ (reprfunc) Euler_repr, /* tp_repr */
+ NULL, /* tp_as_number */
+ &Euler_SeqMethods, /* tp_as_sequence */
+ &Euler_AsMapping, /* tp_as_mapping */
+ NULL, /* tp_hash */
+ NULL, /* tp_call */
+ (reprfunc) Euler_str, /* tp_str */
+ NULL, /* tp_getattro */
+ NULL, /* tp_setattro */
+ NULL, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ euler_doc, /* tp_doc */
+ (traverseproc)BaseMathObject_traverse, /* tp_traverse */
+ (inquiry)BaseMathObject_clear, /* tp_clear */
+ (richcmpfunc)Euler_richcmpr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ NULL, /* tp_iter */
+ NULL, /* tp_iternext */
+ Euler_methods, /* tp_methods */
+ NULL, /* tp_members */
+ Euler_getseters, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ NULL, /* tp_descr_get */
+ NULL, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ NULL, /* tp_init */
+ NULL, /* tp_alloc */
+ Euler_new, /* tp_new */
+ NULL, /* tp_free */
+ NULL, /* tp_is_gc */
+ NULL, /* tp_bases */
+ NULL, /* tp_mro */
+ NULL, /* tp_cache */
+ NULL, /* tp_subclasses */
+ NULL, /* tp_weaklist */
+ NULL /* tp_del */
};
-//------------------------Euler_CreatePyObject (internal)-------------
-//creates a new euler object
+/* ------------------------Euler_CreatePyObject (internal)------------- */
+/* creates a new euler object */
/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
* (i.e. it was allocated elsewhere by MEM_mallocN())
* pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h
index e04d45e4630..69e4c086d03 100644
--- a/source/blender/python/mathutils/mathutils_Euler.h
+++ b/source/blender/python/mathutils/mathutils_Euler.h
@@ -47,7 +47,7 @@ typedef struct {
* be stored in py_data) or be a wrapper for data allocated through
* blender (stored in blend_data). This is an either/or struct not both */
-//prototypes
+/* prototypes */
PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type);
PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order,
unsigned char cb_type, unsigned char cb_subtype);
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 9a0a1b3ca95..64112024dd1 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -182,7 +182,7 @@ static int mathutils_matrix_col_get(BaseMathObject *bmo, int col)
return -1;
/* for 'translation' size will always be '3' even on 4x4 vec */
- num_row = MIN2(self->num_row, ((VectorObject *)bmo)->size);
+ num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size);
for (row = 0; row < num_row; row++) {
bmo->data[row] = MATRIX_ITEM(self, row, col);
@@ -203,7 +203,7 @@ static int mathutils_matrix_col_set(BaseMathObject *bmo, int col)
return -1;
/* for 'translation' size will always be '3' even on 4x4 vec */
- num_row = MIN2(self->num_row, ((VectorObject *)bmo)->size);
+ num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size);
for (row = 0; row < num_row; row++) {
MATRIX_ITEM(self, row, col) = bmo->data[row];
@@ -329,9 +329,9 @@ Mathutils_Callback mathutils_matrix_translation_cb = {
/* matrix column callbacks, this is so you can do matrix.translation = Vector() */
-//----------------------------------mathutils.Matrix() -----------------
-//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
-//create a new matrix type
+/* ----------------------------------mathutils.Matrix() ----------------- */
+/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
+/* create a new matrix type */
static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
if (kwds && PyDict_Size(kwds)) {
@@ -384,13 +384,19 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self)
{
PyObject *ret = Matrix_copy(self);
- PyObject *ret_dummy = matrix_func(ret);
- if (ret_dummy) {
- Py_DECREF(ret_dummy);
- return (PyObject *)ret;
+ if (ret) {
+ PyObject *ret_dummy = matrix_func(ret);
+ if (ret_dummy) {
+ Py_DECREF(ret_dummy);
+ return (PyObject *)ret;
+ }
+ else { /* error */
+ Py_DECREF(ret);
+ return NULL;
+ }
}
- else { /* error */
- Py_DECREF(ret);
+ else {
+ /* copy may fail if the read callback errors out */
return NULL;
}
}
@@ -410,7 +416,7 @@ static void matrix_3x3_as_4x4(float mat[16])
/*-----------------------CLASS-METHODS----------------------------*/
-//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
+/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
PyDoc_STRVAR(C_Matrix_Identity_doc,
".. classmethod:: Identity(size)\n"
"\n"
@@ -518,7 +524,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
const float angle_cos = cosf(angle);
const float angle_sin = sinf(angle);
- //2D rotation matrix
+ /* 2D rotation matrix */
mat[0] = angle_cos;
mat[1] = angle_sin;
mat[2] = -angle_sin;
@@ -532,7 +538,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
if (matSize == 4) {
matrix_3x3_as_4x4(mat);
}
- //pass to matrix creation
+ /* pass to matrix creation */
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
}
@@ -556,8 +562,8 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
return Matrix_CreatePyObject(&mat[0][0], 4, 4, Py_NEW, (PyTypeObject *)cls);
}
-//----------------------------------mathutils.Matrix.Scale() -------------
-//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
+/* ----------------------------------mathutils.Matrix.Scale() ------------- */
+/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
PyDoc_STRVAR(C_Matrix_Scale_doc,
".. classmethod:: Scale(factor, size, axis)\n"
"\n"
@@ -601,7 +607,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
return NULL;
}
}
- if (vec == NULL) { //scaling along axis
+ if (vec == NULL) { /* scaling along axis */
if (matSize == 2) {
mat[0] = factor;
mat[3] = factor;
@@ -645,11 +651,11 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
if (matSize == 4) {
matrix_3x3_as_4x4(mat);
}
- //pass to matrix creation
+ /* pass to matrix creation */
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
}
-//----------------------------------mathutils.Matrix.OrthoProjection() ---
-//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
+/* ----------------------------------mathutils.Matrix.OrthoProjection() --- */
+/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
PyDoc_STRVAR(C_Matrix_OrthoProjection_doc,
".. classmethod:: OrthoProjection(axis, size)\n"
"\n"
@@ -685,7 +691,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
return NULL;
}
- if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane
+ if (PyUnicode_Check(axis)) { /* ortho projection onto cardinal plane */
Py_ssize_t plane_len;
const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len);
if (matSize == 2) {
@@ -726,7 +732,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
}
}
else {
- //arbitrary plane
+ /* arbitrary plane */
int vec_size = (matSize == 2 ? 2 : 3);
float tvec[4];
@@ -737,7 +743,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
return NULL;
}
- //normalize arbitrary axis
+ /* normalize arbitrary axis */
for (x = 0; x < vec_size; x++) {
norm += tvec[x] * tvec[x];
}
@@ -766,7 +772,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
if (matSize == 4) {
matrix_3x3_as_4x4(mat);
}
- //pass to matrix creation
+ /* pass to matrix creation */
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
}
@@ -869,7 +875,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
if (matSize == 4) {
matrix_3x3_as_4x4(mat);
}
- //pass to matrix creation
+ /* pass to matrix creation */
return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
}
@@ -1196,17 +1202,27 @@ static PyObject *Matrix_invert(MatrixObject *self)
if (det != 0) {
/* calculate the classical adjoint */
- if (self->num_col == 2) {
- mat[0] = MATRIX_ITEM(self, 1, 1);
- mat[1] = -MATRIX_ITEM(self, 0, 1);
- mat[2] = -MATRIX_ITEM(self, 1, 0);
- mat[3] = MATRIX_ITEM(self, 0, 0);
- }
- else if (self->num_col == 3) {
- adjoint_m3_m3((float (*)[3])mat, (float (*)[3])self->matrix);
- }
- else if (self->num_col == 4) {
- adjoint_m4_m4((float (*)[4])mat, (float (*)[4])self->matrix);
+ switch (self->num_col) {
+ case 2:
+ {
+ adjoint_m2_m2((float (*)[2])mat, (float (*)[2])self->matrix);
+ break;
+ }
+ case 3:
+ {
+ adjoint_m3_m3((float (*)[3])mat, (float (*)[3])self->matrix);
+ break;
+ }
+ case 4:
+ {
+ adjoint_m4_m4((float (*)[4])mat, (float (*)[4])self->matrix);
+ break;
+ }
+ default:
+ PyErr_Format(PyExc_TypeError,
+ "Matrix invert(ed): size (%d) unsupported",
+ (int)self->num_col);
+ return NULL;
}
/* divide by determinate */
for (x = 0; x < (self->num_col * self->num_row); x++) {
@@ -1236,7 +1252,7 @@ PyDoc_STRVAR(Matrix_inverted_doc,
"\n"
" Return an inverted copy of the matrix.\n"
"\n"
-" :return: the inverted matrix.\n"
+" :return: the inverted matrix.\n"
" :rtype: :class:`Matrix`\n"
"\n"
" .. note:: When the matrix cant be inverted a :exc:`ValueError` exception is raised.\n"
@@ -1246,6 +1262,77 @@ static PyObject *Matrix_inverted(MatrixObject *self)
return matrix__apply_to_copy((PyNoArgsFunction)Matrix_invert, self);
}
+/*---------------------------matrix.adjugate() ---------------------*/
+PyDoc_STRVAR(Matrix_adjugate_doc,
+".. method:: adjugate()\n"
+"\n"
+" Set the matrix to its adjugate.\n"
+"\n"
+" .. note:: When the matrix cant be adjugated a :exc:`ValueError` exception is raised.\n"
+"\n"
+" .. seealso:: <http://en.wikipedia.org/wiki/Adjugate_matrix>\n"
+);
+static PyObject *Matrix_adjugate(MatrixObject *self)
+{
+ if (BaseMath_ReadCallback(self) == -1)
+ return NULL;
+
+ if (self->num_col != self->num_row) {
+ PyErr_SetString(PyExc_TypeError,
+ "Matrix.adjugate(d): "
+ "only square matrices are supported");
+ return NULL;
+ }
+
+ /* calculate the classical adjoint */
+ switch (self->num_col) {
+ case 2:
+ {
+ float mat[2][2];
+ adjoint_m2_m2(mat, (float (*)[2])self->matrix);
+ copy_v4_v4((float *)self->matrix, (float *)mat);
+ break;
+ }
+ case 3:
+ {
+ float mat[3][3];
+ adjoint_m3_m3(mat, (float (*)[3])self->matrix);
+ copy_m3_m3((float (*)[3])self->matrix, mat);
+ break;
+ }
+ case 4:
+ {
+ float mat[4][4];
+ adjoint_m4_m4(mat, (float (*)[4])self->matrix);
+ copy_m4_m4((float (*)[4])self->matrix, mat);
+ break;
+ }
+ default:
+ PyErr_Format(PyExc_TypeError,
+ "Matrix adjugate(d): size (%d) unsupported",
+ (int)self->num_col);
+ return NULL;
+ }
+
+ (void)BaseMath_WriteCallback(self);
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(Matrix_adjugated_doc,
+".. method:: adjugated()\n"
+"\n"
+" Return an adjugated copy of the matrix.\n"
+"\n"
+" :return: the adjugated matrix.\n"
+" :rtype: :class:`Matrix`\n"
+"\n"
+" .. note:: When the matrix cant be adjugated a :exc:`ValueError` exception is raised.\n"
+);
+static PyObject *Matrix_adjugated(MatrixObject *self)
+{
+ return matrix__apply_to_copy((PyNoArgsFunction)Matrix_adjugate, self);
+}
+
PyDoc_STRVAR(Matrix_rotate_doc,
".. method:: rotate(other)\n"
"\n"
@@ -1579,7 +1666,7 @@ static PyObject *Matrix_str(MatrixObject *self)
maxsize[col] = 0;
for (row = 0; row < self->num_row; row++) {
int size = BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col));
- maxsize[col] = MAX2(maxsize[col], size);
+ maxsize[col] = max_ii(maxsize[col], size);
}
}
@@ -1921,7 +2008,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
for (row = 0; row < mat1->num_row; row++) {
double dot = 0.0f;
for (item = 0; item < mat1->num_col; item++) {
- dot += MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col);
+ dot += (double)(MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col));
}
mat[(col * mat1->num_row) + row] = (float)dot;
}
@@ -2000,7 +2087,7 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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) {
@@ -2036,7 +2123,7 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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)
@@ -2281,6 +2368,8 @@ static struct PyMethodDef Matrix_methods[] = {
{"transposed", (PyCFunction) Matrix_transposed, METH_NOARGS, Matrix_transposed_doc},
{"invert", (PyCFunction) Matrix_invert, METH_NOARGS, Matrix_invert_doc},
{"inverted", (PyCFunction) Matrix_inverted, METH_NOARGS, Matrix_inverted_doc},
+ {"adjugate", (PyCFunction) Matrix_adjugate, METH_NOARGS, Matrix_adjugate_doc},
+ {"adjugated", (PyCFunction) Matrix_adjugated, METH_NOARGS, Matrix_adjugated_doc},
{"to_3x3", (PyCFunction) Matrix_to_3x3, METH_NOARGS, Matrix_to_3x3_doc},
/* TODO. {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, */
{"to_4x4", (PyCFunction) Matrix_to_4x4, METH_NOARGS, Matrix_to_4x4_doc},
@@ -2335,8 +2424,8 @@ PyTypeObject matrix_Type = {
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
matrix_doc, /*tp_doc*/
- (traverseproc)BaseMathObject_traverse, //tp_traverse
- (inquiry)BaseMathObject_clear, //tp_clear
+ (traverseproc)BaseMathObject_traverse, /* tp_traverse */
+ (inquiry)BaseMathObject_clear, /*tp_clear*/
(richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
NULL, /*tp_iter*/
@@ -2537,7 +2626,7 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)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) {
@@ -2635,8 +2724,8 @@ PyTypeObject matrix_access_Type = {
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
NULL, /*tp_doc*/
- (traverseproc)MatrixAccess_traverse, //tp_traverse
- (inquiry)MatrixAccess_clear, //tp_clear
+ (traverseproc)MatrixAccess_traverse,/*tp_traverse*/
+ (inquiry)MatrixAccess_clear, /*tp_clear*/
NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
(getiterfunc)MatrixAccess_iter, /* getiterfunc tp_iter; */
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 2debff68af1..cda39932610 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -44,7 +44,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle);
static PyObject *Quaternion_copy(QuaternionObject *self);
static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args);
-//-----------------------------METHODS------------------------------
+/* -----------------------------METHODS------------------------------ */
/* note: BaseMath_ReadCallback must be called beforehand */
static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits)
@@ -124,7 +124,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
return Euler_CreatePyObject(eul, order, Py_NEW, NULL);
}
-//----------------------------Quaternion.toMatrix()------------------
+
PyDoc_STRVAR(Quaternion_to_matrix_doc,
".. method:: to_matrix()\n"
"\n"
@@ -144,7 +144,6 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL);
}
-//----------------------------Quaternion.toMatrix()------------------
PyDoc_STRVAR(Quaternion_to_axis_angle_doc,
".. method:: to_axis_angle()\n"
"\n"
@@ -176,8 +175,6 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self)
return ret;
}
-
-//----------------------------Quaternion.cross(other)------------------
PyDoc_STRVAR(Quaternion_cross_doc,
".. method:: cross(other)\n"
"\n"
@@ -205,7 +202,6 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self));
}
-//----------------------------Quaternion.dot(other)------------------
PyDoc_STRVAR(Quaternion_dot_doc,
".. method:: dot(other)\n"
"\n"
@@ -335,8 +331,8 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
Py_RETURN_NONE;
}
-//----------------------------Quaternion.normalize()----------------
-//normalize the axis of rotation of [theta, vector]
+/* ----------------------------Quaternion.normalize()---------------- */
+/* normalize the axis of rotation of [theta, vector] */
PyDoc_STRVAR(Quaternion_normalize_doc,
".. function:: normalize()\n"
"\n"
@@ -365,7 +361,6 @@ static PyObject *Quaternion_normalized(QuaternionObject *self)
return quat__apply_to_copy((PyNoArgsFunction)Quaternion_normalize, self);
}
-//----------------------------Quaternion.invert()------------------
PyDoc_STRVAR(Quaternion_invert_doc,
".. function:: invert()\n"
"\n"
@@ -394,7 +389,6 @@ static PyObject *Quaternion_inverted(QuaternionObject *self)
return quat__apply_to_copy((PyNoArgsFunction)Quaternion_invert, self);
}
-//----------------------------Quaternion.identity()-----------------
PyDoc_STRVAR(Quaternion_identity_doc,
".. function:: identity()\n"
"\n"
@@ -413,7 +407,7 @@ static PyObject *Quaternion_identity(QuaternionObject *self)
(void)BaseMath_WriteCallback(self);
Py_RETURN_NONE;
}
-//----------------------------Quaternion.negate()-------------------
+
PyDoc_STRVAR(Quaternion_negate_doc,
".. function:: negate()\n"
"\n"
@@ -432,7 +426,7 @@ static PyObject *Quaternion_negate(QuaternionObject *self)
(void)BaseMath_WriteCallback(self);
Py_RETURN_NONE;
}
-//----------------------------Quaternion.conjugate()----------------
+
PyDoc_STRVAR(Quaternion_conjugate_doc,
".. function:: conjugate()\n"
"\n"
@@ -461,7 +455,6 @@ static PyObject *Quaternion_conjugated(QuaternionObject *self)
return quat__apply_to_copy((PyNoArgsFunction)Quaternion_conjugate, self);
}
-//----------------------------Quaternion.copy()----------------
PyDoc_STRVAR(Quaternion_copy_doc,
".. function:: copy()\n"
"\n"
@@ -487,8 +480,7 @@ static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args)
return Quaternion_copy(self);
}
-//----------------------------print object (internal)--------------
-//print the object to screen
+/* print the object to screen */
static PyObject *Quaternion_repr(QuaternionObject *self)
{
PyObject *ret, *tuple;
@@ -555,15 +547,15 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
return Py_INCREF(res), res;
}
-//---------------------SEQUENCE PROTOCOLS------------------------
-//----------------------------len(object)------------------------
-//sequence length
+/* ---------------------SEQUENCE PROTOCOLS------------------------ */
+/* ----------------------------len(object)------------------------ */
+/* sequence length */
static int Quaternion_len(QuaternionObject *UNUSED(self))
{
return QUAT_SIZE;
}
-//----------------------------object[]---------------------------
-//sequence accessor (get)
+/* ----------------------------object[]--------------------------- */
+/* sequence accessor (get) */
static PyObject *Quaternion_item(QuaternionObject *self, int i)
{
if (i < 0) i = QUAT_SIZE - i;
@@ -581,8 +573,8 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
return PyFloat_FromDouble(self->quat[i]);
}
-//----------------------------object[]-------------------------
-//sequence accessor (set)
+/* ----------------------------object[]------------------------- */
+/* sequence accessor (set) */
static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
{
float scalar = (float)PyFloat_AsDouble(ob);
@@ -608,8 +600,8 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
return 0;
}
-//----------------------------object[z:y]------------------------
-//sequence slice (get)
+/* ----------------------------object[z:y]------------------------ */
+/* sequence slice (get) */
static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
{
PyObject *tuple;
@@ -630,8 +622,8 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
return tuple;
}
-//----------------------------object[z:y]------------------------
-//sequence slice (set)
+/* ----------------------------object[z:y]------------------------ */
+/* sequence slice (set) */
static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyObject *seq)
{
int i, size;
@@ -678,7 +670,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -715,7 +707,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
@@ -734,9 +726,9 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
}
}
-//------------------------NUMERIC PROTOCOLS----------------------
-//------------------------obj + obj------------------------------
-//addition
+/* ------------------------NUMERIC PROTOCOLS---------------------- */
+/* ------------------------obj + obj------------------------------ */
+/* addition */
static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
{
float quat[QUAT_SIZE];
@@ -758,8 +750,8 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1));
}
-//------------------------obj - obj------------------------------
-//subtraction
+/* ------------------------obj - obj------------------------------ */
+/* subtraction */
static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
{
int x;
@@ -875,7 +867,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
}
-//-----------------PROTOCOL DECLARATIONS--------------------------
+/* -----------------PROTOCOL DECLARATIONS-------------------------- */
static PySequenceMethods Quaternion_SeqMethods = {
(lenfunc) Quaternion_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
@@ -1060,7 +1052,7 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v
return 0;
}
-//----------------------------------mathutils.Quaternion() --------------
+/* ----------------------------------mathutils.Quaternion() -------------- */
static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *seq = NULL;
@@ -1140,7 +1132,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
}
}
-//-----------------------METHOD DEFINITIONS ----------------------
+/* -----------------------METHOD DEFINITIONS ---------------------- */
static struct PyMethodDef Quaternion_methods[] = {
/* in place only */
{"identity", (PyCFunction) Quaternion_identity, METH_NOARGS, Quaternion_identity_doc},
@@ -1190,60 +1182,60 @@ static PyGetSetDef Quaternion_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-//------------------PY_OBECT DEFINITION--------------------------
+/* ------------------PY_OBECT DEFINITION-------------------------- */
PyDoc_STRVAR(quaternion_doc,
"This object gives access to Quaternions in Blender."
);
PyTypeObject quaternion_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "Quaternion", //tp_name
- sizeof(QuaternionObject), //tp_basicsize
- 0, //tp_itemsize
- (destructor)BaseMathObject_dealloc, //tp_dealloc
- NULL, //tp_print
- NULL, //tp_getattr
- NULL, //tp_setattr
- NULL, //tp_compare
- (reprfunc) Quaternion_repr, //tp_repr
- &Quaternion_NumMethods, //tp_as_number
- &Quaternion_SeqMethods, //tp_as_sequence
- &Quaternion_AsMapping, //tp_as_mapping
- NULL, //tp_hash
- NULL, //tp_call
- (reprfunc) Quaternion_str, //tp_str
- NULL, //tp_getattro
- NULL, //tp_setattro
- NULL, //tp_as_buffer
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
- quaternion_doc, //tp_doc
- (traverseproc)BaseMathObject_traverse, //tp_traverse
- (inquiry)BaseMathObject_clear, //tp_clear
- (richcmpfunc)Quaternion_richcmpr, //tp_richcompare
- 0, //tp_weaklistoffset
- NULL, //tp_iter
- NULL, //tp_iternext
- Quaternion_methods, //tp_methods
- NULL, //tp_members
- Quaternion_getseters, //tp_getset
- NULL, //tp_base
- NULL, //tp_dict
- NULL, //tp_descr_get
- NULL, //tp_descr_set
- 0, //tp_dictoffset
- NULL, //tp_init
- NULL, //tp_alloc
- Quaternion_new, //tp_new
- NULL, //tp_free
- NULL, //tp_is_gc
- NULL, //tp_bases
- NULL, //tp_mro
- NULL, //tp_cache
- NULL, //tp_subclasses
- NULL, //tp_weaklist
- NULL, //tp_del
+ "Quaternion", /* tp_name */
+ sizeof(QuaternionObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)BaseMathObject_dealloc, /* tp_dealloc */
+ NULL, /* tp_print */
+ NULL, /* tp_getattr */
+ NULL, /* tp_setattr */
+ NULL, /* tp_compare */
+ (reprfunc) Quaternion_repr, /* tp_repr */
+ &Quaternion_NumMethods, /* tp_as_number */
+ &Quaternion_SeqMethods, /* tp_as_sequence */
+ &Quaternion_AsMapping, /* tp_as_mapping */
+ NULL, /* tp_hash */
+ NULL, /* tp_call */
+ (reprfunc) Quaternion_str, /* tp_str */
+ NULL, /* tp_getattro */
+ NULL, /* tp_setattro */
+ NULL, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ quaternion_doc, /* tp_doc */
+ (traverseproc)BaseMathObject_traverse, /* tp_traverse */
+ (inquiry)BaseMathObject_clear, /* tp_clear */
+ (richcmpfunc)Quaternion_richcmpr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ NULL, /* tp_iter */
+ NULL, /* tp_iternext */
+ Quaternion_methods, /* tp_methods */
+ NULL, /* tp_members */
+ Quaternion_getseters, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ NULL, /* tp_descr_get */
+ NULL, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ NULL, /* tp_init */
+ NULL, /* tp_alloc */
+ Quaternion_new, /* tp_new */
+ NULL, /* tp_free */
+ NULL, /* tp_is_gc */
+ NULL, /* tp_bases */
+ NULL, /* tp_mro */
+ NULL, /* tp_cache */
+ NULL, /* tp_subclasses */
+ NULL, /* tp_weaklist */
+ NULL, /* tp_del */
};
-//------------------------Quaternion_CreatePyObject (internal)-------------
-//creates a new quaternion object
+/* ------------------------Quaternion_CreatePyObject (internal)------------- */
+/* creates a new quaternion object */
/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
* (i.e. it was allocated elsewhere by MEM_mallocN())
* pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
@@ -1266,7 +1258,7 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty
}
else if (type == Py_NEW) {
self->quat = PyMem_Malloc(QUAT_SIZE * sizeof(float));
- if (!quat) { //new empty
+ if (!quat) { /* new empty */
unit_qt(self->quat);
}
else {
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h
index 4ffe8488843..b88715096bf 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.h
+++ b/source/blender/python/mathutils/mathutils_Quaternion.h
@@ -44,7 +44,7 @@ typedef struct {
* be stored in py_data) or be a wrapper for data allocated through
* blender (stored in blend_data). This is an either/or struct not both */
-//prototypes
+/* prototypes */
PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_type);
PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user,
unsigned char cb_type, unsigned char cb_subtype);
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index d461486d485..19be2b6a62e 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -1100,12 +1100,12 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
- //get dot products
+ /* get dot products */
for (x = 0; x < size; x++) {
dot += (double)(self->vec[x] * tvec[x]);
dot2 += (double)(tvec[x] * tvec[x]);
}
- //projection
+ /* projection */
dot /= dot2;
for (x = 0; x < size; x++) {
vec[x] = (float)dot * tvec[x];
@@ -1976,7 +1976,7 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->size, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -2012,7 +2012,7 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->size, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
@@ -2709,11 +2709,11 @@ static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
r_vec[3] = 1.0f;
- //muliplication
+ /* muliplication */
for (col = 0; col < mat->num_col; col++) {
double dot = 0.0;
for (row = 0; row < mat->num_row; row++) {
- dot += MATRIX_ITEM(mat, row, col) * vec_cpy[row];
+ dot += (double)(MATRIX_ITEM(mat, row, col) * vec_cpy[row]);
}
r_vec[z++] = (float)dot;
}
@@ -2733,7 +2733,7 @@ static PyObject *Vector_negate(VectorObject *self)
negate_vn(self->vec, self->size);
- (void)BaseMath_WriteCallback(self); // already checked for error
+ (void)BaseMath_WriteCallback(self); /* already checked for error */
Py_RETURN_NONE;
}
@@ -2829,10 +2829,10 @@ PyTypeObject vector_Type = {
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
- (traverseproc)BaseMathObject_traverse, //tp_traverse
+ (traverseproc)BaseMathObject_traverse, /* tp_traverse */
/* delete references to contained objects */
- (inquiry)BaseMathObject_clear, //tp_clear
+ (inquiry)BaseMathObject_clear, /* tp_clear */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 818f30ec284..22317636faa 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -51,7 +51,7 @@ PyDoc_STRVAR(M_Geometry_doc,
"The Blender geometry module"
);
-//---------------------------------INTERSECTION FUNCTIONS--------------------
+/* ---------------------------------INTERSECTION FUNCTIONS-------------------- */
PyDoc_STRVAR(M_Geometry_intersect_ray_tri_doc,
".. function:: intersect_ray_tri(v1, v2, v3, ray, orig, clip=True)\n"
@@ -251,10 +251,6 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
}
}
-
-
-
-//----------------------------geometry.normal() -------------------
PyDoc_STRVAR(M_Geometry_normal_doc,
".. function:: normal(v1, v2, v3, v4=None)\n"
"\n"
@@ -338,7 +334,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args)
return Vector_CreatePyObject(n, 3, Py_NEW, NULL);
}
-//--------------------------------- AREA FUNCTIONS--------------------
+/* --------------------------------- AREA FUNCTIONS-------------------- */
PyDoc_STRVAR(M_Geometry_area_tri_doc,
".. function:: area_tri(v1, v2, v3)\n"
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index da32e36dc02..4977663038d 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -43,6 +43,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_noise.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
diff --git a/source/blender/python/mathutils/mathutils_noise.h b/source/blender/python/mathutils/mathutils_noise.h
index f4bec88e59a..2ed3e32f4f1 100644
--- a/source/blender/python/mathutils/mathutils_noise.h
+++ b/source/blender/python/mathutils/mathutils_noise.h
@@ -33,4 +33,4 @@ PyMODINIT_FUNC PyInit_mathutils_noise(void);
PyMODINIT_FUNC PyInit_mathutils_noise_types(void);
PyMODINIT_FUNC PyInit_mathutils_noise_metrics(void);
-#endif // __MATHUTILS_NOISE_H__
+#endif /* __MATHUTILS_NOISE_H__ */
diff --git a/source/blender/python/rna_dump.py b/source/blender/python/rna_dump.py
index 489f011e693..15cc60d997e 100644
--- a/source/blender/python/rna_dump.py
+++ b/source/blender/python/rna_dump.py
@@ -95,7 +95,7 @@ def seek(r, txt, recurs):
if GEN_PATH:
newtxt = txt + '.' + item
- if item == 'rna_type' and VERBOSE_TYPE == False: # just avoid because it spits out loads of data
+ if item == 'rna_type' and VERBOSE_TYPE is False: # just avoid because it spits out loads of data
continue
value = getattr(r, item, None)
@@ -114,7 +114,7 @@ def seek(r, txt, recurs):
except:
length = 0
- if VERBOSE == False and length >= 4:
+ if VERBOSE is False and length >= 4:
for i in (0, length - 1):
if i > 0:
if PRINT_DATA:
diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m
index bb87fe21c49..e0858cd5ec2 100644
--- a/source/blender/quicktime/apple/qtkit_export.m
+++ b/source/blender/quicktime/apple/qtkit_export.m
@@ -143,7 +143,7 @@ QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue)
int quicktime_rnatmpvalue_from_videocodectype(int codecType)
{
int i;
- for (i=0;i<qtVideoCodecCount;i++) {
+ for (i = 0; i < qtVideoCodecCount; i++) {
if (qtVideoCodecList[i].codecType == codecType)
return qtVideoCodecList[i].rnatmpvalue;
}
@@ -154,12 +154,12 @@ int quicktime_rnatmpvalue_from_videocodectype(int codecType)
int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
{
int i;
- for (i=0;i<qtVideoCodecCount;i++) {
+ for (i = 0; i < qtVideoCodecCount; i++) {
if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue)
return qtVideoCodecList[i].codecType;
}
- return 0;
+ return 0;
}
/* Audio codec */
@@ -188,7 +188,7 @@ QuicktimeCodecTypeDesc* quicktime_get_audiocodecType_desc(int indexValue)
int quicktime_rnatmpvalue_from_audiocodectype(int codecType)
{
int i;
- for (i=0;i<qtAudioCodecCount;i++) {
+ for (i = 0; i < qtAudioCodecCount; i++) {
if (qtAudioCodecList[i].codecType == codecType)
return qtAudioCodecList[i].rnatmpvalue;
}
@@ -199,12 +199,12 @@ int quicktime_rnatmpvalue_from_audiocodectype(int codecType)
int quicktime_audiocodecType_from_rnatmpvalue(int rnatmpvalue)
{
int i;
- for (i=0;i<qtAudioCodecCount;i++) {
+ for (i = 0; i < qtAudioCodecCount; i++) {
if (qtAudioCodecList[i].rnatmpvalue == rnatmpvalue)
return qtAudioCodecList[i].codecType;
}
- return 0;
+ return 0;
}
@@ -212,7 +212,7 @@ static NSString *stringWithCodecType(int codecType)
{
char str[5];
- *((int*)str) = EndianU32_NtoB(codecType);
+ *((int *)str) = EndianU32_NtoB(codecType);
str[4] = 0;
return [NSString stringWithCString:str encoding:NSASCIIStringEncoding];
@@ -235,7 +235,7 @@ void makeqtstring (RenderData *rd, char *string)
void filepath_qt(char *string, RenderData *rd)
{
- if (string==NULL) return;
+ if (string == NULL) return;
strcpy(string, rd->pic);
BLI_path_abs(string, G.main->name);
@@ -313,8 +313,8 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSError *error;
char name[1024];
- int success= 1;
- OSStatus err=noErr;
+ int success = 1;
+ OSStatus err = noErr;
if(qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
@@ -323,7 +323,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
/* Check first if the QuickTime 7.2.1 initToWritableFile: method is available */
if ([[[[QTMovie alloc] init] autorelease] respondsToSelector:@selector(initToWritableFile:error:)] != YES) {
BKE_report(reports, RPT_ERROR, "\nUnable to create quicktime movie, need Quicktime rev 7.2.1 or later");
- success= 0;
+ success = 0;
}
else {
makeqtstring(rd, name);
@@ -543,7 +543,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
if(qtexport->movie == nil) {
BKE_report(reports, RPT_ERROR, "Unable to create quicktime movie.");
- success= 0;
+ success = 0;
if (qtexport->filename) [qtexport->filename release];
qtexport->filename = nil;
if (qtexport->audioFileName) [qtexport->audioFileName release];
@@ -561,19 +561,21 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
/* specifying the codec attributes : try to retrieve them from render data first*/
if (rd->qtcodecsettings.codecType) {
- qtexport->frameAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
- stringWithCodecType(rd->qtcodecsettings.codecType),
- QTAddImageCodecType,
- [NSNumber numberWithLong:((rd->qtcodecsettings.codecSpatialQuality)*codecLosslessQuality)/100],
- QTAddImageCodecQuality,
- nil];
+ qtexport->frameAttributes = [
+ NSDictionary dictionaryWithObjectsAndKeys:
+ stringWithCodecType(rd->qtcodecsettings.codecType),
+ QTAddImageCodecType,
+ [NSNumber numberWithLong:((rd->qtcodecsettings.codecSpatialQuality)*codecLosslessQuality)/100],
+ QTAddImageCodecQuality,
+ nil];
}
else {
- qtexport->frameAttributes = [NSDictionary dictionaryWithObjectsAndKeys:@"jpeg",
- QTAddImageCodecType,
- [NSNumber numberWithLong:codecHighQuality],
- QTAddImageCodecQuality,
- nil];
+ qtexport->frameAttributes = [
+ NSDictionary dictionaryWithObjectsAndKeys:@"jpeg",
+ QTAddImageCodecType,
+ [NSNumber numberWithLong:codecHighQuality],
+ QTAddImageCodecQuality,
+ nil];
}
[qtexport->frameAttributes retain];
@@ -624,8 +626,8 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in
return 0;
}
- from_Ptr = (unsigned char*)pixels;
- to_Ptr = (unsigned char*)[blBitmapFormatImage bitmapData];
+ from_Ptr = (unsigned char *)pixels;
+ to_Ptr = (unsigned char *)[blBitmapFormatImage bitmapData];
for (y = 0; y < recty; y++) {
to_i = (recty-y-1)*rectx;
from_i = y*rectx;
@@ -647,7 +649,7 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in
if (qtexport->audioFile) {
UInt32 audioPacketsConverted;
/* Append audio */
- while (qtexport->audioTotalExportedFrames < qtexport->audioLastFrame) {
+ while (qtexport->audioTotalExportedFrames < qtexport->audioLastFrame) {
qtexport->audioBufferList.mNumberBuffers = 1;
qtexport->audioBufferList.mBuffers[0].mNumberChannels = qtexport->audioOutputFormat.mChannelsPerFrame;
@@ -683,7 +685,7 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in
}
}
- [pool drain];
+ [pool drain];
return 1;
}
diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m
index 75b9056de1b..2e910e38871 100644
--- a/source/blender/quicktime/apple/qtkit_import.m
+++ b/source/blender/quicktime/apple/qtkit_import.m
@@ -71,7 +71,7 @@ void quicktime_init(void)
void quicktime_exit(void)
{
- if(G.have_quicktime) {
+ if (G.have_quicktime) {
free_qtcomponentdata();
}
}
@@ -82,27 +82,30 @@ int anim_is_quicktime (const char *name)
NSAutoreleasePool *pool;
// don't let quicktime movie import handle these
- if( BLI_testextensie(name, ".swf") ||
- BLI_testextensie(name, ".txt") ||
- BLI_testextensie(name, ".mpg") ||
- BLI_testextensie(name, ".avi") || // wouldn't be appropriate ;)
- BLI_testextensie(name, ".mov") || // disabled, suboptimal decoding speed
- BLI_testextensie(name, ".mp4") || // disabled, suboptimal decoding speed
- BLI_testextensie(name, ".m4v") || // disabled, suboptimal decoding speed
- BLI_testextensie(name, ".tga") ||
- BLI_testextensie(name, ".png") ||
- BLI_testextensie(name, ".bmp") ||
- BLI_testextensie(name, ".jpg") ||
- BLI_testextensie(name, ".wav") ||
- BLI_testextensie(name, ".zip") ||
- BLI_testextensie(name, ".mp3")) return 0;
+ if (BLI_testextensie(name, ".swf") ||
+ BLI_testextensie(name, ".txt") ||
+ BLI_testextensie(name, ".mpg") ||
+ BLI_testextensie(name, ".avi") || // wouldn't be appropriate ;)
+ BLI_testextensie(name, ".mov") || // disabled, suboptimal decoding speed
+ BLI_testextensie(name, ".mp4") || // disabled, suboptimal decoding speed
+ BLI_testextensie(name, ".m4v") || // disabled, suboptimal decoding speed
+ BLI_testextensie(name, ".tga") ||
+ BLI_testextensie(name, ".png") ||
+ BLI_testextensie(name, ".bmp") ||
+ BLI_testextensie(name, ".jpg") ||
+ BLI_testextensie(name, ".wav") ||
+ BLI_testextensie(name, ".zip") ||
+ BLI_testextensie(name, ".mp3"))
+ {
+ return 0;
+ }
- if(QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
+ if (QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
pool = [[NSAutoreleasePool alloc] init];
- if([QTMovie canInitWithFile:[NSString stringWithCString:name
- encoding:[NSString defaultCStringEncoding]]])
+ if ([QTMovie canInitWithFile:[NSString stringWithCString:name
+ encoding:[NSString defaultCStringEncoding]]])
{
[pool drain];
return true;
@@ -147,7 +150,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height)
uchar *toIBuf = NULL;
int x, y, to_i, from_i;
NSSize bitmapSize;
- NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA,*bitmapImage=nil;
+ NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA, *bitmapImage = nil;
NSEnumerator *enumerator;
NSImageRep *representation;
@@ -162,18 +165,18 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height)
/*Get the bitmap of the image*/
enumerator = [[sourceImage representations] objectEnumerator];
while ((representation = [enumerator nextObject])) {
- if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
- bitmapImage = (NSBitmapImageRep *)representation;
+ if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
+ bitmapImage = (NSBitmapImageRep *)representation;
break;
- }
- }
+ }
+ }
if (bitmapImage == nil) return NULL;
if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0)
&& ![bitmapImage isPlanar]) {
/* Try a fast copy if the image is a meshed RGBA 32bit bitmap*/
- toIBuf = (uchar*)ibuf->rect;
- rasterRGB = (uchar*)[bitmapImage bitmapData];
+ toIBuf = (uchar *)ibuf->rect;
+ rasterRGB = (uchar *)[bitmapImage bitmapData];
for (y = 0; y < height; y++) {
to_i = (height-y-1)*width;
from_i = y*width;
@@ -207,7 +210,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height)
[bitmapImage draw];
[NSGraphicsContext restoreGraphicsState];
- rasterRGB = (uchar*)[blBitmapFormatImageRGB bitmapData];
+ rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData];
if (rasterRGB == NULL) {
[blBitmapFormatImageRGB release];
return NULL;
@@ -228,7 +231,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height)
[bitmapImage draw];
[NSGraphicsContext restoreGraphicsState];
- rasterRGBA = (uchar*)[blBitmapFormatImageRGBA bitmapData];
+ rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData];
if (rasterRGBA == NULL) {
[blBitmapFormatImageRGB release];
[blBitmapFormatImageRGBA release];
@@ -236,7 +239,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height)
}
/*Copy the image to ibuf, flipping it vertically*/
- toIBuf = (uchar*)ibuf->rect;
+ toIBuf = (uchar *)ibuf->rect;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
to_i = (height-y-1)*width + x;
@@ -312,7 +315,7 @@ int startquicktime (struct anim *anim)
pool = [[NSAutoreleasePool alloc] init];
- [QTMovie enterQTKitOnThread];
+ [QTMovie enterQTKitOnThread];
attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithCString:anim->name
@@ -382,7 +385,7 @@ int startquicktime (struct anim *anim)
anim->curposition = 0;
[pool drain];
-
+
return 0;
}
@@ -486,7 +489,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
[bitmapImage draw];
[NSGraphicsContext restoreGraphicsState];
- rasterRGB = (uchar*)[blBitmapFormatImageRGB bitmapData];
+ rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData];
if (rasterRGB == NULL) {
[bitmapImage release];
[blBitmapFormatImageRGB release];
@@ -509,7 +512,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
[bitmapImage draw];
[NSGraphicsContext restoreGraphicsState];
- rasterRGBA = (uchar*)[blBitmapFormatImageRGBA bitmapData];
+ rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData];
if (rasterRGBA == NULL) {
[bitmapImage release];
[blBitmapFormatImageRGB release];
@@ -519,7 +522,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
}
/*Copy the image to ibuf, flipping it vertically*/
- toIBuf = (uchar*)ibuf->rect;
+ toIBuf = (uchar *)ibuf->rect;
for (x = 0; x < bitmapSize.width; x++) {
for (y = 0; y < bitmapSize.height; y++) {
to_i = (bitmapSize.height-y-1)*bitmapSize.width + x;
@@ -543,7 +546,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
/* return successfully */
- return (ibuf);
+ return (ibuf);
}
diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c
index 659fd997c1f..1c4ab5a4b0e 100644
--- a/source/blender/quicktime/apple/quicktime_export.c
+++ b/source/blender/quicktime/apple/quicktime_export.c
@@ -105,8 +105,8 @@ typedef struct QuicktimeExport {
PixMapHandle thePixMap;
ImageDescription **anImageDescription;
- ImBuf *ibuf; //imagedata for Quicktime's Gworld
- ImBuf *ibuf2; //copy of renderdata, to be Y-flipped
+ ImBuf *ibuf; /* imagedata for Quicktime's Gworld */
+ ImBuf *ibuf2; /* copy of renderdata, to be Y-flipped */
} QuicktimeExport;
@@ -178,7 +178,7 @@ int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
return qtVideoCodecList[i].codecType;
}
- return 0;
+ return 0;
}
@@ -218,7 +218,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
/* retreive codecdata from quicktime in a atomcontainer */
myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer);
if (myErr != noErr) {
- BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n");
+ BKE_report(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed");
goto bail;
}
@@ -238,7 +238,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
GetCodecInfo(&ci, qtdata->gSpatialSettings.codecType, 0);
}
else {
- BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed\n");
+ BKE_report(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed");
}
QTUnlockContainer(myContainer);
@@ -268,7 +268,7 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
if (qcd->cdParms && qcd->cdSize) {
myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle);
if (myErr != noErr) {
- BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n");
+ BKE_report(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed");
goto bail;
}
@@ -278,9 +278,9 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- //Fill the render QuicktimeCodecSettigns struct
+ /* Fill the render QuicktimeCodecSettigns struct */
rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality;
- //Do not override scene frame rate (qtdata->gTemporalSettings.framerate)
+ /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */
rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate;
rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType;
@@ -291,11 +291,11 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate;
rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality;
- //Frame duration is already known (qtdata->aDataRateSetting.frameDuration)
+ /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */
}
else {
- BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_GetCodecSettingsFromScene failed\n");
+ BKE_report(reports, RPT_ERROR, "Quicktime: QT_GetCodecSettingsFromScene failed");
}
bail:
if (myHandle != NULL)
@@ -414,7 +414,7 @@ static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, in
gTemporalSettings = qtdata->gTemporalSettings;
if (qtdata->gSpatialSettings.codecType == kH264CodecType) {
if (gTemporalSettings.temporalQuality != codecMinQuality) {
- BKE_reportf(reports, RPT_WARNING, "Only minimum quality compression supported for QuickTime H.264.\n");
+ BKE_report(reports, RPT_WARNING, "Only minimum quality compression supported for Quicktime H.264");
gTemporalSettings.temporalQuality = codecMinQuality;
}
}
@@ -443,18 +443,18 @@ static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int r
Ptr myPtr;
- //copy and flip renderdata
+ /* copy and flip renderdata */
memcpy(qtexport->ibuf2->rect, pixels, 4 * rectx * recty);
IMB_flipy(qtexport->ibuf2);
- //get pointers to parse bitmapdata
+ /* get pointers to parse bitmapdata */
myPtr = GetPixBaseAddr(qtexport->thePixMap);
imageRect = (**qtexport->thePixMap).bounds;
from = (unsigned char *) qtexport->ibuf2->rect;
to = (unsigned char *) myPtr;
- //parse RGBA bitmap into Quicktime's ARGB GWorld
+ /* parse RGBA bitmap into Quicktime's ARGB GWorld */
boxsize = rectx * recty;
for (index = 0; index < boxsize; index++) {
to[0] = from[3];
@@ -564,7 +564,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
/* hack: create an empty file to make FSPathMakeRef() happy */
myFile = open(theFullPath, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRUSR | S_IWUSR);
if (myFile < 0) {
- BKE_reportf(reports, RPT_ERROR, "error while creating movie file!\n");
+ BKE_report(reports, RPT_ERROR, "Error while creating movie file!");
/* do something? */
}
close(myFile);
@@ -599,7 +599,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
#endif
}
else {
- //printf("Created QuickTime movie: %s\n", name);
+ /* printf("Created QuickTime movie: %s\n", name); */
QT_CreateMyVideoTrack(rectx, recty, reports);
}
@@ -636,7 +636,7 @@ void end_qt(void)
DisposeMovie(qtexport->theMovie);
- //printf("Finished QuickTime movie.\n");
+ /* printf("Finished QuickTime movie.\n"); */
}
#ifdef __APPLE__
@@ -684,15 +684,15 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
CheckError(err, "SCSetInfo error", reports);
- if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps
+ if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */
qtdata->kVideoTimeScale = 24000;
qtdata->duration = 1001;
}
- else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps
+ else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */
qtdata->kVideoTimeScale = 30000;
qtdata->duration = 1001;
}
- else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps
+ else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */
qtdata->kVideoTimeScale = 60000;
qtdata->duration = 1001;
}
@@ -714,7 +714,7 @@ void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf)
rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.keyFrameRate = 25;
- rd->qtcodecsettings.bitRate = 5000000; //5 Mbps
+ rd->qtcodecsettings.bitRate = 5000000; /* 5 Mbps */
}
}
}
@@ -804,7 +804,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
qtdata->aDataRateSetting.minSpatialQuality = (rd->qtcodecsettings.minSpatialQuality * codecLosslessQuality) / 100;
qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100;
- qtdata->aDataRateSetting.frameDuration = rd->frs_sec;
+ qtdata->aDataRateSetting.frameDuration = rd->frs_sec;
err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
CheckError(err, "SCSetInfo1 error", op->reports);
@@ -826,9 +826,9 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
- //Fill the render QuicktimeCodecSettings struct
+ /* Fill the render QuicktimeCodecSettings struct */
rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality;
- //Do not override scene frame rate (qtdata->gTemporalSettings.framerate)
+ /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */
rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate;
rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType;
@@ -839,26 +839,26 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate;
rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality;
- //Frame duration is already known (qtdata->aDataRateSetting.frameDuration)
+ /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */
QT_SaveCodecSettingsToScene(rd, op->reports);
/* framerate jugglin' */
- if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps
+ if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */
qtdata->kVideoTimeScale = 24000;
qtdata->duration = 1001;
rd->frs_sec = 24;
rd->frs_sec_base = 1.001;
}
- else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps
+ else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */
qtdata->kVideoTimeScale = 30000;
qtdata->duration = 1001;
rd->frs_sec = 30;
rd->frs_sec_base = 1.001;
}
- else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps
+ else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */
qtdata->kVideoTimeScale = 60000;
qtdata->duration = 1001;
@@ -891,8 +891,8 @@ static int ED_operator_setqtcodec(bContext *C)
}
#if defined(__APPLE__) && defined(GHOST_COCOA)
-//Need to set up a Cocoa NSAutoReleasePool to avoid memory leak
-//And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that
+/* Need to set up a Cocoa NSAutoReleasePool to avoid memory leak
+ * And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that */
extern int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op);
int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h
index ed896357c90..a3469ddafde 100644
--- a/source/blender/quicktime/quicktime_export.h
+++ b/source/blender/quicktime/quicktime_export.h
@@ -87,8 +87,8 @@ void makeqtstring(struct RenderData *rd, char *string); //for playanim.c
-#if (defined(USE_QTKIT) && defined(MAC_OS_X_VERSION_10_6) && __LP64__)
-//Include the quicktime codec types constants that are missing in QTKitDefines.h in 10.6 / 64bit
+#if (defined(USE_QTKIT) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 && __LP64__)
+//Include the quicktime codec types constants that are missing in QTKitDefines.h
enum {
kRawCodecType = 'raw ',
kCinepakCodecType = 'cvid',
@@ -164,6 +164,6 @@ enum {
};
#endif
-#endif //(_WIN32) || (__APPLE__)
+#endif /* (_WIN32) || (__APPLE__) */
-#endif // __QUICKTIME_IMP_H__
+#endif /* __QUICKTIME_IMP_H__ */
diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h
index 19bdbb4814c..8fd016a3d74 100644
--- a/source/blender/quicktime/quicktime_import.h
+++ b/source/blender/quicktime/quicktime_import.h
@@ -43,37 +43,35 @@
#include "../imbuf/IMB_imbuf_types.h"
#ifndef USE_QTKIT
-#ifndef __MOVIES__
-#ifdef _WIN32
-#include <Movies.h>
-#elif defined(__APPLE__)
-#define __CARBONSOUND__
-#import <Carbon/Carbon.h>
-#include <QuickTime/Movies.h>
-#endif
-#endif //__MOVIES__
-#endif //USE_QTKIT
+# ifndef __MOVIES__
+# ifdef _WIN32
+# include <Movies.h>
+# elif defined(__APPLE__)
+# define __CARBONSOUND__
+# import <Carbon/Carbon.h>
+# include <QuickTime/Movies.h>
+# endif
+# endif /* __MOVIES__ */
+#endif /* USE_QTKIT */
#ifdef _WIN32
-#ifndef __FIXMATH__
-#include <FixMath.h>
-#endif /* __FIXMATH__ */
+# ifndef __FIXMATH__
+# include <FixMath.h>
+# endif /* __FIXMATH__ */
#endif /* _WIN32 _ */
-
char *get_valid_qtname(const char *name);
-
-// quicktime movie import functions
+/* quicktime movie import functions */
int anim_is_quicktime (const char *name);
int startquicktime (struct anim *anim);
void free_anim_quicktime (struct anim *anim);
ImBuf *qtime_fetchibuf (struct anim *anim, int position);
-// quicktime image import functions
+/* quicktime image import functions */
int imb_is_a_quicktime (char *name);
ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags);
-#endif // __QUICKTIME_IMPORT_H__
+#endif /* __QUICKTIME_IMPORT_H__ */
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index 2376aeca55e..1331c287d7c 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -35,6 +35,8 @@
#include "DNA_listBase.h"
#include "RNA_types.h"
+struct bNode;
+struct bNodeTree;
struct Object;
struct Render;
struct RenderEngine;
@@ -75,6 +77,8 @@ typedef struct RenderEngineType {
void (*view_update)(struct RenderEngine *engine, const struct bContext *context);
void (*view_draw)(struct RenderEngine *engine, const struct bContext *context);
+ void (*update_script_node)(struct RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node);
+
/* RNA integration */
ExtensionRNA ext;
} RenderEngineType;
@@ -94,6 +98,8 @@ typedef struct RenderEngine {
char *text;
int resolution_x, resolution_y;
+
+ struct ReportList *reports;
} RenderEngine;
RenderEngine *RE_engine_create(RenderEngineType *type);
@@ -109,6 +115,7 @@ void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, int
int RE_engine_test_break(RenderEngine *engine);
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
void RE_engine_update_progress(RenderEngine *engine, float progress);
+void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak);
void RE_engine_report(RenderEngine *engine, int type, const char *msg);
int RE_engine_render(struct Render *re, int do_all);
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index c7a8bfeec1d..ecdd1774221 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -83,7 +83,7 @@ typedef struct RenderLayer {
/* copy of RenderData */
char name[RE_MAXNAME];
unsigned int lay, lay_zmask, lay_exclude;
- int layflag, passflag, pass_xor;
+ int layflag, passflag, pass_xor;
struct Material *mat_override;
struct Group *light_override;
@@ -148,6 +148,7 @@ typedef struct RenderStats {
double starttime, lastframetime;
const char *infostr, *statstr;
char scene_name[MAX_ID_NAME - 2];
+ float mem_used, mem_peak;
} RenderStats;
/* *********************** API ******************** */
@@ -169,6 +170,8 @@ void RE_FreeRender (struct Render *re);
void RE_FreeAllRender (void);
/* only call on file load */
void RE_FreeAllRenderResults(void);
+/* for external render engines that can keep persistent data */
+void RE_FreePersistentData(void);
/* get results and statistics */
void RE_FreeRenderResult(struct RenderResult *rr);
@@ -235,7 +238,7 @@ void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce
/* ancient stars function... go away! */
void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void),
- void (*vertexfunc)(float*), void (*termfunc)(void));
+ void (*vertexfunc)(float *), void (*termfunc)(void));
/* display and event callbacks */
void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr));
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 57fb80f11c0..10045a8f7e1 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -191,12 +191,12 @@ struct MTex;
struct ImBuf;
/* this one uses nodes */
-int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres);
+int multitex_ext(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres);
/* nodes disabled */
-int multitex_ext_safe(struct Tex *tex, float *texvec, struct TexResult *texres);
+int multitex_ext_safe(struct Tex *tex, float texvec[3], struct TexResult *texres);
/* only for internal node usage */
-int multitex_nodes(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres,
- short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex);
+int multitex_nodes(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres,
+ const short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex);
/* shaded view and bake */
struct Render;
diff --git a/source/blender/render/intern/include/envmap.h b/source/blender/render/intern/include/envmap.h
index 24138884cd2..d0f346f7402 100644
--- a/source/blender/render/intern/include/envmap.h
+++ b/source/blender/render/intern/include/envmap.h
@@ -46,7 +46,7 @@ struct Render;
struct TexResult;
void make_envmaps(struct Render *re);
-int envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres);
+int envmaptex(struct Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres);
#endif /* __ENVMAP_H__ */
diff --git a/source/blender/render/intern/include/pointdensity.h b/source/blender/render/intern/include/pointdensity.h
index cc8fabda49c..e0c293e2473 100644
--- a/source/blender/render/intern/include/pointdensity.h
+++ b/source/blender/render/intern/include/pointdensity.h
@@ -43,7 +43,7 @@ struct TexResult;
void cache_pointdensity(struct Render *re, struct Tex *tex);
void make_pointdensities(struct Render *re);
void free_pointdensities(struct Render *re);
-int pointdensitytex(struct Tex *tex, float *texvec, struct TexResult *texres);
+int pointdensitytex(struct Tex *tex, const float texvec[3], struct TexResult *texres);
#endif /* __POINTDENSITY_H__ */
diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h
index 7752baadff4..07fc7d7a6ed 100644
--- a/source/blender/render/intern/include/rayobject.h
+++ b/source/blender/render/intern/include/rayobject.h
@@ -104,7 +104,7 @@ RayObject *RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstance
void RE_rayobject_merge_bb(RayObject *ob, float *min, float *max);
/* initializes an hint for optimizing raycast where it is know that a ray will pass by the given BB often the origin point */
-void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float *min, float *max);
+void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float min[3], float max[3]);
/* initializes an hint for optimizing raycast where it is know that a ray will be contained inside the given cone*/
/* void RE_rayobject_hint_cone(RayObject *r, struct RayHint *hint, float *); */
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 85dbd9356f4..6ed8d6a7b6c 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -59,6 +59,7 @@ struct RenderBuckets;
struct ObjectInstanceRen;
struct RayObject;
struct RayFace;
+struct RenderEngine;
struct ReportList;
struct Main;
@@ -120,12 +121,15 @@ struct Render
/* state settings */
short flag, osa, ok, result_ok;
+ /* due to performance issues, getting initialized from color management settings once on Render initialization */
+ short scene_color_manage;
+
/* result of rendering */
RenderResult *result;
/* if render with single-layer option, other rendered layers are stored here */
RenderResult *pushedresult;
/* a list of RenderResults, for fullsample */
- ListBase fullresult;
+ ListBase fullresult;
/* read/write mutex, all internal code that writes to re->result must use a
* write lock, all external code must use a read lock. internal code is assumed
* to not conflict with writes, so no lock used for that */
@@ -142,8 +146,6 @@ struct Render
/* final picture width and height (within disprect) */
int rectx, recty;
- /* real maximum amount of xparts/yparts after correction for minimum */
- int xparts, yparts;
/* real maximum size of parts after correction for minimum
* partx*xparts can be larger than rectx, in that case last part is smaller */
int partx, party;
@@ -182,6 +184,9 @@ struct Render
ListBase parts;
+ /* render engine */
+ struct RenderEngine *engine;
+
/* octree tables and variables for raytrace */
struct RayObject *raytree;
struct RayFace *rayfaces;
diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h
index 0fbbf52e613..30712250440 100644
--- a/source/blender/render/intern/include/rendercore.h
+++ b/source/blender/render/intern/include/rendercore.h
@@ -62,7 +62,7 @@ typedef struct PixStrMain {
/* ------------------------------------------------------------------------- */
-void calc_view_vector(float *view, float x, float y);
+void calc_view_vector(float view[3], float x, float y);
float mistfactor(float zcor, const float co[3]); /* dist and height, return alpha */
void renderspothalo(struct ShadeInput *shi, float col[4], float alpha);
@@ -95,5 +95,4 @@ extern void init_ao_sphere(struct World *wrld);
extern void init_render_qmcsampler(Render *re);
extern void free_render_qmcsampler(Render *re);
-#endif /* RENDER_EXT_H */
-
+#endif /* __RENDERCORE_H__ */
diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h
index d116dfe7b17..5213f14d773 100644
--- a/source/blender/render/intern/include/renderdatabase.h
+++ b/source/blender/render/intern/include/renderdatabase.h
@@ -88,7 +88,7 @@ void free_renderdata_vertnodes(struct VertTableNode *vertnodes);
void free_renderdata_vlaknodes(struct VlakTableNode *vlaknodes);
void project_renderdata(struct Render *re, void (*projectfunc)(const float *, float mat[][4], float *), int do_pano, float xoffs, int do_buckets);
-int clip_render_object(float boundbox[][3], float *bounds, float mat[][4]);
+int clip_render_object(float boundbox[][3], float bounds[4], float mat[][4]);
/* functions are not exported... so wrong names */
diff --git a/source/blender/render/intern/include/shadbuf.h b/source/blender/render/intern/include/shadbuf.h
index 5cde8e5106a..7c168baada7 100644
--- a/source/blender/render/intern/include/shadbuf.h
+++ b/source/blender/render/intern/include/shadbuf.h
@@ -79,19 +79,19 @@ float ISB_getshadow(ShadeInput *shi, ShadBuf *shb);
/* buffer samples, allocated in camera buffer and pointed to in lampbuffer nodes */
typedef struct ISBSample {
- float zco[3]; /* coordinate in lampview projection */
- short *shadfac; /* initialized zero = full lighted */
- int obi; /* object for face lookup */
- int facenr; /* index in faces list */
+ float zco[3]; /* coordinate in lampview projection */
+ short *shadfac; /* initialized zero = full lighted */
+ int obi; /* object for face lookup */
+ int facenr; /* index in faces list */
} ISBSample;
/* transparent version of buffer sample */
typedef struct ISBSampleA {
- float zco[3]; /* coordinate in lampview projection */
- short *shadfac; /* NULL = full lighted */
- int obi; /* object for face lookup */
- int facenr; /* index in faces list */
- struct ISBSampleA *next; /* in end, we want the first items to align with ISBSample */
+ float zco[3]; /* coordinate in lampview projection */
+ short *shadfac; /* NULL = full lighted */
+ int obi; /* object for face lookup */
+ int facenr; /* index in faces list */
+ struct ISBSampleA *next; /* in end, we want the first items to align with ISBSample */
} ISBSampleA;
/* used for transparent storage only */
diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h
index a8519d8a7fb..4f6e005d742 100644
--- a/source/blender/render/intern/include/shading.h
+++ b/source/blender/render/intern/include/shading.h
@@ -60,7 +60,7 @@ void shade_material_loop(struct ShadeInput *shi, struct ShadeResult *shr);
void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3);
void shade_input_set_triangle(struct ShadeInput *shi, volatile int obi, volatile int facenr, int normal_flip);
void shade_input_copy_triangle(struct ShadeInput *shi, struct ShadeInput *from);
-void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float view[3], float *dxyview, float *co, float *dxco, float *dyco);
+void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float view[3], float dxyview[2], float co[3], float dxco[3], float dyco[3]);
void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float sx, float sy, float z);
void shade_input_set_uv(struct ShadeInput *shi);
void shade_input_set_normals(struct ShadeInput *shi);
diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h
index 74e42109be5..60fa8aa51ba 100644
--- a/source/blender/render/intern/include/sunsky.h
+++ b/source/blender/render/intern/include/sunsky.h
@@ -43,8 +43,7 @@ typedef struct SunSky {
float perez_Y[5], perez_x[5], perez_y[5];
- /* suggested by glome in
- * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/
+ /* suggested by glome in patch [#8063] */
float horizon_brightness;
float spread;
float sun_brightness;
@@ -69,7 +68,7 @@ typedef struct SunSky {
float atm_BetaRM[3];
} SunSky;
-void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness,
+void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float horizon_brightness,
float spread, float sun_brightness, float sun_size, float back_scatter,
float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace);
diff --git a/source/blender/render/intern/include/texture_ocean.h b/source/blender/render/intern/include/texture_ocean.h
index 7d4110aadf3..121142aa0b0 100644
--- a/source/blender/render/intern/include/texture_ocean.h
+++ b/source/blender/render/intern/include/texture_ocean.h
@@ -23,4 +23,9 @@
* ***** END GPL LICENSE BLOCK *****
*/
-int ocean_texture(struct Tex *tex, float *texvec, struct TexResult *texres);
+#ifndef __TEXTURE_OCEAN_H__
+#define __TEXTURE_OCEAN_H__
+
+int ocean_texture(struct Tex *tex, const float texvec[2], struct TexResult *texres);
+
+#endif /* __TEXTURE_OCEAN_H__ */
diff --git a/source/blender/render/intern/include/volume_precache.h b/source/blender/render/intern/include/volume_precache.h
index 8e402bc5418..9aa280d8276 100644
--- a/source/blender/render/intern/include/volume_precache.h
+++ b/source/blender/render/intern/include/volume_precache.h
@@ -30,8 +30,8 @@
*/
-void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float *bbmin, float *bbmax);
-int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, float *co);
+void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float bbmin[3], float bbmax[3]);
+int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, const float co[3]);
void volume_precache(Render *re);
void free_volume_precache(Render *re);
diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h
index 103c04a590f..47d3a892e84 100644
--- a/source/blender/render/intern/raytrace/bvh.h
+++ b/source/blender/render/intern/raytrace/bvh.h
@@ -91,7 +91,7 @@ static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_b
if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
- RE_RC_COUNT(isec->raycounter->bb.hit);
+ RE_RC_COUNT(isec->raycounter->bb.hit);
return 1;
}
diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp
index 6f14c6153f9..c3babf99d51 100644
--- a/source/blender/render/intern/raytrace/rayobject.cpp
+++ b/source/blender/render/intern/raytrace/rayobject.cpp
@@ -467,7 +467,7 @@ float RE_rayobject_cost(RayObject *r)
/* Bounding Boxes */
-void RE_rayobject_merge_bb(RayObject *r, float *min, float *max)
+void RE_rayobject_merge_bb(RayObject *r, float min[3], float max[3])
{
if (RE_rayobject_isRayFace(r)) {
RayFace *face = (RayFace *) RE_rayobject_align(r);
diff --git a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp
index 2d642a0a0d8..198577f61c6 100644
--- a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp
@@ -79,7 +79,7 @@ typedef struct BVHObject {
RayObject *RE_rayobject_blibvh_create(int size)
{
BVHObject *obj = (BVHObject *)MEM_callocN(sizeof(BVHObject), "BVHObject");
- assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */
+ assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */
obj->rayobj.api = &bvh_api;
obj->bvh = BLI_bvhtree_new(size, 0.0, 4, 6);
@@ -137,7 +137,7 @@ static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob)
DO_MIN(min_max, obj->bb[0]);
DO_MAX(min_max + 3, obj->bb[1]);
- BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2);
+ BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2);
*(obj->next_leaf++) = ob;
}
diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp
index c3e761ae069..f797f7a4311 100644
--- a/source/blender/render/intern/raytrace/rayobject_instance.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_instance.cpp
@@ -59,7 +59,7 @@ static RayObjectAPI instance_api =
RE_rayobject_instance_free,
RE_rayobject_instance_bb,
RE_rayobject_instance_cost,
- RE_rayobject_instance_hint_bb
+ RE_rayobject_instance_hint_bb
};
typedef struct InstanceRayObject {
diff --git a/source/blender/render/intern/raytrace/rayobject_internal.h b/source/blender/render/intern/raytrace/rayobject_internal.h
index 3f768e5adcb..92ac39909a8 100644
--- a/source/blender/render/intern/raytrace/rayobject_internal.h
+++ b/source/blender/render/intern/raytrace/rayobject_internal.h
@@ -50,7 +50,7 @@ typedef int (*RE_rayobjectcontrol_test_break_callback)(void *data);
typedef struct RayObjectControl {
void *data;
- RE_rayobjectcontrol_test_break_callback test_break;
+ RE_rayobjectcontrol_test_break_callback test_break;
} RayObjectControl;
/* Returns true if for some reason a heavy processing function should stop
@@ -124,9 +124,9 @@ typedef int (*RE_rayobject_raycast_callback)(RayObject *, struct Isect *);
typedef void (*RE_rayobject_add_callback)(RayObject *raytree, RayObject *rayobject);
typedef void (*RE_rayobject_done_callback)(RayObject *);
typedef void (*RE_rayobject_free_callback)(RayObject *);
-typedef void (*RE_rayobject_merge_bb_callback)(RayObject *, float *min, float *max);
+typedef void (*RE_rayobject_merge_bb_callback)(RayObject *, float min[3], float max[3]);
typedef float (*RE_rayobject_cost_callback)(RayObject *);
-typedef void (*RE_rayobject_hint_bb_callback)(RayObject *, struct RayHint *, float *, float *);
+typedef void (*RE_rayobject_hint_bb_callback)(RayObject *, struct RayHint *, float min[3], float max[3]);
typedef struct RayObjectAPI {
RE_rayobject_raycast_callback raycast;
@@ -154,5 +154,4 @@ int RE_rayobject_intersect(RayObject *r, struct Isect *i);
}
#endif
-#endif
-
+#endif /* __RAYOBJECT_INTERNAL_H__ */
diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp
index 5ae716ac942..77e9dc9d8fd 100644
--- a/source/blender/render/intern/raytrace/rayobject_octree.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp
@@ -382,8 +382,12 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa
while (TRUE) {
- if (x < 0 || y < 0 || x >= oc->ocres || y >= oc->ocres) ;
- else ocface[oc->ocres * x + y] = 1;
+ if (x < 0 || y < 0 || x >= oc->ocres || y >= oc->ocres) {
+ /* pass*/
+ }
+ else {
+ ocface[oc->ocres * x + y] = 1;
+ }
labdao = labda;
if (labdax == labday) {
diff --git a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp
index 16d70297a34..33ce3bd33d5 100644
--- a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp
@@ -68,7 +68,7 @@ void bvh_done<QBVHTree>(QBVHTree *obj)
//Build and optimize the tree
//TODO do this in 1 pass (half memory usage during building)
- VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder);
+ VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder);
if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) {
BLI_memarena_free(arena1);
diff --git a/source/blender/render/intern/raytrace/rayobject_raycounter.cpp b/source/blender/render/intern/raytrace/rayobject_raycounter.cpp
index 7d86b6cf8cb..5335bf50cbc 100644
--- a/source/blender/render/intern/raytrace/rayobject_raycounter.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_raycounter.cpp
@@ -43,10 +43,10 @@ void RE_RC_INFO(RayCounter *info)
printf("\n");
printf("BB tests: %llu\n", info->bb.test );
printf("BB hits: %llu\n", info->bb.hit );
- printf("\n");
+ printf("\n");
printf("SIMD BB tests: %llu\n", info->simd_bb.test );
printf("SIMD BB hits: %llu\n", info->simd_bb.hit );
- printf("\n");
+ printf("\n");
printf("Primitives tests: %llu\n", info->faces.test );
printf("Primitives hits: %llu\n", info->faces.hit );
printf("------------------------------------\n");
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
index 3926e8b8e51..bae65c492f4 100644
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
@@ -77,7 +77,7 @@ RTBuilder *rtbuild_create(int size)
for (int i = 0; i < 3; i++) {
builder->sorted_begin[i] = (RTBuilder::Object **)MEM_mallocN(sizeof(RTBuilder::Object *) * size, "RTBuilder.sorted_objects");
builder->sorted_end[i] = builder->sorted_begin[i];
- }
+ }
return builder;
@@ -193,7 +193,7 @@ static void rtbuild_calc_bb(RTBuilder *b)
}
}
-void rtbuild_merge_bb(RTBuilder *b, float *min, float *max)
+void rtbuild_merge_bb(RTBuilder *b, float min[3], float max[3])
{
rtbuild_calc_bb(b);
DO_MIN(b->bb, min);
@@ -224,7 +224,7 @@ int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis)
Mleafs_per_child = s / nchilds;
mleafs_per_child = Mleafs_per_child / nchilds;
- //split min leafs per child
+ //split min leafs per child
b->child_offset[0] = 0;
for (i = 1; i <= nchilds; i++)
b->child_offset[i] = mleafs_per_child;
@@ -295,7 +295,7 @@ int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis)
return rtbuild_mean_split(b, nchilds, axis);
return nchilds;
- }
+ }
}
int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds)
@@ -324,7 +324,7 @@ struct SweepCost {
/* Object Surface Area Heuristic splitter */
int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
{
- int size = rtbuild_size(b);
+ int size = rtbuild_size(b);
assert(nchilds == 2);
assert(size > 1);
int baxis = -1, boffset = 0;
@@ -348,12 +348,12 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
sweep[i].cost = obj[i]->cost;
}
else {
- sweep[i].bb[0] = MIN2(obj[i]->bb[0], sweep[i + 1].bb[0]);
- sweep[i].bb[1] = MIN2(obj[i]->bb[1], sweep[i + 1].bb[1]);
- sweep[i].bb[2] = MIN2(obj[i]->bb[2], sweep[i + 1].bb[2]);
- sweep[i].bb[3] = MAX2(obj[i]->bb[3], sweep[i + 1].bb[3]);
- sweep[i].bb[4] = MAX2(obj[i]->bb[4], sweep[i + 1].bb[4]);
- sweep[i].bb[5] = MAX2(obj[i]->bb[5], sweep[i + 1].bb[5]);
+ sweep[i].bb[0] = min_ff(obj[i]->bb[0], sweep[i + 1].bb[0]);
+ sweep[i].bb[1] = min_ff(obj[i]->bb[1], sweep[i + 1].bb[1]);
+ sweep[i].bb[2] = min_ff(obj[i]->bb[2], sweep[i + 1].bb[2]);
+ sweep[i].bb[3] = max_ff(obj[i]->bb[3], sweep[i + 1].bb[3]);
+ sweep[i].bb[4] = max_ff(obj[i]->bb[4], sweep[i + 1].bb[4]);
+ sweep[i].bb[5] = max_ff(obj[i]->bb[5], sweep[i + 1].bb[5]);
sweep[i].cost = obj[i]->cost + sweep[i + 1].cost;
}
// right_cost += obj[i]->cost;
@@ -375,8 +375,8 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
// not using log seems to have no impact on raytracing perf, but
// makes tree construction quicker, left out for now to test (brecht)
- // left_side = bb_area(sweep_left.bb, sweep_left.bb+3)*(sweep_left.cost+logf((float)i));
- // right_side= bb_area(sweep[i].bb, sweep[i].bb+3)*(sweep[i].cost+logf((float)size-i));
+ // left_side = bb_area(sweep_left.bb, sweep_left.bb + 3) * (sweep_left.cost + logf((float)i));
+ // right_side = bb_area(sweep[i].bb, sweep[i].bb + 3) * (sweep[i].cost + logf((float)size - i));
left_side = bb_area(sweep_left.bb, sweep_left.bb + 3) * (sweep_left.cost);
right_side = bb_area(sweep[i].bb, sweep[i].bb + 3) * (sweep[i].cost);
hcost = left_side + right_side;
@@ -429,7 +429,7 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
for (int i = 0; i < 3; i++)
std::stable_partition(b->sorted_begin[i], b->sorted_end[i], selected_node);
- return nchilds;
+ return nchilds;
}
/*
@@ -457,26 +457,26 @@ static void split_leafs(RTBuilder *b, int *nth, int partitions, int split_axis)
/*
* Bounding Box utils
*/
-float bb_volume(float *min, float *max)
+float bb_volume(const float min[3], const float max[3])
{
return (max[0] - min[0]) * (max[1] - min[1]) * (max[2] - min[2]);
}
-float bb_area(float *min, float *max)
+float bb_area(const float min[3], const float max[3])
{
float sub[3], a;
sub[0] = max[0] - min[0];
sub[1] = max[1] - min[1];
sub[2] = max[2] - min[2];
- a = (sub[0] * sub[1] + sub[0] * sub[2] + sub[1] * sub[2]) * 2;
+ a = (sub[0] * sub[1] + sub[0] * sub[2] + sub[1] * sub[2]) * 2.0f;
/* used to have an assert() here on negative results
* however, in this case its likely some overflow or ffast math error.
* so just return 0.0f instead. */
return a < 0.0f ? 0.0f : a;
}
-int bb_largest_axis(float *min, float *max)
+int bb_largest_axis(const float min[3], const float max[3])
{
float sub[3];
@@ -494,10 +494,12 @@ int bb_largest_axis(float *min, float *max)
return 1;
else
return 2;
- }
+ }
}
-int bb_fits_inside(float *outer_min, float *outer_max, float *inner_min, float *inner_max)
+/* only returns 0 if merging inner and outerbox would create a box larger than outer box */
+int bb_fits_inside(const float outer_min[3], const float outer_max[3],
+ const float inner_min[3], const float inner_max[3])
{
int i;
for (i = 0; i < 3; i++)
@@ -506,5 +508,5 @@ int bb_fits_inside(float *outer_min, float *outer_max, float *inner_min, float *
for (i = 0; i < 3; i++)
if (outer_max[i] < inner_max[i]) return 0;
- return 1;
+ return 1;
}
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.h b/source/blender/render/intern/raytrace/rayobject_rtbuild.h
index 22e3d009c07..9e296da144b 100644
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.h
+++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.h
@@ -86,7 +86,7 @@ RTBuilder *rtbuild_create(int size);
void rtbuild_free(RTBuilder *b);
void rtbuild_add(RTBuilder *b, RayObject *o);
void rtbuild_done(RTBuilder *b, RayObjectControl *c);
-void rtbuild_merge_bb(RTBuilder *b, float *min, float *max);
+void rtbuild_merge_bb(RTBuilder *b, float min[3], float max[3]);
int rtbuild_size(RTBuilder *b);
RayObject *rtbuild_get_primitive(RTBuilder *b, int offset);
@@ -109,13 +109,14 @@ int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds);
/* bb utils */
-float bb_area(float *min, float *max);
-float bb_volume(float *min, float *max);
-int bb_largest_axis(float *min, float *max);
-int bb_fits_inside(float *outer_min, float *outer_max, float *inner_min, float *inner_max); /* only returns 0 if merging inner and outerbox would create a box larger than outer box */
+float bb_area(const float min[3], const float max[3]);
+float bb_volume(const float min[3], const float max[3]);
+int bb_largest_axis(const float min[3], const float max[3]);
+int bb_fits_inside(const float outer_min[3], const float outer_max[3],
+ const float inner_min[3], const float inner_max[3]);
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* __RAYOBJECT_RTBUILD_H__ */
diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
index 85c9d0d402f..d03bdb74407 100644
--- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
@@ -112,7 +112,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj)
//Finds the optimal packing of this tree using a given cost model
//TODO this uses quite a lot of memory, find ways to reduce memory usage during building
- OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena2).transform(obj->builder);
+ OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena2).transform(obj->builder);
VBVH_optimalPackSIMD<OVBVHNode, PackCost>(PackCost()).transform(root);
obj->root = Reorganize_VBVH<OVBVHNode>(arena1).transform(root);
@@ -125,7 +125,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj)
obj->builder = NULL;
obj->node_arena = arena1;
- obj->cost = 1.0;
+ obj->cost = 1.0;
}
template<int StackSize>
diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h
index a9ed71a76bc..9d9711eee56 100644
--- a/source/blender/render/intern/raytrace/reorganize.h
+++ b/source/blender/render/intern/raytrace/reorganize.h
@@ -75,7 +75,7 @@ void reorganize_find_fittest_parent(Node *tree, Node *node, std::pair<float, Nod
float pcost = bb_area(parent->bb, parent->bb + 3);
cost = std::min(cost, std::make_pair(pcost, parent) );
for (Node *child = parent->child; child; child = child->sibling)
- q.push(child);
+ q.push(child);
}
}
}
@@ -140,7 +140,7 @@ void remove_useless(Node *node, Node **new_node)
(*prev)->sibling = next;
prev = &((*prev)->sibling);
}
- }
+ }
}
if (node->child) {
if (RE_rayobject_isAligned(node->child) && node->child->sibling == 0)
@@ -181,7 +181,7 @@ void pushup(Node *parent)
*prev = child;
prev = &(*prev)->sibling;
child = *prev;
- }
+ }
}
for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; child = child->sibling)
@@ -205,13 +205,13 @@ void pushup_simd(Node *parent)
n += (cn - 1);
append_sibling(child, child->child);
child = child->sibling;
- *prev = child;
+ *prev = child;
}
else {
*prev = child;
prev = &(*prev)->sibling;
child = *prev;
- }
+ }
}
for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; child = child->sibling)
@@ -320,7 +320,7 @@ struct OVBVHNode {
/*
* Reorganize the node based on calculated cut costs
- */
+ */
int best_cutsize;
void set_cut(int cutsize, OVBVHNode ***cut)
{
@@ -357,7 +357,7 @@ struct OVBVHNode {
//Optimize new childs
for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling)
child->optimize();
- }
+ }
}
};
@@ -431,7 +431,7 @@ struct VBVH_optimalPackSIMD {
current_size -= bt[j][current_size];
}
}
- }
+ }
}
};
@@ -493,6 +493,6 @@ struct VBVH_optimalPackSIMD {
if ((G.debug & G_DEBUG) && first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize);
node->optimize();
}
- return node;
- }
+ return node;
+ }
};
diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h
index a58094e5021..6ec75ebb527 100644
--- a/source/blender/render/intern/raytrace/svbvh.h
+++ b/source/blender/render/intern/raytrace/svbvh.h
@@ -29,12 +29,11 @@
* \ingroup render
*/
-
-#ifdef __SSE__
-
#ifndef __SVBVH_H__
#define __SVBVH_H__
+#ifdef __SSE__
+
#include "bvh.h"
#include "BLI_memarena.h"
#include "BKE_global.h"
@@ -94,10 +93,10 @@ static int svbvh_bb_intersect_test(const Isect *isec, const float *_bb)
RE_RC_COUNT(isec->raycounter->bb.test);
if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
- if (t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return 0;
+ if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
- RE_RC_COUNT(isec->raycounter->bb.hit);
+ RE_RC_COUNT(isec->raycounter->bb.hit);
return 1;
}
@@ -166,16 +165,16 @@ inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float ma
for (i = 0; i + 4 <= node->nchilds; i += 4) {
float *res = node->child_bb + 6 * i;
for (int j = 0; j < 3; j++) {
- min[j] = minf(res[4 * j + 0],
- minf(res[4 * j + 1],
- minf(res[4 * j + 2],
- minf(res[4 * j + 3], min[j]))));
+ min[j] = min_ff(res[4 * j + 0],
+ min_ff(res[4 * j + 1],
+ min_ff(res[4 * j + 2],
+ min_ff(res[4 * j + 3], min[j]))));
}
for (int j = 0; j < 3; j++) {
- max[j] = maxf(res[4 * (j + 3) + 0],
- maxf(res[4 * (j + 3) + 1],
- maxf(res[4 * (j + 3) + 2],
- maxf(res[4 * (j + 3) + 3], max[j]))));
+ max[j] = max_ff(res[4 * (j + 3) + 0],
+ max_ff(res[4 * (j + 3) + 1],
+ max_ff(res[4 * (j + 3) + 2],
+ max_ff(res[4 * (j + 3) + 3], max[j]))));
}
}
@@ -231,7 +230,7 @@ struct Reorganize_SVBVH {
return node;
}
- void copy_bb(float *bb, const float *old_bb)
+ void copy_bb(float bb[6], const float old_bb[6])
{
std::copy(old_bb, old_bb + 6, bb);
}
@@ -282,7 +281,7 @@ struct Reorganize_SVBVH {
useless_bb += alloc_childs - nchilds;
while (alloc_childs > nchilds) {
- const static float def_bb[6] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MIN, FLT_MIN, FLT_MIN };
+ const static float def_bb[6] = {FLT_MAX, FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX};
alloc_childs--;
node->child[alloc_childs] = NULL;
copy_bb(node->child_bb + alloc_childs * 6, def_bb);
@@ -308,10 +307,9 @@ struct Reorganize_SVBVH {
prepare_for_simd(node);
return node;
- }
+ }
};
-#endif
-
-#endif //__SSE__
+#endif /* __SSE__ */
+#endif /* __SVBVH_H__ */
diff --git a/source/blender/render/intern/raytrace/vbvh.h b/source/blender/render/intern/raytrace/vbvh.h
index ec671f95c76..9755bf89668 100644
--- a/source/blender/render/intern/raytrace/vbvh.h
+++ b/source/blender/render/intern/raytrace/vbvh.h
@@ -233,6 +233,6 @@ struct Reorganize_VBVH {
*child_ptr = 0;
return node;
- }
+ }
};
#endif
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index b3948563a87..759b0737c01 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -124,6 +124,9 @@
/* or for checking vertex normal flips */
#define FLT_EPSILON10 1.19209290e-06F
+/* could enable at some point but for now there are far too many conversions */
+#pragma GCC diagnostic ignored "-Wdouble-promotion"
+
/* ------------------------------------------------------------------------- */
/* Stuff for stars. This sits here because it uses gl-things. Part of
@@ -156,7 +159,7 @@ static HaloRen *initstar(Render *re, ObjectRen *obr, const float vec[3], float h
*/
void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
- void (*vertexfunc)(float*), void (*termfunc)(void))
+ void (*vertexfunc)(float*), void (*termfunc)(void))
{
extern unsigned char hash[512];
ObjectRen *obr= NULL;
@@ -227,7 +230,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
hlfrand = 2.0 * dblrand;
if (initfunc) {
- initfunc();
+ initfunc();
}
if (re) /* add render object for stars */
@@ -364,7 +367,7 @@ static void split_v_renderfaces(ObjectRen *obr, int startvlak, int UNUSED(startv
if (v==0) {
vlr->v1 = RE_vertren_copy(obr, vlr->v1);
- }
+ }
}
}
}
@@ -446,7 +449,7 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me)
}
/* gets tangent from tface or orco */
-static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemArena *arena, VlakRen *vlr, int do_nmap_tangent, int do_tangent)
+static void calc_tangent_vector(ObjectRen *obr, VlakRen *vlr, int do_tangent)
{
MTFace *tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0);
VertRen *v1=vlr->v1, *v2=vlr->v2, *v3=vlr->v3, *v4=vlr->v4;
@@ -481,12 +484,6 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr
add_v3_v3(tav, tang);
}
- if (do_nmap_tangent) {
- sum_or_add_vertex_tangent(arena, &vtangents[v1->index], tang, uv1);
- sum_or_add_vertex_tangent(arena, &vtangents[v2->index], tang, uv2);
- sum_or_add_vertex_tangent(arena, &vtangents[v3->index], tang, uv3);
- }
-
if (v4) {
tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, vlr->n, tang);
@@ -498,12 +495,6 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr
tav= RE_vertren_get_tangent(obr, v4, 1);
add_v3_v3(tav, tang);
}
-
- if (do_nmap_tangent) {
- sum_or_add_vertex_tangent(arena, &vtangents[v1->index], tang, uv1);
- sum_or_add_vertex_tangent(arena, &vtangents[v3->index], tang, uv3);
- sum_or_add_vertex_tangent(arena, &vtangents[v4->index], tang, uv4);
- }
}
}
@@ -568,8 +559,14 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
//assert(vert_index>=0 && vert_index<4);
SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
- const float *n= (&vlr->v1)[vert_index]->n;
- copy_v3_v3(fNorm, n);
+
+ if (vlr->flag & ME_SMOOTH) {
+ const float *n = (&vlr->v1)[vert_index]->n;
+ copy_v3_v3(fNorm, n);
+ }
+ else {
+ negate_v3_v3(fNorm, vlr->n);
+ }
}
static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert)
{
@@ -585,17 +582,8 @@ static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent
static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangent, int do_nmap_tangent)
{
- MemArena *arena= NULL;
- VertexTangent **vtangents= NULL;
int a;
- if (do_nmap_tangent) {
- arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "nmap tangent arena");
- BLI_memarena_use_calloc(arena);
-
- vtangents= MEM_callocN(sizeof(VertexTangent*)*obr->totvert, "VertexTangent");
- }
-
/* clear all vertex normals */
for (a=0; a<obr->totvert; a++) {
VertRen *ver= RE_findOrAddVert(obr, a);
@@ -613,10 +601,10 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
accumulate_vertex_normals(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4,
vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co, c4);
}
- if (do_nmap_tangent || do_tangent) {
+ if (do_tangent) {
/* tangents still need to be calculated for flat faces too */
/* weighting removed, they are not vertexnormals */
- calc_tangent_vector(obr, vtangents, arena, vlr, do_nmap_tangent, do_tangent);
+ calc_tangent_vector(obr, vlr, do_tangent);
}
}
@@ -630,32 +618,6 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
if (is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n);
if (vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n);
}
-
- if (do_nmap_tangent) {
- VertRen *v1=vlr->v1, *v2=vlr->v2, *v3=vlr->v3, *v4=vlr->v4;
- MTFace *tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0);
-
- if (tface) {
- int k=0;
- float *vtang, *ftang= RE_vlakren_get_nmap_tangent(obr, vlr, 1);
-
- vtang= find_vertex_tangent(vtangents[v1->index], tface->uv[0]);
- copy_v3_v3(ftang, vtang);
- normalize_v3(ftang);
- vtang= find_vertex_tangent(vtangents[v2->index], tface->uv[1]);
- copy_v3_v3(ftang+4, vtang);
- normalize_v3(ftang+4);
- vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]);
- copy_v3_v3(ftang+8, vtang);
- normalize_v3(ftang+8);
- if (v4) {
- vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]);
- copy_v3_v3(ftang+12, vtang);
- normalize_v3(ftang+12);
- }
- for (k=0; k<4; k++) ftang[4*k+3]=1;
- }
- }
}
/* normalize vertex normals */
@@ -675,6 +637,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
}
}
+ /* normal mapping tangent with mikktspace */
if (do_nmap_tangent != FALSE) {
SRenderMeshToTangent mesh2tangent;
SMikkTSpaceContext sContext;
@@ -696,11 +659,6 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
genTangSpaceDefault(&sContext);
}
-
- if (arena)
- BLI_memarena_free(arena);
- if (vtangents)
- MEM_freeN(vtangents);
}
/* ------------------------------------------------------------------------- */
@@ -882,7 +840,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d
else
normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
}
- }
+ }
}
/* ------------------------------------------------------------------------- */
@@ -1570,9 +1528,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
int i, a, k, max_k=0, totpart, do_simplify = FALSE, do_surfacecache = FALSE, use_duplimat = FALSE;
int totchild=0;
int seed, path_nbr=0, orco1=0, num;
- int totface, *origindex = 0;
+ int totface;
char **uv_name=0;
+ const int *index_mf_to_mpoly = NULL;
+ const int *index_mp_to_orig = NULL;
+
/* 1. check that everything is ok & updated */
if (psys==NULL)
return 0;
@@ -1613,7 +1574,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
psys->flag |= PSYS_DRAWING;
- rng= rng_new(psys->seed);
+ rng= BLI_rng_new(psys->seed);
totpart=psys->totpart;
@@ -1742,9 +1703,13 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
do_surfacecache = TRUE;
totface= psmd->dm->getNumTessFaces(psmd->dm);
- origindex= psmd->dm->getTessFaceDataArray(psmd->dm, CD_ORIGINDEX);
+ index_mf_to_mpoly = psmd->dm->getTessFaceDataArray(psmd->dm, CD_ORIGINDEX);
+ index_mp_to_orig = psmd->dm->getPolyDataArray(psmd->dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
for (a=0; a<totface; a++)
- strandbuf->totbound= MAX2(strandbuf->totbound, (origindex)? origindex[a]: a);
+ strandbuf->totbound = max_ii(strandbuf->totbound, (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a): a);
strandbuf->totbound++;
strandbuf->bound= MEM_callocN(sizeof(StrandBound)*strandbuf->totbound, "StrandBound");
@@ -1763,7 +1728,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
/* 3. start creating renderable things */
for (a=0, pa=pars; a<totpart+totchild; a++, pa++, seed++) {
- random = rng_getFloat(rng);
+ random = BLI_rng_get_float(rng);
/* setup per particle individual stuff */
if (a<totpart) {
if (pa->flag & PARS_UNEXIST) continue;
@@ -1855,7 +1820,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
do_simplify = psys_render_simplify_params(psys, cpa, simplify);
if (strandbuf) {
- int orignum= (origindex)? origindex[cpa->num]: cpa->num;
+ int orignum = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, cpa->num) : cpa->num;
if (orignum > sbound - strandbuf->bound) {
sbound= strandbuf->bound + orignum;
@@ -1939,7 +1904,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
copy_v3_v3(state.vel, (cache+k)->vel);
}
else
- continue;
+ continue;
if (k > 0)
curlen += len_v3v3((cache+k-1)->co, (cache+k)->co);
@@ -2099,7 +2064,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if (states)
MEM_freeN(states);
- rng_free(rng);
+ BLI_rng_free(rng);
psys->flag &= ~PSYS_DRAWING;
@@ -2367,7 +2332,7 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float
/* Recalculate the face normal - if flipped before, flip now */
if (vlr->v4) {
normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- }
+ }
else {
normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
}
@@ -2536,7 +2501,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
copy_v3_v3(v1->co, data); data += 3;
if (orco) {
v1->orco= orco; orco+= 3; orcoret++;
- }
+ }
mul_m4_v3(mat, v1->co);
for (v = 1; v < sizev; v++) {
@@ -2544,7 +2509,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
copy_v3_v3(ver->co, data); data += 3;
if (orco) {
ver->orco= orco; orco+= 3; orcoret++;
- }
+ }
mul_m4_v3(mat, ver->co);
}
/* if V-cyclic, add extra vertices at end of the row */
@@ -2554,8 +2519,8 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
if (orco) {
ver->orco= orco; orco+=3; orcoret++; //orcobase + 3*(u*sizev + 0);
}
- }
- }
+ }
+ }
/* Done before next loop to get corner vert */
if (dl->flag & DL_CYCL_U) nsizev++;
@@ -2608,7 +2573,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
p1++; p2++; p3++; p4++;
}
- }
+ }
/* fix normals for U resp. V cyclic faces */
sizeu--; sizev--; /* dec size for face array */
if (dl->flag & DL_CYCL_V) {
@@ -2929,8 +2894,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
vlr->v2= RE_findOrAddVert(obr, startvert+index[1]);
vlr->v3= RE_findOrAddVert(obr, startvert+index[2]);
vlr->v4= NULL;
-
- if (area_tri_v3(vlr->v3->co, vlr->v2->co, vlr->v1->co)>FLT_EPSILON) {
+ if (area_tri_v3(vlr->v3->co, vlr->v2->co, vlr->v1->co)>FLT_EPSILON10) {
normal_tri_v3(tmp, vlr->v3->co, vlr->v2->co, vlr->v1->co);
add_v3_v3(n, tmp);
}
@@ -3274,11 +3238,11 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
/* normalmaps, test if tangents needed, separated from shading */
if (ma->mode_l & MA_TANGENT_V) {
need_tangent= 1;
- if (me->mtface==NULL)
+ if (me->mtpoly==NULL)
need_orco= 1;
}
if (ma->mode_l & MA_NORMAP_TANG) {
- if (me->mtface==NULL) {
+ if (me->mtpoly==NULL) {
need_orco= 1;
need_tangent= 1;
}
@@ -3289,7 +3253,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if (re->flag & R_NEED_TANGENT) {
/* exception for tangent space baking */
- if (me->mtface==NULL) {
+ if (me->mtpoly==NULL) {
need_orco= 1;
need_tangent= 1;
}
@@ -3616,22 +3580,22 @@ static void area_lamp_vectors(LampRen *lar)
/* corner vectors */
lar->area[0][0]= lar->co[0] - xsize*lar->mat[0][0] - ysize*lar->mat[1][0];
lar->area[0][1]= lar->co[1] - xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
- lar->area[0][2]= lar->co[2] - xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
+ lar->area[0][2]= lar->co[2] - xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
/* corner vectors */
lar->area[1][0]= lar->co[0] - xsize*lar->mat[0][0] + ysize*lar->mat[1][0];
lar->area[1][1]= lar->co[1] - xsize*lar->mat[0][1] + ysize*lar->mat[1][1];
- lar->area[1][2]= lar->co[2] - xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
+ lar->area[1][2]= lar->co[2] - xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
/* corner vectors */
lar->area[2][0]= lar->co[0] + xsize*lar->mat[0][0] + ysize*lar->mat[1][0];
lar->area[2][1]= lar->co[1] + xsize*lar->mat[0][1] + ysize*lar->mat[1][1];
- lar->area[2][2]= lar->co[2] + xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
+ lar->area[2][2]= lar->co[2] + xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
/* corner vectors */
lar->area[3][0]= lar->co[0] + xsize*lar->mat[0][0] - ysize*lar->mat[1][0];
lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
- lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
+ lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
/* only for correction button size, matrix size works on energy */
lar->areasize= lar->dist*lar->dist/(4.0f*xsize*ysize);
}
@@ -4106,8 +4070,12 @@ static void set_fullsample_trace_flag(Render *re, ObjectRen *obr)
vlr->flag |= R_FULL_OSA;
}
else if (trace) {
- if (mode & MA_SHLESS);
- else if (vlr->mat->material_type == MA_TYPE_VOLUME);
+ if (mode & MA_SHLESS) {
+ /* pass */
+ }
+ else if (vlr->mat->material_type == MA_TYPE_VOLUME) {
+ /* pass */
+ }
else if ((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) {
/* for blurry reflect/refract, better to take more samples
* inside the raytrace than as OSA samples */
@@ -4328,7 +4296,7 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
/* compute average bounding box of strandpoint itself (width) */
if (obr->strandbuf->flag & R_STRAND_B_UNITS)
- obr->strandbuf->maxwidth= MAX2(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end);
+ obr->strandbuf->maxwidth = max_ff(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end);
else
obr->strandbuf->maxwidth= 0.0f;
@@ -4533,7 +4501,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
ParticleSystem *psys;
int show_emitter, allow_render= 1, index, psysindex, i;
- index= (dob)? dob->index: 0;
+ index= (dob)? dob->persistent_id[0]: 0;
/* the emitter has to be processed first (render levels of modifiers) */
/* so here we only check if the emitter should be rendered */
@@ -4708,10 +4676,12 @@ void RE_Database_Free(Render *re)
static int allow_render_object(Render *re, Object *ob, int nolamps, int onlyselected, Object *actob)
{
/* override not showing object when duplis are used with particles */
- if (ob->transflag & OB_DUPLIPARTS)
- ; /* let particle system(s) handle showing vs. not showing */
- else if ((ob->transflag & OB_DUPLI) && !(ob->transflag & OB_DUPLIFRAMES))
+ if (ob->transflag & OB_DUPLIPARTS) {
+ /* pass */ /* let particle system(s) handle showing vs. not showing */
+ }
+ else if ((ob->transflag & OB_DUPLI) && !(ob->transflag & OB_DUPLIFRAMES)) {
return 0;
+ }
/* don't add non-basic meta objects, ends up having renderobjects with no geometry */
if (ob->type == OB_MBALL && ob!=BKE_mball_basis_find(re->scene, ob))
@@ -4929,7 +4899,8 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
* a dupligroup that has already been created before */
if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
mult_m4_m4m4(mat, re->viewmat, dob->mat);
- obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay);
+ /* ob = particle system, use that layer */
+ obi= RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], 0, mat, ob->lay);
/* fill in instance variables for texturing */
set_dupli_tex_mat(re, obi, dob);
@@ -4956,7 +4927,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) {
if (obi == NULL)
mult_m4_m4m4(mat, re->viewmat, dob->mat);
- obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, psysindex++, mat, obd->lay);
+ obi= RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], psysindex++, mat, obd->lay);
set_dupli_tex_mat(re, obi, dob);
if (dob->type != OB_DUPLIGROUP) {
@@ -5330,7 +5301,7 @@ static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen
calculate_speedvector(vec, 1, winsq, winroot, mesh->co[a], ho, winspeed[a]);
}
- return (float*)winspeed;
+ return (float *)winspeed;
}
return NULL;
@@ -5588,7 +5559,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned
re->i.infostr= "Calculating next frame vectors";
database_fromscene_vectors(re, sce, lay, +1);
- }
+ }
/* copy away vertex info */
copy_dbase_object_vectors(re, &newtable);
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index 03eb21dfa23..28f70211a9c 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -76,7 +76,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf)
BLI_lock_thread(LOCK_IMAGE);
if (env->cube[1] == NULL) {
- BKE_free_envmapdata(env);
+ BKE_free_envmapdata(env);
dx = ibuf->y;
dx /= 2;
@@ -120,7 +120,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf)
IMB_float_from_rect(env->cube[1]);
}
}
- }
+ }
BLI_unlock_thread(LOCK_IMAGE);
}
@@ -148,12 +148,14 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR);
envre->r.layers.first = envre->r.layers.last = NULL;
envre->r.filtertype = 0;
- envre->r.xparts = envre->r.yparts = 2;
+ envre->r.tilex = envre->r.xsch / 2;
+ envre->r.tiley = envre->r.ysch / 2;
envre->r.size = 100;
envre->r.yasp = envre->r.xasp = 1;
RE_InitState(envre, NULL, &envre->r, NULL, cuberes, cuberes, NULL);
envre->scene = re->scene; /* unsure about this... */
+ envre->scene_color_manage = re->scene_color_manage;
envre->lay = re->lay;
/* view stuff in env render */
@@ -215,7 +217,7 @@ static void envmap_transmatrix(float mat[][4], int part)
eul[0] = eul[1] = eul[2] = 0.0;
if (part == 0) { /* neg z */
- ;
+ /* pass */
}
else if (part == 1) { /* pos z */
eul[0] = M_PI;
@@ -575,7 +577,7 @@ void make_envmaps(Render *re)
re->display_init(re->dih, re->result);
re->display_clear(re->dch, re->result);
// re->flag |= R_REDRAW_PRV;
- }
+ }
/* restore */
re->r.mode |= trace;
@@ -642,31 +644,31 @@ static int envcube_isect(EnvMap *env, const float vec[3], float answ[2])
/* ------------------------------------------------------------------------- */
-static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int face)
+static void set_dxtdyt(float r_dxt[3], float r_dyt[3], const float dxt[3], const float dyt[3], int face)
{
if (face == 2 || face == 4) {
- dxts[0] = dxt[0];
- dyts[0] = dyt[0];
- dxts[1] = dxt[2];
- dyts[1] = dyt[2];
+ r_dxt[0] = dxt[0];
+ r_dyt[0] = dyt[0];
+ r_dxt[1] = dxt[2];
+ r_dyt[1] = dyt[2];
}
else if (face == 3 || face == 5) {
- dxts[0] = dxt[1];
- dxts[1] = dxt[2];
- dyts[0] = dyt[1];
- dyts[1] = dyt[2];
+ r_dxt[0] = dxt[1];
+ r_dxt[1] = dxt[2];
+ r_dyt[0] = dyt[1];
+ r_dyt[1] = dyt[2];
}
else {
- dxts[0] = dxt[0];
- dyts[0] = dyt[0];
- dxts[1] = dxt[1];
- dyts[1] = dyt[1];
+ r_dxt[0] = dxt[0];
+ r_dyt[0] = dyt[0];
+ r_dxt[1] = dxt[1];
+ r_dyt[1] = dyt[1];
}
}
/* ------------------------------------------------------------------------- */
-int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
+int envmaptex(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres)
{
extern Render R; /* only in this call */
/* texvec should be the already reflected normal */
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 636b3205b23..d771cf2253d 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -64,7 +64,7 @@
static RenderEngineType internal_render_type = {
NULL, NULL,
"BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL,
- NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
{NULL, NULL, NULL}
};
@@ -73,7 +73,7 @@ static RenderEngineType internal_render_type = {
static RenderEngineType internal_game_type = {
NULL, NULL,
"BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME,
- NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
{NULL, NULL, NULL}
};
@@ -138,7 +138,7 @@ void RE_engine_free(RenderEngine *engine)
{
#ifdef WITH_PYTHON
if (engine->py_instance) {
- BPY_DECREF(engine->py_instance);
+ BPY_DECREF_RNA_INVALIDATE(engine->py_instance);
}
#endif
@@ -290,9 +290,24 @@ void RE_engine_update_progress(RenderEngine *engine, float progress)
}
}
+void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak)
+{
+ Render *re = engine->re;
+
+ if (re) {
+ re->i.mem_used = mem_used;
+ re->i.mem_peak = mem_peak;
+ }
+}
+
void RE_engine_report(RenderEngine *engine, int type, const char *msg)
{
- BKE_report(engine->re->reports, type, msg);
+ Render *re = engine->re;
+
+ if (re)
+ BKE_report(engine->re->reports, type, msg);
+ else if (engine->reports)
+ BKE_report(engine->reports, type, msg);
}
/* Render */
@@ -334,7 +349,12 @@ int RE_engine_render(Render *re, int do_all)
re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0;
/* render */
- engine = RE_engine_create(type);
+ if(!re->engine)
+ re->engine = RE_engine_create(type);
+
+ engine = re->engine;
+
+ /* TODO: actually link to a parent which shouldn't happen */
engine->re = re;
if (re->flag & R_ANIMATION)
@@ -362,6 +382,11 @@ int RE_engine_render(Render *re, int do_all)
if (type->render)
type->render(engine, re->scene);
+ if(!(re->r.mode & R_PERSISTENT_DATA)) {
+ RE_engine_free(re->engine);
+ re->engine = NULL;
+ }
+
if (re->result->do_exr_tile) {
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
render_result_exr_file_end(re);
@@ -374,8 +399,6 @@ int RE_engine_render(Render *re, int do_all)
render_result_free_list(&engine->fullresult, engine->fullresult.first);
- RE_engine_free(engine);
-
if (BKE_reports_contain(re->reports, RPT_ERROR))
G.is_break = TRUE;
diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c
index 1c2613e8d18..8efdf472232 100644
--- a/source/blender/render/intern/source/gammaCorrectionTables.c
+++ b/source/blender/render/intern/source/gammaCorrectionTables.c
@@ -107,13 +107,13 @@ void makeGammaTables(float gamma)
color_step = 1.0 / RE_GAMMA_TABLE_SIZE;
inv_color_step = (float) RE_GAMMA_TABLE_SIZE;
- /* We could squeeze out the two range tables to gain some memory. */
+ /* We could squeeze out the two range tables to gain some memory. */
for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) {
- color_domain_table[i] = i * color_step;
+ color_domain_table[i] = i * color_step;
gamma_range_table[i] = pow(color_domain_table[i],
- valid_gamma);
+ valid_gamma);
inv_gamma_range_table[i] = pow(color_domain_table[i],
- valid_inv_gamma);
+ valid_inv_gamma);
}
/* The end of the table should match 1.0 carefully. In order to avoid */
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 6c86f2a2999..db1454fd82f 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -102,7 +102,7 @@ static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
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);
- }
+ }
}
int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResult *texres)
@@ -150,8 +150,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
fx-= xs;
fy-= ys;
- if ( (tex->flag & TEX_CHECKER_ODD)==0) {
- if ((xs+ys) & 1);else return retval;
+ if ( (tex->flag & TEX_CHECKER_ODD) == 0) {
+ if ((xs + ys) & 1) {
+ /* pass */
+ }
+ else {
+ return retval;
+ }
}
if ( (tex->flag & TEX_CHECKER_EVEN)==0) {
if ((xs+ys) & 1) return retval;
@@ -204,7 +209,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
if (tex->imaflag & TEX_USEALPHA) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
texres->talpha = TRUE;
- }
+ }
}
/* interpolate */
@@ -474,7 +479,9 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
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);
@@ -686,7 +693,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
}
}
else {
- char* rect = (char*)(ibuf->rect + x + y*ibuf->x);
+ char *rect = (char *)(ibuf->rect + x + y*ibuf->x);
col[0] = rect[0]*(1.f/255.f);
col[1] = rect[1]*(1.f/255.f);
col[2] = rect[2]*(1.f/255.f);
@@ -757,39 +764,39 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
/* table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
* used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible */
#define EWA_MAXIDX 255
-static float EWA_WTS[EWA_MAXIDX + 1] =
-{ 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
- 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f, 0.879734f, 0.871638f, 0.863605f,
- 0.855636f, 0.847728f, 0.839883f, 0.832098f, 0.824375f, 0.816712f, 0.809108f, 0.801564f,
- 0.794079f, 0.786653f, 0.779284f, 0.771974f, 0.76472f, 0.757523f, 0.750382f, 0.743297f,
- 0.736267f, 0.729292f, 0.722372f, 0.715505f, 0.708693f, 0.701933f, 0.695227f, 0.688572f,
- 0.68197f, 0.67542f, 0.66892f, 0.662471f, 0.656073f, 0.649725f, 0.643426f, 0.637176f,
- 0.630976f, 0.624824f, 0.618719f, 0.612663f, 0.606654f, 0.600691f, 0.594776f, 0.588906f,
- 0.583083f, 0.577305f, 0.571572f, 0.565883f, 0.56024f, 0.55464f, 0.549084f, 0.543572f,
- 0.538102f, 0.532676f, 0.527291f, 0.521949f, 0.516649f, 0.511389f, 0.506171f, 0.500994f,
- 0.495857f, 0.490761f, 0.485704f, 0.480687f, 0.475709f, 0.470769f, 0.465869f, 0.461006f,
- 0.456182f, 0.451395f, 0.446646f, 0.441934f, 0.437258f, 0.432619f, 0.428017f, 0.42345f,
- 0.418919f, 0.414424f, 0.409963f, 0.405538f, 0.401147f, 0.39679f, 0.392467f, 0.388178f,
- 0.383923f, 0.379701f, 0.375511f, 0.371355f, 0.367231f, 0.363139f, 0.359079f, 0.355051f,
- 0.351055f, 0.347089f, 0.343155f, 0.339251f, 0.335378f, 0.331535f, 0.327722f, 0.323939f,
- 0.320186f, 0.316461f, 0.312766f, 0.3091f, 0.305462f, 0.301853f, 0.298272f, 0.294719f,
- 0.291194f, 0.287696f, 0.284226f, 0.280782f, 0.277366f, 0.273976f, 0.270613f, 0.267276f,
- 0.263965f, 0.26068f, 0.257421f, 0.254187f, 0.250979f, 0.247795f, 0.244636f, 0.241502f,
- 0.238393f, 0.235308f, 0.232246f, 0.229209f, 0.226196f, 0.223206f, 0.220239f, 0.217296f,
- 0.214375f, 0.211478f, 0.208603f, 0.20575f, 0.20292f, 0.200112f, 0.197326f, 0.194562f,
- 0.191819f, 0.189097f, 0.186397f, 0.183718f, 0.18106f, 0.178423f, 0.175806f, 0.17321f,
- 0.170634f, 0.168078f, 0.165542f, 0.163026f, 0.16053f, 0.158053f, 0.155595f, 0.153157f,
- 0.150738f, 0.148337f, 0.145955f, 0.143592f, 0.141248f, 0.138921f, 0.136613f, 0.134323f,
- 0.132051f, 0.129797f, 0.12756f, 0.125341f, 0.123139f, 0.120954f, 0.118786f, 0.116635f,
- 0.114501f, 0.112384f, 0.110283f, 0.108199f, 0.106131f, 0.104079f, 0.102043f, 0.100023f,
- 0.0980186f, 0.09603f, 0.094057f, 0.0920994f, 0.0901571f, 0.08823f, 0.0863179f, 0.0844208f,
- 0.0825384f, 0.0806708f, 0.0788178f, 0.0769792f, 0.0751551f, 0.0733451f, 0.0715493f, 0.0697676f,
- 0.0679997f, 0.0662457f, 0.0645054f, 0.0627786f, 0.0610654f, 0.0593655f, 0.0576789f, 0.0560055f,
- 0.0543452f, 0.0526979f, 0.0510634f, 0.0494416f, 0.0478326f, 0.0462361f, 0.0446521f, 0.0430805f,
- 0.0415211f, 0.039974f, 0.0384389f, 0.0369158f, 0.0354046f, 0.0339052f, 0.0324175f, 0.0309415f,
- 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f, 0.0223242f, 0.020927f, 0.0195408f,
- 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f, 0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f,
- 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
+static float EWA_WTS[EWA_MAXIDX + 1] = {
+ 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
+ 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f, 0.879734f, 0.871638f, 0.863605f,
+ 0.855636f, 0.847728f, 0.839883f, 0.832098f, 0.824375f, 0.816712f, 0.809108f, 0.801564f,
+ 0.794079f, 0.786653f, 0.779284f, 0.771974f, 0.76472f, 0.757523f, 0.750382f, 0.743297f,
+ 0.736267f, 0.729292f, 0.722372f, 0.715505f, 0.708693f, 0.701933f, 0.695227f, 0.688572f,
+ 0.68197f, 0.67542f, 0.66892f, 0.662471f, 0.656073f, 0.649725f, 0.643426f, 0.637176f,
+ 0.630976f, 0.624824f, 0.618719f, 0.612663f, 0.606654f, 0.600691f, 0.594776f, 0.588906f,
+ 0.583083f, 0.577305f, 0.571572f, 0.565883f, 0.56024f, 0.55464f, 0.549084f, 0.543572f,
+ 0.538102f, 0.532676f, 0.527291f, 0.521949f, 0.516649f, 0.511389f, 0.506171f, 0.500994f,
+ 0.495857f, 0.490761f, 0.485704f, 0.480687f, 0.475709f, 0.470769f, 0.465869f, 0.461006f,
+ 0.456182f, 0.451395f, 0.446646f, 0.441934f, 0.437258f, 0.432619f, 0.428017f, 0.42345f,
+ 0.418919f, 0.414424f, 0.409963f, 0.405538f, 0.401147f, 0.39679f, 0.392467f, 0.388178f,
+ 0.383923f, 0.379701f, 0.375511f, 0.371355f, 0.367231f, 0.363139f, 0.359079f, 0.355051f,
+ 0.351055f, 0.347089f, 0.343155f, 0.339251f, 0.335378f, 0.331535f, 0.327722f, 0.323939f,
+ 0.320186f, 0.316461f, 0.312766f, 0.3091f, 0.305462f, 0.301853f, 0.298272f, 0.294719f,
+ 0.291194f, 0.287696f, 0.284226f, 0.280782f, 0.277366f, 0.273976f, 0.270613f, 0.267276f,
+ 0.263965f, 0.26068f, 0.257421f, 0.254187f, 0.250979f, 0.247795f, 0.244636f, 0.241502f,
+ 0.238393f, 0.235308f, 0.232246f, 0.229209f, 0.226196f, 0.223206f, 0.220239f, 0.217296f,
+ 0.214375f, 0.211478f, 0.208603f, 0.20575f, 0.20292f, 0.200112f, 0.197326f, 0.194562f,
+ 0.191819f, 0.189097f, 0.186397f, 0.183718f, 0.18106f, 0.178423f, 0.175806f, 0.17321f,
+ 0.170634f, 0.168078f, 0.165542f, 0.163026f, 0.16053f, 0.158053f, 0.155595f, 0.153157f,
+ 0.150738f, 0.148337f, 0.145955f, 0.143592f, 0.141248f, 0.138921f, 0.136613f, 0.134323f,
+ 0.132051f, 0.129797f, 0.12756f, 0.125341f, 0.123139f, 0.120954f, 0.118786f, 0.116635f,
+ 0.114501f, 0.112384f, 0.110283f, 0.108199f, 0.106131f, 0.104079f, 0.102043f, 0.100023f,
+ 0.0980186f, 0.09603f, 0.094057f, 0.0920994f, 0.0901571f, 0.08823f, 0.0863179f, 0.0844208f,
+ 0.0825384f, 0.0806708f, 0.0788178f, 0.0769792f, 0.0751551f, 0.0733451f, 0.0715493f, 0.0697676f,
+ 0.0679997f, 0.0662457f, 0.0645054f, 0.0627786f, 0.0610654f, 0.0593655f, 0.0576789f, 0.0560055f,
+ 0.0543452f, 0.0526979f, 0.0510634f, 0.0494416f, 0.0478326f, 0.0462361f, 0.0446521f, 0.0430805f,
+ 0.0415211f, 0.039974f, 0.0384389f, 0.0369158f, 0.0354046f, 0.0339052f, 0.0324175f, 0.0309415f,
+ 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f, 0.0223242f, 0.020927f, 0.0195408f,
+ 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f, 0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f,
+ 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
};
/* test if a float value is 'nan'
@@ -982,7 +989,7 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl
alphaclip = clipx_rctf(&rf, 0.0, (float)(ibuf->x));
alphaclip *= clipy_rctf(&rf, 0.0, (float)(ibuf->y));
- alphaclip = maxf(alphaclip, 0.0f);
+ alphaclip = max_ff(alphaclip, 0.0f);
if (alphaclip!=1.0f) {
/* premul it all */
@@ -1004,7 +1011,7 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
if (ibuf->userflags & IB_MIPMAP_INVALID) {
IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
ibuf->userflags &= ~IB_MIPMAP_INVALID;
- }
+ }
BLI_unlock_thread(LOCK_IMAGE);
}
if (ibuf->mipmap[0] == NULL) {
@@ -1240,8 +1247,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
float fProbes;
a *= ff;
b *= ff;
- a = maxf(a, 1.0f);
- b = maxf(b, 1.0f);
+ a = max_ff(a, 1.0f);
+ b = max_ff(b, 1.0f);
fProbes = 2.f*(a / b) - 1.f;
AFD.iProbes = (int)floorf(fProbes + 0.5f);
AFD.iProbes = MIN2(AFD.iProbes, tex->afmax);
@@ -1257,7 +1264,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
if (ecc > (float)tex->afmax) b = a / (float)tex->afmax;
b *= ff;
}
- maxd = maxf(b, 1e-8f);
+ maxd = max_ff(b, 1e-8f);
levf = ((float)M_LOG2E) * logf(maxd);
curmap = 0;
@@ -1342,8 +1349,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
a *= ff;
b *= ff;
- a = maxf(a, 1.0f);
- b = maxf(b, 1.0f);
+ a = max_ff(a, 1.0f);
+ b = max_ff(b, 1.0f);
fProbes = 2.f*(a / b) - 1.f;
/* no limit to number of Probes here */
AFD.iProbes = (int)floorf(fProbes + 0.5f);
@@ -1453,8 +1460,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
image_mipmap_test(tex, ibuf);
if (tex->imaflag & TEX_USEALPHA) {
- if (tex->imaflag & TEX_CALCALPHA);
- else texres->talpha= 1;
+ if (tex->imaflag & TEX_CALCALPHA) {
+ /* pass */
+ }
+ else {
+ texres->talpha = TRUE;
+ }
}
texr.talpha= texres->talpha;
@@ -1550,11 +1561,17 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (boundary==0) {
if ( (tex->flag & TEX_CHECKER_ODD)==0) {
- if ((xs+ys) & 1);
- else return retval;
+ if ((xs + ys) & 1) {
+ /* pass */
+ }
+ else {
+ return retval;
+ }
}
if ( (tex->flag & TEX_CHECKER_EVEN)==0) {
- if ((xs+ys) & 1) return retval;
+ if ((xs + ys) & 1) {
+ return retval;
+ }
}
fx-= xs;
fy-= ys;
@@ -1628,7 +1645,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
dx = minx;
dy = miny;
- maxd = maxf(dx, dy);
+ maxd = max_ff(dx, dy);
if (maxd > 0.5f) maxd = 0.5f;
pixsize = 1.0f / (float) MIN2(ibuf->x, ibuf->y);
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 88c64b44b64..b2cf8db7995 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -555,32 +555,17 @@ void initparts(Render *re, int do_crop)
xmaxb = re->disprect.xmax;
ymaxb = re->disprect.ymax;
- xparts = re->r.xparts;
- yparts = re->r.yparts;
-
- /* mininum part size, but for exr tile saving it was checked already */
- if (!(re->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE))) {
- if (re->r.mode & R_PANORAMA) {
- if (ceil(re->rectx / (float)xparts) < 8)
- xparts = 1 + re->rectx / 8;
- }
- else
- if (ceil(re->rectx / (float)xparts) < 64)
- xparts = 1 + re->rectx / 64;
-
- if (ceil(re->recty / (float)yparts) < 64)
- yparts = 1 + re->recty / 64;
- }
-
/* part size */
- partx = ceil(re->rectx / (float)xparts);
- party = ceil(re->recty / (float)yparts);
+ partx = min_ii(re->r.tilex, re->rectx);
+ party = min_ii(re->r.tiley, re->recty);
- re->xparts = xparts;
- re->yparts = yparts;
re->partx = partx;
re->party = party;
+ /* part count */
+ xparts = (re->rectx + partx - 1) / partx;
+ yparts = (re->recty + party - 1) / party;
+
/* calculate rotation factor of 1 pixel */
if (re->r.mode & R_PANORAMA)
re->panophi = panorama_pixel_rot(re);
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index af774c5be73..a7308821843 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -184,7 +184,7 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr,
if (shi->flippednor)
shade_input_flip_normals(shi);
- madd_v3_v3fl(shi->co, shi->vn, 0.0001f); /* ugly.. */
+ madd_v3_v3fl(shi->co, shi->facenor, -0.0001f); /* ugly.. */
/* not a pretty solution, but fixes common cases */
if (shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) {
@@ -625,9 +625,12 @@ static void occ_build_sh_normalize(OccNode *node)
sh_mul(node->sh, 1.0f / node->area);
for (b = 0; b < TOTCHILD; b++) {
- if (node->childflag & (1 << b)) ;
- else if (node->child[b].node)
+ if (node->childflag & (1 << b)) {
+ /* pass */
+ }
+ else if (node->child[b].node) {
occ_build_sh_normalize(node->child[b].node);
+ }
}
}
@@ -1127,7 +1130,7 @@ static void normalizef(float *n)
n[0] *= d;
n[1] *= d;
n[2] *= d;
- }
+ }
}
/* TODO: exact duplicate of ff_quad_form_factor() in math_geom.c
@@ -1544,7 +1547,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int
for (i = 0; i < 4; i++) {
sub_v3_v3v3(d, samples[i]->co, co);
- //dist2= dot_v3v3(d, d);
+ //dist2 = dot_v3v3(d, d);
wz[i] = 1.0f; //(samples[i]->dist2/(1e-4f + dist2));
wn[i] = pow(dot_v3v3(samples[i]->n, n), 32.0f);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index b1b88fc9fd5..85cafa07759 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -244,6 +244,7 @@ Render *RE_GetRender(const char *name)
return re;
}
+
/* if you want to know exactly what has been done */
RenderResult *RE_AcquireResultRead(Render *re)
{
@@ -387,6 +388,9 @@ void RE_InitRenderCB(Render *re)
/* only call this while you know it will remove the link too */
void RE_FreeRender(Render *re)
{
+ if (re->engine)
+ RE_engine_free(re->engine);
+
BLI_rw_mutex_end(&re->resultmutex);
free_renderdata_tables(re);
@@ -421,6 +425,19 @@ void RE_FreeAllRenderResults(void)
}
}
+void RE_FreePersistentData(void)
+{
+ Render *re;
+
+ /* render engines can be kept around for quick re-render, this clears all */
+ for (re = RenderGlobal.renderlist.first; re; re = re->next) {
+ if (re->engine) {
+ RE_engine_free(re->engine);
+ re->engine = NULL;
+ }
+ }
+}
+
/* ********* initialize state ******** */
@@ -499,13 +516,15 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
}
/* always call, checks for gamma, gamma tables and jitter too */
- make_sample_tables(re);
+ make_sample_tables(re);
/* if preview render, we try to keep old result */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
if (re->r.scemode & R_PREVIEWBUTS) {
- if (re->result && re->result->rectx == re->rectx && re->result->recty == re->recty) ;
+ if (re->result && re->result->rectx == re->rectx && re->result->recty == re->recty) {
+ /* pass */
+ }
else {
render_result_free(re->result);
re->result = NULL;
@@ -654,8 +673,12 @@ static void *do_part_thread(void *pa_v)
}
else if (render_display_draw_enabled(&R)) {
/* on break, don't merge in result for preview renders, looks nicer */
- if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)) ;
- else render_result_merge(R.result, pa->result);
+ if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)) {
+ /* pass */
+ }
+ else {
+ render_result_merge(R.result, pa->result);
+ }
}
}
@@ -671,6 +694,7 @@ float panorama_pixel_rot(Render *re)
{
float psize, phi, xfac;
float borderfac = (float)BLI_rcti_size_x(&re->disprect) / (float)re->winx;
+ int xparts = (re->rectx + re->partx - 1) / re->partx;
/* size of 1 pixel mapped to viewplane coords */
psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx;
@@ -678,7 +702,7 @@ float panorama_pixel_rot(Render *re)
phi = atan(psize / re->clipsta);
/* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
- xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)re->xparts;
+ xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)xparts;
xfac = atan(0.5f * xfac / re->clipsta);
/* and how much the same viewplane angle is wrapped */
psize = 0.5f * phi * ((float)re->partx);
@@ -978,7 +1002,7 @@ static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, floa
rf[1] = mfac * rf[1] + blurfac * rf1[1];
rf[2] = mfac * rf[2] + blurfac * rf1[2];
rf[3] = mfac * rf[3] + blurfac * rf1[3];
- }
+ }
}
}
rectf += stride;
@@ -1070,7 +1094,7 @@ static void do_render_blur_3d(Render *re)
/* weak... the display callback wants an active renderlayer pointer... */
re->result->renlay = render_get_active_layer(re, re->result);
- re->display_draw(re->ddh, re->result, NULL);
+ re->display_draw(re->ddh, re->result, NULL);
}
@@ -1513,6 +1537,7 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree)
re->main = bmain;
re->scene = sce;
+ re->scene_color_manage = BKE_scene_check_color_management_enabled(sce);
/* first call RE_ReadRenderResult on every renderlayer scene. this creates Render structs */
@@ -1560,7 +1585,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
ntreeFreeCache(ntree);
do_render_fields_blur_3d(re);
- }
+ }
else {
/* ensure new result gets added, like for regular renders */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
@@ -1865,7 +1890,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
if (scene->r.border.xmax <= scene->r.border.xmin ||
scene->r.border.ymax <= scene->r.border.ymin)
{
- BKE_report(reports, RPT_ERROR, "No border area selected.");
+ BKE_report(reports, RPT_ERROR, "No border area selected");
return 0;
}
}
@@ -1876,13 +1901,13 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
render_result_exr_file_path(scene, "", 0, str);
if (BLI_file_is_writable(str) == 0) {
- BKE_report(reports, RPT_ERROR, "Can not save render buffers, check the temp default path");
+ BKE_report(reports, RPT_ERROR, "Cannot save render buffers, check the temp default path");
return 0;
}
/* no fullsample and edge */
if ((scene->r.scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) {
- BKE_report(reports, RPT_ERROR, "Full Sample doesn't support Edge Enhance");
+ BKE_report(reports, RPT_ERROR, "Full sample does not support edge enhance");
return 0;
}
@@ -1893,18 +1918,18 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
if (scene->r.scemode & R_DOCOMP) {
if (scene->use_nodes) {
if (!scene->nodetree) {
- BKE_report(reports, RPT_ERROR, "No Nodetree in Scene");
+ BKE_report(reports, RPT_ERROR, "No node tree in scene");
return 0;
}
if (!check_composite_output(scene)) {
- BKE_report(reports, RPT_ERROR, "No Render Output Node in Scene");
+ BKE_report(reports, RPT_ERROR, "No render output node in scene");
return 0;
}
if (scene->r.scemode & R_FULL_SAMPLE) {
if (composite_needs_render(scene, 0) == 0) {
- BKE_report(reports, RPT_ERROR, "Full Sample AA not supported without 3d rendering");
+ BKE_report(reports, RPT_ERROR, "Full sample AA not supported without 3D rendering");
return 0;
}
}
@@ -1923,7 +1948,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
/* forbidden combinations */
if (scene->r.mode & R_PANORAMA) {
if (scene->r.mode & R_ORTHO) {
- BKE_report(reports, RPT_ERROR, "No Ortho render possible for Panorama");
+ BKE_report(reports, RPT_ERROR, "No ortho render possible for panorama");
return 0;
}
}
@@ -1939,7 +1964,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
if (!(srl->layflag & SCE_LAY_DISABLE))
break;
if (srl == NULL) {
- BKE_report(reports, RPT_ERROR, "All RenderLayers are disabled");
+ BKE_report(reports, RPT_ERROR, "All render layers are disabled");
return 0;
}
@@ -2008,6 +2033,7 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc
re->main = bmain;
re->scene = scene;
+ re->scene_color_manage = BKE_scene_check_color_management_enabled(scene);
re->camera_override = camera_override;
re->lay = lay;
@@ -2111,6 +2137,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
/* note; the way it gets 32 bits rects is weak... */
if (ibuf->rect == NULL) {
ibuf->rect = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect");
+ ibuf->mall |= IB_rect;
RE_ResultGet32(re, ibuf->rect);
do_free = TRUE;
}
@@ -2124,13 +2151,14 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
if (do_free) {
MEM_freeN(ibuf->rect);
ibuf->rect = NULL;
+ ibuf->mall &= ~IB_rect;
}
/* imbuf knows which rects are not part of ibuf */
IMB_freeImBuf(ibuf);
printf("Append frame %d", scene->r.cfra);
- }
+ }
else {
if (name_override)
BLI_strncpy(name, name_override, sizeof(name));
@@ -2344,6 +2372,7 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
re->main = bmain;
re->scene = sce;
+ re->scene_color_manage = BKE_scene_check_color_management_enabled(sce);
re->lay = sce->lay;
camera = RE_GetCamera(re);
@@ -2388,6 +2417,7 @@ int RE_ReadRenderResult(Scene *scene, Scene *scenode)
re = RE_NewRender(scene->id.name);
RE_InitState(re, NULL, &scene->r, NULL, winx, winy, &disprect);
re->scene = scene;
+ re->scene_color_manage = BKE_scene_check_color_management_enabled(scene);
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
success = render_result_exr_file_read(re, 0);
@@ -2448,25 +2478,25 @@ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char
IMB_freeImBuf(ibuf_clip);
}
else {
- BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to allocate clip buffer '%s'\n", filename);
+ BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to allocate clip buffer '%s'", filename);
}
}
else {
- BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: incorrect dimensions for partial copy '%s'\n", filename);
+ BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: incorrect dimensions for partial copy '%s'", filename);
}
}
IMB_freeImBuf(ibuf);
}
else {
- BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename);
+ BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'", filename);
}
}
void RE_result_load_from_file(RenderResult *result, ReportList *reports, const char *filename)
{
if (!render_result_exr_file_read_path(result, NULL, filename)) {
- BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename);
+ BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'", filename);
return;
}
}
@@ -2494,8 +2524,8 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env,
if (env->type == ENV_CUBE) {
for (i = 0; i < 12; i += 2) {
- maxX = MAX2(maxX, layout[i] + 1);
- maxY = MAX2(maxY, layout[i + 1] + 1);
+ maxX = max_ii(maxX, (int)layout[i] + 1);
+ maxY = max_ii(maxY, (int)layout[i + 1] + 1);
}
ibuf = IMB_allocImBuf(maxX * dx, maxY * dx, 24, IB_rectfloat);
@@ -2527,7 +2557,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env,
return TRUE;
}
else {
- BKE_report(reports, RPT_ERROR, "Error writing environment map.");
+ BKE_report(reports, RPT_ERROR, "Error writing environment map");
return FALSE;
}
}
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index 8e6078b18e0..3420648cb52 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -162,7 +162,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3])
copy_v3_v3(lvrot, lv);
mul_m3_v3(lar->imat, lvrot);
- x = maxf(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
+ x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
/* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
inpr= 1.0/(sqrt(1.0f+x*x));
@@ -614,7 +614,7 @@ void shadeSkyPixel(float collector[4], float fx, float fy, short thread)
copy_v3_v3(collector, &R.wrld.horr);
collector[3] = 0.0f;
- }
+ }
else {
/* 2. */
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 49c2bf1d053..a540cdb85d5 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -36,6 +36,7 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
+#include "BLI_noise.h"
#include "BLI_kdopbvh.h"
#include "BLI_utildefines.h"
@@ -170,7 +171,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
pd->point_data[i*3 + 0] = state.vel[0];
pd->point_data[i*3 + 1] = state.vel[1];
pd->point_data[i*3 + 2] = state.vel[2];
- }
+ }
if (data_used & POINT_DATA_LIFE) {
float pa_time;
@@ -405,7 +406,7 @@ static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *
}
-int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
+int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres)
{
int retval = TEX_INT;
PointDensity *pd = tex->pd;
@@ -418,7 +419,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
texres->tin = 0.0f;
- if ((!pd) || (!pd->point_tree))
+ if ((!pd) || (!pd->point_tree))
return 0;
init_pointdensityrangedata(pd, &pdr, &density, vec, &age,
@@ -481,7 +482,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
case TEX_PD_COLOR_PARTAGE:
if (pd->coba) {
if (do_colorband(pd->coba, age, col)) {
- texres->talpha= 1;
+ texres->talpha = TRUE;
copy_v3_v3(&texres->tr, col);
texres->tin *= col[3];
texres->ta = texres->tin;
@@ -494,7 +495,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
if (pd->coba) {
if (do_colorband(pd->coba, speed, col)) {
- texres->talpha= 1;
+ texres->talpha = TRUE;
copy_v3_v3(&texres->tr, col);
texres->tin *= col[3];
texres->ta = texres->tin;
@@ -503,7 +504,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
break;
}
case TEX_PD_COLOR_PARTVEL:
- texres->talpha= 1;
+ texres->talpha = TRUE;
mul_v3_fl(vec, pd->speed_scale);
copy_v3_v3(&texres->tr, vec);
texres->ta = texres->tin;
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index aa35d73f3b5..127e0bc07b9 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -239,7 +239,7 @@ RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi)
if (faces == 0)
return NULL;
- //Create Ray cast accelaration structure
+ //Create Ray cast accelaration structure
raytree = RE_rayobject_create( re, re->r.raytrace_structure, faces );
if ( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) )
vlakprimitive = obr->rayprimitives = (VlakPrimitive*)MEM_callocN(faces*sizeof(VlakPrimitive), "ObjectRen primitives");
@@ -549,7 +549,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
/* raytrace likes to separate the spec color */
sub_v3_v3v3(shr->diff, shr->combined, shr->spec);
- }
+ }
}
@@ -564,12 +564,12 @@ static int refraction(float refract[3], const float n[3], const float view[3], f
if (dot>0.0f) {
index = 1.0f/index;
fac= 1.0f - (1.0f - dot*dot)*index*index;
- if (fac<= 0.0f) return 0;
+ if (fac <= 0.0f) return 0;
fac= -dot*index + sqrtf(fac);
}
else {
fac= 1.0f - (1.0f - dot*dot)*index*index;
- if (fac<= 0.0f) return 0;
+ if (fac <= 0.0f) return 0;
fac= -dot*index - sqrtf(fac);
}
@@ -632,7 +632,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr)
if (shi->mat->tx_limit <= 0.0f) {
d= 1.0f;
- }
+ }
else {
float p;
@@ -733,7 +733,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con
if (depth>0) {
float fr, fg, fb, f, f1;
- if ((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) {
+ if ((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) {
float nf, f, refract[3], tracol[4];
tracol[0]= shi.r;
@@ -938,7 +938,7 @@ void init_jitter_plane(LampRen *lar)
DP_energy(lar->jitter, fp, tot, lar->area_size, lar->area_sizey);
}
}
- }
+ }
/* create the dithered tables (could just check lamp type!) */
jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, 0.5f, 0.0f);
jitter_plane_offset(lar->jitter, lar->jitter+4*tot, tot, lar->area_size, lar->area_sizey, 0.5f, 0.5f);
@@ -1151,7 +1151,7 @@ static void QMC_sampleHemiCosine(float vec[3], QMCSampler *qsa, int thread, int
QMC_getSample(s, qsa, thread, num);
- phi = s[0]*2.f*M_PI;
+ phi = s[0]*2.f*M_PI;
sqr = s[1]*sqrt(2-s[1]*s[1]);
vec[0] = cos(phi)*sqr;
@@ -1295,7 +1295,7 @@ static void trace_refract(float col[4], ShadeInput *shi, ShadeResult *shr)
max_samples = 1;
- while (samples < max_samples) {
+ while (samples < max_samples) {
if (refraction(v_refract, shi->vn, shi->view, shi->ang)) {
traflag |= RAY_INSIDE;
}
@@ -1515,7 +1515,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr)
if (!(shi->combinedflag & SCE_PASS_REFRACT))
sub_v3_v3v3(diff, diff, shr->refr);
- shr->alpha = minf(1.0f, tracol[3]);
+ shr->alpha = min_ff(1.0f, tracol[3]);
}
if (do_mir) {
@@ -1822,7 +1822,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in
}
return sphere;
- }
+ }
else {
float *sphere;
float *vec1;
@@ -1847,7 +1847,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in
for (a=0; a<tot; a++, vec+=3, vec1+=3) {
vec1[0]= cost*cosfi*vec[0] - sinfi*vec[1] + sint*cosfi*vec[2];
vec1[1]= cost*sinfi*vec[0] + cosfi*vec[1] + sint*sinfi*vec[2];
- vec1[2]= -sint*vec[0] + cost*vec[2];
+ vec1[2]= -sint*vec[0] + cost*vec[2];
}
}
return sphere;
@@ -1981,7 +1981,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3])
samples++;
if (qsa && qsa->type == SAMP_TYPE_HALTON) {
- /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */
+ /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */
if (adapt_thresh > 0.0f && (samples > max_samples/2) ) {
if (adaptive_sample_contrast_val(samples, prev, fac, adapt_thresh)) {
@@ -2532,7 +2532,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4])
#if 0
/* only when face points away from lamp, in direction of lamp, trace ray and find first exit point */
-static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float *co)
+static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float co[3])
{
Isect isec;
float lampco[3];
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 0bac26e7e3c..f8281586038 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -786,7 +786,7 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file
}
else {
/* TODO, get the error from openexr's exception */
- BKE_report(reports, RPT_ERROR, "Error Writing Render Result, see console");
+ BKE_report(reports, RPT_ERROR, "Error writing render result (see console)");
success = FALSE;
}
IMB_exr_close(exrhandle);
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 982f7e7d824..c507d6595e0 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -35,6 +35,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_noise.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
@@ -184,7 +185,7 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres)
-static int blend(Tex *tex, float *texvec, TexResult *texres)
+static int blend(Tex *tex, const float texvec[3], TexResult *texres)
{
float x, y, t;
@@ -236,7 +237,7 @@ static int blend(Tex *tex, float *texvec, TexResult *texres)
/* newnoise: all noisebased types now have different noisebases to choose from */
-static int clouds(Tex *tex, float *texvec, TexResult *texres)
+static int clouds(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
@@ -302,7 +303,7 @@ static float tex_tri(float a)
/* computes basic wood intensity value at x,y,z */
static float wood_int(Tex *tex, float x, float y, float z)
{
- float wi=0;
+ 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 */
@@ -331,7 +332,7 @@ static float wood_int(Tex *tex, float x, float y, float z)
return wi;
}
-static int wood(Tex *tex, float *texvec, TexResult *texres)
+static int wood(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv=TEX_INT;
@@ -373,7 +374,7 @@ static float marble_int(Tex *tex, float x, float y, float z)
mi = waveform[wf](mi);
if (mt==TEX_SHARP) {
mi = sqrt(mi);
- }
+ }
else if (mt==TEX_SHARPER) {
mi = sqrt(sqrt(mi));
}
@@ -382,7 +383,7 @@ static float marble_int(Tex *tex, float x, float y, float z)
return mi;
}
-static int marble(Tex *tex, float *texvec, TexResult *texres)
+static int marble(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv=TEX_INT;
@@ -406,7 +407,7 @@ static int marble(Tex *tex, float *texvec, TexResult *texres)
/* ------------------------------------------------------------------------- */
-static int magic(Tex *tex, float *texvec, TexResult *texres)
+static int magic(Tex *tex, const float texvec[3], TexResult *texres)
{
float x, y, z, turb=1.0;
int n;
@@ -482,7 +483,7 @@ static int magic(Tex *tex, float *texvec, TexResult *texres)
/* ------------------------------------------------------------------------- */
/* newnoise: stucci also modified to use different noisebasis */
-static int stucci(Tex *tex, float *texvec, TexResult *texres)
+static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
{
float nor[3], b2, ofs;
int retval= TEX_INT;
@@ -493,7 +494,7 @@ static int stucci(Tex *tex, float *texvec, TexResult *texres)
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[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];
@@ -524,7 +525,7 @@ static int stucci(Tex *tex, float *texvec, TexResult *texres)
/* ------------------------------------------------------------------------- */
/* newnoise: musgrave terrain noise types */
-static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres)
+static float mg_mFractalOrfBmTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
float (*mgravefunc)(float, float, float, float, float, float, int);
@@ -554,7 +555,7 @@ static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres)
}
-static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres)
+static float mg_ridgedOrHybridMFTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
@@ -585,7 +586,7 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres)
}
-static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres)
+static float mg_HTerrainTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
@@ -610,7 +611,7 @@ static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres)
}
-static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres)
+static float mg_distNoiseTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
@@ -639,7 +640,7 @@ static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres)
/* ------------------------------------------------------------------------- */
/* newnoise: Voronoi texture type, probably the slowest, especially with minkovsky, bumpmapping, could be done another way */
-static float voronoiTex(Tex *tex, float *texvec, 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 */
@@ -768,7 +769,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
else {
*adr1 = (y + 1.0f) / 2.0f;
*adr2 = (z + 1.0f) / 2.0f;
- ret= 2;
+ ret= 2;
}
return ret;
}
@@ -823,8 +824,8 @@ static int cubemap(MTex *mtex, VlakRen *vlr, const float n[3], float x, float y,
*adr1 = (y + 1.0f) / 2.0f;
*adr2 = (z + 1.0f) / 2.0f;
ret= 2;
- }
- }
+ }
+ }
else {
return cubemap_glob(n, x, y, z, adr1, adr2);
}
@@ -861,14 +862,14 @@ static int cubemap_ob(Object *ob, const float n[3], float x, float y, float z, f
else {
*adr1 = (y + 1.0f) / 2.0f;
*adr2 = (z + 1.0f) / 2.0f;
- ret= 2;
+ ret= 2;
}
return ret;
}
/* ------------------------------------------------------------------------- */
-static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], float *dxt, float *dyt)
+static void do_2d_mapping(MTex *mtex, float texvec[3], VlakRen *vlr, const float n[3], float dxt[3], float dyt[3])
{
Tex *tex;
Object *ob= NULL;
@@ -884,15 +885,15 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
if (R.osa==0) {
if (wrap==MTEX_FLAT) {
- fx = (t[0] + 1.0f) / 2.0f;
- fy = (t[1] + 1.0f) / 2.0f;
+ fx = (texvec[0] + 1.0f) / 2.0f;
+ fy = (texvec[1] + 1.0f) / 2.0f;
}
- else if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy, t[0], t[1], t[2]);
- else if (wrap==MTEX_SPHERE) map_to_sphere(&fx, &fy, t[0], t[1], t[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 {
- if (texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy);
- else if (texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy);
- else cubemap(mtex, vlr, n, t[0], t[1], t[2], &fx, &fy);
+ if (texco == TEXCO_OBJECT) cubemap_ob(ob, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
+ else if (texco == TEXCO_GLOB) cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
+ else cubemap(mtex, vlr, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
}
/* repeat */
@@ -932,14 +933,14 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
fy= tex->cropymin+ fy*fac1;
}
- t[0]= fx;
- t[1]= fy;
+ texvec[0]= fx;
+ texvec[1]= fy;
}
else {
if (wrap==MTEX_FLAT) {
- fx= (t[0] + 1.0f) / 2.0f;
- fy= (t[1] + 1.0f) / 2.0f;
+ 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;
@@ -950,29 +951,36 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
else if (ELEM(wrap, MTEX_TUBE, MTEX_SPHERE)) {
/* exception: the seam behind (y<0.0) */
ok= 1;
- if (t[1]<=0.0f) {
- fx= t[0]+dxt[0];
- fy= t[0]+dyt[0];
- if (fx>=0.0f && fy>=0.0f && t[0]>=0.0f);
- else if (fx<=0.0f && fy<=0.0f && t[0]<=0.0f);
- else ok= 0;
+ 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) {
+ /* pass */
+ }
+ else {
+ ok = 0;
+ }
}
+
if (ok) {
if (wrap==MTEX_TUBE) {
- map_to_tube(area, area+1, t[0], t[1], t[2]);
- map_to_tube(area + 2, area + 3, t[0] + dxt[0], t[1] + dxt[1], t[2] + dxt[2]);
- map_to_tube(area + 4, area + 5, t[0] + dyt[0], t[1] + dyt[1], t[2] + dyt[2]);
+ 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, t[0], t[1], t[2]);
- map_to_sphere(area + 2, area + 3, t[0] + dxt[0], t[1] + dxt[1], t[2] + dxt[2]);
- map_to_sphere(area + 4, area + 5, t[0] + dyt[0], t[1] + dyt[1], t[2] + dyt[2]);
+ else {
+ 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;
}
else {
- if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy, t[0], t[1], t[2]);
- else map_to_sphere(&fx, &fy, t[0], t[1], t[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;
@@ -981,9 +989,9 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
}
else {
- if (texco==TEXCO_OBJECT) proj = cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy);
- else if (texco==TEXCO_GLOB) proj = cubemap_glob(n, t[0], t[1], t[2], &fx, &fy);
- else proj = cubemap(mtex, vlr, n, t[0], t[1], t[2], &fx, &fy);
+ if (texco==TEXCO_OBJECT) proj = cubemap_ob(ob, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
+ else if (texco==TEXCO_GLOB) proj = cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
+ else proj = cubemap(mtex, vlr, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
if (proj==1) {
SWAP(float, dxt[1], dxt[2]);
@@ -1083,117 +1091,117 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
dyt[1]*= fac1;
}
- t[0]= fx;
- t[1]= fy;
+ texvec[0]= fx;
+ texvec[1]= fy;
}
}
/* ************************************** */
-static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres, short thread, short which_output)
+static int multitex(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, short which_output)
{
float tmpvec[3];
- int retval=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int retval = 0; /* return value, int:0, col:1, nor:2, everything:3 */
- texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */
+ texres->talpha = FALSE; /* is set when image texture returns alpha (considered premul) */
if (tex->use_nodes && tex->nodetree) {
retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread,
- tex, which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, NULL, NULL);
+ tex, which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, NULL, NULL);
}
- else
- switch (tex->type) {
-
- case 0:
- texres->tin= 0.0f;
- return 0;
- case TEX_CLOUDS:
- retval= clouds(tex, texvec, texres);
- break;
- case TEX_WOOD:
- retval= wood(tex, texvec, texres);
- break;
- case TEX_MARBLE:
- retval= marble(tex, texvec, texres);
- break;
- case TEX_MAGIC:
- retval= magic(tex, texvec, texres);
- break;
- case TEX_BLEND:
- retval= blend(tex, texvec, texres);
- break;
- case TEX_STUCCI:
- retval= stucci(tex, texvec, texres);
- break;
- case TEX_NOISE:
- retval= texnoise(tex, texres);
- break;
- case TEX_IMAGE:
- if (osatex) retval= imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres);
- else retval= imagewrap(tex, tex->ima, NULL, texvec, texres);
- BKE_image_tag_time(tex->ima); /* tag image as having being used */
- break;
- case TEX_ENVMAP:
- retval= envmaptex(tex, texvec, dxt, dyt, osatex, texres);
- break;
- case TEX_MUSGRAVE:
- /* newnoise: musgrave types */
-
- /* ton: added this, for Blender convention reason.
- * artificer: added the use of tmpvec to avoid scaling texvec
- */
- copy_v3_v3(tmpvec, texvec);
- mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
-
- switch (tex->stype) {
- case TEX_MFRACTAL:
- case TEX_FBM:
- retval= mg_mFractalOrfBmTex(tex, tmpvec, texres);
- break;
- case TEX_RIDGEDMF:
- case TEX_HYBRIDMF:
- retval= mg_ridgedOrHybridMFTex(tex, tmpvec, texres);
- break;
- case TEX_HTERRAIN:
- retval= mg_HTerrainTex(tex, tmpvec, texres);
- break;
+ else {
+ switch (tex->type) {
+ case 0:
+ texres->tin= 0.0f;
+ return 0;
+ case TEX_CLOUDS:
+ retval = clouds(tex, texvec, texres);
+ break;
+ case TEX_WOOD:
+ retval = wood(tex, texvec, texres);
+ break;
+ case TEX_MARBLE:
+ retval = marble(tex, texvec, texres);
+ break;
+ case TEX_MAGIC:
+ retval = magic(tex, texvec, texres);
+ break;
+ case TEX_BLEND:
+ retval = blend(tex, texvec, texres);
+ break;
+ case TEX_STUCCI:
+ retval = stucci(tex, texvec, texres);
+ break;
+ case TEX_NOISE:
+ retval = texnoise(tex, texres);
+ break;
+ case TEX_IMAGE:
+ if (osatex) retval = imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres);
+ else retval = imagewrap(tex, tex->ima, NULL, texvec, texres);
+ BKE_image_tag_time(tex->ima); /* tag image as having being used */
+ break;
+ case TEX_ENVMAP:
+ retval = envmaptex(tex, texvec, dxt, dyt, osatex, texres);
+ break;
+ case TEX_MUSGRAVE:
+ /* newnoise: musgrave types */
+
+ /* ton: added this, for Blender convention reason.
+ * artificer: added the use of tmpvec to avoid scaling texvec
+ */
+ copy_v3_v3(tmpvec, texvec);
+ mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
+
+ switch (tex->stype) {
+ case TEX_MFRACTAL:
+ case TEX_FBM:
+ retval = mg_mFractalOrfBmTex(tex, tmpvec, texres);
+ break;
+ case TEX_RIDGEDMF:
+ case TEX_HYBRIDMF:
+ retval = mg_ridgedOrHybridMFTex(tex, tmpvec, texres);
+ break;
+ case TEX_HTERRAIN:
+ retval = mg_HTerrainTex(tex, tmpvec, texres);
+ break;
+ }
+ break;
+ /* newnoise: voronoi type */
+ case TEX_VORONOI:
+ /* ton: added this, for Blender convention reason.
+ * artificer: added the use of tmpvec to avoid scaling texvec
+ */
+ copy_v3_v3(tmpvec, texvec);
+ mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
+
+ retval = voronoiTex(tex, tmpvec, texres);
+ break;
+ case TEX_DISTNOISE:
+ /* ton: added this, for Blender convention reason.
+ * artificer: added the use of tmpvec to avoid scaling texvec
+ */
+ copy_v3_v3(tmpvec, texvec);
+ mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
+
+ retval = mg_distNoiseTex(tex, tmpvec, texres);
+ break;
+ case TEX_POINTDENSITY:
+ retval = pointdensitytex(tex, texvec, texres);
+ break;
+ case TEX_VOXELDATA:
+ retval = voxeldatatex(tex, texvec, texres);
+ break;
+ case TEX_OCEAN:
+ retval = ocean_texture(tex, texvec, texres);
+ break;
}
- break;
- /* newnoise: voronoi type */
- case TEX_VORONOI:
- /* ton: added this, for Blender convention reason.
- * artificer: added the use of tmpvec to avoid scaling texvec
- */
- copy_v3_v3(tmpvec, texvec);
- mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
-
- retval= voronoiTex(tex, tmpvec, texres);
- break;
- case TEX_DISTNOISE:
- /* ton: added this, for Blender convention reason.
- * artificer: added the use of tmpvec to avoid scaling texvec
- */
- copy_v3_v3(tmpvec, texvec);
- mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
-
- retval= mg_distNoiseTex(tex, tmpvec, texres);
- break;
- case TEX_POINTDENSITY:
- retval= pointdensitytex(tex, texvec, texres);
- break;
- case TEX_VOXELDATA:
- retval= voxeldatatex(tex, texvec, texres);
- break;
- case TEX_OCEAN:
- retval= ocean_texture(tex, texvec, texres);
- break;
}
if (tex->flag & TEX_COLORBAND) {
float col[4];
if (do_colorband(tex->coba, texres->tin, col)) {
- texres->talpha= 1;
+ texres->talpha = TRUE;
texres->tr= col[0];
texres->tg= col[1];
texres->tb= col[2];
@@ -1205,7 +1213,8 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
}
/* this is called from the shader and texture nodes */
-int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres, short thread, short which_output, ShadeInput *shi, MTex *mtex)
+int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres,
+ const short thread, short which_output, ShadeInput *shi, MTex *mtex)
{
if (tex==NULL) {
memset(texres, 0, sizeof(TexResult));
@@ -1221,13 +1230,13 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
if (mtex) {
/* we have mtex, use it for 2d mapping images only */
do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt);
- rgbnor= multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output);
+ rgbnor = multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output);
if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) {
ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
/* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float))
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace);
}
}
@@ -1253,16 +1262,25 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
do_2d_mapping(&localmtex, texvec_l, NULL, NULL, dxt_l, dyt_l);
rgbnor= multitex(tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output);
+
+ {
+ ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
+
+ /* don't linearize float buffers, assumed to be linear */
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
+ IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace);
+ }
}
return rgbnor;
}
- else
+ else {
return multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output);
+ }
}
/* this is called for surface shading */
-static int multitex_mtex(ShadeInput *shi, MTex *mtex, float *texvec, float *dxt, float *dyt, TexResult *texres)
+static int multitex_mtex(ShadeInput *shi, MTex *mtex, float texvec[3], float dxt[3], float dyt[3], TexResult *texres)
{
Tex *tex = mtex->tex;
@@ -1279,13 +1297,13 @@ static int multitex_mtex(ShadeInput *shi, MTex *mtex, float *texvec, float *dxt,
/* Warning, if the texres's values are not declared zero, check the return value to be sure
* the color values are set before using the r/g/b values, otherwise you may use uninitialized values - Campbell */
-int multitex_ext(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
+int multitex_ext(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres)
{
return multitex_nodes(tex, texvec, dxt, dyt, osatex, texres, 0, 0, NULL, NULL);
}
/* extern-tex doesn't support nodes (ntreeBeginExec() can't be called when rendering is going on) */
-int multitex_ext_safe(Tex *tex, float *texvec, TexResult *texres)
+int multitex_ext_safe(Tex *tex, float texvec[3], TexResult *texres)
{
int use_nodes= tex->use_nodes, retval;
@@ -1510,7 +1528,8 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
return in;
}
-static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, float* dx, float* dy, float* texvec, float* dxt, float* dyt)
+static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex,
+ const float co[3], const float dx[3], const float dy[3], float texvec[3], float dxt[3], float dyt[3])
{
/* new: first swap coords, then map, then trans/scale */
if (tex->type == TEX_IMAGE) {
@@ -1542,10 +1561,10 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa
texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f;
texvec[1] = mtex->size[1]*(texvec[1] - 0.5f) + mtex->ofs[1] + 0.5f;
if (shi->osatex) {
- dxt[0] = mtex->size[0]*dxt[0];
- dxt[1] = mtex->size[1]*dxt[1];
- dyt[0] = mtex->size[0]*dyt[0];
- dyt[1] = mtex->size[1]*dyt[1];
+ dxt[0] = mtex->size[0] * dxt[0];
+ dxt[1] = mtex->size[1] * dxt[1];
+ dyt[0] = mtex->size[0] * dyt[0];
+ dyt[1] = mtex->size[1] * dyt[1];
}
/* problem: repeat-mirror is not a 'repeat' but 'extend' in imagetexture.c */
@@ -1675,7 +1694,8 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s
}
}
-static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt)
+static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres,
+ float Tnor, const float co[3], const float dx[3], const float dy[3], float texvec[3], float dxt[3], float dyt[3])
{
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv;
@@ -1733,7 +1753,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
if (mtex->texco == TEXCO_UV) {
/* for the uv case, use the same value for both du/dv,
* since individually scaling the normal derivatives makes them useless... */
- du = minf(du, dv);
+ du = min_ff(du, dv);
idu = (du < 1e-5f) ? bf : (bf/du);
/* +u val */
@@ -1831,7 +1851,9 @@ static void ntap_bump_init(NTapBump *ntap_bump)
memset(ntap_bump, 0, sizeof(*ntap_bump));
}
-static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt)
+static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres,
+ float Tnor, const float co[3], const float dx[3], const float dy[3],
+ float texvec[3], float dxt[3], float dyt[3])
{
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
@@ -2257,11 +2279,11 @@ void do_material_tex(ShadeInput *shi, Render *re)
if (texres.nor && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) {
if (use_compat_bump) {
rgbnor = compatible_bump_compute(&compat_bump, shi, mtex, tex,
- &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
+ &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
}
else if (use_ntap_bump) {
rgbnor = ntap_bump_compute(&ntap_bump, shi, mtex, tex,
- &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
+ &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
}
else {
texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
@@ -2377,7 +2399,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
/* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float))
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
}
@@ -2445,7 +2467,9 @@ void do_material_tex(ShadeInput *shi, Render *re)
copy_v3_v3(nor, texres.nor);
- if (mtex->normapspace == MTEX_NSPACE_CAMERA);
+ if (mtex->normapspace == MTEX_NSPACE_CAMERA) {
+ /* pass */
+ }
else if (mtex->normapspace == MTEX_NSPACE_WORLD) {
mul_mat3_m4_v3(re->viewmat, nor);
}
@@ -2648,9 +2672,16 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_
copy_v3_v3(co, xyz);
if (mtex->texflag & MTEX_OB_DUPLI_ORIG) {
if (shi->obi && shi->obi->duplitexmat)
- mul_m4_v3(shi->obi->duplitexmat, co);
- }
+ mul_m4_v3(shi->obi->duplitexmat, co);
+ }
mul_m4_v3(ob->imat_ren, co);
+
+ if (mtex->texflag & MTEX_MAPTO_BOUNDS && ob->bb) {
+ /* use bb vec[0] as min and bb vec[6] as max */
+ co[0] = (co[0] - ob->bb->vec[0][0]) / (ob->bb->vec[6][0]-ob->bb->vec[0][0]) * 2.0f - 1.0f;
+ co[1] = (co[1] - ob->bb->vec[0][1]) / (ob->bb->vec[6][1]-ob->bb->vec[0][1]) * 2.0f - 1.0f;
+ co[2] = (co[2] - ob->bb->vec[0][2]) / (ob->bb->vec[6][2]-ob->bb->vec[0][2]) * 2.0f - 1.0f;
+ }
}
}
/* not really orco, but 'local' */
@@ -2663,6 +2694,13 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_
Object *ob= shi->obi->ob;
copy_v3_v3(co, xyz);
mul_m4_v3(ob->imat_ren, co);
+
+ if (mtex->texflag & MTEX_MAPTO_BOUNDS && ob->bb) {
+ /* use bb vec[0] as min and bb vec[6] as max */
+ co[0] = (co[0] - ob->bb->vec[0][0]) / (ob->bb->vec[6][0]-ob->bb->vec[0][0]) * 2.0f - 1.0f;
+ co[1] = (co[1] - ob->bb->vec[0][1]) / (ob->bb->vec[6][1]-ob->bb->vec[0][1]) * 2.0f - 1.0f;
+ co[2] = (co[2] - ob->bb->vec[0][2]) / (ob->bb->vec[6][2]-ob->bb->vec[0][2]) * 2.0f - 1.0f;
+ }
}
}
else if (mtex->texco==TEXCO_GLOB) {
@@ -2729,6 +2767,12 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_
if ((rgbnor & TEX_RGB) == 0) {
copy_v3_v3(tcol, &mtex->r);
}
+ else if (mtex->mapto & MAP_DENSITY) {
+ copy_v3_v3(tcol, &texres.tr);
+ if (texres.talpha) {
+ texres.tin = stencilTin;
+ }
+ }
else {
copy_v3_v3(tcol, &texres.tr);
if (texres.talpha) {
@@ -2887,7 +2931,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
ImBuf *ibuf = BKE_image_get_ibuf(ima, &mtex->tex->iuser);
/* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float))
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
}
@@ -2922,10 +2966,14 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
}
if (mtex->mapto & MAP_ALPHA) {
if (rgb) {
- if (texres.talpha) texres.tin= texres.ta;
- else texres.tin = rgb_to_bw(&texres.tr);
+ if (texres.talpha) {
+ texres.tin = texres.ta;
+ }
+ else {
+ texres.tin = rgb_to_bw(&texres.tr);
+ }
}
-
+
col_r[3]*= texres.tin;
}
}
@@ -3038,7 +3086,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
break;
}
- /* placement */
+ /* placement */
if (mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
@@ -3102,7 +3150,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
/* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float))
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
}
@@ -3201,7 +3249,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r
}
co= tempvec;
- dx= dxt; dy= dyt;
+ dx= dxt; dy= dyt;
if (shi->osatex) {
copy_v3_v3(dxt, shi->dxlv);
copy_v3_v3(dyt, shi->dylv);
@@ -3316,7 +3364,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r
ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
/* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float))
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
}
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 0d894073cee..9fe2620747c 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -59,6 +59,7 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_texture.h"
+#include "BKE_scene.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -93,7 +94,7 @@ extern struct Render R;
/* x and y are current pixels in rect to be rendered */
/* do not normalize! */
-void calc_view_vector(float *view, float x, float y)
+void calc_view_vector(float view[3], float x, float y)
{
view[2]= -ABS(R.clipsta);
@@ -184,7 +185,8 @@ static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, in
fullsample= (totsample > 1);
amount= 0;
- accol[0]=accol[1]=accol[2]=accol[3]= 0.0f;
+ accol[0] = accol[1] = accol[2] = accol[3]= 0.0f;
+ col[0] = col[1] = col[2] = col[3]= 0.0f;
flarec= har->flarec;
while (ps) {
@@ -271,23 +273,33 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl)
har= R.sortedhalos[a];
/* layer test, clip halo with y */
- if ((har->lay & lay)==0);
- else if (testrect.ymin > har->maxy);
- else if (testrect.ymax < har->miny);
+ if ((har->lay & lay) == 0) {
+ /* pass */
+ }
+ else if (testrect.ymin > har->maxy) {
+ /* pass */
+ }
+ else if (testrect.ymax < har->miny) {
+ /* pass */
+ }
else {
minx= floor(har->xs-har->rad);
maxx= ceil(har->xs+har->rad);
- if (testrect.xmin > maxx);
- else if (testrect.xmax < minx);
+ if (testrect.xmin > maxx) {
+ /* pass */
+ }
+ else if (testrect.xmax < minx) {
+ /* pass */
+ }
else {
- minx= MAX2(minx, testrect.xmin);
- maxx= MIN2(maxx, testrect.xmax);
+ minx = max_ii(minx, testrect.xmin);
+ maxx = min_ii(maxx, testrect.xmax);
- miny= MAX2(har->miny, testrect.ymin);
- maxy= MIN2(har->maxy, testrect.ymax);
+ miny = max_ii(har->miny, testrect.ymin);
+ maxy = min_ii(har->maxy, testrect.ymax);
for (y=miny; y<maxy; y++) {
int rectofs= (y-disprect.ymin)*pa->rectx + (minx - disprect.xmin);
@@ -660,7 +672,7 @@ int get_sample_layers(RenderPart *pa, RenderLayer *rl, RenderLayer **rlpp)
RenderResult *rr= BLI_findlink(&pa->fullresult, sample);
rlpp[sample]= BLI_findlink(&rr->layers, nr);
- }
+ }
return R.osa;
}
else {
@@ -703,7 +715,7 @@ static void sky_tile(RenderPart *pa, RenderLayer *rl)
addAlphaUnderFloat(pass, col);
}
}
- }
+ }
}
if (y&1)
@@ -761,8 +773,8 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl)
if (*zrect >= 9.9e10f || rgbrect[3]==0.0f) {
continue;
}
-
- if ((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) {
+
+ if ((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) {
float tmp_rgb[3];
/* skip if worldspace lamp vector is below horizon */
@@ -917,7 +929,7 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma
PixStrMain *psm;
PixStr *ps, *last= NULL;
- if (*rd) {
+ if (*rd) {
ps= (PixStr *)(*rd);
while (ps) {
@@ -980,7 +992,9 @@ static void convert_to_key_alpha(RenderPart *pa, RenderLayer *rl)
float *rectf= rlpp[sample]->rectf;
for (y= pa->rectx*pa->recty; y>0; y--, rectf+=4) {
- if (rectf[3] >= 1.0f);
+ if (rectf[3] >= 1.0f) {
+ /* pass */
+ }
else if (rectf[3] > 0.0f) {
rectf[0] /= rectf[3];
rectf[1] /= rectf[3];
@@ -1569,7 +1583,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe
copy_v3_v3(shi->facenor, nor);
shade_input_set_viewco(shi, x, y, sx, sy, z);
- *area = minf(len_v3(shi->dxco) * len_v3(shi->dyco), 2.0f * orthoarea);
+ *area = min_ff(len_v3(shi->dxco) * len_v3(shi->dyco), 2.0f * orthoarea);
shade_input_set_uv(shi);
shade_input_set_normals(shi);
@@ -1833,16 +1847,23 @@ static void renderhalo_post(RenderResult *rr, float *rectf, HaloRen *har) /* pos
har->miny= miny= haloys - har->rad/R.ycor;
har->maxy= maxy= haloys + har->rad/R.ycor;
- if (maxy<0);
- else if (rr->recty<miny);
+ if (maxy < 0) {
+ /* pass */
+ }
+ else if (rr->recty < miny) {
+ /* pass */
+ }
else {
- minx= floor(haloxs-har->rad);
- maxx= ceil(haloxs+har->rad);
+ minx = floor(haloxs - har->rad);
+ maxx = ceil(haloxs + har->rad);
- if (maxx<0);
- else if (rr->rectx<minx);
+ if (maxx < 0) {
+ /* pass */
+ }
+ else if (rr->rectx < minx) {
+ /* pass */
+ }
else {
-
if (minx<0) minx= 0;
if (maxx>=rr->rectx) maxx= rr->rectx-1;
if (miny<0) miny= 0;
@@ -1992,7 +2013,7 @@ void add_halo_flare(Render *re)
re->display_draw(re->ddh, rr, NULL);
}
- R.r.mode= mode;
+ R.r.mode= mode;
}
/* ************************* bake ************************ */
@@ -2099,7 +2120,9 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
copy_v3_v3(nor, shi->vn);
- if (R.r.bake_normal_space == R_BAKE_SPACE_CAMERA);
+ if (R.r.bake_normal_space == R_BAKE_SPACE_CAMERA) {
+ /* pass */
+ }
else if (R.r.bake_normal_space == R_BAKE_SPACE_TANGENT) {
float mat[3][3], imat[3][3];
@@ -2202,7 +2225,8 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
float rgb[3];
copy_v3_v3(rgb, shr.combined);
- IMB_colormanagement_scene_linear_to_colorspace_v3(rgb, bs->rect_colorspace);
+ if (R.scene_color_manage)
+ IMB_colormanagement_scene_linear_to_colorspace_v3(rgb, bs->rect_colorspace);
rgb_float_to_uchar(col, rgb);
}
else {
@@ -2352,10 +2376,28 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v)
v2= vlr->v2->co;
v3= vlr->v3->co;
}
-
- /* renderco */
+
l= 1.0f-u-v;
+
+ /* shrink barycentric coordinates inwards slightly to avoid some issues
+ * where baking selected to active might just miss the other face at the
+ * near the edge of a face */
+ if (bs->actob) {
+ const float eps = 1.0f - 1e-4f;
+ float invsum;
+
+ u = (u - 0.5f)*eps + 0.5f;
+ v = (v - 0.5f)*eps + 0.5f;
+ l = (l - 0.5f)*eps + 0.5f;
+
+ invsum = 1.0f/(u + v + l);
+
+ u *= invsum;
+ v *= invsum;
+ l *= invsum;
+ }
+ /* renderco */
shi->co[0]= l*v3[0]+u*v1[0]+v*v2[0];
shi->co[1]= l*v3[1]+u*v1[1]+v*v2[1];
shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2];
@@ -2451,7 +2493,7 @@ static int get_next_bake_face(BakeShade *bs)
return 0;
}
- BLI_lock_thread(LOCK_CUSTOM1);
+ BLI_lock_thread(LOCK_CUSTOM1);
for (; obi; obi=obi->next, v=0) {
obr= obi->obr;
@@ -2492,11 +2534,13 @@ static int get_next_bake_face(BakeShade *bs)
/* clear image */
if (R.r.bake_flag & R_BAKE_CLEAR)
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
-
+
/* might be read by UI to set active image for display */
R.bakebuf= ima;
- }
-
+ }
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+
bs->obi= obi;
bs->vlr= vlr;
@@ -2532,7 +2576,7 @@ static void shade_tface(BakeShade *bs)
/* note, these calls only free/fill contents of zspan struct, not zspan itself */
zbuf_free_span(bs->zspan);
zbuf_alloc_span(bs->zspan, bs->ibuf->x, bs->ibuf->y, R.clipcrop);
- }
+ }
bs->rectx= bs->ibuf->x;
bs->recty= bs->ibuf->y;
@@ -2630,6 +2674,8 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
Image *ima;
int a, vdone = FALSE, use_mask = FALSE, result = BAKE_RESULT_OK;
+ re->scene_color_manage = BKE_scene_check_color_management_enabled(re->scene);
+
/* initialize render global */
R= *re;
R.bakebuf= NULL;
@@ -2712,7 +2758,6 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, re->r.bake_filter);
ibuf->userflags |= IB_BITMAPDIRTY;
- if (ibuf->rect_float) IMB_rect_from_float(ibuf);
}
}
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index 6395a04b534..7a7602dcce2 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -244,7 +244,7 @@ VertRen *RE_findOrAddVert(ObjectRen *obr, int nr)
memset(obr->vertnodes+obr->vertnodeslen, 0, TABLEINITSIZE*sizeof(VertTableNode));
obr->vertnodeslen+=TABLEINITSIZE;
- if (temp) MEM_freeN(temp);
+ if (temp) MEM_freeN(temp);
}
v= obr->vertnodes[a].vert;
@@ -487,7 +487,7 @@ VlakRen *RE_findOrAddVlak(ObjectRen *obr, int nr)
memset(obr->vlaknodes+obr->vlaknodeslen, 0, TABLEINITSIZE*sizeof(VlakTableNode));
obr->vlaknodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
- if (temp) MEM_freeN(temp);
+ if (temp) MEM_freeN(temp);
}
v= obr->vlaknodes[a].vlak;
@@ -658,7 +658,7 @@ StrandRen *RE_findOrAddStrand(ObjectRen *obr, int nr)
memset(obr->strandnodes+obr->strandnodeslen, 0, TABLEINITSIZE*sizeof(StrandTableNode));
obr->strandnodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
- if (temp) MEM_freeN(temp);
+ if (temp) MEM_freeN(temp);
}
v= obr->strandnodes[a].strand;
@@ -892,7 +892,7 @@ HaloRen *RE_findOrAddHalo(ObjectRen *obr, int nr)
if (temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void*));
memset(&(obr->bloha[obr->blohalen]), 0, TABLEINITSIZE*sizeof(void*));
obr->blohalen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
- if (temp) MEM_freeN(temp);
+ if (temp) MEM_freeN(temp);
}
h= obr->bloha[a];
@@ -976,10 +976,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma,
if (ma->mtex[0]) {
- if ( (ma->mode & MA_HALOTEX) ) har->tex= 1;
- else if (har->mat->septex & (1<<0)); /* only 1 level textures */
+ if (ma->mode & MA_HALOTEX) {
+ har->tex = 1;
+ }
+ else if (har->mat->septex & (1 << 0)) {
+ /* only 1 level textures */
+ }
else {
-
mtex= ma->mtex[0];
copy_v3_v3(texvec, vec);
@@ -1181,6 +1184,7 @@ static int panotestclip(Render *re, int do_pano, float *v)
/* to be used for halos en infos */
float abs4;
short c=0;
+ int xparts = (re->rectx + re->partx - 1) / re->partx;
if (do_pano == FALSE) {
return testclip(v);
@@ -1194,7 +1198,7 @@ static int panotestclip(Render *re, int do_pano, float *v)
if ( v[1]>abs4) c+=4;
else if ( v[1]< -abs4) c+=8;
- abs4*= re->xparts;
+ abs4*= xparts;
if ( v[0]>abs4) c+=2;
else if ( v[0]< -abs4) c+=1;
@@ -1353,40 +1357,42 @@ void RE_makeRenderInstances(Render *re)
re->instancetable= newlist;
}
-int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4])
+int clip_render_object(float boundbox[][3], float bounds[4], float winmat[][4])
{
float mat[4][4], vec[4];
- int a, fl, flag= -1;
+ int a, fl, flag = -1;
copy_m4_m4(mat, winmat);
- for (a=0; a<8; a++) {
+ for (a=0; a < 8; a++) {
vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0];
vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1];
vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2];
vec[3]= 1.0;
mul_m4_v4(mat, vec);
- fl= 0;
+ fl = 0;
if (bounds) {
- if (vec[0] < bounds[0]*vec[3]) fl |= 1;
- else if (vec[0] > bounds[1]*vec[3]) fl |= 2;
+ if (vec[0] < bounds[0] * vec[3]) fl |= 1;
+ else if (vec[0] > bounds[1] * vec[3]) fl |= 2;
- if (vec[1] > bounds[3]*vec[3]) fl |= 4;
- else if (vec[1]< bounds[2]*vec[3]) fl |= 8;
+ if (vec[1] > bounds[3] * vec[3]) fl |= 4;
+ else if (vec[1] < bounds[2] * vec[3]) fl |= 8;
}
else {
- if (vec[0] < -vec[3]) fl |= 1;
- else if (vec[0] > vec[3]) fl |= 2;
+ if (vec[0] < -vec[3]) fl |= 1;
+ else if (vec[0] > vec[3]) fl |= 2;
- if (vec[1] > vec[3]) fl |= 4;
+ if (vec[1] > vec[3]) fl |= 4;
else if (vec[1] < -vec[3]) fl |= 8;
}
- if (vec[2] < -vec[3]) fl |= 16;
- else if (vec[2] > vec[3]) fl |= 32;
+ if (vec[2] < -vec[3]) fl |= 16;
+ else if (vec[2] > vec[3]) fl |= 32;
flag &= fl;
- if (flag==0) return 0;
+ if (flag == 0) {
+ return 0;
+ }
}
return flag;
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index bed3fb5f754..a7f6b40981d 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -89,7 +89,7 @@ extern struct Render R;
static void copy_to_ztile(int *rectz, int size, int x1, int y1, int tile, char *r1)
{
- int len4, *rz;
+ int len4, *rz;
int x2, y2;
x2= x1+tile;
@@ -159,9 +159,9 @@ static void make_jitter_weight_tab(Render *re, ShadBuf *shb, short filtertype)
for (jit= shb->jit, a=0; a<tot; a++, jit+=2) {
if (filtertype==LA_SHADBUF_TENT)
- shb->weight[a]= 0.71f - sqrt(jit[0]*jit[0] + jit[1]*jit[1]);
+ shb->weight[a] = 0.71f - sqrtf(jit[0] * jit[0] + jit[1] * jit[1]);
else if (filtertype==LA_SHADBUF_GAUSS)
- shb->weight[a]= RE_filter_value(R_FILTER_GAUSS, 1.8f*sqrt(jit[0]*jit[0] + jit[1]*jit[1]));
+ shb->weight[a] = RE_filter_value(R_FILTER_GAUSS, 1.8f * sqrtf(jit[0] * jit[0] + jit[1] * jit[1]));
else
shb->weight[a]= 1.0f;
@@ -217,15 +217,15 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon)
if (ds->z == newds->z) {
/* still in same z position, simply check
* visibility difference against epsilon */
- if (!(fabs(newds->v - ds->v) <= epsilon)) {
+ if (!(fabsf(newds->v - ds->v) <= epsilon)) {
break;
}
}
else {
/* compute slopes */
- div= (double)0x7FFFFFFF/((double)ds->z - (double)newds->z);
- min= ((ds->v - epsilon) - newds->v)*div;
- max= ((ds->v + epsilon) - newds->v)*div;
+ div= (double)0x7FFFFFFF / ((double)ds->z - (double)newds->z);
+ min= (double)((ds->v - epsilon) - newds->v) * div;
+ max= (double)((ds->v + epsilon) - newds->v) * div;
/* adapt existing slopes */
if (first) {
@@ -264,8 +264,8 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon)
}
else {
/* compute visibility at center between slopes at z */
- slope= (slopemin+slopemax)*0.5f;
- v= newds->v + slope*((z - newds->z)/(double)0x7FFFFFFF);
+ slope = (slopemin + slopemax) * 0.5;
+ v = (double)newds->v + slope * ((double)(z - newds->z) / (double)0x7FFFFFFF);
}
newds++;
@@ -528,21 +528,21 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square)
for (y=0; y<size; y+=16) {
if (y< size/2) miny= y+15-size/2;
- else miny= y-size/2;
+ else miny= y-size/2;
for (x=0; x<size; x+=16) {
/* is tile within spotbundle? */
a= size/2;
if (x< a) minx= x+15-a;
- else minx= x-a;
+ else minx= x-a;
dist= sqrt( (float)(minx*minx+miny*miny) );
if (square==0 && dist>(float)(a+12)) { /* 12, tested with a onlyshadow lamp */
a= 256; verg= 0; /* 0x80000000; */ /* 0x7FFFFFFF; */
rz1= (&verg)+1;
- }
+ }
else {
copy_to_ztile(rectz, size, x, y, 16, rcline);
rz1= (int *)rcline;
@@ -637,7 +637,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
maxtotvert= 0;
for (obr=re->objecttable.first; obr; obr=obr->next)
- maxtotvert= MAX2(obr->totvert, maxtotvert);
+ maxtotvert = max_ii(obr->totvert, maxtotvert);
clipflag= MEM_callocN(sizeof(char)*maxtotvert, "autoclipflag");
@@ -669,8 +669,8 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
clipflag[vlr->v2->index]= 1;
clipflag[vlr->v3->index]= 1;
if (vlr->v4) clipflag[vlr->v4->index]= 1;
- }
- }
+ }
+ }
/* calculate min and max */
for (a=0; a< obr->totvert;a++) {
@@ -778,7 +778,7 @@ void makeshadowbuf(Render *re, LampRen *lar)
* transforming from observer view to lamp view, including lamp window matrix */
angle= saacos(lar->spotsi);
- temp= 0.5f*shb->size*cos(angle)/sin(angle);
+ temp = 0.5f * shb->size * cosf(angle) / sinf(angle);
shb->pixsize= (shb->d)/temp;
wsize= shb->pixsize*(shb->size/2.0f);
@@ -856,10 +856,10 @@ void threaded_makeshadowbufs(Render *re)
if (lar->shb)
totthread++;
- totthread= MIN2(totthread, re->r.threads);
+ totthread = min_ii(totthread, re->r.threads);
}
else
- totthread= 1; /* preview render */
+ totthread = 1; /* preview render */
if (totthread <= 1) {
for (lar=re->lampren.first; lar; lar= lar->next) {
@@ -1394,7 +1394,7 @@ float shadow_halo(LampRen *lar, const float p1[3], const float p2[3])
}
}
- labda = minf(labdax, labday);
+ labda = min_ff(labdax, labday);
if (labda==labdao || labda>=1.0f) break;
zf= zf1 + labda*(zf2-zf1);
@@ -1663,9 +1663,9 @@ static void bspface_init_strand(BSPFace *face)
face->len= face->rc[0]*face->rc[0]+ face->rc[1]*face->rc[1];
- if (face->len!=0.0f) {
- face->radline_end= face->radline/sqrt(face->len);
- face->len= 1.0f/face->len;
+ if (face->len != 0.0f) {
+ face->radline_end = face->radline / sqrtf(face->len);
+ face->len = 1.0f / face->len;
}
}
@@ -1867,7 +1867,7 @@ static void isb_bsp_recalc_box(ISBBranch *root)
init_box(&root->box);
for (a=root->totsamp-1; a>=0; a--)
bound_boxf(&root->box, root->samples[a]->zco);
- }
+ }
}
/* callback function for zbuf clip */
@@ -2040,7 +2040,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
if (vlr->v4)
c4= testclip(hoco[3]);
- /* ***** NO WIRE YET */
+ /* ***** NO WIRE YET */
if (ma->material_type == MA_TYPE_WIRE) {
if (vlr->v4)
zbufclipwire(&zspan, i, a+1, vlr->ec, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
@@ -2187,7 +2187,7 @@ static int isb_add_samples(RenderPart *pa, ISBBranch *root, MemArena *memarena,
}
if (bsp_err) break;
}
- }
+ }
MEM_freeN(xcos);
MEM_freeN(ycos);
@@ -2394,7 +2394,7 @@ static int isb_add_samples_transp(RenderPart *pa, ISBBranch *root, MemArena *mem
}
if (bsp_err) break;
}
- }
+ }
MEM_freeN(xcos);
MEM_freeN(ycos);
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index ff543b8ce06..db93a21de2d 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -87,12 +87,6 @@ extern struct Render R;
*
*/
-#define VECADDISFAC(v1,v3,fac) { \
- *(v1 + 0) += *(v3 + 0) * (fac); \
- *(v1 + 1) += *(v3 + 1) * (fac); \
- *(v1 + 2) += *(v3 + 2) * (fac); \
-} (void)0
-
/* initialize material variables in shadeinput,
* doing inverse gamma correction where applicable */
void shade_input_init_material(ShadeInput *shi)
@@ -121,13 +115,13 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
shi->depth--;
/* a couple of passes */
- VECADDISFAC(shr->combined, shr_t.combined, fac);
+ madd_v3_v3fl(shr->combined, shr_t.combined, fac);
if (shi->passflag & SCE_PASS_SPEC)
- VECADDISFAC(shr->spec, shr_t.spec, fac);
+ madd_v3_v3fl(shr->spec, shr_t.spec, fac);
if (shi->passflag & SCE_PASS_DIFFUSE)
- VECADDISFAC(shr->diff, shr_t.diff, fac);
+ madd_v3_v3fl(shr->diff, shr_t.diff, fac);
if (shi->passflag & SCE_PASS_SHADOW)
- VECADDISFAC(shr->shad, shr_t.shad, fac);
+ madd_v3_v3fl(shr->shad, shr_t.shad, fac);
negate_v3(shi->vn);
negate_v3(shi->facenor);
@@ -242,7 +236,7 @@ void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3)
/* 1---2 1---2 0 = orig face, 1 = new face */
/* Update vert nums to point to correct verts of original face */
- if (vlr->flag & R_DIVIDE_24) {
+ if (vlr->flag & R_DIVIDE_24) {
if (vlr->flag & R_FACE_SPLIT) {
(*i1)++; (*i2)++; (*i3)++;
}
@@ -783,7 +777,7 @@ void shade_input_set_uv(ShadeInput *shi)
CLAMP(shi->u, -2.0f, 1.0f);
CLAMP(shi->v, -2.0f, 1.0f);
}
- }
+ }
}
void shade_input_set_normals(ShadeInput *shi)
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 6883710d1be..77602edf955 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -57,6 +57,9 @@
#include "shading.h" /* own include */
+/* could enable at some point but for now there are far too many conversions */
+#pragma GCC diagnostic ignored "-Wdouble-promotion"
+
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
/* only to be used here in this file, it's for speed */
@@ -114,7 +117,7 @@ static void fogcolor(const float colf[3], float *rco, float *view)
addAlphaOverFloat(colf, hor);
sub_v3_v3(vec, dview);
- }
+ }
}
#endif
@@ -123,37 +126,52 @@ float mistfactor(float zcor, float const co[3])
{
float fac, hi;
- fac= zcor - R.wrld.miststa; /* zcor is calculated per pixel */
+ fac = zcor - R.wrld.miststa; /* zcor is calculated per pixel */
/* fac= -co[2]-R.wrld.miststa; */
- if (fac>0.0f) {
- if (fac< R.wrld.mistdist) {
+ if (fac > 0.0f) {
+ if (fac < R.wrld.mistdist) {
- fac= (fac/(R.wrld.mistdist));
+ fac = (fac / R.wrld.mistdist);
- if (R.wrld.mistype==0) fac*= fac;
- else if (R.wrld.mistype==1);
- else fac= sqrt(fac);
+ if (R.wrld.mistype == 0) {
+ fac *= fac;
+ }
+ else if (R.wrld.mistype == 1) {
+ /* pass */
+ }
+ else {
+ fac = sqrt(fac);
+ }
}
- else fac= 1.0f;
+ else {
+ fac = 1.0f;
+ }
+ }
+ else {
+ fac = 0.0f;
}
- else fac= 0.0f;
/* height switched off mist */
if (R.wrld.misthi!=0.0f && fac!=0.0f) {
/* at height misthi the mist is completely gone */
- hi= R.viewinv[0][2]*co[0]+R.viewinv[1][2]*co[1]+R.viewinv[2][2]*co[2]+R.viewinv[3][2];
+ hi = R.viewinv[0][2] * co[0] +
+ R.viewinv[1][2] * co[1] +
+ R.viewinv[2][2] * co[2] +
+ R.viewinv[3][2];
- if (hi>R.wrld.misthi) fac= 0.0f;
+ if (hi > R.wrld.misthi) {
+ fac = 0.0f;
+ }
else if (hi>0.0f) {
hi= (R.wrld.misthi-hi)/R.wrld.misthi;
fac*= hi*hi;
}
}
- return (1.0f-fac)* (1.0f-R.wrld.misi);
+ return (1.0f-fac)* (1.0f-R.wrld.misi);
}
static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
@@ -213,7 +231,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
}
}
- /* scale z to make sure volume is normalized */
+ /* scale z to make sure volume is normalized */
nray[2] *= (double)lar->sh_zfac;
/* nray does not need normalization */
@@ -299,8 +317,8 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
/* calculate t0: is the maximum visible z (when halo is intersected by face) */
if (do_clip) {
- if (use_yco == FALSE) t0 = (maxz - npos[2]) / nray[2];
- else t0 = (maxy - npos[1]) / nray[1];
+ if (use_yco == FALSE) t0 = ((double)maxz - npos[2]) / nray[2];
+ else t0 = ((double)maxy - npos[1]) / nray[1];
if (t0 < t1) return;
if (t0 < t2) t2= t0;
@@ -453,9 +471,10 @@ static float area_lamp_energy(float (*area)[3], const float co[3], const float v
/* cross product */
#define CROSS(dest, a, b) \
- { dest[0]= a[1] * b[2] - a[2] * b[1]; \
- dest[1]= a[2] * b[0] - a[0] * b[2]; \
- dest[2]= a[0] * b[1] - a[1] * b[0]; \
+ { \
+ dest[0]= a[1] * b[2] - a[2] * b[1]; \
+ dest[1]= a[2] * b[0] - a[0] * b[2]; \
+ dest[2]= a[0] * b[1] - a[1] * b[0]; \
} (void)0
CROSS(cross[0], vec[0], vec[1]);
@@ -532,7 +551,7 @@ static float spec(float inp, int hard)
b1= inp*inp;
/* avoid FPE */
- if (b1<0.01f) b1= 0.01f;
+ if (b1<0.01f) b1= 0.01f;
if ((hard & 1)==0) inp= 1.0f;
if (hard & 2) inp*= b1;
@@ -545,7 +564,7 @@ static float spec(float inp, int hard)
b1*= b1;
/* avoid FPE */
- if (b1<0.001f) b1= 0.0f;
+ if (b1<0.001f) b1= 0.0f;
if (hard & 32) inp*= b1;
b1*= b1;
@@ -553,7 +572,7 @@ static float spec(float inp, int hard)
b1*= b1;
if (hard & 128) inp*=b1;
- if (b1<0.001f) b1= 0.0f;
+ if (b1<0.001f) b1= 0.0f;
if (hard & 256) {
b1*= b1;
@@ -811,7 +830,7 @@ static float Minnaert_Diff(float nl, const float n[3], const float v[3], float d
nv = 0.0f;
if (darkness <= 1.0f)
- i = nl * pow(maxf(nv * nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/
+ i = nl * pow(max_ff(nv * nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/
else
i = nl * pow( (1.001f - nv), (darkness - 1.0f) ); /*Nvidia model*/
@@ -1217,7 +1236,7 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d
copy_v3_v3(lvrot, lv);
mul_m3_v3(lar->imat, lvrot);
- x = maxf(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
+ x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
/* 1.0f/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
inpr= 1.0f/(sqrt(1.0f+x*x));
@@ -1301,7 +1320,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
if (lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE);
if (lar->mode & LA_SHAD_TEX) do_lamp_tex(lar, lv, shi, lashdw, LA_SHAD_TEX);
- /* tangent case; calculate fake face normal, aligned with lampvector */
+ /* tangent case; calculate fake face normal, aligned with lampvector */
/* note, vnor==vn is used as tangent trigger for buffer shadow */
if (vlr->flag & R_TANGENT) {
float cross[3], nstrand[3], blend;
@@ -1347,11 +1366,13 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
/* inp = dotproduct, is = shader result, i = lamp energy (with shadow), i_noshad = i without shadow */
inp= dot_v3v3(vn, lv);
- /* phong threshold to prevent backfacing faces having artefacts on ray shadow (terminator problem) */
+ /* phong threshold to prevent backfacing faces having artifacts on ray shadow (terminator problem) */
/* this complex construction screams for a nicer implementation! (ton) */
if (R.r.mode & R_SHADOW) {
if (ma->mode & MA_SHADOW) {
- if (lar->type==LA_HEMI || lar->type==LA_AREA);
+ if (lar->type == LA_HEMI || lar->type == LA_AREA) {
+ /* pass */
+ }
else if ((ma->mode & MA_RAYBIAS) && (lar->mode & LA_SHAD_RAY) && (vlr->flag & R_SMOOTH)) {
float thresh= shi->obr->ob->smoothresh;
if (inp>thresh)
@@ -1466,8 +1487,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
if (shadfac[3]>0.0f && shi->spec!=0.0f && !(lar->mode & LA_NO_SPEC) && !(lar->mode & LA_ONLYSHADOW)) {
- if (!(passflag & (SCE_PASS_COMBINED|SCE_PASS_SPEC)));
- else if (lar->type==LA_HEMI) {
+ if (!(passflag & (SCE_PASS_COMBINED | SCE_PASS_SPEC))) {
+ /* pass */
+ }
+ else if (lar->type == LA_HEMI) {
float t;
/* hemi uses no spec shaders (yet) */
@@ -1617,7 +1640,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr)
}
}
- /* quite disputable this... also note it doesn't mirror-raytrace */
+ /* quite disputable this... also note it doesn't mirror-raytrace */
if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT)) && shi->amb!=0.0f) {
float f;
@@ -1825,7 +1848,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
}
}
- if (shi->combinedflag & SCE_PASS_SHADOW)
+ if (shi->combinedflag & SCE_PASS_SHADOW)
copy_v3_v3(shr->combined, shr->shad); /* note, no ';' ! */
else
copy_v3_v3(shr->combined, shr->diff);
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c
index 69e738e840d..6d0e15ea46e 100644
--- a/source/blender/render/intern/source/sss.c
+++ b/source/blender/render/intern/source/sss.c
@@ -238,7 +238,9 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd)
float indexf, t, idxf;
int index;
- if (rr > (RD_TABLE_RANGE_2*RD_TABLE_RANGE_2));
+ if (rr > (RD_TABLE_RANGE_2 * RD_TABLE_RANGE_2)) {
+ /* pass */
+ }
else if (rr > RD_TABLE_RANGE) {
rr= sqrt(rr);
indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE_2);
@@ -305,7 +307,7 @@ ScatterSettings *scatter_settings_new(float refl, float radius, float ior, float
ss->Fdr= -1.440f/ior*ior + 0.710f/ior + 0.668f + 0.0636f*ior;
ss->A= (1.0f + ss->Fdr)/(1.0f - ss->Fdr);
ss->ld= radius;
- ss->ro= minf(refl, 0.999f);
+ ss->ro= min_ff(refl, 0.999f);
ss->color= ss->ro*reflfac + (1.0f-reflfac);
ss->alpha_= compute_reduced_albedo(ss);
@@ -379,7 +381,7 @@ static void add_radiance(ScatterTree *tree, float *frontrad, float *backrad, flo
}
}
-static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int self, ScatterResult *result)
+static void traverse_octree(ScatterTree *tree, ScatterNode *node, const float co[3], int self, ScatterResult *result)
{
float sub[3], dist;
int i, index = 0;
@@ -430,7 +432,7 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int
}
}
-static void compute_radiance(ScatterTree *tree, float *co, float *rad)
+static void compute_radiance(ScatterTree *tree, const float co[3], float *rad)
{
ScatterResult result;
float rdsum[3], backrad[3], backrdsum[3];
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index dc3225b7f09..2fe8adaa1ee 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -449,6 +449,7 @@ typedef struct StrandPart {
int sample;
int shadow;
float (*jit)[2];
+ int samples;
StrandSegment *segment;
float t[3], s[3];
@@ -545,7 +546,7 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float
bufferz= 0x7FFFFFFF;
if (spart->rectmask) maskz= 0x7FFFFFFF;
- if (*rd) {
+ if (*rd) {
for (ps= (PixStr *)(*rd); ps; ps= ps->next) {
if (mask & ps->mask) {
bufferz= ps->z;
@@ -669,12 +670,8 @@ static void strand_render(Render *re, StrandSegment *sseg, float winmat[][4], St
float dt= p2->t - p1->t;
int a;
- if (re->osa) {
- for (a=0; a<re->osa; a++)
- do_scanconvert_strand(re, spart, zspan, t, dt, p1->zco2, p1->zco1, p2->zco1, p2->zco2, a);
- }
- else
- do_scanconvert_strand(re, spart, zspan, t, dt, p1->zco2, p1->zco1, p2->zco1, p2->zco2, 0);
+ for (a=0; a<spart->samples; a++)
+ do_scanconvert_strand(re, spart, zspan, t, dt, p1->zco2, p1->zco1, p2->zco1, p2->zco2, a);
}
else {
float hoco1[4], hoco2[4];
@@ -786,7 +783,7 @@ void render_strand_segment(Render *re, float winmat[][4], StrandPart *spart, ZSp
}
/* render call to fill in strands */
-int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBase *apsmbase, unsigned int lay, int UNUSED(negzmask), float winmat[][4], int winx, int winy, int UNUSED(sample), float (*jit)[2], float clipcrop, int shadow, StrandShadeCache *cache)
+int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBase *apsmbase, unsigned int lay, int UNUSED(negzmask), float winmat[][4], int winx, int winy, int samples, float (*jit)[2], float clipcrop, int shadow, StrandShadeCache *cache)
{
ObjectRen *obr;
ObjectInstanceRen *obi;
@@ -820,6 +817,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
spart.cache= cache;
spart.shadow= shadow;
spart.jit= jit;
+ spart.samples= samples;
zbuf_alloc_span(&zspan, pa->rectx, pa->recty, clipcrop);
diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c
index 94e94b98d26..e4a42fcd675 100644
--- a/source/blender/render/intern/source/sunsky.c
+++ b/source/blender/render/intern/source/sunsky.c
@@ -146,7 +146,7 @@ static float PerezFunction(struct SunSky *sunsky, const float *lam, float theta,
* sun_size, controls sun's size
* back_scatter, controls back scatter light
* */
-void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness,
+void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float horizon_brightness,
float spread, float sun_brightness, float sun_size, float back_scatter,
float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace)
{
@@ -217,8 +217,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b
sunsky->perez_y[3] = -0.04405f * T - 1.65369f;
sunsky->perez_y[4] = -0.01092f * T + 0.05291f;
- /* suggested by glome in
- * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/
+ /* suggested by glome in patch [#8063] */
sunsky->perez_Y[0] *= sunsky->horizon_brightness;
sunsky->perez_x[0] *= sunsky->horizon_brightness;
sunsky->perez_y[0] *= sunsky->horizon_brightness;
@@ -330,8 +329,8 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3])
int i;
float fLambda[3];
- fLambda[0] = 0.65f;
- fLambda[1] = 0.57f;
+ fLambda[0] = 0.65f;
+ fLambda[1] = 0.57f;
fLambda[2] = 0.475f;
fAlpha = 1.3f;
diff --git a/source/blender/render/intern/source/texture_ocean.c b/source/blender/render/intern/source/texture_ocean.c
index b2bc635cba7..a7547479093 100644
--- a/source/blender/render/intern/source/texture_ocean.c
+++ b/source/blender/render/intern/source/texture_ocean.c
@@ -55,7 +55,7 @@ extern struct Render R;
/* ***** actual texture sampling ***** */
-int ocean_texture(Tex *tex, float *texvec, TexResult *texres)
+int ocean_texture(Tex *tex, const float texvec[2], TexResult *texres)
{
OceanTex *ot = tex->ot;
ModifierData *md;
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
index 8a92695a15e..8757be740f3 100644
--- a/source/blender/render/intern/source/volume_precache.c
+++ b/source/blender/render/intern/source/volume_precache.c
@@ -92,7 +92,7 @@ static int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset
}
/* Uses ray tracing to check if a point is inside or outside an ObjectInstanceRen */
-static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), float *co)
+static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), const float co[3])
{
Isect isect= {{0}};
float dir[3] = {0.0f, 0.0f, 1.0f};
@@ -118,7 +118,7 @@ static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), flo
}
/* find the bounding box of an objectinstance in global space */
-void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float *bbmin, float *bbmax)
+void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float bbmin[3], float bbmax[3])
{
ObjectRen *obr = obi->obr;
VolumePrecache *vp = obi->volume_precache;
@@ -270,7 +270,7 @@ BLI_INLINE int ms_I(int x, int y, int z, int *n) /* has a pad of 1 voxel surroun
BLI_INLINE int v_I_pad(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */
{
/* same ordering to light cache, with padding */
- return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x;
+ return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x;
}
BLI_INLINE int lc_to_ms_I(int x, int y, int z, int *n)
@@ -389,7 +389,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi
const int j = ms_I(x, y, z, n); //ms index
time= PIL_check_seconds_timer();
- c++;
+ c++;
if (vp->data_r[i] > 0.0f)
sr[j] += vp->data_r[i];
if (vp->data_g[i] > 0.0f)
@@ -826,7 +826,7 @@ void free_volume_precache(Render *re)
BLI_freelistN(&re->volumes);
}
-int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, float *co)
+int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, const float co[3])
{
RayObject *tree;
int inside=0;
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 220fcd3e986..fe4cff76093 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -76,7 +76,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
if (lar->shb) {
float dxco[3] = {0.f, 0.f, 0.f}, dyco[3] = {0.f, 0.f, 0.f};
- visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0);
+ visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0);
}
else if (lar->mode & LA_SHAD_RAY) {
/* trace shadow manually, no good lamp api atm */
@@ -205,7 +205,7 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], f
else {
shadeSkyView(col_r, co, shi->view, NULL, shi->thread);
shadeSunView(col_r, shi->view);
- }
+ }
}
@@ -221,7 +221,7 @@ static void vol_get_precached_scattering(Render *re, ShadeInput *shi, float scat
/* find sample point in global space bounding box 0.0-1.0 */
global_bounds_obi(re, shi->obi, bbmin, bbmax);
sub_v3_v3v3(dim, bbmax, bbmin);
- mul_v3_m4v3(world_co, re->viewinv, co);
+ mul_v3_m4v3(world_co, re->viewinv, co);
/* sample_co in 0.0-1.0 */
sample_co[0] = (world_co[0] - bbmin[0]) / dim[0];
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index d73171648fb..42849a01971 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -227,69 +227,102 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
/* draw code for smoke */
if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke))) {
SmokeModifierData *smd = (SmokeModifierData *)md;
-
+ SmokeDomainSettings *sds = smd->domain;
- if (smd->domain && smd->domain->fluid) {
- if (cfra < smd->domain->point_cache[0]->startframe)
+ if (sds && sds->fluid) {
+ if (cfra < sds->point_cache[0]->startframe)
; /* don't show smoke before simulation starts, this could be made an option in the future */
else if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
size_t totRes;
size_t i;
float *heat;
- copy_v3_v3_int(vd->resol, smd->domain->res);
- totRes = vd_resol_size(vd);
+ if (!smoke_has_heat(sds->fluid)) return;
- /* scaling heat values from -2.0-2.0 to 0.0-1.0 */
+ copy_v3_v3_int(vd->resol, sds->res);
+ totRes = vd_resol_size(vd);
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
+ /* get heat data */
+ heat = smoke_get_heat(sds->fluid);
-
- heat = smoke_get_heat(smd->domain->fluid);
-
+ /* scale heat values from -2.0-2.0 to 0.0-1.0 */
for (i = 0; i < totRes; i++) {
vd->dataset[i] = (heat[i] + 2.0f) / 4.0f;
}
-
- /* vd->dataset = smoke_get_heat(smd->domain->fluid); */
}
else if (vd->smoked_type == TEX_VD_SMOKEVEL) {
size_t totRes;
size_t i;
float *xvel, *yvel, *zvel;
- copy_v3_v3_int(vd->resol, smd->domain->res);
+ copy_v3_v3_int(vd->resol, sds->res);
totRes = vd_resol_size(vd);
-
- /* scaling heat values from -2.0-2.0 to 0.0-1.0 */
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
+ /* get velocity data */
+ xvel = smoke_get_velocity_x(sds->fluid);
+ yvel = smoke_get_velocity_y(sds->fluid);
+ zvel = smoke_get_velocity_z(sds->fluid);
- xvel = smoke_get_velocity_x(smd->domain->fluid);
- yvel = smoke_get_velocity_y(smd->domain->fluid);
- zvel = smoke_get_velocity_z(smd->domain->fluid);
-
+ /* map velocities between 0 and 0.3f */
for (i = 0; i < totRes; i++) {
- vd->dataset[i] = sqrt(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f;
+ vd->dataset[i] = sqrtf(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f;
}
}
- else {
+ else if (vd->smoked_type == TEX_VD_SMOKEFLAME) {
size_t totRes;
- float *density;
+ float *flame;
- if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
- smoke_turbulence_get_res(smd->domain->wt, vd->resol);
- density = smoke_turbulence_get_density(smd->domain->wt);
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ if (!smoke_turbulence_has_fuel(sds->wt)) return;
+ smoke_turbulence_get_res(sds->wt, vd->resol);
+ flame = smoke_turbulence_get_flame(sds->wt);
}
else {
- copy_v3_v3_int(vd->resol, smd->domain->res);
- density = smoke_get_density(smd->domain->fluid);
+ if (!smoke_has_fuel(sds->fluid)) return;
+ copy_v3_v3_int(vd->resol, sds->res);
+ flame = smoke_get_flame(sds->fluid);
}
- /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */
+ /* always store copy, as smoke internal data can change */
totRes = vd_resol_size(vd);
+ vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
+ memcpy(vd->dataset, flame, sizeof(float)*totRes);
+ }
+ else {
+ size_t totCells;
+ int depth = 4;
+ vd->data_type = TEX_VD_RGBA_PREMUL;
+
+ /* data resolution */
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ smoke_turbulence_get_res(sds->wt, vd->resol);
+ }
+ else {
+ copy_v3_v3_int(vd->resol, sds->res);
+ }
+
+ /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */
+ totCells = vd_resol_size(vd) * depth;
/* always store copy, as smoke internal data can change */
- vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
- memcpy(vd->dataset, density, sizeof(float) * totRes);
+ vd->dataset = MEM_mapallocN(sizeof(float) * totCells, "smoke data");
+
+ if (sds->flags & MOD_SMOKE_HIGHRES) {
+ if (smoke_turbulence_has_colors(sds->wt)) {
+ smoke_turbulence_get_rgba(sds->wt, vd->dataset, 1);
+ }
+ else {
+ smoke_turbulence_get_rgba_from_density(sds->wt, sds->active_color, vd->dataset, 1);
+ }
+ }
+ else {
+ if (smoke_has_colors(sds->fluid)) {
+ smoke_get_rgba(sds->fluid, vd->dataset, 1);
+ }
+ else {
+ smoke_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1);
+ }
+ }
} /* end of fluid condition */
}
}
@@ -320,6 +353,8 @@ void cache_voxeldata(Tex *tex, int scene_frame)
MEM_freeN(vd->dataset);
vd->dataset = NULL;
}
+ /* reset data_type */
+ vd->data_type = TEX_VD_INTENSITY;
if (vd->flag & TEX_VD_STILL)
curframe = vd->still_frame;
@@ -379,9 +414,11 @@ void make_voxeldata(struct Render *re)
int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres)
{
- int retval = TEX_INT;
- VoxelData *vd = tex->vd;
- float co[3], offset[3] = {0.5, 0.5, 0.5};
+ VoxelData *vd = tex->vd;
+ float co[3], offset[3] = {0.5, 0.5, 0.5}, a;
+ int retval = (vd->data_type == TEX_VD_RGBA_PREMUL) ? TEX_RGB : TEX_INT;
+ int depth = (vd->data_type == TEX_VD_RGBA_PREMUL) ? 4 : 1;
+ int ch;
if (vd->dataset == NULL) {
texres->tin = 0.0f;
@@ -420,31 +457,63 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre
break;
}
}
-
- switch (vd->interp_type) {
- case TEX_VD_NEARESTNEIGHBOR:
- texres->tin = BLI_voxel_sample_nearest(vd->dataset, vd->resol, co);
- break;
- case TEX_VD_LINEAR:
- texres->tin = BLI_voxel_sample_trilinear(vd->dataset, vd->resol, co);
- break;
- case TEX_VD_QUADRATIC:
- texres->tin = BLI_voxel_sample_triquadratic(vd->dataset, vd->resol, co);
- break;
- case TEX_VD_TRICUBIC_CATROM:
- case TEX_VD_TRICUBIC_BSPLINE:
- texres->tin = BLI_voxel_sample_tricubic(vd->dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE));
- break;
+
+ for (ch = 0; ch < depth; ch++) {
+ float *dataset = vd->dataset + ch*vd->resol[0]*vd->resol[1]*vd->resol[2];
+ float *result = &texres->tin;
+
+ if (vd->data_type == TEX_VD_RGBA_PREMUL) {
+ switch (ch) {
+ case 0:
+ result = &texres->tr;
+ break;
+ case 1:
+ result = &texres->tg;
+ break;
+ case 2:
+ result = &texres->tb;
+ break;
+ }
+ }
+
+ switch (vd->interp_type) {
+ case TEX_VD_NEARESTNEIGHBOR:
+ *result = BLI_voxel_sample_nearest(dataset, vd->resol, co);
+ break;
+ case TEX_VD_LINEAR:
+ *result = BLI_voxel_sample_trilinear(dataset, vd->resol, co);
+ break;
+ case TEX_VD_QUADRATIC:
+ *result = BLI_voxel_sample_triquadratic(dataset, vd->resol, co);
+ break;
+ case TEX_VD_TRICUBIC_CATROM:
+ case TEX_VD_TRICUBIC_BSPLINE:
+ *result = BLI_voxel_sample_tricubic(dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE));
+ break;
+ }
}
-
+
+ a = texres->tin;
texres->tin *= vd->int_multiplier;
BRICONT;
- texres->tr = texres->tin;
- texres->tg = texres->tin;
- texres->tb = texres->tin;
+ if (vd->data_type == TEX_VD_RGBA_PREMUL) {
+ /* unmultiply */
+ if (a>0.001f) {
+ texres->tr /= a;
+ texres->tg /= a;
+ texres->tb /= a;
+ }
+ texres->talpha = 1;
+ }
+ else {
+ texres->tr = texres->tin;
+ texres->tg = texres->tin;
+ texres->tb = texres->tin;
+ }
+
texres->ta = texres->tin;
BRICONTRGB;
- return retval;
+ return retval;
}
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index bf6962d0087..62bf9ac2005 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -76,6 +76,9 @@
/* own includes */
#include "zbuf.h"
+/* could enable at some point but for now there are far too many conversions */
+#pragma GCC diagnostic ignored "-Wdouble-promotion"
+
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
/* only to be used here in this file, it's for speed */
@@ -150,7 +153,7 @@ static void zbuf_add_to_span(ZSpan *zspan, const float *v1, const float *v2)
}
else {
dx0 = 0.0f;
- xs0 = minf(minv[0], maxv[0]);
+ xs0 = min_ff(minv[0], maxv[0]);
}
/* empty span */
@@ -409,7 +412,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr,
if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; }
if (apn->next==NULL) apn->next= addpsA(zspan);
apn= apn->next;
- }
+ }
}
}
zverg+= zxd;
@@ -501,7 +504,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co
if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; }
if (apn->next==0) apn->next= addpsA(zspan);
apn= apn->next;
- }
+ }
}
}
}
@@ -572,7 +575,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co
if (apn->p[3]==zvlnr) {apn->mask[3]|= mask; break; }
if (apn->next==0) apn->next= addpsA(zspan);
apn= apn->next;
- }
+ }
}
}
}
@@ -1029,7 +1032,7 @@ void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const
/**
* Fill the z buffer, but invert z order, and add the face index to
- * the corresponing face buffer.
+ * the corresponding face buffer.
*
* This is one of the z buffer fill functions called in zbufclip() and
* zbufwireclip().
@@ -1624,7 +1627,7 @@ static void clippyra(float *labda, float *v1, float *v2, int *b2, int *b3, int a
else {
dw= clipcrop*(v2[3]-v1[3]);
v13= clipcrop*v1[3];
- }
+ }
/* according the original article by Liang&Barsky, for clipping of
* homogeneous coordinates with viewplane, the value of "0" is used instead of "-w" .
* This differs from the other clipping cases (like left or top) and I considered
@@ -1682,7 +1685,7 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo
adr[1]= v1[1]+l1*(v2[1]-v1[1]);
adr[2]= v1[2]+l1*(v2[2]-v1[2]);
adr[3]= v1[3]+l1*(v2[3]-v1[3]);
- }
+ }
else trias[*b1]= v1;
(*b1)++;
@@ -2022,7 +2025,7 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg)
EXTEND_PIXEL(row1 + 2);
EXTEND_PIXEL(row2 + 2);
EXTEND_PIXEL(row3 + 2);
- }
+ }
if (tot) {
len++;
curz[0]= (int)(z/(float)tot);
@@ -2038,14 +2041,16 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg)
MEM_freeN(temprectp);
- if (neg); /* z values for negative are already correct */
+ if (neg) {
+ /* z values for negative are already correct */
+ }
else {
/* clear not filled z values */
for (len= xs*ys -1; len>=0; len--) {
if (rectp[len]==0) {
rectz[len] = -0x7FFFFFFF;
rectp[len]= -1; /* env code */
- }
+ }
}
}
}
@@ -2730,7 +2735,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float
x= sn2-sn1;
while (x>=0) {
- if ( zverg < *rz) {
+ if (zverg < (double)*rz) {
*rz= zverg;
*rp= *col;
}
@@ -3231,7 +3236,7 @@ static void copyto_abufz(RenderPart *pa, int *arectz, int *rectmask, int sample)
*rza= 0x7FFFFFFF;
if (rectmask) *rma= 0x7FFFFFFF;
- if (*rd) {
+ if (*rd) {
/* when there's a sky pixstruct, fill in sky-Z, otherwise solid Z */
for (ps= (PixStr *)(*rd); ps; ps= ps->next) {
if (sample & ps->mask) {
@@ -3515,7 +3520,7 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob)
RenderPass *rpass;
for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- if (rpass->passtype == SCE_PASS_INDEXOB||rpass->passtype == SCE_PASS_INDEXMA) {
+ if (rpass->passtype == SCE_PASS_INDEXOB) {
float *fp= rpass->rect + offset;
*fp= (float)ob->index;
break;
@@ -3523,6 +3528,19 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob)
}
}
+static void add_transp_material_index(RenderLayer *rl, int offset, Material *mat)
+{
+ RenderPass *rpass;
+
+ for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
+ if (rpass->passtype == SCE_PASS_INDEXMA) {
+ float *fp= rpass->rect + offset;
+ *fp= (float)mat->index;
+ break;
+ }
+ }
+}
+
/* ONLY OSA! merge all shaderesult samples to one */
/* target should have been cleared */
static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
@@ -3874,7 +3892,7 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf
addAlphaUnderFloat(samp_shr->combined, shr->combined);
- samp_shr->z = minf(samp_shr->z, shr->z);
+ samp_shr->z = min_ff(samp_shr->z, shr->z);
if (addpassflag & SCE_PASS_VECTOR) {
copy_v4_v4(samp_shr->winspeed, shr->winspeed);
@@ -4127,10 +4145,12 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
}
}
if (addpassflag & SCE_PASS_INDEXMA) {
- ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr;
- if (obr->ob) {
+ ObjectRen *obr = R.objectinstance[zrow[totface-1].obi].obr;
+ VlakRen *vr = obr->vlaknodes->vlak;
+ Material *mat = vr->mat;
+ if (mat) {
for (a= 0; a<totfullsample; a++)
- add_transp_obindex(rlpp[a], od, obr->ob);
+ add_transp_material_index(rlpp[a], od, mat);
}
}
@@ -4241,7 +4261,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
MEM_freeN(APixbufstrand);
if (sscache)
strand_shade_cache_free(sscache);
- freepsA(&apsmbase);
+ freepsA(&apsmbase);
if (R.r.mode & R_SHADOW)
ISB_free(pa);
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index ab8252f2661..a3cfbf00f3d 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -29,6 +29,7 @@ set(INC
../blenkernel
../blenlib
../blenloader
+ ../compositor
../editors/include
../editors/io
../gpu
@@ -36,7 +37,6 @@ set(INC
../makesdna
../makesrna
../nodes
- ../compositor
../render/extern/include
../../gameengine/BlenderRoutines
../../../intern/elbeem/extern
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index d64da68755a..9a3b8513810 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -106,7 +106,7 @@ int WM_homefile_read_exec(struct bContext *C, struct wmOperator *op);
int WM_homefile_read(struct bContext *C, struct ReportList *reports, short from_memory);
int WM_homefile_write_exec(struct bContext *C, struct wmOperator *op);
void WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports);
-int WM_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy);
+int WM_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports);
void WM_autosave_init(struct wmWindowManager *wm);
/* mouse cursors */
@@ -214,6 +214,7 @@ int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short c
void WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */
void WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context); /* make props context sensitive or not */
+int WM_operator_properties_default(struct PointerRNA *ptr, const int do_update);
void WM_operator_properties_reset(struct wmOperator *op);
void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
@@ -320,9 +321,9 @@ enum {
WM_JOB_SUSPEND = (1 << 3)
};
-/* identifying jobs by owner alone is unreliable, this isnt saved, order can change */
+/* identifying jobs by owner alone is unreliable, this isnt saved, order can change (keep 0 for 'any') */
enum {
- WM_JOB_TYPE_ANY = -1,
+ WM_JOB_TYPE_ANY = 0,
WM_JOB_TYPE_COMPOSITE,
WM_JOB_TYPE_RENDER,
WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */
@@ -358,8 +359,9 @@ void WM_jobs_callbacks(struct wmJob *,
void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
void WM_jobs_stop(struct wmWindowManager *wm, void *owner, void *startjob);
void WM_jobs_kill(struct wmWindowManager *wm, void *owner, void (*)(void *, short int *, short int *, float *));
-void WM_jobs_stop_all(struct wmWindowManager *wm);
-
+void WM_jobs_kill_all(struct wmWindowManager *wm);
+ void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
+
int WM_jobs_has_running(struct wmWindowManager *wm);
/* clipboard */
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 5c88babfb47..43369154dbb 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -43,7 +43,7 @@ struct EnumPropertyItem;
wmKeyConfig *WM_keyconfig_new (struct wmWindowManager *wm, const char *idname);
wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname);
-void WM_keyconfig_remove (struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
+int WM_keyconfig_remove (struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
void WM_keyconfig_free (struct wmKeyConfig *keyconf);
void WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname);
@@ -63,8 +63,8 @@ wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, in
wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
-void WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
-char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len);
+int WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
+char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len);
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index c848a4123e9..04763e44581 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -424,7 +424,7 @@ typedef struct wmEvent {
char ascii; /* from ghost, fallback if utf8 isn't set */
char pad;
- /* previous state */
+ /* previous state, used for double click and the 'click' */
short prevtype;
short prevval;
int prevx, prevy;
@@ -435,7 +435,8 @@ typedef struct wmEvent {
short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
short keymodifier; /* rawkey modifier */
- short pad1;
+ /* set in case a KM_PRESS went by unhandled */
+ short check_click;
/* keymap item, set by handler (weak?) */
const char *keymap_idname;
@@ -547,7 +548,11 @@ typedef struct wmOperatorType {
/* verify if the operator can be executed in the current context, note
* that the operator might still fail to execute even if this return true */
- int (*poll)(struct bContext *);
+ int (*poll)(struct bContext *)
+#ifdef __GNUC__
+ __attribute__((warn_unused_result))
+#endif
+ ;
/* optional panel for redo and repeat, autogenerated if not set */
void (*ui)(struct bContext *, struct wmOperator *);
@@ -558,8 +563,8 @@ typedef struct wmOperatorType {
/* previous settings - for initializing on re-use */
struct IDProperty *last_properties;
- /* rna property to use for generic invoke functions.
- * menus, enum search... etc */
+ /* Default rna property to use for generic invoke functions.
+ * menus, enum search... etc. Example: Enum 'type' for a Delete menu */
PropertyRNA *prop;
/* struct wmOperatorTypeMacro */
@@ -571,7 +576,11 @@ typedef struct wmOperatorType {
/* only used for operators defined with python
* use to store pointers to python functions */
void *pyop_data;
- int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot);
+ int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot)
+#ifdef __GNUC__
+ __attribute__((warn_unused_result))
+#endif
+ ;
/* RNA integration */
ExtensionRNA ext;
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index a34d294461c..8fe387765ce 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -78,7 +78,7 @@ void WM_operator_free(wmOperator *op)
if (op->py_instance) {
/* do this first in case there are any __del__ functions or
* similar that use properties */
- BPY_DECREF(op->py_instance);
+ BPY_DECREF_RNA_INVALIDATE(op->py_instance);
}
#endif
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 7853b40c98a..ebde6407a48 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -61,7 +61,7 @@ static GHOST_TStandardCursor convert_cursor(int curs)
case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow;
case CURSOR_WAIT: return GHOST_kStandardCursorWait;
case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair;
- case CURSOR_HELP:
+ case CURSOR_HELP:
#ifdef __APPLE__
return GHOST_kStandardCursorLeftRight;
#else
@@ -317,7 +317,7 @@ void WM_cursor_time(wmWindow *win, int nr)
/* Because defining a cursor mixes declarations and executable code
* each cursor needs it's own scoping block or it would be split up
* over several hundred lines of code. To enforce/document this better
- * I define 2 pretty braindead macros so it's obvious what the extra "[]"
+ * I define 2 pretty brain-dead macros so it's obvious what the extra "[]"
* are for */
#define BEGIN_CURSOR_BLOCK {
@@ -560,7 +560,7 @@ BEGIN_CURSOR_BLOCK
BlenderCursor[BC_CROSSCURSOR] = &CrossCursor;
END_CURSOR_BLOCK
- /********************** EditCross Cursor ***********************/
+ /********************** EditCross Cursor ***********************/
BEGIN_CURSOR_BLOCK
static char editcross_sbm[] = {
0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03,
@@ -775,7 +775,7 @@ BEGIN_CURSOR_BLOCK
END_CURSOR_BLOCK
- /********************** TextEdit Cursor ***********************/
+ /********************** TextEdit Cursor ***********************/
BEGIN_CURSOR_BLOCK
static char textedit_sbm[] = {
0xe0, 0x03, 0x10, 0x04, 0x60, 0x03, 0x40, 0x01,
@@ -808,7 +808,7 @@ BEGIN_CURSOR_BLOCK
END_CURSOR_BLOCK
- /********************** Paintbrush Cursor ***********************/
+ /********************** Paintbrush Cursor ***********************/
BEGIN_CURSOR_BLOCK
static char paintbrush_sbm[] = {
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index e18199f4d04..0b58009ebcc 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -143,7 +143,7 @@ void wm_dropbox_free(void)
BLI_freelistN(&dm->dropboxes);
}
- BLI_freelistN(&dropboxes);
+ BLI_freelistN(&dropboxes);
}
/* *********************************** */
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 8e2977acb1c..ad19df3aaf6 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -86,7 +86,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
bScreen *screen = win->screen;
wmPaintCursor *pc;
- if (screen->subwinactive == ar->swinid) {
+ if (ar->swinid && screen->subwinactive == ar->swinid) {
for (pc = wm->paintcursors.first; pc; pc = pc->next) {
if (pc->poll == NULL || pc->poll(C)) {
ARegion *ar_other = CTX_wm_region(C);
@@ -638,7 +638,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
if (paintcursor && wm->paintcursors.first) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->swinid == screen->subwinactive) {
+ if (ar->swinid && ar->swinid == screen->subwinactive) {
CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar);
@@ -718,12 +718,14 @@ static int wm_automatic_draw_method(wmWindow *win)
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE))
return USER_DRAW_OVERLAP;
/* also Intel drivers are slow */
+ /* 2.64 BCon3 period, let's try if intel now works...
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_UNIX, GPU_DRIVER_ANY))
return USER_DRAW_OVERLAP;
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY))
return USER_DRAW_OVERLAP_FLIP;
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY))
return USER_DRAW_OVERLAP_FLIP;
+ */
/* Windows software driver darkens color on each redraw */
else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE))
return USER_DRAW_OVERLAP_FLIP;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 3ddfc511747..551f9157dfe 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -256,8 +256,12 @@ void wm_event_do_notifiers(bContext *C)
for (win = wm->windows.first; win; win = win->next) {
/* filter out notifiers */
- if (note->category == NC_SCREEN && note->reference && note->reference != win->screen) ;
- else if (note->category == NC_SCENE && note->reference && note->reference != win->screen->scene) ;
+ if (note->category == NC_SCREEN && note->reference && note->reference != win->screen) {
+ /* pass */
+ }
+ else if (note->category == NC_SCENE && note->reference && note->reference != win->screen->scene) {
+ /* pass */
+ }
else {
ScrArea *sa;
ARegion *ar;
@@ -336,6 +340,11 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
int is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE);
int retval;
+ /* UI code doesn't handle return values - it just always returns break.
+ to make the DBL_CLICK conversion work, we just don't send this to UI */
+ if (event->val == KM_DBL_CLICK)
+ return WM_HANDLER_CONTINUE;
+
/* UI is quite aggressive with swallowing events, like scrollwheel */
/* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
if (do_wheel_ui == FALSE) {
@@ -444,10 +453,10 @@ void WM_event_print(wmEvent *event)
RNA_enum_identifier(event_type_items, event->type, &type_id);
RNA_enum_identifier(event_value_items, event->val, &val_id);
- printf("wmEvent - type:%d/%s, val:%d/%s, "
- "shift:%d, ctrl:%d, alt:%d, oskey:%d, keymodifier:%d, "
- "mouse:(%d,%d), ascii:'%c', utf8:'%.*s', "
- "keymap_idname:%s, pointer:%p\n",
+ printf("wmEvent type:%d / %s, val:%d / %s, \n"
+ " shift:%d, ctrl:%d, alt:%d, oskey:%d, keymodifier:%d, \n"
+ " mouse:(%d,%d), ascii:'%c', utf8:'%.*s', "
+ " keymap_idname:%s, pointer:%p\n",
event->type, type_id, event->val, val_id,
event->shift, event->ctrl, event->alt, event->oskey, event->keymodifier,
event->x, event->y, event->ascii,
@@ -845,7 +854,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event,
WM_operator_last_properties_init(op);
}
- if ((G.debug & G_DEBUG_EVENTS) && event && event->type != MOUSEMOVE) {
+ if ((G.debug & G_DEBUG_HANDLERS) && event && event->type != MOUSEMOVE) {
printf("%s: handle evt %d win %d op %s\n",
__func__, event ? event->type : 0, CTX_wm_screen(C)->subwinactive, ot->idname);
}
@@ -884,8 +893,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event,
wm_operator_reports(C, op, retval, (reports != NULL));
}
- if (retval & OPERATOR_HANDLED)
- ; /* do nothing, wm_operator_exec() has been called somewhere */
+ if (retval & OPERATOR_HANDLED) {
+ /* do nothing, wm_operator_exec() has been called somewhere */
+ }
else if (retval & OPERATOR_FINISHED) {
if (!is_nested_call) { /* not called by py script */
WM_operator_last_properties_store(op);
@@ -1272,25 +1282,50 @@ int WM_userdef_event_map(int kmitype)
static void wm_eventemulation(wmEvent *event)
{
+ /* Store last mmb event value to make emulation work when modifier keys are released first. */
static int mmb_emulated = 0; /* this should be in a data structure somwhere */
/* middlemouse emulation */
if (U.flag & USER_TWOBUTTONMOUSE) {
- if (event->type == LEFTMOUSE && (event->alt || mmb_emulated == KM_PRESS)) {
- event->type = MIDDLEMOUSE;
- event->alt = 0;
- mmb_emulated = event->val;
+ if (event->type == LEFTMOUSE) {
+
+ if (event->val == KM_PRESS && event->alt) {
+ event->type = MIDDLEMOUSE;
+ event->alt = 0;
+ mmb_emulated = 1;
+ }
+ else if (event->val == KM_RELEASE) {
+ /* only send middle-mouse release if emulated */
+ if (mmb_emulated) {
+ event->type = MIDDLEMOUSE;
+ event->alt = 0;
+ }
+ mmb_emulated = 0;
+ }
}
+
}
#ifdef __APPLE__
+
/* rightmouse emulation */
if (U.flag & USER_TWOBUTTONMOUSE) {
- if (event->type == LEFTMOUSE && (event->oskey || mmb_emulated == KM_PRESS)) {
- event->type = RIGHTMOUSE;
- event->oskey = 0;
- mmb_emulated = event->val;
+ if (event->type == LEFTMOUSE) {
+
+ if (event->val == KM_PRESS && event->oskey) {
+ event->type = RIGHTMOUSE;
+ event->oskey = 0;
+ mmb_emulated = 1;
+ }
+ else if (event->val == KM_RELEASE) {
+ if (mmb_emulated) {
+ event->oskey = RIGHTMOUSE;
+ event->alt = 0;
+ }
+ mmb_emulated = 0;
+ }
}
+
}
#endif
@@ -1322,7 +1357,12 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
/* the matching rules */
if (kmitype == KM_TEXTINPUT)
- if (ISTEXTINPUT(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
+ if (winevent->val == KM_PRESS) { // prevent double clicks
+ /* NOT using ISTEXTINPUT anymore because (at least on Windows) some key codes above 255
+ could have printable ascii keys - BUG [#30479] */
+ if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
+ }
+
if (kmitype != KM_ANY)
if (winevent->type != kmitype) return 0;
@@ -1339,14 +1379,8 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
if (kmi->oskey != KM_ANY)
if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0;
- if (kmi->keymodifier)
- if (winevent->keymodifier != kmi->keymodifier) return 0;
+ if (winevent->keymodifier != kmi->keymodifier) return 0;
- /* key modifiers always check when event has it */
- /* otherwise regular keypresses with keymodifier still work */
- if (winevent->keymodifier)
- if (ISTEXTINPUT(winevent->type))
- if (winevent->keymodifier != kmi->keymodifier) return 0;
return 1;
}
@@ -1366,13 +1400,30 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (wm_eventmatch(event, kmi)) {
+ event->prevtype = event->type;
+ event->prevval = event->val;
event->type = EVT_MODAL_MAP;
event->val = kmi->propvalue;
+
+ break;
}
}
}
}
+/* bad hacking event system... better restore event type for checking of KM_CLICK for example */
+/* XXX modal maps could use different method (ton) */
+static void wm_event_modalmap_end(wmEvent *event)
+{
+ if (event->type == EVT_MODAL_MAP) {
+ event->type = event->prevtype;
+ event->prevtype = 0;
+ event->val = event->prevval;
+ event->prevval = 0;
+ }
+
+}
+
/* Warning: this function removes a modal handler, when finished */
static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler,
wmEvent *event, PointerRNA *properties)
@@ -1399,7 +1450,8 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
retval = ot->modal(C, op, event);
OPERATOR_RETVAL_CHECK(retval);
-
+ wm_event_modalmap_end(event);
+
/* when this is _not_ the case the modal modifier may have loaded
* a new blend file (demo mode does this), so we have to assume
* the event, operator etc have all been freed. - campbell */
@@ -1544,72 +1596,55 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
/* needed for uiPupMenuReports */
if (event->val == EVT_FILESELECT_EXEC) {
-#if 0 // use REDALERT now
+ int retval;
- /* a bit weak, might become arg for WM_event_fileselect? */
- /* XXX also extension code in image-save doesnt work for this yet */
- if (RNA_struct_find_property(handler->op->ptr, "check_existing") &&
- RNA_boolean_get(handler->op->ptr, "check_existing"))
- {
- char *path = RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0);
- /* this gives ownership to pupmenu */
- uiPupMenuSaveOver(C, handler->op, (path) ? path : "");
- if (path)
- MEM_freeN(path);
- }
- else
-#endif
- {
- int retval;
-
- if (handler->op->type->flag & OPTYPE_UNDO)
- wm->op_undo_depth++;
-
- retval = handler->op->type->exec(C, handler->op);
+ if (handler->op->type->flag & OPTYPE_UNDO)
+ wm->op_undo_depth++;
- /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
- if (handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
- wm->op_undo_depth--;
+ retval = handler->op->type->exec(C, handler->op);
- if (retval & OPERATOR_FINISHED)
- if (G.debug & G_DEBUG_WM)
- wm_operator_print(C, handler->op);
+ /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
+ if (handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
+ wm->op_undo_depth--;
- /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
- if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0)
- if (handler->op->type->flag & OPTYPE_UNDO)
- ED_undo_push_op(C, handler->op);
+ if (retval & OPERATOR_FINISHED)
+ if (G.debug & G_DEBUG_WM)
+ wm_operator_print(C, handler->op);
- if (handler->op->reports->list.first) {
+ /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
+ if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0)
+ if (handler->op->type->flag & OPTYPE_UNDO)
+ ED_undo_push_op(C, handler->op);
- /* FIXME, temp setting window, this is really bad!
+ if (handler->op->reports->list.first) {
+
+ /* FIXME, temp setting window, this is really bad!
* only have because lib linking errors need to be seen by users :(
* it can be removed without breaking anything but then no linking errors - campbell */
- wmWindow *win_prev = CTX_wm_window(C);
- ScrArea *area_prev = CTX_wm_area(C);
- ARegion *ar_prev = CTX_wm_region(C);
-
- if (win_prev == NULL)
- CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
+ wmWindow *win_prev = CTX_wm_window(C);
+ ScrArea *area_prev = CTX_wm_area(C);
+ ARegion *ar_prev = CTX_wm_region(C);
- handler->op->reports->printlevel = RPT_WARNING;
- uiPupMenuReports(C, handler->op->reports);
+ if (win_prev == NULL)
+ CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
- /* XXX - copied from 'wm_operator_finished()' */
- /* add reports to the global list, otherwise they are not seen */
- BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list);
+ handler->op->reports->printlevel = RPT_WARNING;
+ uiPupMenuReports(C, handler->op->reports);
- CTX_wm_window_set(C, win_prev);
- CTX_wm_area_set(C, area_prev);
- CTX_wm_region_set(C, ar_prev);
- }
+ /* XXX - copied from 'wm_operator_finished()' */
+ /* add reports to the global list, otherwise they are not seen */
+ BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list);
- if (retval & OPERATOR_FINISHED) {
- WM_operator_last_properties_store(handler->op);
- }
+ CTX_wm_window_set(C, win_prev);
+ CTX_wm_area_set(C, area_prev);
+ CTX_wm_region_set(C, ar_prev);
+ }
- WM_operator_free(handler->op);
+ if (retval & OPERATOR_FINISHED) {
+ WM_operator_last_properties_store(handler->op);
}
+
+ WM_operator_free(handler->op);
}
else {
if (handler->op->type->cancel) {
@@ -1668,10 +1703,13 @@ static int wm_action_not_handled(int action)
return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
}
-static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
+static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers)
{
#ifndef NDEBUG
- const int do_debug_handler = (G.debug & G_DEBUG_EVENTS);
+ const int do_debug_handler = (G.debug & G_DEBUG_HANDLERS)
+ /* comment this out to flood the console! (if you really want to test) */
+ && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)
+ ;
#endif
wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler, *nexthandler;
@@ -1682,13 +1720,6 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
return action;
}
-#ifndef NDEBUG
- if (do_debug_handler) {
- printf("%s: handling event\n", __func__);
- WM_event_print(event);
- }
-#endif
-
/* modal handlers can get removed in this loop, we keep the loop this way
*
* note: check 'handlers->first' because in rare cases the handlers can be cleared
@@ -1744,11 +1775,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
if (action & WM_HANDLER_BREAK) {
/* not always_pass here, it denotes removed handler */
-#ifndef NDEBUG
- if (do_debug_handler) {
- printf("%s: handled! '%s'...", __func__, kmi->idname);
- }
-#endif
+
+ if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS))
+ printf("%s: handled! '%s'\n", __func__, kmi->idname);
+
break;
}
else {
@@ -1840,49 +1870,66 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
}
}
- /* test for CLICK event */
- if (wm_action_not_handled(action) && event->val == KM_RELEASE) {
- wmWindow *win = CTX_wm_window(C);
+ if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL))
+ wm_cursor_arrow_move(CTX_wm_window(C), event);
- if (win && win->eventstate->prevtype == event->type && win->eventstate->prevval == KM_PRESS) {
- /* test for double click first,
- * note1: this can be problematic because single click operators can get the
- * double click event but then with old mouse coords which is highly confusing,
- * so check for mouse moves too.
- * note2: the first click event will be handled but still used to create a
- * double click event if clicking again quickly.
- * If no double click events are found it will fallback to a single click.
- * So a double click event can result in 2 successive single click calls
- * if its not handled by the keymap - campbell */
- if ((ABS(event->x - win->eventstate->prevclickx)) <= 2 &&
- (ABS(event->y - win->eventstate->prevclicky)) <= 2 &&
- ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time))
- {
- event->val = KM_DBL_CLICK;
- /* removed this because in cases where we're this is used as a single click
- * event, this will give old coords,
- * since the distance is checked above, using new coords should be ok. */
- // event->x = win->eventstate->prevclickx;
- // event->y = win->eventstate->prevclicky;
- action |= wm_handlers_do(C, event, handlers);
- }
+ return action;
+}
- if (wm_action_not_handled(action)) {
- event->val = KM_CLICK;
- action |= wm_handlers_do(C, event, handlers);
+/* this calls handlers twice - to solve (double-)click events */
+static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
+{
+ int action = wm_handlers_do_intern(C, event, handlers);
+
+ /* fileread case */
+ if (CTX_wm_window(C) == NULL)
+ return action;
+
+ if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !ISTIMER(event->type)) {
+
+ /* test for CLICK events */
+ if (wm_action_not_handled(action)) {
+ wmWindow *win = CTX_wm_window(C);
+
+ /* eventstate stores if previous event was a KM_PRESS, in case that
+ * wasn't handled, the KM_RELEASE will become a KM_CLICK */
+
+ if (win && event->val == KM_PRESS) {
+ win->eventstate->check_click = TRUE;
}
+
+ if (win && win->eventstate->prevtype == event->type) {
+
+ if (event->val == KM_RELEASE && win->eventstate->prevval == KM_PRESS && win->eventstate->check_click == TRUE) {
+ event->val = KM_CLICK;
+
+ if (G.debug & (G_DEBUG_HANDLERS)) {
+ printf("%s: handling CLICK\n", __func__);
+ }
+ action |= wm_handlers_do_intern(C, event, handlers);
- /* revert value if not handled */
- if (wm_action_not_handled(action)) {
- event->val = KM_RELEASE;
+ event->val = KM_RELEASE;
+ }
+ else if (event->val == KM_DBL_CLICK) {
+ event->val = KM_PRESS;
+ action |= wm_handlers_do_intern(C, event, handlers);
+
+ /* revert value if not handled */
+ if (wm_action_not_handled(action)) {
+ event->val = KM_DBL_CLICK;
+ }
+ }
}
}
+ else {
+ wmWindow *win = CTX_wm_window(C);
+
+ if (win)
+ win->eventstate->check_click = 0;
+ }
}
- if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL))
- wm_cursor_arrow_move(CTX_wm_window(C), event);
-
return action;
}
@@ -2060,10 +2107,13 @@ void wm_event_do_handlers(bContext *C)
while ( (event = win->queue.first) ) {
int action = WM_HANDLER_CONTINUE;
- if ((G.debug & G_DEBUG_EVENTS) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
- printf("%s: pass on evt %d val %d\n", __func__, event->type, event->val);
+#ifdef DEBUG
+ if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ printf("\n%s: Handling event\n", __func__);
+ WM_event_print(event);
}
-
+#endif
+
wm_eventemulation(event);
CTX_wm_window_set(C, win);
@@ -2176,40 +2226,6 @@ void wm_event_do_handlers(bContext *C)
}
}
- /* store last event for this window */
- /* mousemove and timer events don't overwrite last type */
- if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !ISTIMER(event->type)) {
- if (wm_action_not_handled(action)) {
- if (win->eventstate->prevtype == event->type) {
- /* set click time on first click (press -> release) */
- if (win->eventstate->prevval == KM_PRESS && event->val == KM_RELEASE) {
- win->eventstate->prevclicktime = PIL_check_seconds_timer();
- win->eventstate->prevclickx = event->x;
- win->eventstate->prevclicky = event->y;
- }
- }
- else {
- /* reset click time if event type not the same */
- win->eventstate->prevclicktime = 0;
- }
-
- win->eventstate->prevval = event->val;
- win->eventstate->prevtype = event->type;
- }
- else if (event->val == KM_CLICK) { /* keep click for double click later */
- win->eventstate->prevtype = event->type;
- win->eventstate->prevval = event->val;
- win->eventstate->prevclicktime = PIL_check_seconds_timer();
- win->eventstate->prevclickx = event->x;
- win->eventstate->prevclicky = event->y;
- }
- else { /* reset if not */
- win->eventstate->prevtype = -1;
- win->eventstate->prevval = 0;
- win->eventstate->prevclicktime = 0;
- }
- }
-
/* unlink and free here, blender-quit then frees all */
BLI_remlink(&win->queue, event);
wm_event_free(event);
@@ -2618,7 +2634,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
event->customdatatype = EVT_DATA_TABLET;
event->customdata = wmtab;
event->customdatafree = 1;
- }
+ }
}
/* adds customdata to event */
@@ -2716,49 +2732,45 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event = *evt;
switch (type) {
- /* mouse move */
+ /* mouse move, also to inactive window (X11 does this) */
case GHOST_kEventCursorMove:
{
- if (win->active) {
- GHOST_TEventCursorData *cd = customdata;
- wmEvent *lastevent = win->queue.last;
- int cx, cy;
-
- GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
- evt->x = cx;
- evt->y = (win->sizey - 1) - cy;
-
- event.x = evt->x;
- event.y = evt->y;
-
- event.type = MOUSEMOVE;
+ GHOST_TEventCursorData *cd = customdata;
+ wmEvent *lastevent = win->queue.last;
+ int cx, cy;
+
+ GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
+ evt->x = cx;
+ evt->y = (win->sizey - 1) - cy;
+
+ event.x = evt->x;
+ event.y = evt->y;
- /* some painting operators want accurate mouse events, they can
- * handle in between mouse move moves, others can happily ignore
- * them for better performance */
- if (lastevent && lastevent->type == MOUSEMOVE)
- lastevent->type = INBETWEEN_MOUSEMOVE;
+ event.type = MOUSEMOVE;
- update_tablet_data(win, &event);
- wm_event_add(win, &event);
+ /* some painting operators want accurate mouse events, they can
+ * handle in between mouse move moves, others can happily ignore
+ * them for better performance */
+ if (lastevent && lastevent->type == MOUSEMOVE)
+ lastevent->type = INBETWEEN_MOUSEMOVE;
- //printf("sending MOUSEMOVE %d %d\n", event.x, event.y);
+ update_tablet_data(win, &event);
+ wm_event_add(win, &event);
+
+ /* also add to other window if event is there, this makes overdraws disappear nicely */
+ /* it remaps mousecoord to other window in event */
+ owin = wm_event_cursor_other_windows(wm, win, &event);
+ if (owin) {
+ wmEvent oevent = *(owin->eventstate);
- /* also add to other window if event is there, this makes overdraws disappear nicely */
- /* it remaps mousecoord to other window in event */
- owin = wm_event_cursor_other_windows(wm, win, &event);
- if (owin) {
- wmEvent oevent = *(owin->eventstate);
-
- oevent.x = owin->eventstate->x = event.x;
- oevent.y = owin->eventstate->y = event.y;
- oevent.type = MOUSEMOVE;
-
- update_tablet_data(owin, &oevent);
- wm_event_add(owin, &oevent);
- }
+ oevent.x = owin->eventstate->x = event.x;
+ oevent.y = owin->eventstate->y = event.y;
+ oevent.type = MOUSEMOVE;
+ update_tablet_data(owin, &oevent);
+ wm_event_add(owin, &oevent);
}
+
break;
}
case GHOST_kEventTrackpad:
@@ -2783,7 +2795,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.x = evt->x = cx;
event.y = evt->y = (win->sizey - 1) - cy;
}
-
+
+ event.val = 0;
+
/* Use prevx/prevy so we can calculate the delta later */
event.prevx = event.x - pd->deltaX;
event.prevy = event.y - (-pd->deltaY);
@@ -2797,7 +2811,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
case GHOST_kEventButtonUp:
{
GHOST_TEventButtonData *bd = customdata;
-
+
+ /* get value and type from ghost */
event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
if (bd->button == GHOST_kButtonMaskLeft)
@@ -2811,6 +2826,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
else
event.type = MIDDLEMOUSE;
+ /* copy previous state to prev event state (two old!) */
+ evt->prevval = evt->val;
+ evt->prevtype = evt->type;
+
+ /* copy to event state */
+ evt->val = event.val;
+ evt->type = event.type;
+
if (win->active == 0) {
int cx, cy;
@@ -2821,6 +2844,23 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.y = evt->y = cy;
}
+ /* double click test */
+ if (event.type == evt->prevtype && event.val == KM_PRESS) {
+ if ((ABS(event.x - evt->prevclickx)) <= 2 &&
+ (ABS(event.y - evt->prevclicky)) <= 2 &&
+ ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time))
+ {
+ if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
+ printf("%s Send double click\n", __func__);
+ event.val = KM_DBL_CLICK;
+ }
+ }
+ if (event.val == KM_PRESS) {
+ evt->prevclicktime = PIL_check_seconds_timer();
+ evt->prevclickx = event.x;
+ evt->prevclicky = event.y;
+ }
+
/* add to other window if event is there (not to both!) */
owin = wm_event_cursor_other_windows(wm, win, &event);
if (owin) {
@@ -2851,6 +2891,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/
event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE;
+ /* copy previous state to prev event state (two old!) */
+ evt->prevval = evt->val;
+ evt->prevtype = evt->type;
+
+ /* copy to event state */
+ evt->val = event.val;
+ evt->type = event.type;
+
/* exclude arrow keys, esc, etc from text input */
if (type == GHOST_kEventKeyUp) {
event.ascii = '\0';
@@ -2876,28 +2924,28 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
}
}
- /* modifiers */
+ /* modifiers assign to eventstate, so next event gets the modifer (makes modifier key events work) */
/* assigning both first and second is strange - campbell */
switch (event.type) {
case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
- event.shift = evt->shift = (event.val == KM_PRESS) ?
- ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->shift = (event.val == KM_PRESS) ?
+ ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
case LEFTCTRLKEY: case RIGHTCTRLKEY:
- event.ctrl = evt->ctrl = (event.val == KM_PRESS) ?
- ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->ctrl = (event.val == KM_PRESS) ?
+ ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
case LEFTALTKEY: case RIGHTALTKEY:
- event.alt = evt->alt = (event.val == KM_PRESS) ?
- ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->alt = (event.val == KM_PRESS) ?
+ ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
case OSKEY:
- event.oskey = evt->oskey = (event.val == KM_PRESS) ?
- ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->oskey = (event.val == KM_PRESS) ?
+ ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
default:
if (event.val == KM_PRESS && event.keymodifier == 0)
@@ -2907,21 +2955,44 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
break;
}
- /* this case happens on some systems that on holding a key pressed,
- * generate press events without release, we still want to keep the
- * modifier in win->eventstate, but for the press event of the same
- * key we don't want the key modifier */
+ /* double click test */
+ /* if previous event was same type, and previous was release, and now it presses... */
+ if (event.type == evt->prevtype && evt->prevval == KM_RELEASE && event.val == KM_PRESS) {
+ if ((ABS(event.x - evt->prevclickx)) <= 2 &&
+ (ABS(event.y - evt->prevclicky)) <= 2 &&
+ ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time))
+ {
+ if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
+ printf("%s Send double click\n", __func__);
+ evt->val = event.val = KM_DBL_CLICK;
+ }
+ }
+
+ /* this case happens on holding a key pressed, it should not generate
+ * press events events with the same key as modifier */
if (event.keymodifier == event.type)
event.keymodifier = 0;
+
/* this case happened with an external numpad, it's not really clear
* why, but it's also impossible to map a key modifier to an unknwon
* key, so it shouldn't harm */
if (event.keymodifier == UNKNOWNKEY)
event.keymodifier = 0;
- /* if test_break set, it catches this. XXX Keep global for now? */
- if (event.type == ESCKEY)
+ /* if test_break set, it catches this. Do not set with modifier presses. XXX Keep global for now? */
+ if ((event.type == ESCKEY && event.val == KM_PRESS) &&
+ /* check other modifiers because ms-windows uses these to bring up the task manager */
+ (event.shift == 0 && event.ctrl == 0 && event.alt == 0))
+ {
G.is_break = TRUE;
+ }
+
+ /* double click test - only for press */
+ if (event.val == KM_PRESS) {
+ evt->prevclicktime = PIL_check_seconds_timer();
+ evt->prevclickx = event.x;
+ evt->prevclicky = event.y;
+ }
wm_event_add(win, &event);
@@ -2947,6 +3018,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.type = TIMER;
event.customdatatype = EVT_DATA_TIMER;
event.customdata = customdata;
+ event.val = 0;
+ event.keymodifier = 0;
wm_event_add(win, &event);
break;
@@ -2955,10 +3028,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
case GHOST_kEventNDOFMotion:
{
event.type = NDOF_MOTION;
+ event.val = 0;
attach_ndof_data(&event, customdata);
wm_event_add(win, &event);
- //printf("sending NDOF_MOTION, prev = %d %d\n", event.x, event.y);
+ if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) )
+ printf("%s sending NDOF_MOTION, prev = %d %d\n", __func__, event.x, event.y);
break;
}
@@ -3018,7 +3093,4 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
}
- /* Handy when debugging checking events */
- /* WM_event_print(&event); */
-
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 7b78dbedb31..0e4af46d0fc 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -144,7 +144,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
/* code copied from wm_init_exit.c */
for (wm = wmlist->first; wm; wm = wm->id.next) {
- WM_jobs_stop_all(wm);
+ WM_jobs_kill_all(wm);
for (win = wm->windows.first; win; win = win->next) {
@@ -190,9 +190,12 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* cases 1 and 2 */
if (oldwmlist->first == NULL) {
- if (G.main->wm.first) ; /* nothing todo */
- else
+ if (G.main->wm.first) {
+ /* nothing todo */
+ }
+ else {
wm_add_default(C);
+ }
}
else {
/* cases 3 and 4 */
@@ -447,9 +450,8 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
if (sce->r.engine[0] &&
BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{
- BKE_reportf(reports, RPT_WARNING,
- "Engine not available: '%s' for scene: %s, "
- "an addon may need to be installed or enabled",
+ BKE_reportf(reports, RPT_ERROR, "Engine '%s' not available for scene '%s' "
+ "(an addon may need to be installed or enabled)",
sce->r.engine, sce->id.name + 2);
}
}
@@ -462,17 +464,17 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
else if (retval == BKE_READ_EXOTIC_OK_OTHER)
BKE_write_undo(C, "Import file");
else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) {
- BKE_reportf(reports, RPT_ERROR, IFACE_("Can't read file: \"%s\", %s."), filepath,
- errno ? strerror(errno) : IFACE_("Unable to open the file"));
+ BKE_reportf(reports, RPT_ERROR, "Cannot read file '%s': %s", filepath,
+ errno ? strerror(errno) : TIP_("unable to open the file"));
}
else if (retval == BKE_READ_EXOTIC_FAIL_FORMAT) {
- BKE_reportf(reports, RPT_ERROR, IFACE_("File format is not supported in file: \"%s\"."), filepath);
+ BKE_reportf(reports, RPT_ERROR, "File format is not supported in file '%s'", filepath);
}
else if (retval == BKE_READ_EXOTIC_FAIL_PATH) {
- BKE_reportf(reports, RPT_ERROR, IFACE_("File path invalid: \"%s\"."), filepath);
+ BKE_reportf(reports, RPT_ERROR, "File path '%s' invalid", filepath);
}
else {
- BKE_reportf(reports, RPT_ERROR, IFACE_("Unknown error loading: \"%s\"."), filepath);
+ BKE_reportf(reports, RPT_ERROR, "Unknown error loading '%s'", filepath);
BLI_assert(!"invalid 'retval'");
}
@@ -713,7 +715,7 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt)
IB_rect, FALSE, FALSE, err_out);
}
- if (ibuf) {
+ if (ibuf) {
float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
/* dirty oversampling */
@@ -760,7 +762,7 @@ int write_crash_blend(void)
}
}
-int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *reports, int copy)
+int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *reports)
{
Library *li;
int len;
@@ -788,7 +790,7 @@ int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *re
/* send the OnSave event */
for (li = G.main->library.first; li; li = li->id.next) {
if (BLI_path_cmp(li->filepath, filepath) == 0) {
- BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.240s'", filepath);
+ BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath);
return -1;
}
}
@@ -816,7 +818,7 @@ int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *re
fileflags |= G_FILE_HISTORY; /* write file history */
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
- if (!copy) {
+ if (!(fileflags & G_FILE_SAVE_COPY)) {
G.relbase_valid = 1;
BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index b5f84eafacf..122a494779c 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -47,6 +47,10 @@
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -66,10 +70,6 @@
#include "BKE_material.h" /* clear_matcopybuf */
#include "BKE_tracking.h" /* free tracking clipboard */
-#include "BLI_listbase.h"
-#include "BLI_string.h"
-#include "BLI_utildefines.h"
-
#include "RE_engine.h"
#include "RE_pipeline.h" /* RE_ free stuff */
@@ -341,7 +341,7 @@ int WM_init_game(bContext *C)
else {
ReportTimerInfo *rti;
- BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found. Game auto start is not possible.");
+ BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found, game auto start is not possible");
/* After adding the report to the global list, reset the report timer. */
WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
@@ -411,7 +411,7 @@ void WM_exit_ext(bContext *C, const short do_python)
if (C && wm) {
wmWindow *win;
- WM_jobs_stop_all(wm);
+ WM_jobs_kill_all(wm);
for (win = wm->windows.first; win; win = win->next) {
@@ -462,6 +462,7 @@ void WM_exit_ext(bContext *C, const short do_python)
#ifdef WITH_INTERNATIONAL
BLF_free_unifont();
+ BLF_lang_free();
#endif
ANIM_keyingset_infos_exit();
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 4a410363167..f5c83d48cb9 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -131,31 +131,34 @@ struct wmJob {
};
/* finds:
- * 1st priority: job with same owner and name
- * 2nd priority: job with same owner
+ * if type, compare for it, otherwise any matching job
*/
-static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name)
+static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
- wmJob *wm_job, *found = NULL;
+ wmJob *wm_job;
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner) {
- found = wm_job;
- if (name && strcmp(wm_job->name, name) == 0)
+
+ if (job_type) {
+ if ( wm_job->job_type == job_type)
+ return wm_job;
+ }
+ else
return wm_job;
}
- return found;
+ return NULL;
}
/* ******************* public API ***************** */
/* returns current or adds new job, but doesnt run it */
-/* every owner only gets a single job, adding a new one will stop running stop and
+/* every owner only gets a single job, adding a new one will stop running job and
* when stopped it starts the new one */
wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
{
- wmJob *wm_job = wm_job_find(wm, owner, name);
+ wmJob *wm_job = wm_job_find(wm, owner, job_type);
if (wm_job == NULL) {
wm_job = MEM_callocN(sizeof(wmJob), "new job");
@@ -167,7 +170,11 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
wm_job->job_type = job_type;
BLI_strncpy(wm_job->name, name, sizeof(wm_job->name));
}
+ /* else: a running job, be careful */
+ /* prevent creating a job with an invalid type */
+ BLI_assert(wm_job->job_type != WM_JOB_TYPE_ANY);
+
return wm_job;
}
@@ -192,7 +199,7 @@ int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
float WM_jobs_progress(wmWindowManager *wm, void *owner)
{
- wmJob *wm_job = wm_job_find(wm, owner, NULL);
+ wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job && wm_job->flag & WM_JOB_PROGRESS)
return wm_job->progress;
@@ -202,7 +209,7 @@ float WM_jobs_progress(wmWindowManager *wm, void *owner)
char *WM_jobs_name(wmWindowManager *wm, void *owner)
{
- wmJob *wm_job = wm_job_find(wm, owner, NULL);
+ wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job)
return wm_job->name;
@@ -360,7 +367,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
}
}
-/* stop job, free data completely */
+/* stop job, end thread, free data completely */
static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
{
if (wm_job->running) {
@@ -385,7 +392,8 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
}
-void WM_jobs_stop_all(wmWindowManager *wm)
+/* wait until every job ended */
+void WM_jobs_kill_all(wmWindowManager *wm)
{
wmJob *wm_job;
@@ -394,6 +402,18 @@ void WM_jobs_stop_all(wmWindowManager *wm)
}
+/* wait until every job ended, except for one owner (used in undo to keep screen job alive) */
+void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner)
+{
+ wmJob *wm_job;
+
+ for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ if (wm_job->owner != owner)
+ wm_jobs_kill_job(wm, wm_job);
+ }
+}
+
+
/* signal job(s) from this owner or callback to stop, timer is required to get handled */
void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
{
@@ -466,7 +486,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
if (wm_job->flag & WM_JOB_PROGRESS)
WM_event_add_notifier(C, NC_WM | ND_JOB, NULL);
wm_job->do_update = FALSE;
- }
+ }
if (wm_job->ready) {
if (wm_job->endjob)
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index bcddc984ed3..7aa2b403897 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -190,9 +190,9 @@ wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname)
return keyconf;
}
-void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
+int WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
{
- if (keyconf) {
+ if (BLI_findindex(&wm->keyconfigs, keyconf) != -1) {
if (strncmp(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr)) == 0) {
BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr));
WM_keyconfig_update_tag(NULL, NULL);
@@ -200,6 +200,11 @@ void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
BLI_remlink(&wm->keyconfigs, keyconf);
WM_keyconfig_free(keyconf);
+
+ return TRUE;
+ }
+ else {
+ return FALSE;
}
}
@@ -381,7 +386,7 @@ wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, const char *idname, int type,
return kmi;
}
-void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
+int WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
{
if (BLI_findindex(&keymap->items, kmi) != -1) {
if (kmi->ptr) {
@@ -391,6 +396,10 @@ void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
BLI_freelinkN(&keymap->items, kmi);
WM_keyconfig_update_tag(keymap, kmi);
+ return TRUE;
+ }
+ else {
+ return FALSE;
}
}
@@ -816,7 +825,7 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
static wmKeyMapItem *wm_keymap_item_find_handlers(
const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext),
- IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
+ IDProperty *properties, int is_strict, int hotkey, wmKeyMap **keymap_r)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler;
@@ -834,9 +843,22 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
if (hotkey)
if (!ISHOTKEY(kmi->type))
continue;
-
- if (compare_props) {
- if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
+
+ if (properties) {
+
+ /* example of debugging keymaps */
+#if 0
+ if (kmi->ptr) {
+ if (strcmp("MESH_OT_rip_move", opname) == 0) {
+ printf("OPERATOR\n");
+ IDP_spit(properties);
+ printf("KEYMAP\n");
+ IDP_spit(kmi->ptr->data);
+ }
+ }
+#endif
+
+ if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
if (keymap_r) *keymap_r = keymap;
return kmi;
}
@@ -857,7 +879,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
static wmKeyMapItem *wm_keymap_item_find_props(
const bContext *C, const char *opname, int opcontext,
- IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
+ IDProperty *properties, int is_strict, int hotkey, wmKeyMap **keymap_r)
{
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
@@ -866,10 +888,10 @@ static wmKeyMapItem *wm_keymap_item_find_props(
/* look into multiple handler lists to find the item */
if (win)
- found = wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ found = wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, is_strict, hotkey, keymap_r);
if (sa && found == NULL)
- found = wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ found = wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, is_strict, hotkey, keymap_r);
if (found == NULL) {
if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
@@ -878,7 +900,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar)
- found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, is_strict, hotkey, keymap_r);
}
}
else if (ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) {
@@ -886,18 +908,18 @@ static wmKeyMapItem *wm_keymap_item_find_props(
ar = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
if (ar)
- found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, is_strict, hotkey, keymap_r);
}
else if (ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) {
if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW))
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
if (ar)
- found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, is_strict, hotkey, keymap_r);
}
else {
if (ar)
- found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
+ found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, is_strict, hotkey, keymap_r);
}
}
@@ -906,12 +928,28 @@ static wmKeyMapItem *wm_keymap_item_find_props(
static wmKeyMapItem *wm_keymap_item_find(
const bContext *C, const char *opname, int opcontext,
- IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r)
+ IDProperty *properties, const short hotkey, const short UNUSED(sloppy), wmKeyMap **keymap_r)
{
wmKeyMapItem *found = wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r);
- if (!found && sloppy)
- found = wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r);
+ if (!found && properties) {
+ wmOperatorType *ot = WM_operatortype_find(opname, TRUE);
+ if (ot) {
+ /* make a copy of the properties and set any unset props
+ * to their default values, so the ID property compare function succeeds */
+ PointerRNA opptr;
+ IDProperty *properties_default = IDP_CopyProperty(properties);
+
+ RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
+
+ if (WM_operator_properties_default(&opptr, TRUE)) {
+ found = wm_keymap_item_find_props(C, opname, opcontext, properties_default, 0, hotkey, keymap_r);
+ }
+
+ IDP_FreeProperty(properties_default);
+ MEM_freeN(properties_default);
+ }
+ }
return found;
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index f8685dd7c79..962eb55996d 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -72,6 +72,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h" /* BKE_ST_MAXNAME */
+#include "BKE_utildefines.h"
#include "BKE_idcode.h"
@@ -80,6 +81,7 @@
#include "BLF_api.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -619,6 +621,42 @@ void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context)
RNA_STRUCT_END;
}
+
+/** set all props to their default,
+ * \param do_update Only update un-initialized props.
+ *
+ * \note, theres nothing spesific to operators here.
+ * this could be made a general function.
+ */
+int WM_operator_properties_default(PointerRNA *ptr, const int do_update)
+{
+ int is_change = FALSE;
+ RNA_STRUCT_BEGIN(ptr, prop)
+ {
+ switch (RNA_property_type(prop)) {
+ case PROP_POINTER:
+ {
+ StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
+ if (ptype != &RNA_Struct) {
+ PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
+ is_change |= WM_operator_properties_default(&opptr, do_update);
+ }
+ break;
+ }
+ default:
+ if ((do_update == FALSE) || (RNA_property_is_set(ptr, prop) == FALSE)) {
+ if (RNA_property_reset(ptr, prop, -1)) {
+ is_change = 1;
+ }
+ }
+ break;
+ }
+ }
+ RNA_STRUCT_END;
+
+ return is_change;
+}
+
/* remove all props without PROP_SKIP_SAVE */
void WM_operator_properties_reset(wmOperator *op)
{
@@ -674,6 +712,8 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
else {
pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = uiPupMenuLayout(pup);
+ /* set this so the default execution context is the same as submenus */
+ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
}
@@ -745,7 +785,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op)
wmOperator *op = (wmOperator *)arg_op;
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
#if 0 /* ok, this isn't so easy... */
uiDefBut(block, LABEL, 0, RNA_struct_ui_name(op->type->srna), 10, 10, 180, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -807,7 +847,7 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return WM_operator_call_notest(C, op); /* call exec direct */
- }
+ }
else {
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -857,12 +897,16 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
if (action == FILE_SAVE) {
+ /* note, this is only used to check if we should highlight the filename area red when the
+ * filepath is an existing file. */
prop = RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "filter_backup", (filter & BLENDERFILE_BACKUP), "Filter .blend files", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", "");
@@ -993,7 +1037,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockClearFlag(block, UI_BLOCK_LOOP);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
/* if register is not enabled, the operator gets freed on OPERATOR_FINISHED
* ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */
@@ -1071,7 +1115,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
/* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogs have many items
* where quitting by accident is very annoying */
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style);
@@ -1112,7 +1156,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockClearFlag(block, UI_BLOCK_LOOP);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style);
@@ -1162,7 +1206,7 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
if ((op->type->flag & OPTYPE_REGISTER) == 0) {
BKE_reportf(op->reports, RPT_ERROR,
- "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname);
+ "Operator '%s' does not have register enabled, incorrect invoke function", op->type->idname);
return OPERATOR_CANCELLED;
}
@@ -1193,11 +1237,12 @@ int WM_operator_redo_popup(bContext *C, wmOperator *op)
{
/* CTX_wm_reports(C) because operator is on stack, not active in event system */
if ((op->type->flag & OPTYPE_REGISTER) == 0) {
- BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s' does not have register enabled, incorrect invoke function.", op->type->idname);
+ BKE_reportf(CTX_wm_reports(C), RPT_ERROR,
+ "Operator redo '%s' does not have register enabled, incorrect invoke function", op->type->idname);
return OPERATOR_CANCELLED;
}
if (op->type->poll && op->type->poll(C) == 0) {
- BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context.", op->type->idname);
+ BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context", op->type->idname);
return OPERATOR_CANCELLED;
}
@@ -1214,7 +1259,7 @@ static int wm_debug_menu_exec(bContext *C, wmOperator *op)
ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
WM_event_add_notifier(C, NC_WINDOW, NULL);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
@@ -1233,7 +1278,7 @@ static void WM_OT_debug_menu(wmOperatorType *ot)
ot->exec = wm_debug_menu_exec;
ot->poll = WM_operator_winactive;
- RNA_def_int(ot->srna, "debug_value", 0, -10000, 10000, "Debug Value", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000);
}
@@ -1291,6 +1336,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
int i;
MenuType *mt = WM_menutype_find("USERPREF_MT_splash", TRUE);
char url[96];
+ char file [FILE_MAX];
#ifndef WITH_HEADLESS
extern char datatoc_splash_png[];
@@ -1316,10 +1362,14 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 5;
rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 5;
-#endif //WITH_BUILDINFO
+#endif /* WITH_BUILDINFO */
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
+
+ /* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized
+ * with the OS when the splash shows, window clipping in this case gives
+ * ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
but = uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
uiButSetFunc(but, wm_block_splash_close, block, NULL);
@@ -1328,7 +1378,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
#ifdef WITH_BUILDINFO
uiDefBut(block, LABEL, 0, version_buf, 494 - ver_width, 282 - 24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiDefBut(block, LABEL, 0, revision_buf, 494 - rev_width, 282 - 36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
-#endif //WITH_BUILDINFO
+#endif /* WITH_BUILDINFO */
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style);
@@ -1374,7 +1424,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiItemL(col, IFACE_("Recent"), ICON_NONE);
for (recent = G.recent_files.first, i = 0; (i < 5) && (recent); recent = recent->next, i++) {
- uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ BLI_split_file_part(recent->filepath, file, sizeof(file));
+ if (BLO_has_bfile_extension(file))
+ uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ else
+ uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
}
uiItemS(col);
@@ -1458,7 +1512,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_
uiBut *but;
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
@@ -1500,12 +1554,12 @@ static int wm_search_menu_poll(bContext *C)
else {
ScrArea *sa = CTX_wm_area(C);
if (sa) {
- if (sa->spacetype == SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console
- if (sa->spacetype == SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor
+ if (sa->spacetype == SPACE_CONSOLE) return 0; /* XXX - so we can use the shortcut in the console */
+ if (sa->spacetype == SPACE_TEXT) return 0; /* XXX - so we can use the spacebar in the text editor */
}
else {
Object *editob = CTX_data_edit_object(C);
- if (editob && editob->type == OB_FONT) return 0; // XXX - so we can use the spacebar for entering text
+ if (editob && editob->type == OB_FONT) return 0; /* XXX - so we can use the spacebar for entering text */
}
}
return 1;
@@ -1714,7 +1768,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev
{
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return WM_operator_call_notest(C, op);
- }
+ }
else {
/* XXX TODO solve where to get last linked library from */
if (G.lib[0] != '\0') {
@@ -1839,6 +1893,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
/* mark all library linked objects to be updated */
recalc_all_library_objects(bmain);
+ IMB_colormanagement_check_file_config(bmain);
/* append, rather than linking */
if ((flag & FILE_LINK) == 0) {
@@ -2024,7 +2079,6 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
char path[FILE_MAX];
int fileflags;
- int copy = 0;
save_set_compress(op);
@@ -2034,29 +2088,27 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
BLI_strncpy(path, G.main->name, FILE_MAX);
untitled(path);
}
-
- if (RNA_struct_property_is_set(op->ptr, "copy"))
- copy = RNA_boolean_get(op->ptr, "copy");
fileflags = G.fileflags;
/* set compression flag */
- if (RNA_boolean_get(op->ptr, "compress")) fileflags |= G_FILE_COMPRESS;
- else fileflags &= ~G_FILE_COMPRESS;
- if (RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP;
- else fileflags &= ~G_FILE_RELATIVE_REMAP;
+ BKE_BIT_TEST_SET(fileflags, RNA_boolean_get(op->ptr, "compress"),
+ G_FILE_COMPRESS);
+ BKE_BIT_TEST_SET(fileflags, RNA_boolean_get(op->ptr, "relative_remap"),
+ G_FILE_RELATIVE_REMAP);
+ BKE_BIT_TEST_SET(fileflags,
+ (RNA_struct_property_is_set(op->ptr, "copy") &&
+ RNA_boolean_get(op->ptr, "copy")),
+ G_FILE_SAVE_COPY);
+
#ifdef USE_BMESH_SAVE_AS_COMPAT
- /* property only exists for 'Save As' */
- if (RNA_struct_find_property(op->ptr, "use_mesh_compat")) {
- if (RNA_boolean_get(op->ptr, "use_mesh_compat")) fileflags |= G_FILE_MESH_COMPAT;
- else fileflags &= ~G_FILE_MESH_COMPAT;
- }
- else {
- fileflags &= ~G_FILE_MESH_COMPAT;
- }
+ BKE_BIT_TEST_SET(fileflags,
+ (RNA_struct_find_property(op->ptr, "use_mesh_compat") &&
+ RNA_boolean_get(op->ptr, "use_mesh_compat")),
+ G_FILE_MESH_COMPAT);
#endif
- if (WM_file_write(C, path, fileflags, op->reports, copy) != 0)
+ if (WM_file_write(C, path, fileflags, op->reports) != 0)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_WM | ND_FILESAVE, NULL);
@@ -2109,7 +2161,6 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
char name[FILE_MAX];
- int check_existing = 1;
int ret;
/* cancel if no active window */
@@ -2129,13 +2180,9 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
untitled(name);
RNA_string_set(op->ptr, "filepath", name);
-
- if (RNA_struct_find_property(op->ptr, "check_existing"))
- if (RNA_boolean_get(op->ptr, "check_existing") == 0)
- check_existing = 0;
-
+
if (G.save_over) {
- if (check_existing && BLI_exists(name)) {
+ if (BLI_exists(name)) {
uiPupMenuSaveOver(C, op, name);
ret = OPERATOR_RUNNING_MODAL;
}
@@ -2182,7 +2229,7 @@ static int wm_exit_blender_op(bContext *C, wmOperator *op)
{
WM_operator_free(op);
- WM_exit(C);
+ WM_exit(C);
return OPERATOR_FINISHED;
}
@@ -2280,10 +2327,10 @@ static int border_apply_rect(wmOperator *op)
/* operator arguments and storage. */
- RNA_int_set(op->ptr, "xmin", MIN2(rect->xmin, rect->xmax));
- RNA_int_set(op->ptr, "ymin", MIN2(rect->ymin, rect->ymax));
- RNA_int_set(op->ptr, "xmax", MAX2(rect->xmin, rect->xmax));
- RNA_int_set(op->ptr, "ymax", MAX2(rect->ymin, rect->ymax));
+ RNA_int_set(op->ptr, "xmin", min_ii(rect->xmin, rect->xmax));
+ RNA_int_set(op->ptr, "ymin", min_ii(rect->ymin, rect->ymax));
+ RNA_int_set(op->ptr, "xmax", max_ii(rect->xmin, rect->xmax));
+ RNA_int_set(op->ptr, "ymax", max_ii(rect->ymin, rect->ymax));
return 1;
}
@@ -3145,7 +3192,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
/* check flags */
if ((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) {
- BKE_reportf(op->reports, RPT_ERROR, "Property can't be both boolean and float");
+ BKE_report(op->reports, RPT_ERROR, "Property cannot be both boolean and float");
return 0;
}
@@ -3168,7 +3215,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
if (flags & RC_PROP_ALLOW_MISSING)
return 1;
else {
- BKE_reportf(op->reports, RPT_ERROR, "Couldn't resolve path %s", name);
+ BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name);
return 0;
}
}
@@ -3181,8 +3228,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
((flags & RC_PROP_REQUIRE_FLOAT) && prop_type != PROP_FLOAT))
{
MEM_freeN(str);
- BKE_reportf(op->reports, RPT_ERROR,
- "Property from path %s is not a float", name);
+ BKE_reportf(op->reports, RPT_ERROR, "Property from path '%s' is not a float", name);
return 0;
}
}
@@ -3190,8 +3236,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
/* check property's array length */
if (*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) {
MEM_freeN(str);
- BKE_reportf(op->reports, RPT_ERROR,
- "Property from path %s has length %d instead of %d",
+ BKE_reportf(op->reports, RPT_ERROR, "Property from path '%s' has length %d instead of %d",
name, len, req_length);
return 0;
}
@@ -3259,8 +3304,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
else if (rc->image_id_ptr.data) {
/* extra check, pointer must be to an ID */
if (!RNA_struct_is_ID(rc->image_id_ptr.type)) {
- BKE_report(op->reports, RPT_ERROR,
- "Pointer from path image_id is not an ID");
+ BKE_report(op->reports, RPT_ERROR, "Pointer from path image_id is not an ID");
return 0;
}
}
@@ -3501,7 +3545,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
if (type == 0) {
if (ar)
ED_region_do_draw(C, ar);
- }
+ }
else if (type == 1) {
wmWindow *win = CTX_wm_window(C);
@@ -3874,7 +3918,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_border");
- WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); // XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel
+ WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); /* XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel */
}
/* zoom to border modal operators */
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 7632344dfc3..b323f9d70a8 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -91,6 +91,8 @@ typedef struct PlayState {
short stopped;
short go;
+ int fstep;
+
/* current picture */
struct PlayAnimPict *picture;
@@ -215,7 +217,6 @@ typedef struct PlayAnimPict {
static struct ListBase picsbase = {NULL, NULL};
static int fromdisk = FALSE;
-static int fstep = 1;
static float zoomx = 1.0, zoomy = 1.0;
static double ptottime = 0.0, swaptime = 0.04;
@@ -231,7 +232,7 @@ static int pupdate_time(void)
return (ptottime < 0);
}
-static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid)
+static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
{
if (ibuf == NULL) {
@@ -289,7 +290,7 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
int pic;
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf) {
- playanim_toscreen(NULL, ibuf, fontid);
+ playanim_toscreen(NULL, ibuf, fontid, fstep);
IMB_freeImBuf(ibuf);
}
@@ -392,7 +393,7 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL);
}
if (ibuf) {
- playanim_toscreen(picture, ibuf, fontid);
+ playanim_toscreen(picture, ibuf, fontid, fstep);
IMB_freeImBuf(ibuf);
}
pupdate_time();
@@ -448,34 +449,34 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (val) ps->pingpong = !ps->pingpong;
break;
case GHOST_kKeyNumpad1:
- if (val) swaptime = fstep / 60.0;
+ if (val) swaptime = ps->fstep / 60.0;
break;
case GHOST_kKeyNumpad2:
- if (val) swaptime = fstep / 50.0;
+ if (val) swaptime = ps->fstep / 50.0;
break;
case GHOST_kKeyNumpad3:
- if (val) swaptime = fstep / 30.0;
+ if (val) swaptime = ps->fstep / 30.0;
break;
case GHOST_kKeyNumpad4:
if (g_WS.qual & WS_QUAL_SHIFT)
- swaptime = fstep / 24.0;
+ swaptime = ps->fstep / 24.0;
else
- swaptime = fstep / 25.0;
+ swaptime = ps->fstep / 25.0;
break;
case GHOST_kKeyNumpad5:
- if (val) swaptime = fstep / 20.0;
+ if (val) swaptime = ps->fstep / 20.0;
break;
case GHOST_kKeyNumpad6:
- if (val) swaptime = fstep / 15.0;
+ if (val) swaptime = ps->fstep / 15.0;
break;
case GHOST_kKeyNumpad7:
- if (val) swaptime = fstep / 12.0;
+ if (val) swaptime = ps->fstep / 12.0;
break;
case GHOST_kKeyNumpad8:
- if (val) swaptime = fstep / 10.0;
+ if (val) swaptime = ps->fstep / 10.0;
break;
case GHOST_kKeyNumpad9:
- if (val) swaptime = fstep / 6.0;
+ if (val) swaptime = ps->fstep / 6.0;
break;
case GHOST_kKeyLeftArrow:
if (val) {
@@ -533,10 +534,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (val) {
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->curframe_ibuf)
- printf(" Name: %s | Speed: %.2f frames/s\n", ps->curframe_ibuf->name, fstep / swaptime);
+ printf(" Name: %s | Speed: %.2f frames/s\n", ps->curframe_ibuf->name, ps->fstep / swaptime);
}
else {
- swaptime = fstep / 5.0;
+ swaptime = ps->fstep / 5.0;
}
}
break;
@@ -591,8 +592,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
break;
case GHOST_kKeyNumpadPlus:
if (val == 0) break;
- zoomx += 2.0;
- zoomy += 2.0;
+ zoomx += 2.0f;
+ zoomy += 2.0f;
/* no break??? - is this intentional? - campbell XXX25 */
case GHOST_kKeyNumpadMinus:
{
@@ -600,8 +601,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
/* int ofsx, ofsy; */ /* UNUSED */
if (val == 0) break;
- if (zoomx > 1.0) zoomx -= 1.0;
- if (zoomy > 1.0) zoomy -= 1.0;
+ if (zoomx > 1.0f) zoomx -= 1.0f;
+ if (zoomy > 1.0f) zoomy -= 1.0f;
// playanim_window_get_position(&ofsx, &ofsy);
playanim_window_get_size(&sizex, &sizey);
/* ofsx += sizex / 2; */ /* UNUSED */
@@ -666,10 +667,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
zoomx = (float) sizex / ps->ibufx;
zoomy = (float) sizey / ps->ibufy;
- zoomx = floor(zoomx + 0.5);
- zoomy = floor(zoomy + 0.5);
- if (zoomx < 1.0) zoomx = 1.0;
- if (zoomy < 1.0) zoomy = 1.0;
+ zoomx = floor(zoomx + 0.5f);
+ zoomy = floor(zoomy + 0.5f);
+ if (zoomx < 1.0f) zoomx = 1.0f;
+ if (zoomy < 1.0f) zoomy = 1.0f;
sizex = zoomx * ps->ibufx;
sizey = zoomy * ps->ibufy;
@@ -677,7 +678,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
glPixelZoom(zoomx, zoomy);
glEnable(GL_DITHER);
ptottime = 0.0;
- playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid);
+ playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid, ps->fstep);
break;
}
@@ -749,6 +750,8 @@ void WM_main_playanim(int argc, const char **argv)
ps.picture = NULL;
/* resetmap = FALSE */
+ ps.fstep = 1;
+
ps.fontid = -1;
while (argc > 1) {
@@ -796,8 +799,8 @@ void WM_main_playanim(int argc, const char **argv)
argv++;
break;
case 'j':
- fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
- swaptime *= fstep;
+ ps.fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
+ swaptime *= ps.fstep;
argc--;
argv++;
break;
@@ -896,11 +899,11 @@ void WM_main_playanim(int argc, const char **argv)
efra = MAXFRAME;
}
- build_pict_list(filepath, (efra - sfra) + 1, fstep, ps.fontid);
+ build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
for (i = 2; i < argc; i++) {
BLI_strncpy(filepath, argv[i], sizeof(filepath));
- build_pict_list(filepath, (efra - sfra) + 1, fstep, ps.fontid);
+ build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
}
IMB_freeImBuf(ibuf);
@@ -972,7 +975,7 @@ void WM_main_playanim(int argc, const char **argv)
while (pupdate_time()) PIL_sleep_ms(1);
ptottime -= swaptime;
- playanim_toscreen(ps.picture, ibuf, ps.fontid);
+ playanim_toscreen(ps.picture, ibuf, ps.fontid, ps.fstep);
} /* else deleten */
else {
printf("error: can't play this image type\n");
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 3ecadcc76b6..8a7cd8af34f 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -163,10 +163,6 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
win->curswin = swin = MEM_callocN(sizeof(wmSubWindow), "swinopen");
BLI_addtail(&win->subwindows, swin);
- if (G.debug & G_DEBUG_EVENTS) {
- printf("%s: swin %d added\n", __func__, freewinid);
- }
-
swin->swinid = freewinid;
swin->winrct = *winrct;
@@ -192,7 +188,7 @@ void wm_subwindow_close(wmWindow *win, int swinid)
wm_subwindow_free(swin);
BLI_remlink(&win->subwindows, swin);
MEM_freeN(swin);
- }
+ }
else {
printf("%s: Internal error, bad winid: %d\n", __func__, swinid);
}
@@ -408,7 +404,7 @@ int WM_framebuffer_to_index(unsigned int col)
return col & 0xFFFFFF;
default: // 18 bits...
return ((col & 0xFC0000) >> 6) + ((col & 0xFC00) >> 4) + ((col & 0xFC) >> 2);
- }
+ }
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index b5792e86e43..1da6328d7c8 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -164,7 +164,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
if (CTX_wm_window(C) == win)
CTX_wm_window_set(C, NULL);
- }
+ }
/* always set drawable and active to NULL,
* prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
@@ -300,11 +300,9 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
void wm_window_title(wmWindowManager *wm, wmWindow *win)
{
- /* handle the 'temp' window, only set title when not set before */
if (win->screen && win->screen->temp) {
- char *title = GHOST_GetTitle(win->ghostwin);
- if (title == NULL || title[0] == 0)
- GHOST_SetTitle(win->ghostwin, "Blender");
+ /* nothing to do for 'temp' windows,
+ * because WM_window_open_temp always sets window title */
}
else {
@@ -347,7 +345,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
(GHOST_TWindowState)win->windowstate,
GHOST_kDrawingContextTypeOpenGL,
0 /* no stereo */,
- 0 /* no AA */);
+ U.ogl_multisamples /* AA */);
if (ghostwin) {
/* needed so we can detect the graphics card below */
@@ -375,7 +373,6 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
/* standard state vars for window */
glEnable(GL_SCISSOR_TEST);
-
GPU_state_init();
}
}
@@ -416,6 +413,10 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
win->posy = wm_init_state.start_y;
win->sizex = wm_init_state.size_x;
win->sizey = wm_init_state.size_y;
+
+ /* we can't properly resize a maximized window */
+ win->windowstate = GHOST_kWindowStateNormal;
+
wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM;
}
@@ -650,7 +651,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
else if (!GHOST_ValidWindow(g_system, ghostwin)) {
/* XXX - should be checked, why are we getting an event here, and */
/* what is it? */
- puts("<!> event has invalid window");
+ puts("<!> event has invalid window");
return 1;
}
else {
@@ -943,6 +944,8 @@ static int wm_window_timer(const bContext *C)
wmEvent event = *(win->eventstate);
event.type = wt->event_type;
+ event.val = 0;
+ event.keymodifier = 0;
event.customdatatype = EVT_DATA_TIMER;
event.customdata = wt;
wm_event_add(win, &event);
@@ -1003,7 +1006,7 @@ void wm_ghost_init(bContext *C)
g_system = GHOST_CreateSystem();
GHOST_AddEventConsumer(g_system, consumer);
- }
+ }
}
void wm_ghost_exit(void)
@@ -1078,7 +1081,7 @@ char *WM_clipboard_text_get(int selection)
return NULL;
/* always convert from \r\n to \n */
- newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get");
+ newbuf = MEM_callocN(strlen(buf) + 1, __func__);
for (p = buf, p2 = newbuf; *p; p++) {
if (*p != '\r')
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index a33d37ac50e..2d0dd2ef911 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -32,10 +32,10 @@
#define __WM_EVENT_SYSTEM_H__
/* return value of handler-operator call */
-#define WM_HANDLER_CONTINUE 0
-#define WM_HANDLER_BREAK 1
-#define WM_HANDLER_HANDLED 2
-#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */
+#define WM_HANDLER_CONTINUE 0
+#define WM_HANDLER_BREAK 1
+#define WM_HANDLER_HANDLED 2
+#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */
struct ScrArea;
struct ARegion;
@@ -44,40 +44,40 @@ struct ARegion;
typedef struct wmEventHandler {
struct wmEventHandler *next, *prev;
-
- int type, flag; /* type default=0, rest is custom */
-
+
+ int type, flag; /* type default=0, rest is custom */
+
/* keymap handler */
- wmKeyMap *keymap; /* pointer to builtin/custom keymaps */
- rcti *bblocal, *bbwin; /* optional local and windowspace bb */
-
+ wmKeyMap *keymap; /* pointer to builtin/custom keymaps */
+ rcti *bblocal, *bbwin; /* optional local and windowspace bb */
+
/* modal operator handler */
- wmOperator *op; /* for derived/modal handlers */
- struct ScrArea *op_area; /* for derived/modal handlers */
- struct ARegion *op_region; /* for derived/modal handlers */
+ wmOperator *op; /* for derived/modal handlers */
+ struct ScrArea *op_area; /* for derived/modal handlers */
+ struct ARegion *op_region; /* for derived/modal handlers */
/* ui handler */
- wmUIHandlerFunc ui_handle; /* callback receiving events */
- wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */
- void *ui_userdata; /* user data pointer */
- struct ScrArea *ui_area; /* for derived/modal handlers */
- struct ARegion *ui_region; /* for derived/modal handlers */
- struct ARegion *ui_menu; /* for derived/modal handlers */
-
+ wmUIHandlerFunc ui_handle; /* callback receiving events */
+ wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */
+ void *ui_userdata; /* user data pointer */
+ struct ScrArea *ui_area; /* for derived/modal handlers */
+ struct ARegion *ui_region; /* for derived/modal handlers */
+ struct ARegion *ui_menu; /* for derived/modal handlers */
+
/* fileselect handler re-uses modal operator data */
- struct bScreen *filescreen; /* screen it started in, to validate exec */
-
+ struct bScreen *filescreen; /* screen it started in, to validate exec */
+
/* drop box handler */
ListBase *dropboxes;
-
+
} wmEventHandler;
/* handler flag */
/* after this handler all others are ignored */
-#define WM_HANDLER_BLOCKING 1
+#define WM_HANDLER_BLOCKING 1
/* handler tagged to be freed in wm_handlers_do() */
-#define WM_HANDLER_DO_FREE 2
+#define WM_HANDLER_DO_FREE 2
@@ -89,23 +89,23 @@ enum {
/* wm_event_system.c */
-void wm_event_free_all (wmWindow *win);
-void wm_event_free (wmEvent *event);
-void wm_event_free_handler (wmEventHandler *handler);
+void wm_event_free_all (wmWindow *win);
+void wm_event_free (wmEvent *event);
+void wm_event_free_handler (wmEventHandler *handler);
- /* goes over entire hierarchy: events -> window -> screen -> area -> region */
-void wm_event_do_handlers (bContext *C);
+ /* goes over entire hierarchy: events -> window -> screen -> area -> region */
+void wm_event_do_handlers (bContext *C);
-void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
+void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
-void wm_event_do_notifiers (bContext *C);
+void wm_event_do_notifiers (bContext *C);
/* wm_keymap.c */
/* wm_dropbox.c */
-void wm_dropbox_free(void);
-void wm_drags_check_ops(bContext *C, wmEvent *event);
-void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
+void wm_dropbox_free(void);
+void wm_drags_check_ops(bContext *C, wmEvent *event);
+void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
#endif /* __WM_EVENT_SYSTEM_H__ */
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 7dbc25883ad..62baa328654 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -287,8 +287,9 @@ enum {
/* for event checks */
/* only used for KM_TEXTINPUT, so assume that we want all user-inputtable ascii codes included */
+ /* UNUSED - see wm_eventmatch - BUG [#30479]
#define ISTEXTINPUT(event) (event >= ' ' && event <= 255)
-
+ */
/* test whether the event is a key on the keyboard */
#define ISKEYBOARD(event) (event >= ' ' && event <= 320)