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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-09-23 22:50:56 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-09-23 22:50:56 +0400
commita42ba82f638e481d7fd3c3ed2ba05c331ef6717e (patch)
tree81a2b9221799707b49b74a5df8bb3ff964ba78bd /source/blender
parent7afbdff1b6c348227e652e1c3071ab7ba7c91c44 (diff)
parenta73dd3476e7d180d3320afc04d218ce22f2f3bfc (diff)
Merged changes in the trunk up to revision 50829.
Conflicts resolved: source/blender/blenloader/intern/readfile.c source/blender/render/intern/source/convertblender.c source/blender/render/intern/source/pipeline.c Also addressed code inconsistency due to changes in the trunk revision 50628 (color management with OCIO) and 50806 (UV project material). OCIO-related changes are marked OCIO_TODO as in some other files modified in revision 50628.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/avi/intern/avi.c21
-rw-r--r--source/blender/blenfont/BLF_api.h3
-rw-r--r--source/blender/blenfont/CMakeLists.txt1
-rw-r--r--source/blender/blenfont/SConscript2
-rw-r--r--source/blender/blenfont/intern/blf.c5
-rw-r--r--source/blender/blenfont/intern/blf_font.c23
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c2
-rw-r--r--source/blender/blenfont/intern/blf_internal.h4
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h4
-rw-r--r--source/blender/blenfont/intern/blf_lang.c4
-rw-r--r--source/blender/blenkernel/BKE_blender.h4
-rw-r--r--source/blender/blenkernel/BKE_colortools.h27
-rw-r--r--source/blender/blenkernel/BKE_curve.h2
-rw-r--r--source/blender/blenkernel/BKE_customdata.h2
-rw-r--r--source/blender/blenkernel/BKE_group.h4
-rw-r--r--source/blender/blenkernel/BKE_image.h5
-rw-r--r--source/blender/blenkernel/BKE_key.h50
-rw-r--r--source/blender/blenkernel/BKE_mask.h7
-rw-r--r--source/blender/blenkernel/BKE_node.h5
-rw-r--r--source/blender/blenkernel/BKE_object.h1
-rw-r--r--source/blender/blenkernel/BKE_property.h27
-rw-r--r--source/blender/blenkernel/BKE_sca.h2
-rw-r--r--source/blender/blenkernel/BKE_scene.h2
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h12
-rw-r--r--source/blender/blenkernel/CMakeLists.txt4
-rw-r--r--source/blender/blenkernel/SConscript7
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c4
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c8
-rw-r--r--source/blender/blenkernel/intern/action.c472
-rw-r--r--source/blender/blenkernel/intern/blender.c14
-rw-r--r--source/blender/blenkernel/intern/cloth.c35
-rw-r--r--source/blender/blenkernel/intern/collision.c2
-rw-r--r--source/blender/blenkernel/intern/colortools.c98
-rw-r--r--source/blender/blenkernel/intern/constraint.c55
-rw-r--r--source/blender/blenkernel/intern/curve.c27
-rw-r--r--source/blender/blenkernel/intern/customdata.c28
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c4
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c21
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c4
-rw-r--r--source/blender/blenkernel/intern/group.c64
-rw-r--r--source/blender/blenkernel/intern/icons.c4
-rw-r--r--source/blender/blenkernel/intern/idprop.c4
-rw-r--r--source/blender/blenkernel/intern/image.c115
-rw-r--r--source/blender/blenkernel/intern/image_gen.c6
-rw-r--r--source/blender/blenkernel/intern/implicit.c22
-rw-r--r--source/blender/blenkernel/intern/key.c95
-rw-r--r--source/blender/blenkernel/intern/mask.c5
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c10
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/blenkernel/intern/mball.c18
-rw-r--r--source/blender/blenkernel/intern/mesh.c7
-rw-r--r--source/blender/blenkernel/intern/modifier.c2
-rw-r--r--source/blender/blenkernel/intern/movieclip.c21
-rw-r--r--source/blender/blenkernel/intern/object.c189
-rw-r--r--source/blender/blenkernel/intern/ocean.c9
-rw-r--r--source/blender/blenkernel/intern/particle.c4
-rw-r--r--source/blender/blenkernel/intern/particle_system.c5
-rw-r--r--source/blender/blenkernel/intern/property.c65
-rw-r--r--source/blender/blenkernel/intern/sca.c25
-rw-r--r--source/blender/blenkernel/intern/scene.c36
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c9
-rw-r--r--source/blender/blenkernel/intern/seqmodifier.c41
-rw-r--r--source/blender/blenkernel/intern/sequencer.c135
-rw-r--r--source/blender/blenkernel/intern/smoke.c6
-rw-r--r--source/blender/blenkernel/intern/softbody.c4
-rw-r--r--source/blender/blenkernel/intern/sound.c1
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c12
-rw-r--r--source/blender/blenkernel/intern/text.c27
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenkernel/intern/tracking.c41
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c2
-rw-r--r--source/blender/blenlib/BLI_dynstr.h7
-rw-r--r--source/blender/blenlib/BLI_endian_switch.h38
-rw-r--r--source/blender/blenlib/BLI_fileops_types.h2
-rw-r--r--source/blender/blenlib/BLI_math_base.h4
-rw-r--r--source/blender/blenlib/BLI_math_color.h4
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/BLI_rect.h28
-rw-r--r--source/blender/blenlib/BLI_string.h6
-rw-r--r--source/blender/blenlib/BLI_threads.h1
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c2
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c11
-rw-r--r--source/blender/blenlib/intern/boxpack2d.c16
-rw-r--r--source/blender/blenlib/intern/fileops.c22
-rw-r--r--source/blender/blenlib/intern/freetypefont.c3
-rw-r--r--source/blender/blenlib/intern/math_color.c6
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c15
-rw-r--r--source/blender/blenlib/intern/math_matrix.c18
-rw-r--r--source/blender/blenlib/intern/math_rotation.c4
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c9
-rw-r--r--source/blender/blenlib/intern/md5.c2
-rw-r--r--source/blender/blenlib/intern/noise.c3
-rw-r--r--source/blender/blenlib/intern/path_util.c2
-rw-r--r--source/blender/blenlib/intern/pbvh.c6
-rw-r--r--source/blender/blenlib/intern/rct.c37
-rw-r--r--source/blender/blenlib/intern/scanfill.c4
-rw-r--r--source/blender/blenlib/intern/storage.c2
-rw-r--r--source/blender/blenlib/intern/string_cursor_utf8.c2
-rw-r--r--source/blender/blenlib/intern/threads.c5
-rw-r--r--source/blender/blenlib/intern/uvproject.c2
-rw-r--r--source/blender/blenlib/intern/voronoi.c12
-rw-r--r--source/blender/blenlib/intern/winstuff.c2
-rw-r--r--source/blender/blenloader/BLO_readfile.h3
-rw-r--r--source/blender/blenloader/intern/readfile.c135
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c6
-rw-r--r--source/blender/blenloader/intern/writefile.c11
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c2
-rw-r--r--source/blender/bmesh/operators/bmo_create.c2
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c2
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c2
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c4
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c146
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c6
-rw-r--r--source/blender/bmesh/operators/bmo_wireframe.c2
-rw-r--r--source/blender/bmesh/tools/BME_bevel.c10
-rw-r--r--source/blender/collada/collada.cpp1
-rw-r--r--source/blender/compositor/COM_compositor.h15
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp12
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h26
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp6
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h4
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp10
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp2
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp8
-rw-r--r--source/blender/compositor/intern/COM_Node.h4
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.h2
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h2
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.h2
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp3
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp8
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp22
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp62
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp7
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp13
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SplitViewerOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.h13
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp16
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c72
-rw-r--r--source/blender/editors/animation/anim_deps.c2
-rw-r--r--source/blender/editors/animation/anim_filter.c63
-rw-r--r--source/blender/editors/animation/anim_markers.c4
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c7
-rw-r--r--source/blender/editors/animation/keyframing.c4
-rw-r--r--source/blender/editors/armature/editarmature.c4
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c30
-rw-r--r--source/blender/editors/armature/meshlaplacian.c2
-rw-r--r--source/blender/editors/armature/poseobject.c111
-rw-r--r--source/blender/editors/curve/editcurve.c15
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c24
-rw-r--r--source/blender/editors/include/ED_armature.h1
-rw-r--r--source/blender/editors/include/ED_clip.h2
-rw-r--r--source/blender/editors/include/ED_curve.h2
-rw-r--r--source/blender/editors/include/ED_image.h3
-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.h2
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/include/ED_sequencer.h2
-rw-r--r--source/blender/editors/include/ED_util.h2
-rw-r--r--source/blender/editors/include/ED_view3d.h139
-rw-r--r--source/blender/editors/include/UI_interface.h18
-rw-r--r--source/blender/editors/include/UI_view2d.h18
-rw-r--r--source/blender/editors/interface/interface.c94
-rw-r--r--source/blender/editors/interface/interface_draw.c117
-rw-r--r--source/blender/editors/interface/interface_handlers.c405
-rw-r--r--source/blender/editors/interface/interface_icons.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h25
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/editors/interface/interface_ops.c22
-rw-r--r--source/blender/editors/interface/interface_panel.c24
-rw-r--r--source/blender/editors/interface/interface_regions.c109
-rw-r--r--source/blender/editors/interface/interface_style.c12
-rw-r--r--source/blender/editors/interface/interface_templates.c174
-rw-r--r--source/blender/editors/interface/interface_widgets.c306
-rw-r--r--source/blender/editors/interface/view2d.c143
-rw-r--r--source/blender/editors/interface/view2d_ops.c82
-rw-r--r--source/blender/editors/io/io_collada.c54
-rw-r--r--source/blender/editors/io/io_ops.c2
-rw-r--r--source/blender/editors/mask/mask_add.c4
-rw-r--r--source/blender/editors/mask/mask_draw.c8
-rw-r--r--source/blender/editors/mask/mask_editaction.c1
-rw-r--r--source/blender/editors/mesh/editface.c4
-rw-r--r--source/blender/editors/mesh/editmesh_add.c65
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.c4
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c16
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c4
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c12
-rw-r--r--source/blender/editors/mesh/editmesh_select.c9
-rw-r--r--source/blender/editors/mesh/editmesh_slide.c8
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c41
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c15
-rw-r--r--source/blender/editors/mesh/mesh_data.c183
-rw-r--r--source/blender/editors/mesh/mesh_intern.h6
-rw-r--r--source/blender/editors/mesh/mesh_ops.c5
-rw-r--r--source/blender/editors/mesh/meshtools.c96
-rw-r--r--source/blender/editors/metaball/mball_edit.c3
-rw-r--r--source/blender/editors/object/object_add.c8
-rw-r--r--source/blender/editors/object/object_bake.c13
-rw-r--r--source/blender/editors/object/object_edit.c20
-rw-r--r--source/blender/editors/object/object_hook.c6
-rw-r--r--source/blender/editors/object/object_lattice.c4
-rw-r--r--source/blender/editors/object/object_modifier.c19
-rw-r--r--source/blender/editors/object/object_select.c2
-rw-r--r--source/blender/editors/object/object_shapekey.c22
-rw-r--r--source/blender/editors/physics/particle_edit.c14
-rw-r--r--source/blender/editors/physics/physics_fluid.c4
-rw-r--r--source/blender/editors/render/render_internal.c30
-rw-r--r--source/blender/editors/render/render_opengl.c90
-rw-r--r--source/blender/editors/render/render_preview.c46
-rw-r--r--source/blender/editors/screen/area.c54
-rw-r--r--source/blender/editors/screen/glutil.c20
-rw-r--r--source/blender/editors/screen/screen_edit.c6
-rw-r--r--source/blender/editors/screen/screen_ops.c61
-rw-r--r--source/blender/editors/screen/screendump.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c58
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c111
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c19
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c4
-rw-r--r--source/blender/editors/space_action/action_draw.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c4
-rw-r--r--source/blender/editors/space_action/action_select.c5
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c2
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c7
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_draw.c33
-rw-r--r--source/blender/editors/space_clip/clip_editor.c43
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c4
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c8
-rw-r--r--source/blender/editors/space_clip/clip_ops.c8
-rw-r--r--source/blender/editors/space_clip/space_clip.c4
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/file_intern.h1
-rw-r--r--source/blender/editors/space_file/file_ops.c41
-rw-r--r--source/blender/editors/space_file/file_panels.c19
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/editors/space_file/filesel.c8
-rw-r--r--source/blender/editors/space_file/fsmenu.c189
-rw-r--r--source/blender/editors/space_file/fsmenu.h8
-rw-r--r--source/blender/editors/space_file/space_file.c3
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c6
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c4
-rw-r--r--source/blender/editors/space_graph/graph_select.c2
-rw-r--r--source/blender/editors/space_image/image_buttons.c109
-rw-r--r--source/blender/editors/space_image/image_draw.c131
-rw-r--r--source/blender/editors/space_image/image_edit.c8
-rw-r--r--source/blender/editors/space_image/image_intern.h2
-rw-r--r--source/blender/editors/space_image/image_ops.c136
-rw-r--r--source/blender/editors/space_image/space_image.c21
-rw-r--r--source/blender/editors/space_info/info_stats.c2
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c8
-rw-r--r--source/blender/editors/space_logic/logic_window.c2658
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c3
-rw-r--r--source/blender/editors/space_nla/nla_edit.c7
-rw-r--r--source/blender/editors/space_nla/nla_select.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c116
-rw-r--r--source/blender/editors/space_node/node_draw.c24
-rw-r--r--source/blender/editors/space_node/node_edit.c9
-rw-r--r--source/blender/editors/space_node/node_header.c2
-rw-r--r--source/blender/editors/space_node/node_intern.h2
-rw-r--r--source/blender/editors/space_node/node_select.c4
-rw-r--r--source/blender/editors/space_node/node_templates.c2
-rw-r--r--source/blender/editors/space_node/node_view.c34
-rw-r--r--source/blender/editors/space_node/space_node.c1
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c9
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c147
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c20
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c46
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c66
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c15
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c52
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_text/text_header.c5
-rw-r--r--source/blender/editors/space_text/text_ops.c13
-rw-r--r--source/blender/editors/space_text/text_python.c4
-rw-r--r--source/blender/editors/space_time/time_ops.c2
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c26
-rw-r--r--source/blender/editors/space_view3d/drawobject.c17
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c114
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c68
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c25
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c39
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c180
-rw-r--r--source/blender/editors/transform/transform.c112
-rw-r--r--source/blender/editors/transform/transform_conversions.c25
-rw-r--r--source/blender/editors/transform/transform_snap.c14
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c2
-rwxr-xr-xsource/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp6
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Canvas.cpp3
-rw-r--r--source/blender/gpu/GPU_buffers.h5
-rw-r--r--source/blender/gpu/GPU_draw.h4
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c109
-rw-r--r--source/blender/gpu/intern/gpu_draw.c53
-rw-r--r--source/blender/gpu/intern/gpu_material.c8
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp2
-rw-r--r--source/blender/imbuf/CMakeLists.txt10
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h156
-rw-r--r--source/blender/imbuf/IMB_imbuf.h20
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h21
-rw-r--r--source/blender/imbuf/SConscript4
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h1
-rw-r--r--source/blender/imbuf/intern/IMB_colormanagement_intern.h93
-rw-r--r--source/blender/imbuf/intern/IMB_filetype.h25
-rw-r--r--source/blender/imbuf/intern/IMB_metadata.h2
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c16
-rw-r--r--source/blender/imbuf/intern/anim_movie.c37
-rw-r--r--source/blender/imbuf/intern/bmp.c8
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c15
-rw-r--r--source/blender/imbuf/intern/colormanagement.c2436
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp6
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp12
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.h4
-rw-r--r--source/blender/imbuf/intern/divers.c139
-rw-r--r--source/blender/imbuf/intern/filetype.c30
-rw-r--r--source/blender/imbuf/intern/indexer.c3
-rw-r--r--source/blender/imbuf/intern/indexer_dv.c2
-rw-r--r--source/blender/imbuf/intern/iris.c23
-rw-r--r--source/blender/imbuf/intern/jp2.c155
-rw-r--r--source/blender/imbuf/intern/jpeg.c14
-rw-r--r--source/blender/imbuf/intern/metadata.c2
-rw-r--r--source/blender/imbuf/intern/moviecache.c2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp41
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.h2
-rw-r--r--source/blender/imbuf/intern/png.c41
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c8
-rw-r--r--source/blender/imbuf/intern/readimage.c38
-rw-r--r--source/blender/imbuf/intern/rectop.c16
-rw-r--r--source/blender/imbuf/intern/scaling.c2
-rw-r--r--source/blender/imbuf/intern/targa.c15
-rw-r--r--source/blender/imbuf/intern/thumbs.c11
-rw-r--r--source/blender/imbuf/intern/tiff.c15
-rw-r--r--source/blender/imbuf/intern/util.c2
-rw-r--r--source/blender/imbuf/intern/writeimage.c36
-rw-r--r--source/blender/makesdna/DNA_color_types.h22
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h4
-rw-r--r--source/blender/makesdna/DNA_image_types.h5
-rw-r--r--source/blender/makesdna/DNA_key_types.h2
-rw-r--r--source/blender/makesdna/DNA_material_types.h14
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h3
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h9
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h4
-rw-r--r--source/blender/makesdna/DNA_scene_types.h28
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h13
-rw-r--r--source/blender/makesdna/DNA_space_types.h8
-rw-r--r--source/blender/makesrna/RNA_access.h3
-rw-r--r--source/blender/makesrna/intern/rna_ID.c10
-rw-r--r--source/blender/makesrna/intern/rna_access.c4
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c5
-rw-r--r--source/blender/makesrna/intern/rna_animation.c2
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c1
-rw-r--r--source/blender/makesrna/intern/rna_armature.c4
-rw-r--r--source/blender/makesrna/intern/rna_armature_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_camera_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_color.c250
-rw-r--r--source/blender/makesrna/intern/rna_controller.c2
-rw-r--r--source/blender/makesrna/intern/rna_controller_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_curve.c6
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c4
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c2
-rw-r--r--source/blender/makesrna/intern/rna_image.c12
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c20
-rw-r--r--source/blender/makesrna/intern/rna_internal.h22
-rw-r--r--source/blender/makesrna/intern/rna_key.c6
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c156
-rw-r--r--source/blender/makesrna/intern/rna_mask.c4
-rw-r--r--source/blender/makesrna/intern/rna_material.c8
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c32
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c4
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c9
-rw-r--r--source/blender/makesrna/intern/rna_nla.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c4
-rw-r--r--source/blender/makesrna/intern/rna_object.c8
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c14
-rw-r--r--source/blender/makesrna/intern/rna_particle.c2
-rw-r--r--source/blender/makesrna/intern/rna_pose.c18
-rw-r--r--source/blender/makesrna/intern/rna_property.c4
-rw-r--r--source/blender/makesrna/intern/rna_scene.c68
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_screen.c4
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c2
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c5
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c5
-rw-r--r--source/blender/makesrna/intern/rna_space.c29
-rw-r--r--source/blender/makesrna/intern/rna_texture_api.c10
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c8
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c14
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c15
-rw-r--r--source/blender/makesrna/intern/rna_wm.c8
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c6
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c4
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c8
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c8
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c12
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c64
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c8
-rw-r--r--source/blender/nodes/composite/node_composite_util.c5
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c33
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_outputFile.c3
-rw-r--r--source/blender/nodes/intern/node_common.c2
-rw-r--r--source/blender/nodes/intern/node_util.h2
-rw-r--r--source/blender/nodes/texture/node_texture_util.c2
-rw-r--r--source/blender/nodes/texture/node_texture_util.h2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c4
-rw-r--r--source/blender/python/intern/CMakeLists.txt1
-rw-r--r--source/blender/python/intern/bpy.c4
-rw-r--r--source/blender/python/intern/bpy.h5
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.c9
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c2
-rw-r--r--source/blender/python/intern/bpy_interface.c27
-rw-r--r--source/blender/python/intern/bpy_interface_atexit.c1
-rw-r--r--source/blender/python/intern/bpy_library.c3
-rw-r--r--source/blender/python/intern/bpy_library.h32
-rw-r--r--source/blender/python/intern/bpy_rna.c18
-rw-r--r--source/blender/python/intern/bpy_rna.h4
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c3
-rw-r--r--source/blender/python/intern/gpu.c3
-rw-r--r--source/blender/python/intern/stubs.c11
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c2
-rw-r--r--source/blender/quicktime/apple/qtkit_import.m1
-rw-r--r--source/blender/quicktime/apple/quicktime_import.c2
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h2
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h7
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h3
-rw-r--r--source/blender/render/intern/include/render_result.h8
-rw-r--r--source/blender/render/intern/include/renderdatabase.h2
-rw-r--r--source/blender/render/intern/include/zbuf.h5
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.cpp2
-rw-r--r--source/blender/render/intern/raytrace/rayobject_vbvh.cpp4
-rw-r--r--source/blender/render/intern/source/convertblender.c97
-rw-r--r--source/blender/render/intern/source/envmap.c3
-rw-r--r--source/blender/render/intern/source/gammaCorrectionTables.c2
-rw-r--r--source/blender/render/intern/source/imagetexture.c14
-rw-r--r--source/blender/render/intern/source/initrender.c4
-rw-r--r--source/blender/render/intern/source/occlusion.c1
-rw-r--r--source/blender/render/intern/source/pipeline.c108
-rw-r--r--source/blender/render/intern/source/render_result.c59
-rw-r--r--source/blender/render/intern/source/render_texture.c45
-rw-r--r--source/blender/render/intern/source/rendercore.c45
-rw-r--r--source/blender/render/intern/source/renderdatabase.c27
-rw-r--r--source/blender/render/intern/source/shadbuf.c7
-rw-r--r--source/blender/render/intern/source/shadeinput.c204
-rw-r--r--source/blender/render/intern/source/strand.c5
-rw-r--r--source/blender/render/intern/source/texture_ocean.c2
-rw-r--r--source/blender/render/intern/source/zbuf.c6
-rw-r--r--source/blender/windowmanager/WM_api.h20
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c13
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c4
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c4
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c23
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c3
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c4
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c36
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c12
-rw-r--r--source/blender/windowmanager/intern/wm_window.c8
505 files changed, 8897 insertions, 7733 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c
index cda2cf303eb..2845b2f95c9 100644
--- a/source/blender/avi/intern/avi.c
+++ b/source/blender/avi/intern/avi.c
@@ -734,16 +734,15 @@ AviError AVI_close(AviMovie *movie)
fclose(movie->fp);
- for (i = 0; movie->header && (i < movie->header->Streams); i++) {
- if (movie->streams && (movie->streams[i].sf != NULL)) {
+ for (i = 0; i < movie->header->Streams; i++) {
+ if (movie->streams[i].sf != NULL) {
MEM_freeN(movie->streams[i].sf);
}
}
- if (movie->header != NULL)
- MEM_freeN(movie->header);
- if (movie->streams != NULL)
- MEM_freeN(movie->streams);
+ MEM_freeN(movie->header);
+ MEM_freeN(movie->streams);
+
if (movie->entries != NULL)
MEM_freeN(movie->entries);
if (movie->offset_table != NULL)
@@ -1082,15 +1081,15 @@ AviError AVI_close_compress(AviMovie *movie)
fclose(movie->fp);
- for (i = 0; movie->header && (i < movie->header->Streams); i++) {
+ for (i = 0; i < movie->header->Streams; i++) {
if (movie->streams && (movie->streams[i].sf != NULL)) {
MEM_freeN(movie->streams[i].sf);
}
}
- if (movie->header != NULL)
- MEM_freeN(movie->header);
- if (movie->entries != NULL)
- MEM_freeN(movie->entries);
+
+ MEM_freeN(movie->header);
+ MEM_freeN(movie->entries);
+
if (movie->streams != NULL)
MEM_freeN(movie->streams);
if (movie->offset_table != NULL)
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 0732e02b5fc..ce10951d6ff 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -33,6 +33,7 @@
#define __BLF_API_H__
struct rctf;
+struct ColorManagedDisplay;
int BLF_init(int points, int dpi);
void BLF_exit(void);
@@ -151,7 +152,7 @@ void BLF_shadow_offset(int fontid, int x, int y);
*
* BLF_buffer(NULL, NULL, 0, 0, 0, FALSE);
*/
-void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management);
+void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display);
/* Set the color to be used for text. */
void BLF_buffer_col(int fontid, float r, float g, float b, float a);
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index ebf9ff4db39..da60710a137 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INC
../blenlib
../editors/include
../makesdna
+ ../imbuf
../../../intern/guardedalloc
)
diff --git a/source/blender/blenfont/SConscript b/source/blender/blenfont/SConscript
index c46960d2311..d3c7b1c2fcc 100644
--- a/source/blender/blenfont/SConscript
+++ b/source/blender/blenfont/SConscript
@@ -4,7 +4,7 @@ Import ('env')
sources = env.Glob('intern/*.c')
-incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../editors/include'
+incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../imbuf ../editors/include'
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 d4739b37f93..92fcb576e7d 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -50,7 +50,6 @@
#include "blf_internal_types.h"
#include "blf_internal.h"
-
/* Max number of font in memory.
* Take care that now every font have a glyph cache per size/dpi,
* so we don't need load the same font with different size, just
@@ -746,7 +745,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, int do_color_management)
+void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display)
{
FontBLF *font = BLF_get(fontid);
@@ -756,7 +755,7 @@ void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int
font->buf_info.w = w;
font->buf_info.h = h;
font->buf_info.ch = nch;
- font->buf_info.do_color_management = do_color_management;
+ font->buf_info.display = display;
}
}
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index ab43804db8e..1900efa2dbc 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -53,6 +53,8 @@
#include "BIF_gl.h"
#include "BLF_api.h"
+#include "IMB_colormanagement.h"
+
#include "blf_internal_types.h"
#include "blf_internal.h"
@@ -159,7 +161,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
} \
} (void)0
-void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
+void blf_font_draw(FontBLF *font, const char *str, size_t len)
{
unsigned int c;
GlyphBLF *g, *g_prev = NULL;
@@ -172,7 +174,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
blf_font_ensure_ascii_table(font);
- while (str[i] && i < len) {
+ while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
if (c == BLI_UTF8_ERR)
@@ -191,7 +193,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
}
/* faster version of blf_font_draw, ascii only for view dimensions */
-void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len)
+void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
{
unsigned char c;
GlyphBLF *g, *g_prev = NULL;
@@ -245,11 +247,12 @@ void blf_font_buffer(FontBLF *font, const char *str)
blf_font_ensure_ascii_table(font);
/* another buffer specific call for color conversion */
- if (buf_info->do_color_management) {
- srgb_to_linearrgb_v4(b_col_float, buf_info->col);
+ if (buf_info->display) {
+ copy_v4_v4(b_col_float, buf_info->col);
+ IMB_colormanagement_display_to_scene_linear_v3(b_col_float, buf_info->display);
}
else {
- copy_v4_v4(b_col_float, buf_info->col);
+ srgb_to_linearrgb_v4(b_col_float, buf_info->col);
}
while (str[i]) {
@@ -427,8 +430,8 @@ void blf_font_width_and_height(FontBLF *font, const char *str, float *width, flo
}
blf_font_boundbox(font, str, &box);
- *width = (BLI_RCT_SIZE_X(&box) * xa);
- *height = (BLI_RCT_SIZE_Y(&box) * ya);
+ *width = (BLI_rctf_size_x(&box) * xa);
+ *height = (BLI_rctf_size_y(&box) * ya);
}
float blf_font_width(FontBLF *font, const char *str)
@@ -442,7 +445,7 @@ float blf_font_width(FontBLF *font, const char *str)
xa = 1.0f;
blf_font_boundbox(font, str, &box);
- return BLI_RCT_SIZE_X(&box) * xa;
+ return BLI_rctf_size_x(&box) * xa;
}
float blf_font_height(FontBLF *font, const char *str)
@@ -456,7 +459,7 @@ float blf_font_height(FontBLF *font, const char *str)
ya = 1.0f;
blf_font_boundbox(font, str, &box);
- return BLI_RCT_SIZE_Y(&box) * ya;
+ return BLI_rctf_size_y(&box) * ya;
}
float blf_font_fixed_width(FontBLF *font)
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 63225651e5b..91ecded88be 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -415,7 +415,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
g->uv[1][1] = ((float)(g->yoff + g->height)) / ((float)gc->p2_height);
/* update the x offset for the next glyph. */
- gc->x_offs += (int)(BLI_RCT_SIZE_X(&g->box) + gc->pad);
+ gc->x_offs += (int)(BLI_rctf_size_x(&g->box) + gc->pad);
gc->rem_glyphs--;
g->build_tex = 1;
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index ba66fce8374..65a54783978 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -51,8 +51,8 @@ struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size);
void blf_font_size(struct FontBLF *font, int size, int dpi);
-void blf_font_draw(struct FontBLF *font, const char *str, unsigned int len);
-void blf_font_draw_ascii(struct FontBLF *font, const char *str, unsigned int len);
+void blf_font_draw(struct FontBLF *font, const char *str, size_t len);
+void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len);
void blf_font_buffer(struct FontBLF *font, const char *str);
void blf_font_boundbox(struct FontBLF *font, const char *str, struct rctf *box);
void blf_font_width_and_height(struct FontBLF *font, const char *str, float *width, float *height);
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index 4c617da7583..1acc3dad4cf 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -145,8 +145,8 @@ typedef struct FontBufInfoBLF {
/* number of channels. */
int ch;
- /* is the float buffer linear */
- int do_color_management;
+ /* display device used for color management */
+ struct ColorManagedDisplay *display;
/* and the color, the alphas is get from the glyph!
* color is srgb space */
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index 2b7e225d709..d0b77222114 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -129,7 +129,7 @@ void BLF_lang_init(void)
}
/* get LANG/LANGUAGE environment variable */
-static void get_language_variable(const char *varname, char *var, int maxlen)
+static void get_language_variable(const char *varname, char *var, const size_t maxlen)
{
char *env = getenv(varname);
@@ -149,7 +149,7 @@ static void get_language_variable(const char *varname, char *var, int maxlen)
/* get language to be used based on locale(which might be empty when using default language) and
* LANG environment variable
*/
-static void get_language(const char *locale, const char *lang, char *language, int maxlen)
+static void get_language(const char *locale, const char *lang, char *language, const size_t maxlen)
{
if (locale[0]) {
BLI_strncpy(language, locale, maxlen);
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 1e67027ae8c..db1139c9c7b 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 263
-#define BLENDER_SUBVERSION 18
+#define BLENDER_SUBVERSION 21
/* 262 was the last editmesh release but its has compatibility code for bmesh data,
* so set the minversion to 2.61 */
@@ -53,7 +53,7 @@ extern "C" {
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR a
/* alpha/beta/rc/release, docs use this */
-#define BLENDER_VERSION_CYCLE beta
+#define BLENDER_VERSION_CYCLE rc
extern char versionstr[]; /* from blender.c */
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index 9ce2de79dbf..728f88b3c16 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -31,6 +31,9 @@
* \ingroup bke
*/
+struct ColorManagedColorspaceSettings;
+struct ColorManagedDisplaySettings;
+struct ColorManagedViewSettings;
struct CurveMapping;
struct CurveMap;
struct CurveMapPoint;
@@ -39,7 +42,7 @@ struct Histogram;
struct ImBuf;
struct rctf;
-#if defined _WIN32
+#if defined _MSC_VER
# define DO_INLINE __inline
#elif defined(__sun) || defined(__sun__)
# define DO_INLINE
@@ -58,7 +61,7 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, con
#define CURVEMAP_SLOPE_NEGATIVE 0
#define CURVEMAP_SLOPE_POSITIVE 1
-void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset, int slope);
+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);
@@ -89,9 +92,25 @@ void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBu
void curvemapping_premultiply(struct CurveMapping *cumap, int restore);
-void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management);
-void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management);
+void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf,
+ const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
void scopes_free(struct Scopes *scopes);
void scopes_new(struct Scopes *scopes);
+void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings);
+void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings,
+ const struct ColorManagedDisplaySettings *settings);
+
+void BKE_color_managed_view_settings_init(struct ColorManagedViewSettings *settings);
+void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings,
+ const struct ColorManagedViewSettings *settings);
+void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings);
+
+void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings);
+void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings,
+ const struct ColorManagedColorspaceSettings *settings);
+
#endif
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index a845ac10c9d..e6161cebf54 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -93,6 +93,8 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float
/* ** Nurbs ** */
+int BKE_nurbList_index_get_co(struct ListBase *editnurb, const int index, float r_co[3]);
+
int BKE_nurbList_verts_count(struct ListBase *nurb);
int BKE_nurbList_verts_count_without_handles(struct ListBase *nurb);
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 19dd67b88f8..33361b9921c 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -73,6 +73,8 @@ extern const CustomDataMask CD_MASK_FACECORNERS;
#define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type))
+void customData_mask_layers__print(CustomDataMask mask);
+
/**
* Checks if the layer at physical offset \a layer_n (in data->layers) support math
* the below operations.
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index 67cdee9fa07..3e9803a908b 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -52,10 +52,6 @@ int group_is_animated(struct Object *parent, struct Group *group);
void group_tag_recalc(struct Group *group);
void group_handle_recalc_and_update(struct Scene *scene, struct Object *parent, struct Group *group);
-#if 0 /* UNUSED */
-struct Object *group_get_member_with_action(struct Group *group, struct bAction *act);
-void group_relink_nla_objects(struct Object *ob);
-#endif
#endif
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 67461281674..ac324b2af00 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -46,6 +46,8 @@ struct Object;
struct ImageFormatData;
struct Main;
+#define IMA_MAX_SPACE 64
+
/* call from library */
void BKE_image_free(struct Image *me);
@@ -64,6 +66,7 @@ int BKE_imtype_is_movie(const char imtype);
int BKE_imtype_supports_zbuf(const char imtype);
int BKE_imtype_supports_compress(const char imtype);
int BKE_imtype_supports_quality(const char imtype);
+int BKE_imtype_supports_float(const char imtype);
char BKE_imtype_valid_channels(const char imtype);
char BKE_imtype_valid_depths(const char imtype);
@@ -72,7 +75,7 @@ char BKE_imtype_from_arg(const char *arg);
void BKE_imformat_defaults(struct ImageFormatData *im_format);
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf);
-struct anim *openanim(const char *name, int flags, int streamindex);
+struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]);
void BKE_image_de_interlace(struct Image *ima, int odd);
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 1ad451b0937..01baf8feb2a 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -47,13 +47,13 @@ struct Mesh;
extern "C" {
#endif
-void BKE_key_free(struct Key *sc);
-void free_key_nolib(struct Key *key);
-struct Key *add_key(struct ID *id);
+void BKE_key_free(struct Key *sc);
+void BKE_key_free_nolib(struct Key *key);
+struct Key *BKE_key_add(struct ID *id);
struct Key *BKE_key_copy(struct Key *key);
-struct Key *copy_key_nolib(struct Key *key);
-void BKE_key_make_local(struct Key *key);
-void sort_keys(struct Key *key);
+struct Key *BKE_key_copy_nolib(struct Key *key);
+void BKE_key_make_local(struct Key *key);
+void BKE_key_sort(struct Key *key);
void key_curve_position_weights(float t, float data[4], int type);
void key_curve_tangent_weights(float t, float data[4], int type);
@@ -61,27 +61,29 @@ void key_curve_normal_weights(float t, float data[4], int type);
float *do_ob_key(struct Scene *scene, struct Object *ob);
-struct Key *ob_get_key(struct Object *ob);
-struct KeyBlock *add_keyblock(struct Key *key, const char *name);
-struct KeyBlock *add_keyblock_ctime(struct Key *key, const char *name, const short do_force);
-struct KeyBlock *ob_get_keyblock(struct Object *ob);
-struct KeyBlock *ob_get_reference_keyblock(struct Object *ob);
-struct KeyBlock *key_get_keyblock(struct Key *key, int index);
-struct KeyBlock *key_get_named_keyblock(struct Key *key, const char name[]);
-char *key_get_curValue_rnaPath(struct Key *key, struct KeyBlock *kb);
+struct Key *BKE_key_from_object(struct Object *ob);
+struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
+struct KeyBlock *BKE_keyblock_from_object_reference(struct Object *ob);
+
+struct KeyBlock *BKE_keyblock_add(struct Key *key, const char *name);
+struct KeyBlock *BKE_keyblock_add_ctime(struct Key *key, const char *name, const short do_force);
+struct KeyBlock *BKE_keyblock_from_key(struct Key *key, int index);
+struct KeyBlock *BKE_keyblock_find_name(struct Key *key, const char name[]);
+void BKE_keyblock_copy_settings(struct KeyBlock *kb_dst, const struct KeyBlock *kb_src);
+char *BKE_keyblock_curval_rnapath_get(struct Key *key, struct KeyBlock *kb);
// needed for the GE
-void do_rel_key(const int start, int end, const int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, const int mode);
+void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, const int mode);
/* conversion functions */
-void key_to_mesh(struct KeyBlock *kb, struct Mesh *me);
-void mesh_to_key(struct Mesh *me, struct KeyBlock *kb);
-void key_to_latt(struct KeyBlock *kb, struct Lattice *lt);
-void latt_to_key(struct Lattice *lt, struct KeyBlock *kb);
-void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb);
-void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
-float (*key_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3];
-void vertcos_to_key(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]);
-void offset_to_key(struct Object *ob, struct KeyBlock *kb, float (*ofs)[3]);
+void BKE_key_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me);
+void BKE_key_convert_from_mesh(struct Mesh *me, struct KeyBlock *kb);
+void BKE_key_convert_to_lattice(struct KeyBlock *kb, struct Lattice *lt);
+void BKE_key_convert_from_lattice(struct Lattice *lt, struct KeyBlock *kb);
+void BKE_key_convert_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb);
+void BKE_key_convert_from_curve(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
+float (*BKE_key_convert_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3];
+void BKE_key_convert_from_vertcos(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]);
+void BKE_key_convert_from_offset(struct Object *ob, struct KeyBlock *kb, float (*ofs)[3]);
/* key.c */
extern int slurph_opt;
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 51e301fec80..cc15ceecbac 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -131,6 +131,7 @@ void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSp
void BKE_mask_layer_calc_handles(struct MaskLayer *masklay);
void BKE_mask_layer_calc_handles_deform(struct MaskLayer *masklay);
void BKE_mask_calc_handles(struct Mask *mask);
+void BKE_mask_update_deform(struct Mask *mask);
void BKE_mask_spline_ensure_deform(struct MaskSpline *spline);
/* animation */
@@ -163,10 +164,10 @@ void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, i
int BKE_mask_get_duration(struct Mask *mask);
-#define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT)
+#define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f3) & SELECT)
#define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT)
-#define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) )
-#define MASKPOINT_ISSEL_HANDLE(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) )
+#define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f3) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) )
+#define MASKPOINT_ISSEL_HANDLE(p) ( (((p)->bezt.f1 | (p)->bezt.f3) & SELECT) )
#define MASKPOINT_SEL_ALL(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f2 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0
#define MASKPOINT_DESEL_ALL(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f2 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 438d5110666..6ad2ad924e2 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -64,6 +64,8 @@ struct Tex;
struct SpaceNode;
struct ARegion;
struct Object;
+struct ColorManagedViewSettings;
+struct ColorManagedDisplaySettings;
/* ************** NODE TYPE DEFINITIONS ***** */
@@ -725,7 +727,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria
struct CompBuf;
struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
-void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews);
+void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews,
+ const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings);
void ntreeCompositTagRender(struct Scene *sce);
int ntreeCompositTagAnimated(struct bNodeTree *ntree);
void ntreeCompositTagGenerators(struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 31642dad60d..269d96d5c38 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -93,6 +93,7 @@ void BKE_object_to_mat3(struct Object *ob, float mat[][3]);
void BKE_object_to_mat4(struct Object *ob, float mat[][4]);
void BKE_object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent);
+int BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_property.h b/source/blender/blenkernel/BKE_property.h
index a29dc0e7be4..e0eb8c04b60 100644
--- a/source/blender/blenkernel/BKE_property.h
+++ b/source/blender/blenkernel/BKE_property.h
@@ -35,19 +35,18 @@ struct bProperty;
struct ListBase;
struct Object;
-void free_property(struct bProperty *prop);
-void free_properties(struct ListBase *lb);
-struct bProperty *copy_property(struct bProperty *prop);
-void copy_properties(struct ListBase *lbn, struct ListBase *lbo);
-void init_property(struct bProperty *prop);
-struct bProperty *new_property(int type);
-void unique_property(struct bProperty *first, struct bProperty *prop, int force);
-struct bProperty *get_ob_property(struct Object *ob, const char *name);
-void set_ob_property(struct Object *ob, struct bProperty *propc);
-int compare_property(struct bProperty *prop, const char *str);
-void set_property(struct bProperty *prop, const char *str);
-void add_property(struct bProperty *prop, const char *str);
-void set_property_valstr(struct bProperty *prop, char *str);
-void cp_property(struct bProperty *prop1, struct bProperty *prop2);
+void BKE_bproperty_free(struct bProperty *prop);
+void BKE_bproperty_free_list(struct ListBase *lb);
+struct bProperty *BKE_bproperty_copy(struct bProperty *prop);
+void BKE_bproperty_copy_list(struct ListBase *lbn, struct ListBase *lbo);
+void BKE_bproperty_init(struct bProperty *prop);
+struct bProperty *BKE_bproperty_new(int type);
+void BKE_bproperty_unique(struct bProperty *first, struct bProperty *prop, int force);
+struct bProperty *BKE_bproperty_object_get(struct Object *ob, const char *name);
+void BKE_bproperty_object_set(struct Object *ob, struct bProperty *propc);
+// int BKE_bproperty_cmp(struct bProperty *prop, const char *str);
+void BKE_bproperty_set(struct bProperty *prop, const char *str);
+void BKE_bproperty_add(struct bProperty *prop, const char *str);
+void BKE_bproperty_set_valstr(struct bProperty *prop, char *str);
#endif
diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h
index 22b44511195..d598a26fdf9 100644
--- a/source/blender/blenkernel/BKE_sca.h
+++ b/source/blender/blenkernel/BKE_sca.h
@@ -74,5 +74,7 @@ void sca_move_sensor(struct bSensor *sens_to_move, struct Object *ob, int move_u
void sca_move_controller(struct bController *cont_to_move, struct Object *ob, int move_up);
void sca_move_actuator(struct bActuator *act_to_move, struct Object *ob, int move_up);
+const char *sca_state_name_get(Object *ob, short bit);
+
#endif
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index bce4243190a..023b7e85c40 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -108,6 +108,8 @@ float get_render_aosss_error(struct RenderData *r, float error);
int BKE_scene_use_new_shading_nodes(struct Scene *scene);
+void BKE_scene_disable_color_management(struct Scene *scene);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 51a64c97ca6..0c571f62f0e 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -177,6 +177,16 @@ struct ImBuf *BKE_sequencer_give_ibuf_seqbase(SeqRenderData context, float cfra,
void BKE_sequencer_give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chan_shown);
/* **********************************************************************
+ * sequencer.c
+ *
+ * sequencer color space functions
+ * ********************************************************************** */
+
+void BKE_sequencer_imbuf_to_sequencer_space(struct Scene *scene, struct ImBuf *ibuf, int make_float);
+void BKE_sequencer_imbuf_from_sequencer_space(struct Scene *scene, struct ImBuf *ibuf);
+void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]);
+
+/* **********************************************************************
* sequencer scene functions
* ********************************************************************** */
struct Editing *BKE_sequencer_editing_get(struct Scene *scene, int alloc);
@@ -350,7 +360,7 @@ struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seq
struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
/* view3d draw callback, run when not in background view */
-typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, char[256]);
+typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, int, char[256]);
extern SequencerDrawView sequencer_view3d_cb;
/* copy/paste */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index c89d0ecb142..9a24a3ca4e0 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -45,6 +45,7 @@ set(INC
../../../intern/mikktspace
../../../intern/opennl/extern
../../../intern/raskter
+ ../../../intern/smoke/extern
# XXX - BAD LEVEL CALL WM_api.h
../windowmanager
@@ -344,9 +345,6 @@ if(WITH_MOD_FLUID)
endif()
if(WITH_MOD_SMOKE)
- list(APPEND INC
- ../../../intern/smoke/extern
- )
add_definitions(-DWITH_SMOKE)
endif()
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index 58827e326a3..8a656c735f6 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -3,6 +3,10 @@ Import ('env')
import os
sources = env.Glob('intern/*.c')
+sources.remove('intern' + os.sep + 'mask_rasterize.c')
+sources.remove('intern' + os.sep + 'mask.c')
+
+sources_mask = env.Glob('intern/mask*.c')
incs = '. #/intern/guardedalloc #/intern/memutil'
incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager'
@@ -118,7 +122,10 @@ if env['WITH_BF_INTERNATIONAL']:
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']
+
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') )
else:
env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [166,25,0] )
+
+env.BlenderLib ( libname = 'bf_blenkernel_mask', sources = sources_mask, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [200,25,0] )
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 387d4775ad4..82ac0736b07 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -1397,7 +1397,7 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss)
return eCCGError_None;
}
-#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset)
+#define VERT_getNo(e, lvl) _vert_getNo(v, lvl, vertDataSize, normalDataOffset)
#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
@@ -1491,7 +1491,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
/* XXX can I reduce the number of normalisations here? */
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = (CCGVert *) effectedV[ptrIdx];
- float length, *no = _vert_getNo(v, lvl, vertDataSize, normalDataOffset);
+ float length, *no = VERT_getNo(v, lvl);
NormZero(no);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 8c0aea5723f..5e13fe78a43 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -384,7 +384,7 @@ void DM_ensure_tessface(DerivedMesh *dm)
}
}
- else if (dm->dirty && DM_DIRTY_TESS_CDLAYERS) {
+ else if (dm->dirty & DM_DIRTY_TESS_CDLAYERS) {
BLI_assert(CustomData_has_layer(&dm->faceData, CD_POLYINDEX));
DM_update_tessface_data(dm);
}
@@ -808,7 +808,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
if (mti->isDisabled && mti->isDisabled(md, 0)) return NULL;
if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) {
- key_to_mesh(kb, me);
+ BKE_key_convert_to_mesh(kb, me);
}
if (mti->type == eModifierTypeType_OnlyDeform) {
@@ -878,7 +878,7 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free
* by a more flexible customdata system, but not simple */
if (!em) {
ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
- KeyBlock *kb = key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest);
+ KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ob), clmd->sim_parms->shapekey_rest);
if (kb->data)
return kb->data;
@@ -1276,7 +1276,7 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
}
if (!kb) {
- kb = add_keyblock(me->key, layer->name);
+ kb = BKE_keyblock_add(me->key, layer->name);
kb->uid = layer->uid;
}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 06bf5211abb..925658b84f4 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1214,475 +1214,3 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c
}
}
-/* ********** NLA with non-poses works with ipo channels ********** */
-
-#if 0 // XXX OLD ANIMATION SYSTEM (TO BE REMOVED)
-
-/* ************************ Blending with NLA *************** */
-
-static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mode)
-{
- float dstweight;
-
- switch (mode) {
- case ACTSTRIPMODE_BLEND:
- dstweight = 1.0F - srcweight;
- break;
- case ACTSTRIPMODE_ADD:
- dstweight = 1.0F;
- break;
- default:
- dstweight = 1.0F;
- }
-
- interp_v3_v3v3(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight);
-}
-
-
-/*
- * bone matching diagram, strips A and B
- *
- * .------------------------.
- * | A |
- * '------------------------'
- * . . b2
- * . .-------------v----------.
- * . | B . |
- * . '------------------------'
- * . . .
- * . . .
- * offset: . 0 . A-B . A-b2+B
- * . . .
- *
- * */
-
-
-static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, float srcweight, short mode)
-{
- /* matching offset bones */
- /* take dst offset, and put src on on that location */
-
- if (strip->offs_bone[0] == 0)
- return;
-
- /* are we also blending with matching bones? */
- if (strip->prev && strip->start >= strip->prev->start) {
- bPoseChannel *dpchan = BKE_pose_channel_find_name(dst, strip->offs_bone);
- if (dpchan) {
- bPoseChannel *spchan = BKE_pose_channel_find_name(src, strip->offs_bone);
- if (spchan) {
- float vec[3];
-
- /* dst->ctime has the internal strip->prev action time */
- /* map this time to nla time */
-
- float ctime = get_actionstrip_frame(strip, src->ctime, 1);
-
- if (ctime > strip->prev->end) {
- bActionChannel *achan;
-
- /* add src to dest, minus the position of src on strip->prev->end */
-
- ctime = get_actionstrip_frame(strip, strip->prev->end, 0);
-
- achan = get_action_channel(strip->act, strip->offs_bone);
- if (achan && achan->ipo) {
- bPoseChannel pchan;
- /* Evaluates and sets the internal ipo value */
- calc_ipo(achan->ipo, ctime);
- /* This call also sets the pchan flags */
- execute_action_ipo(achan, &pchan);
-
- /* store offset that moves src to location of pchan */
- sub_v3_v3v3(vec, dpchan->loc, pchan.loc);
-
- mul_mat3_m4_v3(dpchan->bone->arm_mat, vec);
- }
- }
- else {
- /* store offset that moves src to location of dst */
-
- sub_v3_v3v3(vec, dpchan->loc, spchan->loc);
- mul_mat3_m4_v3(dpchan->bone->arm_mat, vec);
- }
-
- /* if blending, we only add with factor scrweight */
- mul_v3_fl(vec, srcweight);
-
- add_v3_v3(dst->cyclic_offset, vec);
- }
- }
- }
-
- add_v3_v3(dst->cyclic_offset, src->cyclic_offset);
-}
-
-/* added "sizecorr" here, to allow armatures to be scaled and still have striding.
- * Only works for uniform scaling. In general I'd advise against scaling armatures ever though! (ton)
- */
-static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip, Path *path, float pathdist, float *stride_offset)
-{
- bAction *act = strip->act;
- const char *name = strip->stridechannel;
- bActionChannel *achan = get_action_channel(act, name);
- int stride_axis = strip->stride_axis;
-
- if (achan && achan->ipo) {
- IpoCurve *icu = NULL;
- float minx = 0.0f, maxx = 0.0f, miny = 0.0f, maxy = 0.0f;
- int foundvert = 0;
-
- if (stride_axis == 0) stride_axis = AC_LOC_X;
- else if (stride_axis == 1) stride_axis = AC_LOC_Y;
- else stride_axis = AC_LOC_Z;
-
- /* calculate the min/max */
- for (icu = achan->ipo->curve.first; icu; icu = icu->next) {
- if (icu->adrcode == stride_axis) {
- if (icu->totvert > 1) {
- foundvert = 1;
- minx = icu->bezt[0].vec[1][0];
- maxx = icu->bezt[icu->totvert - 1].vec[1][0];
-
- miny = icu->bezt[0].vec[1][1];
- maxy = icu->bezt[icu->totvert - 1].vec[1][1];
- }
- break;
- }
- }
-
- if (foundvert && miny != maxy) {
- float stridelen = sizecorr * fabs(maxy - miny), striptime;
- float actiondist, pdist, pdistNewNormalized, offs;
- float vec1[4], vec2[4], dir[3];
-
- /* internal cycling, actoffs is in frames */
- offs = stridelen * strip->actoffs / (maxx - minx);
-
- /* amount path moves object */
- pdist = (float)fmod(pathdist + offs, stridelen);
- striptime = pdist / stridelen;
-
- /* amount stride bone moves */
- actiondist = sizecorr * eval_icu(icu, minx + striptime * (maxx - minx)) - miny;
-
- pdist = fabs(actiondist) - pdist;
- pdistNewNormalized = (pathdist + pdist) / path->totdist;
-
- /* now we need to go pdist further (or less) on cu path */
- where_on_path(ob, (pathdist) / path->totdist, vec1, dir); /* vec needs size 4 */
- if (pdistNewNormalized <= 1) {
- /* search for correction in positive path-direction */
- where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */
- sub_v3_v3v3(stride_offset, vec2, vec1);
- }
- else {
- /* we reached the end of the path, search backwards instead */
- where_on_path(ob, (pathdist - pdist) / path->totdist, vec2, dir); /* vec needs size 4 */
- sub_v3_v3v3(stride_offset, vec1, vec2);
- }
- mul_mat3_m4_v3(ob->obmat, stride_offset);
- return striptime;
- }
- }
- return 0.0f;
-}
-
-static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float time)
-{
- /* only called when strip has cyclic, so >= 1.0f works... */
- if (time >= 1.0f) {
- bActionChannel *achan = get_action_channel(strip->act, strip->offs_bone);
-
- if (achan && achan->ipo) {
- IpoCurve *icu = NULL;
- Bone *bone;
- float min[3] = {0.0f, 0.0f, 0.0f}, max[3] = {0.0f, 0.0f, 0.0f};
- int index = 0, foundvert = 0;
-
- /* calculate the min/max */
- for (icu = achan->ipo->curve.first; icu; icu = icu->next) {
- if (icu->totvert > 1) {
-
- if (icu->adrcode == AC_LOC_X)
- index = 0;
- else if (icu->adrcode == AC_LOC_Y)
- index = 1;
- else if (icu->adrcode == AC_LOC_Z)
- index = 2;
- else
- continue;
-
- foundvert = 1;
- min[index] = icu->bezt[0].vec[1][1];
- max[index] = icu->bezt[icu->totvert - 1].vec[1][1];
- }
- }
- if (foundvert) {
- /* bring it into armature space */
- sub_v3_v3v3(min, max, min);
- bone = BKE_armature_find_bone_name(ob->data, strip->offs_bone); /* weak */
- if (bone) {
- mul_mat3_m4_v3(bone->arm_mat, min);
-
- /* dominant motion, cyclic_offset was cleared in BKE_pose_rest */
- if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) {
- if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0] = time * min[0];
- if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1] = time * min[1];
- if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2] = time * min[2];
- }
- else {
- if (fabsf(min[0]) >= fabsf(min[1]) && fabsf(min[0]) >= fabsf(min[2]))
- pose->cyclic_offset[0] = time * min[0];
- else if (fabsf(min[1]) >= fabsf(min[0]) && fabsf(min[1]) >= fabsf(min[2]))
- pose->cyclic_offset[1] = time * min[1];
- else
- pose->cyclic_offset[2] = time * min[2];
- }
- }
- }
- }
- }
-}
-
-/* simple case for now; only the curve path with constraint value > 0.5 */
-/* blending we might do later... */
-static Object *get_parent_path(Object *ob)
-{
- bConstraint *con;
-
- if (ob->parent && ob->parent->type == OB_CURVE)
- return ob->parent;
-
- for (con = ob->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
- if (con->enforce > 0.5f) {
- bFollowPathConstraint *data = con->data;
- return data->tar;
- }
- }
- }
- return NULL;
-}
-
-/* ************** do the action ************ */
-
-/* ----- nla, etc. --------- */
-
-static void do_nla(Scene *scene, Object *ob, int blocktype)
-{
- bPose *tpose = NULL;
- Key *key = NULL;
- ListBase tchanbase = {NULL, NULL}, chanbase = {NULL, NULL};
- bActionStrip *strip, *striplast = NULL, *stripfirst = NULL;
- float striptime, frametime, length, actlength;
- float blendfac, stripframe;
- float scene_cfra = BKE_scene_frame_get(scene);
- int doit, dostride;
-
- if (blocktype == ID_AR) {
- BKE_pose_copy_data(&tpose, ob->pose, 1);
- BKE_pose_rest(ob->pose); // potentially destroying current not-keyed pose
- }
- else {
- key = ob_get_key(ob);
- }
-
- /* check on extend to left or right, when no strip is hit by 'cfra' */
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- /* escape loop on a hit */
- if (scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */
- break;
- if (scene_cfra < strip->start) {
- if (stripfirst == NULL)
- stripfirst = strip;
- else if (stripfirst->start > strip->start)
- stripfirst = strip;
- }
- else if (scene_cfra > strip->end) {
- if (striplast == NULL)
- striplast = strip;
- else if (striplast->end < strip->end)
- striplast = strip;
- }
- }
- if (strip == NULL) { /* extend */
- if (striplast)
- scene_cfra = striplast->end;
- else if (stripfirst)
- scene_cfra = stripfirst->start;
- }
-
- /* and now go over all strips */
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- doit = dostride = 0;
-
- if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */
-
- /* Determine if the current frame is within the strip's range */
- length = strip->end - strip->start;
- actlength = strip->actend - strip->actstart;
- striptime = (scene_cfra - strip->start) / length;
- stripframe = (scene_cfra - strip->start);
-
- if (striptime >= 0.0) {
-
- if (blocktype == ID_AR)
- BKE_pose_rest(tpose);
-
- /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */
- if (striptime < 1.0f + 0.1f / length) {
-
- /* Handle path */
- if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype == ID_AR) && (ob->ipoflag & OB_DISABLE_PATH) == 0) {
- Object *parent = get_parent_path(ob);
-
- if (parent) {
- Curve *cu = parent->data;
- float ctime, pdist;
-
- if (cu->flag & CU_PATH) {
- /* Ensure we have a valid path */
- if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(scene, parent, 0);
- if (cu->path) {
-
- /* Find the position on the path */
- ctime = bsystem_time(scene, ob, scene_cfra, 0.0);
-
- if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime) == 0) {
- /* correct for actions not starting on zero */
- ctime = (ctime - strip->actstart) / cu->pathlen;
- CLAMP(ctime, 0.0, 1.0);
- }
- pdist = ctime * cu->path->totdist;
-
- if (tpose && strip->stridechannel[0]) {
- striptime = stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset);
- }
- else {
- if (strip->stridelen) {
- striptime = pdist / strip->stridelen;
- striptime = (float)fmod(striptime + strip->actoffs, 1.0);
- }
- else
- striptime = 0;
- }
-
- frametime = (striptime * actlength) + strip->actstart;
- frametime = bsystem_time(scene, ob, frametime, 0.0);
-
- if (blocktype == ID_AR) {
- extract_pose_from_action(tpose, strip->act, frametime);
- }
- else if (blocktype == ID_OB) {
- extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
- if (key)
- extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
- }
- doit = dostride = 1;
- }
- }
- }
- }
- /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */
- else {
-
- /* Mod to repeat */
- if (strip->repeat != 1.0f) {
- float cycle = striptime * strip->repeat;
-
- striptime = (float)fmod(cycle, 1.0f + 0.1f / length);
- cycle -= striptime;
-
- if (blocktype == ID_AR)
- cyclic_offs_bone(ob, tpose, strip, cycle);
- }
-
- frametime = (striptime * actlength) + strip->actstart;
- frametime = nla_time(scene, frametime, (float)strip->repeat);
-
- if (blocktype == ID_AR) {
- extract_pose_from_action(tpose, strip->act, frametime);
- }
- else if (blocktype == ID_OB) {
- extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
- if (key)
- extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
- }
-
- doit = 1;
- }
- }
- /* Handle extend */
- else {
- if (strip->flag & ACTSTRIP_HOLDLASTFRAME) {
- /* we want the strip to hold on the exact fraction of the repeat value */
-
- frametime = actlength * (strip->repeat - (int)strip->repeat);
- if (frametime <= 0.000001f) frametime = actlength; /* rounding errors... */
- frametime = bsystem_time(scene, ob, frametime + strip->actstart, 0.0);
-
- if (blocktype == ID_AR)
- extract_pose_from_action(tpose, strip->act, frametime);
- else if (blocktype == ID_OB) {
- extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
- if (key)
- extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
- }
-
- /* handle cycle hold */
- if (strip->repeat != 1.0f) {
- if (blocktype == ID_AR)
- cyclic_offs_bone(ob, tpose, strip, strip->repeat - 1.0f);
- }
-
- doit = 1;
- }
- }
-
- /* Handle blendin & blendout */
- if (doit) {
- /* Handle blendin */
-
- if (strip->blendin > 0.0 && stripframe <= strip->blendin && scene_cfra >= strip->start) {
- blendfac = stripframe / strip->blendin;
- }
- else if (strip->blendout > 0.0 && stripframe >= (length - strip->blendout) && scene_cfra <= strip->end) {
- blendfac = (length - stripframe) / (strip->blendout);
- }
- else
- blendfac = 1;
-
- if (blocktype == ID_AR) { /* Blend this pose with the accumulated pose */
- /* offset bone, for matching cycles */
- blend_pose_offset_bone(strip, ob->pose, tpose, blendfac, strip->mode);
-
- blend_poses(ob->pose, tpose, blendfac, strip->mode);
- if (dostride)
- blend_pose_strides(ob->pose, tpose, blendfac, strip->mode);
- }
- else {
- blend_ipochannels(&chanbase, &tchanbase, blendfac, strip->mode);
- BLI_freelistN(&tchanbase);
- }
- }
- }
- }
- }
-
- if (blocktype == ID_OB) {
- execute_ipochannels(&chanbase);
- }
- else if (blocktype == ID_AR) {
- /* apply stride offset to object */
- add_v3_v3(ob->obmat[3], ob->pose->stride_offset);
- }
-
- /* free */
- if (tpose)
- BKE_pose_free(tpose);
- if (chanbase.first)
- BLI_freelistN(&chanbase);
-}
-
-#endif // XXX OLD ANIMATION SYSTEM (TO BE REMOVED)
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 09519f68415..99b788e80ce 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -89,8 +89,10 @@
#include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie
+#include "IMB_colormanagement.h"
+
#ifdef WITH_PYTHON
-#include "BPY_extern.h"
+# include "BPY_extern.h"
#endif
Global G;
@@ -217,8 +219,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
/* no load screens? */
if (mode) {
/* comes from readfile.c */
- extern void lib_link_screen_restore(Main *, bScreen *, Scene *);
-
SWAP(ListBase, G.main->wm, bfd->main->wm);
SWAP(ListBase, G.main->screen, bfd->main->screen);
SWAP(ListBase, G.main->script, bfd->main->script);
@@ -232,7 +232,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
if (curscreen) curscreen->scene = curscene; /* can run in bgmode */
/* clear_global will free G.main, here we can still restore pointers */
- lib_link_screen_restore(bfd->main, curscreen, curscene);
+ blo_lib_link_screen_restore(bfd->main, curscreen, curscene);
}
/* free G.main Main database */
@@ -322,7 +322,11 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
/* baseflags, groups, make depsgraph, etc */
BKE_scene_set_background(G.main, CTX_data_scene(C));
-
+
+ if (mode != 'u') {
+ IMB_colormanagement_check_file_config(G.main);
+ }
+
MEM_freeN(bfd);
(void)curscene; /* quiet warning */
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index b0de7a5ea6c..4241756a109 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -50,36 +50,7 @@
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
-#ifdef _WIN32
-void tstart( void )
-{}
-void tend( void )
-{
-}
-double tval( void )
-{
- return 0;
-}
-#else
-#include <sys/time.h>
-static struct timeval _tstart, _tend;
-static struct timezone tz;
-void tstart( void )
-{
- gettimeofday(&_tstart, &tz);
-}
-void tend(void)
-{
- gettimeofday(&_tend, &tz);
-}
-double tval(void)
-{
- double t1, t2;
- t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 );
- t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 );
- return t2-t1;
-}
-#endif
+// #include "PIL_time.h" /* timing for debug prints */
/* Our available solvers. */
// 255 is the magic reserved number, so NEVER try to put 255 solvers in here!
@@ -410,13 +381,13 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
cloth_apply_vgroup ( clmd, result );
cloth_update_springs( clmd );
- tstart();
+ // TIMEIT_START(cloth_step)
/* call the solver. */
if (solvers [clmd->sim_parms->solver_type].solver)
ret = solvers[clmd->sim_parms->solver_type].solver(ob, framenr, clmd, effectors);
- tend();
+ // TIMEIT_END(cloth_step)
pdEndEffectors(&effectors);
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index af9bb971d05..6631afcddaf 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -161,8 +161,6 @@ void bvhtree_update_from_mvert(BVHTree * bvhtree, MFace *faces, int numfaces, MV
/***********************************
Collision modifier code end
***********************************/
-#define mySWAP(a, b) do { double tmp = b ; b = a ; a = tmp ; } while (0)
-
// w3 is not perfect
static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3 )
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index d65c81b4f9b..b66bd1fd32b 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -49,6 +49,7 @@
#include "BKE_fcurve.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -174,6 +175,7 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con
}
curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul);
+ cumap->changed_timestamp++;
}
/* ***************** operations on single curve ************* */
@@ -260,7 +262,7 @@ CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y)
return newcmp;
}
-void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
+void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
{
if (cuma->curve)
MEM_freeN(cuma->curve);
@@ -479,7 +481,7 @@ static float curvemap_calc_extend(const CurveMap *cuma, float x, const float fir
}
/* only creates a table for a single channel in CurveMapping */
-static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
+static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
{
CurveMapPoint *cmp = cuma->curve;
BezTriple *bezt;
@@ -677,7 +679,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
CurveMap *cuma = cumap->cm + cumap->cur;
CurveMapPoint *cmp = cuma->curve;
rctf *clipr = &cumap->clipr;
- float thresh = 0.01f * BLI_RCT_SIZE_X(clipr);
+ float thresh = 0.01f * BLI_rctf_size_x(clipr);
float dx = 0.0f, dy = 0.0f;
int a;
@@ -996,7 +998,8 @@ static void save_sample_line(Scopes *scopes, const int idx, const float fx, cons
}
}
-void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short use_color_management)
+void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
{
int i, x, y;
float *fp;
@@ -1008,6 +1011,8 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short
int y1 = 0.5f + hist->co[0][1] * ibuf->y;
int y2 = 0.5f + hist->co[1][1] * ibuf->y;
+ struct ColormanageProcessor *cm_processor = NULL;
+
hist->channels = 3;
hist->x_resolution = 256;
hist->xmax = 1.0f;
@@ -1015,6 +1020,9 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;
+ if (ibuf->rect_float)
+ cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+
/* persistent draw */
hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */
@@ -1029,10 +1037,8 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
- if (use_color_management)
- linearrgb_to_srgb_v3_v3(rgb, fp);
- else
- copy_v3_v3(rgb, fp);
+ copy_v3_v3(rgb, fp);
+ IMB_colormanagement_processor_apply_v3(cm_processor, rgb);
hist->data_luma[i] = rgb_to_luma(rgb);
hist->data_r[i] = rgb[0];
@@ -1050,9 +1056,13 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short
}
}
}
+
+ if (cm_processor)
+ IMB_colormanagement_processor_free(cm_processor);
}
-void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
+void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
{
int x, y, c;
unsigned int n, nl;
@@ -1065,6 +1075,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
int ycc_mode = -1;
const short is_float = (ibuf->rect_float != NULL);
+ struct ColormanageProcessor *cm_processor = NULL;
+
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;
if (scopes->ok == 1) return;
@@ -1134,6 +1146,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
else
rc = (unsigned char *)ibuf->rect;
+ if (ibuf->rect_float)
+ cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+
for (y = 0; y < ibuf->y; y++) {
if (savedlines < scopes->sample_lines && y >= ((savedlines) * ibuf->y) / (scopes->sample_lines + 1)) {
saveline = 1;
@@ -1144,11 +1159,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
for (x = 0; x < ibuf->x; x++) {
if (is_float) {
- if (use_color_management)
- linearrgb_to_srgb_v3_v3(rgba, rf);
- else
- copy_v3_v3(rgba, rf);
- rgba[3] = rf[3];
+ copy_v4_v4(rgba, rf);
+ IMB_colormanagement_processor_apply_v4(cm_processor, rgba);
}
else {
for (c = 0; c < 4; c++)
@@ -1219,6 +1231,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
MEM_freeN(bin_b);
MEM_freeN(bin_a);
+ if (cm_processor)
+ IMB_colormanagement_processor_free(cm_processor);
+
scopes->ok = 1;
}
@@ -1257,3 +1272,58 @@ void scopes_new(Scopes *scopes)
scopes->waveform_3 = NULL;
scopes->vecscope = NULL;
}
+
+void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settings)
+{
+ const char *display_name = IMB_colormanagement_display_get_default_name();
+
+ BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device));
+}
+
+void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings,
+ const ColorManagedDisplaySettings *settings)
+{
+ BLI_strncpy(new_settings->display_device, settings->display_device, sizeof(new_settings->display_device));
+}
+
+void BKE_color_managed_view_settings_init(ColorManagedViewSettings *settings)
+{
+ /* OCIO_TODO: use default view transform here when OCIO is completely integrated
+ * and proper versioning stuff is added.
+ * for now use NONE to be compatible with all current files
+ */
+ BLI_strncpy(settings->view_transform, "Default", sizeof(settings->view_transform));
+
+ settings->gamma = 1.0f;
+ settings->exposure = 0.0f;
+}
+
+void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,
+ const ColorManagedViewSettings *settings)
+{
+ BLI_strncpy(new_settings->view_transform, settings->view_transform, sizeof(new_settings->view_transform));
+
+ new_settings->flag = settings->flag;
+ new_settings->exposure = settings->exposure;
+ new_settings->gamma = settings->gamma;
+
+ if (settings->curve_mapping)
+ new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping);
+}
+
+void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings)
+{
+ if (settings->curve_mapping)
+ curvemapping_free(settings->curve_mapping);
+}
+
+void BKE_color_managed_colorspace_settings_init(ColorManagedColorspaceSettings *colorspace_settings)
+{
+ BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name));
+}
+
+void BKE_color_managed_colorspace_settings_copy(ColorManagedColorspaceSettings *colorspace_settings,
+ const ColorManagedColorspaceSettings *settings)
+{
+ BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name));
+}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 6b9e0921c3b..e3f7ae1b1c7 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1030,7 +1030,6 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
if (VALID_CONS_TARGET(ct)) {
float size[3], vec[3];
float totmat[3][3];
- float tmat[4][4];
/* Get size property, since ob->size is only the object's own relative size, not its global one */
mat4_to_size(size, cob->matrix);
@@ -1053,9 +1052,8 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
vectomat(vec, ct->matrix[2],
(short)data->reserved1, (short)data->reserved2,
data->flags, totmat);
-
- copy_m4_m4(tmat, cob->matrix);
- mul_m4_m3m4(cob->matrix, totmat, tmat);
+
+ mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
}
}
@@ -2281,7 +2279,6 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
float totmat[3][3];
float tmpmat[3][3];
float invmat[3][3];
- float tmat[4][4];
float mdet;
/* Vector object -> target */
@@ -2509,8 +2506,6 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
totmat[1][0] = tmpmat[1][0]; totmat[1][1] = tmpmat[1][1]; totmat[1][2] = tmpmat[1][2];
totmat[2][0] = tmpmat[2][0]; totmat[2][1] = tmpmat[2][1]; totmat[2][2] = tmpmat[2][2];
- copy_m4_m4(tmat, cob->matrix);
-
mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2],
totmat[1][0], totmat[1][1], totmat[1][2],
totmat[2][0], totmat[2][1], totmat[2][2]);
@@ -2519,7 +2514,7 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
}
/* apply out transformaton to the object */
- mul_m4_m3m4(cob->matrix, totmat, tmat);
+ mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
}
}
@@ -2717,7 +2712,6 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
if (VALID_CONS_TARGET(ct)) {
float size[3], scale[3], vec[3], xx[3], zz[3], orth[3];
float totmat[3][3];
- float tmat[4][4];
float dist;
/* store scaling before destroying obmat */
@@ -2815,9 +2809,8 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
normalize_v3_v3(totmat[2], zz);
break;
} /* switch (data->plane) */
-
- copy_m4_m4(tmat, cob->matrix);
- mul_m4_m3m4(cob->matrix, totmat, tmat);
+
+ mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
}
}
@@ -4061,32 +4054,36 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
copy_v3_v3(cob->matrix[3], disp);
}
- if (data->depth_ob && data->depth_ob->derivedFinal) {
+ if (data->depth_ob) {
Object *depth_ob = data->depth_ob;
- BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
- BVHTreeRayHit hit;
- float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
- int result;
+ DerivedMesh *target = object_get_derived_final(depth_ob);
+ if (target) {
+ BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
+ BVHTreeRayHit hit;
+ float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
+ int result;
- invert_m4_m4(imat, depth_ob->obmat);
+ invert_m4_m4(imat, depth_ob->obmat);
- mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
- mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
+ mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
+ mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
- sub_v3_v3v3(ray_nor, ray_end, ray_start);
+ sub_v3_v3v3(ray_nor, ray_end, ray_start);
- bvhtree_from_mesh_faces(&treeData, depth_ob->derivedFinal, 0.0f, 4, 6);
+ bvhtree_from_mesh_faces(&treeData, target, 0.0f, 4, 6);
- hit.dist = FLT_MAX;
- hit.index = -1;
+ hit.dist = FLT_MAX;
+ hit.index = -1;
- result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
+ result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
- if (result != -1) {
- mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
- }
+ if (result != -1) {
+ mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
+ }
- free_bvhtree_from_mesh(&treeData);
+ free_bvhtree_from_mesh(&treeData);
+ target->release(target);
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index a2f88781cbb..09ca0df0680 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -429,6 +429,33 @@ void BKE_curve_texspace_calc(Curve *cu)
}
}
+int BKE_nurbList_index_get_co(ListBase *nurb, const int index, float r_co[3])
+{
+ Nurb *nu;
+ int tot = 0;
+
+ for (nu = nurb->first; nu; nu = nu->next) {
+ int tot_nu;
+ if (nu->type == CU_BEZIER) {
+ tot_nu = nu->pntsu;
+ if (index - tot < tot_nu) {
+ copy_v3_v3(r_co, nu->bezt[index - tot].vec[1]);
+ return TRUE;
+ }
+ }
+ else {
+ tot_nu = nu->pntsu * nu->pntsv;
+ if (index - tot < tot_nu) {
+ copy_v3_v3(r_co, nu->bp[index - tot].vec);
+ return TRUE;
+ }
+ }
+ tot += tot_nu;
+ }
+
+ return FALSE;
+}
+
int BKE_nurbList_verts_count(ListBase *nurb)
{
Nurb *nu;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 342ee5bba41..ba859cadf92 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -271,28 +271,6 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
BLI_linklist_free(dest_dw, linklist_free_simple);
}
-
-static void layerInterp_msticky(void **sources, const float *weights,
- const float *UNUSED(sub_weights), int count, void *dest)
-{
- float co[2], w;
- MSticky *mst;
- int i;
-
- co[0] = co[1] = 0.0f;
- for (i = 0; i < count; i++) {
- w = weights ? weights[i] : 1.0f;
- mst = (MSticky *)sources[i];
-
- madd_v2_v2fl(co, mst->co, w);
- }
-
- /* delay writing to the destination incase dest is in sources */
- mst = (MSticky *)dest;
- copy_v2_v2(mst->co, co);
-}
-
-
static void layerCopy_tface(const void *source, void *dest, int count)
{
const MTFace *source_tf = (const MTFace *)source;
@@ -1055,8 +1033,8 @@ static void layerInterp_mvert_skin(void **sources, const float *weights,
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 0: CD_MVERT */
{sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
- /* 1: CD_MSTICKY */
- {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL,
+ /* 1: CD_MSTICKY */ /* DEPRECATED */
+ {sizeof(float) * 2, "", 1, NULL, NULL, NULL, NULL, NULL,
NULL},
/* 2: CD_MDEFORMVERT */
{sizeof(MDeformVert), "MDeformVert", 1, NULL, layerCopy_mdeformvert,
@@ -1155,7 +1133,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(GridPaintMask), "GridPaintMask", 1, NULL, layerCopy_grid_paint_mask,
layerFree_grid_paint_mask, NULL, NULL, NULL},
/* 36: CD_SKIN_NODE */
- {sizeof(MVertSkin), "MVertSkin", 1, "Skin", NULL, NULL,
+ {sizeof(MVertSkin), "MVertSkin", 1, NULL, NULL, NULL,
layerInterp_mvert_skin, NULL, layerDefault_mvert_skin}
};
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index b8d5294eabc..31a6f768f89 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -501,7 +501,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ob->adt)
dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key && key->adt)
dag_add_driver_relation(key->adt, dag, node, 1);
@@ -2650,7 +2650,7 @@ static void dag_id_flush_update(Scene *sce, ID *id)
/* set flags based on ShapeKey */
if (idtype == ID_KE) {
for (obt = bmain->object.first; obt; obt = obt->id.next) {
- Key *key = ob_get_key(obt);
+ Key *key = BKE_key_from_object(obt);
if (!(ob && obt == ob) && ((ID *)key == id)) {
obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA);
lib_id_recalc_tag(bmain, &obt->id);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index f47ac641cf9..1cb29b90133 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -669,7 +669,7 @@ static void boundInsert(Bounds3D *b, float point[3])
}
}
-float getSurfaceDimension(PaintSurfaceData *sData)
+static float getSurfaceDimension(PaintSurfaceData *sData)
{
Bounds3D *mb = &sData->bData->mesh_bounds;
return MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2]));
@@ -910,7 +910,7 @@ static void free_bakeData(PaintSurfaceData *data)
}
/* free surface data if it's not used anymore */
-void surface_freeUnusedData(DynamicPaintSurface *surface)
+static void surface_freeUnusedData(DynamicPaintSurface *surface)
{
if (!surface->data) return;
@@ -1368,7 +1368,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
MEM_freeN(temp_data);
}
-void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
+static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
{
PaintSurfaceData *sData = surface->data;
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
@@ -1605,7 +1605,7 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri
/*
* Apply canvas data to the object derived mesh
*/
-struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
+static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
Object *ob,
DerivedMesh *dm)
{
@@ -1830,9 +1830,12 @@ void dynamicPaint_cacheUpdateFrames(DynamicPaintSurface *surface)
}
}
-void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm)
+static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm)
{
- if (canvas->dm) canvas->dm->release(canvas->dm);
+ if (canvas->dm) {
+ canvas->dm->release(canvas->dm);
+ }
+
canvas->dm = CDDM_copy(dm);
}
@@ -2748,7 +2751,7 @@ static void dynamicPaint_freeBrushMaterials(BrushMaterials *bMats)
/*
* Get material diffuse color and alpha (including linked textures) in given coordinates
*/
-void dynamicPaint_doMaterialTex(BrushMaterials *bMats, float color[3], float *alpha, Object *brushOb, const float volume_co[3], const float surface_co[3], int faceIndex, short isQuad, DerivedMesh *orcoDm)
+static void dynamicPaint_doMaterialTex(BrushMaterials *bMats, float color[3], float *alpha, Object *brushOb, const float volume_co[3], const float surface_co[3], int faceIndex, short isQuad, DerivedMesh *orcoDm)
{
Material *mat = bMats->mat;
MFace *mface = orcoDm->getTessFaceArray(orcoDm);
@@ -3953,7 +3956,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
}
/* find two adjacency points (closest_id) and influence (closest_d) to move paint towards when affected by a force */
-void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, float force[3], float closest_d[2], int closest_id[2])
+static void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, float force[3], float closest_d[2], int closest_id[2])
{
BakeAdjPoint *bNeighs = sData->bData->bNeighs;
int numOfNeighs = sData->adj_data->n_num[index];
@@ -4342,7 +4345,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
}
}
-void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale)
+static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale)
{
PaintSurfaceData *sData = surface->data;
BakeAdjPoint *bNeighs = sData->bData->bNeighs;
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index befec1907da..8d430eb58b5 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -152,7 +152,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* don't consider two-edged faces */
- if (efa->len < 3) {
+ if (UNLIKELY(efa->len < 3)) {
/* do nothing */
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 538d2469a93..68321076398 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -48,10 +48,6 @@
#include "BKE_fcurve.h"
#include "BKE_idprop.h"
-
-#define SMALL -1.0e-10
-#define SELECT 1
-
/* ******************************** F-Modifiers ********************************* */
/* Info ------------------------------- */
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 0d9a69008ee..3392f6f109b 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -116,16 +116,6 @@ void BKE_group_unlink(Group *group)
if (ob->dup_group == group) {
ob->dup_group = NULL;
-#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
- {
- bActionStrip *strip;
- /* duplicator strips use a group object, we remove it */
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- if (strip->object)
- strip->object = NULL;
- }
- }
-#endif
}
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -389,57 +379,3 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group
}
}
}
-
-#if 0
-Object *group_get_member_with_action(Group *group, bAction *act)
-{
- GroupObject *go;
-
- if (group == NULL || act == NULL) return NULL;
-
- for (go = group->gobject.first; go; go = go->next) {
- if (go->ob) {
- if (go->ob->action == act)
- return go->ob;
- if (go->ob->nlastrips.first) {
- bActionStrip *strip;
-
- for (strip = go->ob->nlastrips.first; strip; strip = strip->next) {
- if (strip->act == act)
- return go->ob;
- }
- }
- }
- }
- return NULL;
-}
-
-/* if group has NLA, we try to map the used objects in NLA to group members */
-/* this assuming that object has received a new group link */
-void group_relink_nla_objects(Object *ob)
-{
- Group *group;
- GroupObject *go;
- bActionStrip *strip;
-
- if (ob == NULL || ob->dup_group == NULL) return;
- group = ob->dup_group;
-
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- if (strip->object) {
- for (go = group->gobject.first; go; go = go->next) {
- if (go->ob) {
- if (strcmp(go->ob->id.name, strip->object->id.name) == 0)
- break;
- }
- }
- if (go)
- strip->object = go->ob;
- else
- strip->object = NULL;
- }
-
- }
-}
-
-#endif
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 8a49cba7649..d8c3e260399 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -65,7 +65,7 @@ static void icon_free(void *val)
Icon *icon = val;
if (icon) {
- if (icon->drawinfo_free) {
+ if (icon->drawinfo_free) {
icon->drawinfo_free(icon->drawinfo);
}
else if (icon->drawinfo) {
@@ -255,7 +255,7 @@ void BKE_icon_changed(int id)
prv->changed_timestamp[i]++;
}
}
- }
+ }
}
int BKE_icon_getid(struct ID *id)
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 8229df28ab8..8ceaab56f83 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -484,7 +484,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
BLI_remlink(&group->data.group, loop);
IDP_FreeProperty(loop);
- MEM_freeN(loop);
+ MEM_freeN(loop);
}
else {
group->len++;
@@ -679,7 +679,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
case IDP_DOUBLE:
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
*(double *)&prop->data.val = val->d;
- break;
+ break;
case IDP_ARRAY:
{
/* for now, we only support float and int and double arrays */
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 3f756e74b26..d620fc50e86 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -47,6 +47,7 @@
#include "MEM_guardedalloc.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -70,6 +71,7 @@
#include "BLI_bpath.h"
#include "BKE_bmfont.h"
+#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_icons.h"
#include "BKE_image.h"
@@ -243,6 +245,11 @@ static Image *image_alloc(const char *name, short source, short type)
ima->source = source;
ima->type = type;
+
+ if (source == IMA_SRC_VIEWER)
+ ima->flag |= IMA_VIEW_AS_RENDER;
+
+ BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings);
}
return ima;
}
@@ -325,6 +332,8 @@ Image *BKE_image_copy(Image *ima)
nima->aspx = ima->aspx;
nima->aspy = ima->aspy;
+ BKE_color_managed_colorspace_settings_copy(&nima->colorspace_settings, &ima->colorspace_settings);
+
return nima;
}
@@ -594,7 +603,8 @@ Image *BKE_image_load_exists(const char *filepath)
return BKE_image_load(filepath);
}
-static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4])
+static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type,
+ float color[4], ColorManagedColorspaceSettings *colorspace_settings)
{
ImBuf *ibuf;
unsigned char *rect = NULL;
@@ -603,12 +613,24 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
if (floatbuf) {
ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat);
rect_float = ibuf->rect_float;
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
+
+ if (colorspace_settings->name[0] == '\0') {
+ const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_FLOAT);
+
+ BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name));
+ }
}
else {
ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
rect = (unsigned char *)ibuf->rect;
- ibuf->profile = IB_PROFILE_SRGB;
+
+ if (colorspace_settings->name[0] == '\0') {
+ const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
+
+ BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name));
+ }
+
+ IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name);
}
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
@@ -643,7 +665,7 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch
ima->gen_type = gen_type;
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
- ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color);
+ ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok = IMA_OK_LOADED;
@@ -1009,6 +1031,19 @@ int BKE_imtype_supports_quality(const char imtype)
return 0;
}
+int BKE_imtype_supports_float(const char imtype)
+{
+ switch (imtype) {
+ case R_IMF_IMTYPE_CINEON:
+ case R_IMF_IMTYPE_DPX:
+ case R_IMF_IMTYPE_RADHDR:
+ case R_IMF_IMTYPE_OPENEXR:
+ case R_IMF_IMTYPE_MULTILAYER:
+ return TRUE;
+ }
+ return 0;
+}
+
char BKE_imtype_valid_channels(const char imtype)
{
char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */
@@ -1207,6 +1242,9 @@ void BKE_imformat_defaults(ImageFormatData *im_format)
im_format->imtype = R_IMF_IMTYPE_PNG;
im_format->quality = 90;
im_format->compress = 90;
+
+ BKE_color_managed_display_settings_init(&im_format->display_settings);
+ BKE_color_managed_view_settings_init(&im_format->view_settings);
}
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)
@@ -1477,10 +1515,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
int x, y, y_ofs;
float h_fixed;
const int mono = blf_mono_font_render; // XXX
+ struct ColorManagedDisplay *display;
+ const char *display_device;
/* this could be an argument if we want to operate on non linear float imbuf's
* for now though this is only used for renders which use scene settings */
- const int do_color_management = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0;
#define BUFF_MARGIN_X 2
#define BUFF_MARGIN_Y 1
@@ -1488,6 +1527,9 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
if (!rect && !rectf)
return;
+ display_device = scene->display_settings.display_device;
+ display = IMB_colormanagement_display_get_named(display_device);
+
stampdata(scene, camera, &stamp_data, 1);
/* TODO, do_versions */
@@ -1497,7 +1539,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* set before return */
BLF_size(mono, scene->r.stamp_font_id, 72);
- BLF_buffer(mono, rectf, rect, width, height, channels, do_color_management);
+ BLF_buffer(mono, rectf, rect, width, height, channels, display);
BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
pad = BLF_width_max(mono);
@@ -1514,7 +1556,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
y -= h;
/* also a little of space to the background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
/* and draw the text. */
@@ -1531,7 +1573,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
y -= h;
/* and space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1547,7 +1589,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
y -= h;
/* and space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1563,7 +1605,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
y -= h;
/* and space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1578,7 +1620,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
/* and pad the text. */
@@ -1594,7 +1636,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed;
/* extra space for background */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
/* and pad the text. */
@@ -1609,7 +1651,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
/* and pad the text. */
@@ -1624,7 +1666,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.camera);
@@ -1637,7 +1679,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.cameralens);
@@ -1650,7 +1692,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
x = width - w - 2;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
/* and pad the text. */
@@ -1666,7 +1708,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
y = height - h;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+ 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);
BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1878,12 +1920,12 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int
}
/* used by sequencer too */
-struct anim *openanim(const char *name, int flags, int streamindex)
+struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
{
struct anim *anim;
struct ImBuf *ibuf;
- anim = IMB_open_anim(name, flags, streamindex);
+ anim = IMB_open_anim(name, flags, streamindex, colorspace);
if (anim == NULL) return NULL;
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
@@ -2177,8 +2219,10 @@ void BKE_image_backup_render(Scene *scene, Image *ima)
/* in that case we have to build a render-result */
static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
{
+ const char *colorspace = ima->colorspace_settings.name;
+ int predivide = ima->flag & IMA_CM_PREDIVIDE;
- ima->rr = RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y);
+ ima->rr = RE_MultilayerConvert(ibuf->userdata, colorspace, predivide, ibuf->x, ibuf->y);
#ifdef WITH_OPENEXR
IMB_exr_close(ibuf->userdata);
@@ -2226,7 +2270,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
flag |= IB_premul;
/* read ibuf */
- ibuf = IMB_loadiffname(name, flag);
+ ibuf = IMB_loadiffname(name, flag, ima->colorspace_settings.name);
#if 0
if (ibuf) {
@@ -2304,7 +2348,6 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f
ibuf->flags |= IB_rectfloat;
ibuf->mall = IB_rectfloat;
ibuf->channels = rpass->channels;
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
image_initialize_after_load(ima, ibuf);
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame);
@@ -2334,7 +2377,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
BKE_image_user_file_path(iuser, ima, str);
/* FIXME: make several stream accessible in image editor, too*/
- ima->anim = openanim(str, IB_rect, 0);
+ ima->anim = openanim(str, IB_rect, 0, ima->colorspace_settings.name);
/* let's initialize this user */
if (ima->anim && iuser && iuser->frames == 0)
@@ -2385,8 +2428,8 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
flag = IB_rect | IB_multilayer;
if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul;
- ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data,
- ima->packedfile->size, flag, "<packed data>");
+ ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag,
+ ima->colorspace_settings.name, "<packed data>");
}
else {
flag = IB_rect | IB_multilayer | IB_metadata;
@@ -2398,7 +2441,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
BKE_image_user_file_path(iuser, ima, str);
/* read ibuf */
- ibuf = IMB_loadiffname(str, flag);
+ ibuf = IMB_loadiffname(str, flag, ima->colorspace_settings.name);
}
if (ibuf) {
@@ -2455,7 +2498,6 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
ibuf->rect_float = rpass->rect;
ibuf->flags |= IB_rectfloat;
ibuf->channels = rpass->channels;
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0);
}
@@ -2561,6 +2603,13 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
}
+ /* invalidate color managed buffers if render result changed */
+ BLI_lock_thread(LOCK_COLORMANAGE);
+ if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float != rectf)
+ {
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+ }
+
ibuf->x = rres.rectx;
ibuf->y = rres.recty;
@@ -2592,8 +2641,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
ibuf->flags &= ~IB_zbuffloat;
}
- /* since its possible to access the buffer from the image directly, set the profile [#25073] */
- ibuf->profile = (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE;
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+
ibuf->dither = dither;
if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) {
@@ -2750,7 +2799,8 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
/* UV testgrid or black or solid etc */
if (ima->gen_x == 0) ima->gen_x = 1024;
if (ima->gen_y == 0) ima->gen_y = 1024;
- ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
+ ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type,
+ color, &ima->colorspace_settings);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok = IMA_OK_LOADED;
}
@@ -2966,5 +3016,8 @@ void BKE_image_get_aspect(Image *image, float *aspx, float *aspy)
*aspx = 1.0;
/* x is always 1 */
- *aspy = image->aspy / image->aspx;
+ if (image)
+ *aspy = image->aspy / image->aspx;
+ else
+ *aspy = 1.0f;
}
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 4d7013b9f73..37572eebed6 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -289,7 +289,11 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
BLF_size(mono, 54, 72); /* hard coded size! */
- BLF_buffer(mono, rect_float, rect, width, height, 4, TRUE);
+ /* OCIO_TODO: using NULL as display will assume using sRGB display
+ * this is correct since currently generated images are assumed to be in sRGB space,
+ * but this would probably needed to be fixed in some way
+ */
+ BLF_buffer(mono, rect_float, rect, width, height, 4, NULL);
for (y = 0; y < height; y += step) {
text[1] = '1';
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 1c6974b2615..ebb95a6561e 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -48,8 +48,11 @@
#include "BKE_global.h"
-#define CLOTH_OPENMP_LIMIT 512
+#ifdef _OPENMP
+# define CLOTH_OPENMP_LIMIT 512
+#endif
+#if 0 /* debug timing */
#ifdef _WIN32
#include <windows.h>
static LARGE_INTEGER _itstart, _itend;
@@ -81,7 +84,7 @@ double itval(void)
static struct timeval _itstart, _itend;
static struct timezone itz;
-void itstart(void)
+static void itstart(void)
{
gettimeofday(&_itstart, &itz);
}
@@ -89,7 +92,7 @@ static void itend(void)
{
gettimeofday(&_itend, &itz);
}
-double itval(void)
+static double itval(void)
{
double t1, t2;
t1 = (double)_itstart.tv_sec + (double)_itstart.tv_usec/(1000*1000);
@@ -97,6 +100,7 @@ double itval(void)
return t2-t1;
}
#endif
+#endif /* debug timing */
static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
static float ZERO[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
@@ -1691,13 +1695,13 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect
mul_bfmatrix_lfvector(dFdXmV, dFdX, lV);
add_lfvectorS_lfvectorS(B, lF, dt, dFdXmV, (dt*dt), numverts);
-
- itstart();
-
+
+ // itstart();
+
cg_filtered(dV, A, B, z, S); /* conjugate gradient algorithm to solve Ax=b */
// cg_filtered_pre(dV, A, B, z, S, P, Pinv, bigI);
-
- itend();
+
+ // itend();
// printf("cg_filtered calc time: %f\n", (float)itval());
cp_lfvector(olddV, dV, numverts);
@@ -1713,7 +1717,7 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect
* (edge distance constraints) in a lagrangian solver. then add forces to help
* guide the implicit solver to that state. this function is called after
* collisions*/
-int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt)
+static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt)
{
Cloth *cloth= clmd->clothObject;
float (*cos)[3] = MEM_callocN(sizeof(float)*3*cloth->numverts, "cos cloth_calc_helper_forces");
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index b79608342dd..5b05ce02104 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -94,7 +94,7 @@ void BKE_key_free(Key *key)
}
-void free_key_nolib(Key *key)
+void BKE_key_free_nolib(Key *key)
{
KeyBlock *kb;
@@ -121,7 +121,7 @@ void free_key_nolib(Key *key)
/* from misc_util: flip the bytes from x */
/* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
-Key *add_key(ID *id) /* common function */
+Key *BKE_key_add(ID *id) /* common function */
{
Key *key;
char *el;
@@ -196,7 +196,7 @@ Key *BKE_key_copy(Key *key)
}
-Key *copy_key_nolib(Key *key)
+Key *BKE_key_copy_nolib(Key *key)
{
Key *keyn;
KeyBlock *kbn, *kb;
@@ -241,7 +241,7 @@ void BKE_key_make_local(Key *key)
* currently being called.
*/
-void sort_keys(Key *key)
+void BKE_key_sort(Key *key)
{
KeyBlock *kb;
KeyBlock *kb2;
@@ -711,7 +711,7 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const
}
}
-void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb, const int mode)
+void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb, const int mode)
{
KeyBlock *kb;
int *ofsp, ofs[3], elemsize, b;
@@ -1071,7 +1071,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
{
- KeyBlock *k[4], *actkb = ob_get_keyblock(ob);
+ KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag = 0;
@@ -1106,7 +1106,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
kb->weights = get_weights_array(ob, kb->vgroup);
}
- do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY);
+ BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY);
for (kb = key->block.first; kb; kb = kb->next) {
if (kb->weights) MEM_freeN(kb->weights);
@@ -1154,11 +1154,11 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const
for (a = 0, nu = cu->nurb.first; nu; nu = nu->next, a += step) {
if (nu->bp) {
step = nu->pntsu * nu->pntsv;
- do_rel_key(a, a + step, tot, out, key, actkb, KEY_MODE_BPOINT);
+ BKE_key_evaluate_relative(a, a + step, tot, out, key, actkb, KEY_MODE_BPOINT);
}
else if (nu->bezt) {
step = 3 * nu->pntsu;
- do_rel_key(a, a + step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE);
+ BKE_key_evaluate_relative(a, a + step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE);
}
else {
step = 0;
@@ -1169,7 +1169,7 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const
static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
{
Curve *cu = ob->data;
- KeyBlock *k[4], *actkb = ob_get_keyblock(ob);
+ KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag = 0;
@@ -1251,7 +1251,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
{
Lattice *lt = ob->data;
- KeyBlock *k[4], *actkb = ob_get_keyblock(ob);
+ KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag;
@@ -1277,7 +1277,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
for (kb = key->block.first; kb; kb = kb->next)
kb->weights = get_weights_array(ob, kb->vgroup);
- do_rel_key(0, tot, tot, out, key, actkb, KEY_MODE_DUMMY);
+ BKE_key_evaluate_relative(0, tot, tot, out, key, actkb, KEY_MODE_DUMMY);
for (kb = key->block.first; kb; kb = kb->next) {
if (kb->weights) MEM_freeN(kb->weights);
@@ -1302,8 +1302,8 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
/* returns key coordinates (+ tilt) when key applied, NULL otherwise */
float *do_ob_key(Scene *scene, Object *ob)
{
- Key *key = ob_get_key(ob);
- KeyBlock *actkb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *actkb = BKE_keyblock_from_object(ob);
char *out;
int tot = 0, size = 0;
@@ -1386,7 +1386,7 @@ float *do_ob_key(Scene *scene, Object *ob)
return (float *)out;
}
-Key *ob_get_key(Object *ob)
+Key *BKE_key_from_object(Object *ob)
{
if (ob == NULL) return NULL;
@@ -1405,7 +1405,7 @@ Key *ob_get_key(Object *ob)
return NULL;
}
-KeyBlock *add_keyblock(Key *key, const char *name)
+KeyBlock *BKE_keyblock_add(Key *key, const char *name)
{
KeyBlock *kb;
float curpos = -0.1;
@@ -1439,7 +1439,7 @@ KeyBlock *add_keyblock(Key *key, const char *name)
/**
* \note caller may want to set this to current time, but don't do it here since we need to sort
- * which could cause problems in some cases, see #add_keyblock_ctime */
+ * which could cause problems in some cases, see #BKE_keyblock_add_ctime */
kb->pos = curpos + 0.1f; /* only used for absolute shape keys */
return kb;
@@ -1453,22 +1453,22 @@ KeyBlock *add_keyblock(Key *key, const char *name)
* \param name Optional name for the new keyblock.
* \param do_force always use ctime even for relative keys.
*/
-KeyBlock *add_keyblock_ctime(Key *key, const char *name, const short do_force)
+KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, const short do_force)
{
- KeyBlock *kb = add_keyblock(key, name);
+ KeyBlock *kb = BKE_keyblock_add(key, name);
if (do_force || (key->type != KEY_RELATIVE)) {
kb->pos = key->ctime / 100.0f;
- sort_keys(key);
+ BKE_key_sort(key);
}
return kb;
}
/* only the active keyblock */
-KeyBlock *ob_get_keyblock(Object *ob)
+KeyBlock *BKE_keyblock_from_object(Object *ob)
{
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
@@ -1478,9 +1478,9 @@ KeyBlock *ob_get_keyblock(Object *ob)
return NULL;
}
-KeyBlock *ob_get_reference_keyblock(Object *ob)
+KeyBlock *BKE_keyblock_from_object_reference(Object *ob)
{
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
if (key)
return key->refkey;
@@ -1489,7 +1489,7 @@ KeyBlock *ob_get_reference_keyblock(Object *ob)
}
/* get the appropriate KeyBlock given an index */
-KeyBlock *key_get_keyblock(Key *key, int index)
+KeyBlock *BKE_keyblock_from_key(Key *key, int index)
{
KeyBlock *kb;
int i;
@@ -1509,18 +1509,29 @@ KeyBlock *key_get_keyblock(Key *key, int index)
}
/* get the appropriate KeyBlock given a name to search for */
-KeyBlock *key_get_named_keyblock(Key *key, const char name[])
+KeyBlock *BKE_keyblock_find_name(Key *key, const char name[])
{
- if (key && name)
- return BLI_findstring(&key->block, name, offsetof(KeyBlock, name));
-
- return NULL;
+ return BLI_findstring(&key->block, name, offsetof(KeyBlock, name));
+}
+
+/**
+ * \brief copy shape-key attributes, but not key data.or name/uid
+ */
+void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src)
+{
+ kb_dst->pos = kb_src->pos;
+ kb_dst->curval = kb_src->curval;
+ kb_dst->type = kb_src->type;
+ kb_dst->relative = kb_src->relative;
+ BLI_strncpy(kb_dst->vgroup, kb_src->vgroup, sizeof(kb_dst->vgroup));
+ kb_dst->slidermin = kb_src->slidermin;
+ kb_dst->slidermax = kb_src->slidermax;
}
/* Get RNA-Path for 'value' setting of the given ShapeKey
* NOTE: the user needs to free the returned string once they're finish with it
*/
-char *key_get_curValue_rnaPath(Key *key, KeyBlock *kb)
+char *BKE_keyblock_curval_rnapath_get(Key *key, KeyBlock *kb)
{
PointerRNA ptr;
PropertyRNA *prop;
@@ -1542,7 +1553,7 @@ char *key_get_curValue_rnaPath(Key *key, KeyBlock *kb)
/* conversion functions */
/************************* Lattice ************************/
-void latt_to_key(Lattice *lt, KeyBlock *kb)
+void BKE_key_convert_from_lattice(Lattice *lt, KeyBlock *kb)
{
BPoint *bp;
float *fp;
@@ -1563,7 +1574,7 @@ void latt_to_key(Lattice *lt, KeyBlock *kb)
}
}
-void key_to_latt(KeyBlock *kb, Lattice *lt)
+void BKE_key_convert_to_lattice(KeyBlock *kb, Lattice *lt)
{
BPoint *bp;
float *fp;
@@ -1581,7 +1592,7 @@ void key_to_latt(KeyBlock *kb, Lattice *lt)
}
/************************* Curve ************************/
-void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
+void BKE_key_convert_from_curve(Curve *cu, KeyBlock *kb, ListBase *nurb)
{
Nurb *nu;
BezTriple *bezt;
@@ -1632,7 +1643,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
}
}
-void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
+void BKE_key_convert_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
{
Nurb *nu;
BezTriple *bezt;
@@ -1683,7 +1694,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
}
/************************* Mesh ************************/
-void mesh_to_key(Mesh *me, KeyBlock *kb)
+void BKE_key_convert_from_mesh(Mesh *me, KeyBlock *kb)
{
MVert *mvert;
float *fp;
@@ -1704,7 +1715,7 @@ void mesh_to_key(Mesh *me, KeyBlock *kb)
}
}
-void key_to_mesh(KeyBlock *kb, Mesh *me)
+void BKE_key_convert_to_mesh(KeyBlock *kb, Mesh *me)
{
MVert *mvert;
float *fp;
@@ -1721,7 +1732,7 @@ void key_to_mesh(KeyBlock *kb, Mesh *me)
}
/************************* vert coords ************************/
-float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3]
+float (*BKE_key_convert_to_vertcos(Object * ob, KeyBlock * kb))[3]
{
float (*vertCos)[3], *co;
float *fp = kb->data;
@@ -1743,7 +1754,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3]
if (tot == 0) return NULL;
- vertCos = MEM_callocN(tot * sizeof(*vertCos), "key_to_vertcos vertCos");
+ vertCos = MEM_callocN(tot * sizeof(*vertCos), "BKE_key_convert_to_vertcos vertCos");
/* Copy coords to array */
co = (float *)vertCos;
@@ -1797,7 +1808,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3]
return vertCos;
}
-void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
+void BKE_key_convert_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)[3])
{
float *co = (float *)vertCos, *fp;
int tot = 0, a, elemsize;
@@ -1826,7 +1837,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
return;
}
- fp = kb->data = MEM_callocN(tot * elemsize, "key_to_vertcos vertCos");
+ fp = kb->data = MEM_callocN(tot * elemsize, "BKE_key_convert_to_vertcos vertCos");
/* Copy coords to keyblock */
@@ -1877,7 +1888,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
}
}
-void offset_to_key(Object *ob, KeyBlock *kb, float (*ofs)[3])
+void BKE_key_convert_from_offset(Object *ob, KeyBlock *kb, float (*ofs)[3])
{
int a;
float *co = (float *)ofs, *fp = kb->data;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 97b46d4829d..3564071334c 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1112,7 +1112,8 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[
return FALSE;
}
-int BKE_mask_evaluate_parent_delta(MaskParent *parent, float ctime, float r_delta[2])
+/* could make external but for now its only used internally */
+static int mask_evaluate_parent_delta(MaskParent *parent, float ctime, float r_delta[2])
{
float parent_co[2];
@@ -1452,7 +1453,7 @@ void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do
*point_deform = *point;
point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
- if (BKE_mask_evaluate_parent_delta(&point->parent, ctime, delta)) {
+ if (mask_evaluate_parent_delta(&point->parent, ctime, delta)) {
add_v2_v2(point_deform->bezt.vec[0], delta);
add_v2_v2(point_deform->bezt.vec[1], delta);
add_v2_v2(point_deform->bezt.vec[2], delta);
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 18617f0ef2e..1a9ac9dc0af 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -253,9 +253,9 @@ void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
}
-void maskrasterize_spline_differentiate_point_outset(float (*diff_feather_points)[2], float (*diff_points)[2],
- const unsigned int tot_diff_point, const float ofs,
- const short do_test)
+static void maskrasterize_spline_differentiate_point_outset(float (*diff_feather_points)[2], float (*diff_points)[2],
+ const unsigned int tot_diff_point, const float ofs,
+ const short do_test)
{
unsigned int k_prev = tot_diff_point - 2;
unsigned int k_curr = tot_diff_point - 1;
@@ -410,8 +410,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
{
MemArena *arena = BLI_memarena_new(1 << 16, __func__);
- const float bucket_dim_x = BLI_RCT_SIZE_X(&layer->bounds);
- const float bucket_dim_y = BLI_RCT_SIZE_Y(&layer->bounds);
+ const float bucket_dim_x = BLI_rctf_size_x(&layer->bounds);
+ const float bucket_dim_y = BLI_rctf_size_y(&layer->bounds);
layer->buckets_x = (bucket_dim_x / pixel_size) / (float)BUCKET_PIXELS_PER_CELL;
layer->buckets_y = (bucket_dim_y / pixel_size) / (float)BUCKET_PIXELS_PER_CELL;
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index fc1c5e43cbf..3408e2393c9 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -942,7 +942,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
if (ma->texco & (TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM | TEXCO_STRAND | TEXCO_STRESS)) needuv = 1;
else if (ma->texco & (TEXCO_GLOB | TEXCO_UV | TEXCO_OBJECT | TEXCO_SPEED)) needuv = 1;
- else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW | TEXCO_STICKY)) needuv = 1;
+ else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW)) needuv = 1;
if ((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT))
needtang = 1;
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 3925c3cc858..2030ab0f552 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -186,7 +186,7 @@ void BKE_mball_unlink(MetaBall *mb)
/* do not free mball itself */
void BKE_mball_free(MetaBall *mb)
{
- BKE_mball_unlink(mb);
+ BKE_mball_unlink(mb);
if (mb->adt) {
BKE_free_animdata((ID *)mb);
@@ -562,7 +562,7 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
basis = ob;
basisnr = obnr;
}
- }
+ }
}
}
@@ -691,7 +691,7 @@ static float densfunc(MetaElem *ball, float x, float y, float z)
/* *** end deprecated *** */
}
- dist2 = 1.0f - (len_v3(dvec) / ball->rad2);
+ dist2 = 1.0f - (len_squared_v3(dvec) / ball->rad2);
if ((ball->flag & MB_NEGATIVE) == 0) {
return (dist2 < 0.0f) ? -0.5f : (ball->s * dist2 * dist2 * dist2) - 0.5f;
@@ -732,7 +732,7 @@ static octal_node *find_metaball_octal_node(octal_node *node, float x, float y,
return find_metaball_octal_node(node->nodes[2], x, y, z, depth--);
else
return node;
- }
+ }
}
}
else {
@@ -762,7 +762,7 @@ static octal_node *find_metaball_octal_node(octal_node *node, float x, float y,
return find_metaball_octal_node(node->nodes[6], x, y, z, depth--);
else
return node;
- }
+ }
}
}
@@ -861,7 +861,7 @@ static void *new_pgn_element(int size)
}
BLI_freelistN(&lb);
- return NULL;
+ return NULL;
}
size = 4 * ( (size + 3) / 4);
@@ -1628,7 +1628,7 @@ static void polygonize(PROCESS *mbproc, MetaBall *mb)
for (a = 0; a < G_mb.totelem; a++) {
/* try to find 8 points on the surface for each MetaElem */
- find_first_points(mbproc, mb, a);
+ find_first_points(mbproc, mb, a);
}
/* polygonize all MetaElems of current MetaBall */
@@ -2038,7 +2038,7 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float
}
- /* ml belongs to the (4)5th node too */
+ /* ml belongs to the (4)5th node too */
if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 4);
}
@@ -2226,7 +2226,7 @@ static void init_metaball_octal_tree(int depth)
}
}
- /* size of first node */
+ /* size of first node */
size[0] = node->x_max - node->x_min;
size[1] = node->y_max - node->y_min;
size[2] = node->z_max - node->z_min;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 8c3ec7e2e40..206d80a6ff0 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -367,7 +367,6 @@ void mesh_update_customdata_pointers(Mesh *me, const short do_ensure_tess_cd)
me->mvert = CustomData_get_layer(&me->vdata, CD_MVERT);
me->dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT);
- me->msticky = CustomData_get_layer(&me->vdata, CD_MSTICKY);
me->medge = CustomData_get_layer(&me->edata, CD_MEDGE);
@@ -1944,8 +1943,9 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo
MVert *mv = &mverts[i];
float *no = tnorms[i];
- if (normalize_v3(no) == 0.0f)
+ if (UNLIKELY(normalize_v3(no) == 0.0f)) {
normalize_v3_v3(no, mv->co);
+ }
normal_float_to_short_v3(mv->no, no);
}
@@ -1981,8 +1981,9 @@ void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces,
MVert *mv = &mverts[i];
float *no = tnorms[i];
- if (normalize_v3(no) == 0.0f)
+ if (UNLIKELY(normalize_v3(no) == 0.0f)) {
normalize_v3_v3(no, mv->co);
+ }
normal_float_to_short_v3(mv->no, no);
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 65538e5bea2..28de80a7157 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -482,7 +482,7 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
}
/* shape key modifier, not yet for curves */
- if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
+ if (ELEM(ob->type, OB_MESH, OB_LATTICE) && BKE_key_from_object(ob)) {
if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage;
else
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 268234c7e73..97d4c150b84 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -66,6 +66,7 @@
#include "BKE_animsys.h"
#include "BKE_constraint.h"
+#include "BKE_colortools.h"
#include "BKE_library.h"
#include "BKE_global.h"
#include "BKE_main.h"
@@ -73,6 +74,7 @@
#include "BKE_image.h" /* openanim */
#include "BKE_tracking.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_moviecache.h"
@@ -197,19 +199,25 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user,
struct ImBuf *ibuf;
char name[FILE_MAX];
int loadflag, use_proxy = FALSE;
+ char *colorspace;
use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL;
if (use_proxy) {
int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
get_proxy_fname(clip, user->render_size, undistort, framenr, name);
+
+ /* proxies were built using default color space settings */
+ colorspace = NULL;
}
- else
+ else {
get_sequence_fname(clip, framenr, name);
+ colorspace = clip->colorspace_settings.name;
+ }
loadflag = IB_rect | IB_multilayer;
/* read ibuf */
- ibuf = IMB_loadiffname(name, loadflag);
+ ibuf = IMB_loadiffname(name, loadflag, colorspace);
return ibuf;
}
@@ -223,7 +231,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
BLI_path_abs(str, ID_BLEND_PATH(G.main, &clip->id));
/* FIXME: make several stream accessible in image editor, too */
- clip->anim = openanim(str, IB_rect, 0);
+ clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name);
if (clip->anim) {
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
@@ -383,7 +391,7 @@ static int moviecache_hashcmp(const void *av, const void *bv)
return 0;
}
-void *moviecache_getprioritydata(void *key_v)
+static void *moviecache_getprioritydata(void *key_v)
{
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v;
MovieClipCachePriorityData *priority_data;
@@ -394,7 +402,7 @@ void *moviecache_getprioritydata(void *key_v)
return priority_data;
}
-int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v)
+static int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v)
{
MovieClipImBufCacheKey *last_userkey = (MovieClipImBufCacheKey *) last_userkey_v;
MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v;
@@ -402,7 +410,7 @@ int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v)
return -abs(last_userkey->framenr - priority_data->framenr);
}
-void moviecache_prioritydeleter(void *priority_data_v)
+static void moviecache_prioritydeleter(void *priority_data_v)
{
MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v;
@@ -478,6 +486,7 @@ static MovieClip *movieclip_alloc(const char *name)
clip->aspx = clip->aspy = 1.0f;
BKE_tracking_settings_init(&clip->tracking);
+ BKE_color_managed_colorspace_settings_init(&clip->colorspace_settings);
clip->proxy.build_size_flag = IMB_PROXY_25;
clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN |
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f8f2ae86f1d..6fd7a55dd0a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -307,17 +307,27 @@ void BKE_object_free(Object *ob)
ID *id = ob->data;
id->us--;
if (id->us == 0) {
- if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data);
- else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data);
- else if (ob->type == OB_MBALL) BKE_mball_unlink(ob->data);
+ switch (ob->type) {
+ case OB_MESH:
+ BKE_mesh_unlink((Mesh *)id);
+ break;
+ case OB_CURVE:
+ BKE_curve_unlink((Curve *)id);
+ break;
+ case OB_MBALL:
+ BKE_mball_unlink((MetaBall *)id);
+ break;
+ }
}
ob->data = NULL;
}
-
- for (a = 0; a < ob->totcol; a++) {
- if (ob->mat[a]) ob->mat[a]->id.us--;
+
+ if (ob->mat) {
+ for (a = 0; a < ob->totcol; a++) {
+ if (ob->mat[a]) ob->mat[a]->id.us--;
+ }
+ MEM_freeN(ob->mat);
}
- if (ob->mat) MEM_freeN(ob->mat);
if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat = NULL;
ob->matbits = NULL;
@@ -332,7 +342,7 @@ void BKE_object_free(Object *ob)
BKE_pose_free(ob->pose);
if (ob->mpath)
animviz_free_motionpath(ob->mpath);
- free_properties(&ob->prop);
+ BKE_bproperty_free_list(&ob->prop);
BKE_object_free_modifiers(ob);
free_sensors(&ob->sensors);
@@ -1079,12 +1089,12 @@ static void copy_object_pose(Object *obn, Object *ob)
}
}
-static int object_pose_context(Object *ob)
+int BKE_object_pose_context_check(Object *ob)
{
- if ( (ob) &&
- (ob->type == OB_ARMATURE) &&
- (ob->pose) &&
- (ob->mode & OB_MODE_POSE))
+ if ((ob) &&
+ (ob->type == OB_ARMATURE) &&
+ (ob->pose) &&
+ (ob->mode & OB_MODE_POSE))
{
return 1;
}
@@ -1098,12 +1108,12 @@ Object *BKE_object_pose_armature_get(Object *ob)
if (ob == NULL)
return NULL;
- if (object_pose_context(ob))
+ if (BKE_object_pose_context_check(ob))
return ob;
ob = modifiers_isDeformedByArmature(ob);
- if (object_pose_context(ob))
+ if (BKE_object_pose_context_check(ob))
return ob;
return NULL;
@@ -1147,7 +1157,7 @@ Object *BKE_object_copy(Object *ob)
}
obn->prop.first = obn->prop.last = NULL;
- copy_properties(&obn->prop, &ob->prop);
+ BKE_bproperty_copy_list(&obn->prop, &ob->prop);
copy_sensors(&obn->sensors, &ob->sensors);
copy_controllers(&obn->controllers, &ob->controllers);
@@ -1766,9 +1776,8 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
static void give_parvert(Object *par, int nr, float vec[3])
{
BMEditMesh *em;
- int a, count;
-
- vec[0] = vec[1] = vec[2] = 0.0f;
+
+ zero_v3(vec);
if (par->type == OB_MESH) {
Mesh *me = par->data;
@@ -1795,18 +1804,28 @@ static void give_parvert(Object *par, int nr, float vec[3])
dm = (em) ? em->derivedFinal : par->derivedFinal;
if (dm) {
- MVert *mvert = dm->getVertArray(dm);
- int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
- int i, vindex, numVerts = dm->getNumVerts(dm);
-
- /* get the average of all verts with (original index == nr) */
- count = 0;
- for (i = 0; i < numVerts; i++) {
- vindex = (index) ? index[i] : i;
-
- if (vindex == nr) {
- add_v3_v3(vec, mvert[i].co);
- count++;
+ int count = 0;
+ int numVerts = dm->getNumVerts(dm);
+
+ if (nr < numVerts) {
+ MVert *mvert = dm->getVertArray(dm);
+ int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
+ int i;
+
+ /* get the average of all verts with (original index == nr) */
+ if (index) {
+ for (i = 0; i < numVerts; i++) {
+ if (index[i] == nr) {
+ add_v3_v3(vec, mvert[i].co);
+ count++;
+ }
+ }
+ }
+ else {
+ if (nr < numVerts) {
+ add_v3_v3(vec, mvert[nr].co);
+ count++;
+ }
}
}
@@ -1828,71 +1847,31 @@ static void give_parvert(Object *par, int nr, float vec[3])
}
}
else if (ELEM(par->type, OB_CURVE, OB_SURF)) {
- Nurb *nu;
- Curve *cu;
- BPoint *bp;
- BezTriple *bezt;
- int found = 0;
- ListBase *nurbs;
-
- cu = par->data;
- nurbs = BKE_curve_nurbs_get(cu);
- nu = nurbs->first;
-
- count = 0;
- while (nu && !found) {
- if (nu->type == CU_BEZIER) {
- bezt = nu->bezt;
- a = nu->pntsu;
- while (a--) {
- if (count == nr) {
- found = 1;
- copy_v3_v3(vec, bezt->vec[1]);
- break;
- }
- count++;
- bezt++;
- }
- }
- else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
- while (a--) {
- if (count == nr) {
- found = 1;
- memcpy(vec, bp->vec, sizeof(float) * 3);
- break;
- }
- count++;
- bp++;
- }
- }
- nu = nu->next;
- }
+ Curve *cu = par->data;
+ ListBase *nurb = BKE_curve_nurbs_get(cu);;
+ BKE_nurbList_index_get_co(nurb, nr, vec);
}
else if (par->type == OB_LATTICE) {
- Lattice *latt = par->data;
- BPoint *bp;
- DispList *dl = BKE_displist_find(&par->disp, DL_VERTS);
- float *co = dl ? dl->verts : NULL;
-
+ Lattice *latt = par->data;
+ DispList *dl = BKE_displist_find(&par->disp, DL_VERTS);
+ float (*co)[3] = dl ? (float (*)[3])dl->verts : NULL;
+ int tot;
+
if (latt->editlatt) latt = latt->editlatt->latt;
-
- a = latt->pntsu * latt->pntsv * latt->pntsw;
- count = 0;
- bp = latt->def;
- while (a--) {
- if (count == nr) {
- if (co)
- memcpy(vec, co, 3 * sizeof(float));
- else
- memcpy(vec, bp->vec, 3 * sizeof(float));
- break;
+
+ tot = latt->pntsu * latt->pntsv * latt->pntsw;
+
+ /* ensure dl is correct size */
+ BLI_assert(dl == NULL || dl->nr == tot);
+
+ if (nr < tot) {
+ if (co) {
+ copy_v3_v3(vec, co[nr]);
+ }
+ else {
+ copy_v3_v3(vec, latt->def[nr].vec);
}
- count++;
- if (co) co += 3;
- else bp++;
}
}
}
@@ -2899,22 +2878,22 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int
int newkey = 0;
if (key == NULL) {
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
newkey = 1;
}
if (newkey || from_mix == FALSE) {
/* create from mesh */
- kb = add_keyblock_ctime(key, name, FALSE);
- mesh_to_key(me, kb);
+ kb = BKE_keyblock_add_ctime(key, name, FALSE);
+ BKE_key_convert_from_mesh(me, kb);
}
else {
/* copy from current values */
float *data = do_ob_key(scene, ob);
/* create new block with prepared data */
- kb = add_keyblock_ctime(key, name, FALSE);
+ kb = BKE_keyblock_add_ctime(key, name, FALSE);
kb->data = data;
kb->totelem = me->totvert;
}
@@ -2930,20 +2909,20 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
int newkey = 0;
if (key == NULL) {
- key = lt->key = add_key((ID *)lt);
+ key = lt->key = BKE_key_add((ID *)lt);
key->type = KEY_RELATIVE;
newkey = 1;
}
if (newkey || from_mix == FALSE) {
- kb = add_keyblock_ctime(key, name, FALSE);
+ kb = BKE_keyblock_add_ctime(key, name, FALSE);
if (!newkey) {
KeyBlock *basekb = (KeyBlock *)key->block.first;
kb->data = MEM_dupallocN(basekb->data);
kb->totelem = basekb->totelem;
}
else {
- latt_to_key(lt, kb);
+ BKE_key_convert_from_lattice(lt, kb);
}
}
else {
@@ -2951,7 +2930,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
float *data = do_ob_key(scene, ob);
/* create new block with prepared data */
- kb = add_keyblock_ctime(key, name, FALSE);
+ kb = BKE_keyblock_add_ctime(key, name, FALSE);
kb->totelem = lt->pntsu * lt->pntsv * lt->pntsw;
kb->data = data;
}
@@ -2968,21 +2947,21 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
int newkey = 0;
if (key == NULL) {
- key = cu->key = add_key((ID *)cu);
+ key = cu->key = BKE_key_add((ID *)cu);
key->type = KEY_RELATIVE;
newkey = 1;
}
if (newkey || from_mix == FALSE) {
/* create from curve */
- kb = add_keyblock_ctime(key, name, FALSE);
+ kb = BKE_keyblock_add_ctime(key, name, FALSE);
if (!newkey) {
KeyBlock *basekb = (KeyBlock *)key->block.first;
kb->data = MEM_dupallocN(basekb->data);
kb->totelem = basekb->totelem;
}
else {
- curve_to_key(cu, kb, lb);
+ BKE_key_convert_from_curve(cu, kb, lb);
}
}
else {
@@ -2990,7 +2969,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
float *data = do_ob_key(scene, ob);
/* create new block with prepared data */
- kb = add_keyblock_ctime(key, name, FALSE);
+ kb = BKE_keyblock_add_ctime(key, name, FALSE);
kb->totelem = BKE_nurbList_verts_count(lb);
kb->data = data;
}
@@ -3020,7 +2999,7 @@ int BKE_object_is_modified(Scene *scene, Object *ob)
{
int flag = 0;
- if (ob_get_key(ob)) {
+ if (BKE_key_from_object(ob)) {
flag |= eModifierMode_Render;
}
else {
@@ -3288,7 +3267,7 @@ void BKE_object_groups_clear(Scene *scene, Base *base, Object *object)
{
Group *group = NULL;
- BLI_assert(base->object == object);
+ BLI_assert((base == NULL) || (base->object == object));
if (scene && base == NULL) {
base = BKE_scene_base_find(scene, object);
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index b862a824d50..4f3921936e8 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -1117,19 +1117,20 @@ void BKE_simulate_ocean_cache(struct OceanCache *och, int frame)
/* if image is already loaded in mem, return */
if (och->ibufs_disp[f] != NULL) return;
+ /* use default color spaces since we know for sure cache files were saved with default settings too */
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE);
- och->ibufs_disp[f] = IMB_loadiffname(string, 0);
+ och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL);
//if (och->ibufs_disp[f] == NULL) printf("error loading %s\n", string);
//else printf("loaded cache %s\n", string);
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM);
- och->ibufs_foam[f] = IMB_loadiffname(string, 0);
+ och->ibufs_foam[f] = IMB_loadiffname(string, 0, NULL);
//if (och->ibufs_foam[f] == NULL) printf("error loading %s\n", string);
//else printf("loaded cache %s\n", string);
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL);
- och->ibufs_norm[f] = IMB_loadiffname(string, 0);
+ och->ibufs_norm[f] = IMB_loadiffname(string, 0, NULL);
//if (och->ibufs_norm[f] == NULL) printf("error loading %s\n", string);
//else printf("loaded cache %s\n", string);
}
@@ -1172,8 +1173,6 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
- ibuf_disp->profile = ibuf_foam->profile = ibuf_normal->profile = IB_PROFILE_LINEAR_RGB;
-
BKE_simulate_ocean(o, och->time[i], och->wave_scale, och->chop_amount);
/* add new foam */
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 26952db8fba..ef03db7ed8f 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -4539,8 +4539,8 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
/* can happen with bad pointcache or physics calculation
* since this becomes geometry, nan's and inf's crash raytrace code.
* better not allow this. */
- if (!finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) ||
- !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) )
+ if ((!finite(bb->vec[0])) || (!finite(bb->vec[1])) || (!finite(bb->vec[2])) ||
+ (!finite(bb->vel[0])) || (!finite(bb->vel[1])) || (!finite(bb->vel[2])) )
{
zero_v3(bb->vec);
zero_v3(bb->vel);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index bae8efa758e..2c0452bc2d1 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3776,7 +3776,7 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
* simulation. This should be called once per particle during a simulation
* step, after the velocity has been updated. element_size defines the scale of
* the simulation, and is typically the distance to neighbourning particles. */
-void update_courant_num(ParticleSimulationData *sim, ParticleData *pa,
+static void update_courant_num(ParticleSimulationData *sim, ParticleData *pa,
float dtime, SPHData *sphdata)
{
float relative_vel[3];
@@ -3788,8 +3788,7 @@ void update_courant_num(ParticleSimulationData *sim, ParticleData *pa,
sim->courant_num = speed * dtime / sphdata->element_size;
}
/* Update time step size to suit current conditions. */
-float update_timestep(ParticleSystem *psys, ParticleSimulationData *sim,
- float t_frac)
+static float update_timestep(ParticleSystem *psys, ParticleSimulationData *sim, float t_frac)
{
if (sim->courant_num == 0.0f)
psys->dt_frac = 1.0f;
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index 46ddce4b51b..8da4f11fed3 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -27,9 +27,12 @@
/** \file blender/blenkernel/intern/property.c
* \ingroup bke
+ *
+ * This module deals with bProperty only,
+ * they are used on blender objects in the game engine
+ * (where they get converted into C++ classes - CValue and subclasses)
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -45,7 +48,7 @@
#include "BKE_property.h"
-void free_property(bProperty *prop)
+void BKE_bproperty_free(bProperty *prop)
{
if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
@@ -53,17 +56,17 @@ void free_property(bProperty *prop)
}
-void free_properties(ListBase *lb)
+void BKE_bproperty_free_list(ListBase *lb)
{
bProperty *prop;
while ( (prop = lb->first) ) {
BLI_remlink(lb, prop);
- free_property(prop);
+ BKE_bproperty_free(prop);
}
}
-bProperty *copy_property(bProperty *prop)
+bProperty *BKE_bproperty_copy(bProperty *prop)
{
bProperty *propn;
@@ -76,13 +79,13 @@ bProperty *copy_property(bProperty *prop)
return propn;
}
-void copy_properties(ListBase *lbn, ListBase *lbo)
+void BKE_bproperty_copy_list(ListBase *lbn, ListBase *lbo)
{
bProperty *prop, *propn;
- free_properties(lbn); /* in case we are copying to an object with props */
+ BKE_bproperty_free_list(lbn); /* in case we are copying to an object with props */
prop = lbo->first;
while (prop) {
- propn = copy_property(prop);
+ propn = BKE_bproperty_copy(prop);
BLI_addtail(lbn, propn);
prop = prop->next;
}
@@ -90,7 +93,7 @@ void copy_properties(ListBase *lbn, ListBase *lbo)
}
-void init_property(bProperty *prop)
+void BKE_bproperty_init(bProperty *prop)
{
/* also use when property changes type */
@@ -113,22 +116,22 @@ void init_property(bProperty *prop)
}
-bProperty *new_property(int type)
+bProperty *BKE_bproperty_new(int type)
{
bProperty *prop;
prop = MEM_callocN(sizeof(bProperty), "property");
prop->type = type;
- init_property(prop);
+ BKE_bproperty_init(prop);
strcpy(prop->name, "prop");
return prop;
}
-/* used by unique_property() only */
-static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name)
+/* used by BKE_bproperty_unique() only */
+static bProperty *bproperty_get(bProperty *first, bProperty *self, const char *name)
{
bProperty *p;
for (p = first; p; p = p->next) {
@@ -137,7 +140,7 @@ static bProperty *get_property__internal(bProperty *first, bProperty *self, cons
}
return NULL;
}
-void unique_property(bProperty *first, bProperty *prop, int force)
+void BKE_bproperty_unique(bProperty *first, bProperty *prop, int force)
{
bProperty *p;
@@ -151,13 +154,13 @@ void unique_property(bProperty *first, bProperty *prop, int force)
if (force) {
/* change other names to make them unique */
- while ((p = get_property__internal(first, prop, prop->name))) {
- unique_property(first, p, 0);
+ while ((p = bproperty_get(first, prop, prop->name))) {
+ BKE_bproperty_unique(first, p, 0);
}
}
else {
/* change our own name until its unique */
- if (get_property__internal(first, prop, prop->name)) {
+ if (bproperty_get(first, prop, prop->name)) {
/* there is a collision */
char new_name[sizeof(prop->name)];
char base_name[sizeof(prop->name)];
@@ -175,33 +178,34 @@ void unique_property(bProperty *first, bProperty *prop, int force)
BLI_snprintf(num, sizeof(num), "%d", i++);
BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num));
strcat(new_name, num);
- } while (get_property__internal(first, prop, new_name));
+ } while (bproperty_get(first, prop, new_name));
BLI_strncpy(prop->name, new_name, sizeof(prop->name));
}
}
}
-bProperty *get_ob_property(Object *ob, const char *name)
+bProperty *BKE_bproperty_object_get(Object *ob, const char *name)
{
return BLI_findstring(&ob->prop, name, offsetof(bProperty, name));
}
-void set_ob_property(Object *ob, bProperty *propc)
+void BKE_bproperty_object_set(Object *ob, bProperty *propc)
{
bProperty *prop;
- prop = get_ob_property(ob, propc->name);
+ prop = BKE_bproperty_object_get(ob, propc->name);
if (prop) {
- free_property(prop);
+ BKE_bproperty_free(prop);
BLI_remlink(&ob->prop, prop);
}
- BLI_addtail(&ob->prop, copy_property(propc));
+ BLI_addtail(&ob->prop, BKE_bproperty_copy(propc));
}
/* negative: prop is smaller
* positive: prop is larger
*/
-int compare_property(bProperty *prop, const char *str)
+#if 0 /* UNUSED */
+int BKE_bproperty_cmp(bProperty *prop, const char *str)
{
// extern int Gdfra; /* sector.c */
float fvalue, ftest;
@@ -237,8 +241,9 @@ int compare_property(bProperty *prop, const char *str)
return 0;
}
+#endif
-void set_property(bProperty *prop, const char *str)
+void BKE_bproperty_set(bProperty *prop, const char *str)
{
// extern int Gdfra; /* sector.c */
@@ -262,7 +267,7 @@ void set_property(bProperty *prop, const char *str)
}
-void add_property(bProperty *prop, const char *str)
+void BKE_bproperty_add(bProperty *prop, const char *str)
{
// extern int Gdfra; /* sector.c */
@@ -282,7 +287,7 @@ void add_property(bProperty *prop, const char *str)
}
/* reads value of property, sets it in chars in str */
-void set_property_valstr(bProperty *prop, char *str)
+void BKE_bproperty_set_valstr(bProperty *prop, char *str)
{
// extern int Gdfra; /* sector.c */
@@ -303,11 +308,13 @@ void set_property_valstr(bProperty *prop, char *str)
}
}
+#if 0 /* UNUSED */
void cp_property(bProperty *prop1, bProperty *prop2)
{
char str[128];
- set_property_valstr(prop2, str);
+ BKE_bproperty_set_valstr(prop2, str);
- set_property(prop1, str);
+ BKE_bproperty_set(prop1, str);
}
+#endif
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 7d9d2f02c06..6c1fbbfa9a0 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -210,7 +210,7 @@ void unlink_controllers(ListBase *lb)
bController *cont;
for (cont= lb->first; cont; cont= cont->next)
- unlink_controller(cont);
+ unlink_controller(cont);
}
void free_controller(bController *cont)
@@ -536,7 +536,7 @@ void clear_sca_new_poins(void)
ob= G.main->object.first;
while (ob) {
clear_sca_new_poins_ob(ob);
- ob= ob->id.next;
+ ob= ob->id.next;
}
}
@@ -624,7 +624,7 @@ void set_sca_new_poins(void)
ob= G.main->object.first;
while (ob) {
set_sca_new_poins_ob(ob);
- ob= ob->id.next;
+ ob= ob->id.next;
}
}
@@ -696,7 +696,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
if (sta->target == ob) sta->target = NULL;
}
act= act->next;
- }
+ }
}
/* ******************** INTERFACE ******************* */
@@ -875,3 +875,20 @@ void unlink_logicbricks(void **poin, void ***ppoin, short *tot)
return;
}
}
+
+const char *sca_state_name_get(Object *ob, short bit)
+{
+ bController *cont;
+ unsigned int mask;
+
+ mask = (1<<bit);
+ cont = ob->controllers.first;
+ while (cont) {
+ if (cont->state_mask & mask) {
+ return cont->name;
+ }
+ cont = cont->next;
+ }
+ return NULL;
+}
+
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 66647a994bc..0c0396ea758 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -57,6 +57,7 @@
#include "BKE_anim.h"
#include "BKE_animsys.h"
+#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_group.h"
@@ -76,6 +77,8 @@
#include "RE_engine.h"
+#include "IMB_colormanagement.h"
+
//XXX #include "BIF_previewrender.h"
//XXX #include "BIF_editseq.h"
@@ -169,6 +172,11 @@ Scene *BKE_scene_copy(Scene *sce, int type)
obase = obase->next;
base = base->next;
}
+
+ /* copy color management settings */
+ 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);
}
/* tool settings */
@@ -339,6 +347,8 @@ void BKE_scene_free(Scene *sce)
MEM_freeN(sce->fps_info);
sound_destroy_scene(sce);
+
+ BKE_color_managed_view_settings_free(&sce->view_settings);
}
Scene *BKE_scene_add(const char *name)
@@ -379,7 +389,14 @@ Scene *BKE_scene_add(const char *name)
sce->r.frs_sec_base = 1;
sce->r.edgeint = 10;
sce->r.ocres = 128;
+
+ /* OCIO_TODO: for forwards compatibiliy only, so if no tonecurve are used,
+ * images would look in the same way as in current blender
+ *
+ * perhaps at some point should be completely deprecated?
+ */
sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT;
+
sce->r.gauss = 1.0;
/* deprecated but keep for upwards compat */
@@ -553,6 +570,9 @@ Scene *BKE_scene_add(const char *name)
sound_create_scene(sce);
+ BKE_color_managed_display_settings_init(&sce->display_settings);
+ BKE_color_managed_view_settings_init(&sce->view_settings);
+
return sce;
}
@@ -1248,3 +1268,19 @@ void BKE_scene_base_flag_from_objects(struct Scene *scene)
base = base->next;
}
}
+
+void BKE_scene_disable_color_management(Scene *scene)
+{
+ ColorManagedDisplaySettings *display_settings = &scene->display_settings;
+ ColorManagedViewSettings *view_settings = &scene->view_settings;
+ const char *view;
+
+ /* NOTE: None display with Default view should always exist in OCIO configuration, otherwise it wouldn't work as expected */
+ BLI_strncpy(display_settings->display_device, "None", sizeof(display_settings->display_device));
+
+ view = IMB_colormanagement_view_get_default_name(display_settings->display_device);
+
+ if (view) {
+ BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform));
+ }
+}
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 4dbe0b6290c..eaf3ec384c8 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -52,6 +52,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "RNA_access.h"
@@ -119,13 +120,13 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf *
}
if (ibuf1 && !ibuf1->rect_float && out->rect_float) {
- IMB_float_from_rect_simple(ibuf1);
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf1, TRUE);
}
if (ibuf2 && !ibuf2->rect_float && out->rect_float) {
- IMB_float_from_rect_simple(ibuf2);
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf2, TRUE);
}
if (ibuf3 && !ibuf3->rect_float && out->rect_float) {
- IMB_float_from_rect_simple(ibuf3);
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf3, TRUE);
}
if (ibuf1 && !ibuf1->rect && !out->rect_float) {
@@ -137,7 +138,7 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf *
if (ibuf3 && !ibuf3->rect && !out->rect_float) {
IMB_rect_from_float(ibuf3);
}
-
+
return out;
}
diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c
index 6028b40756d..b0dcad64722 100644
--- a/source/blender/blenkernel/intern/seqmodifier.c
+++ b/source/blender/blenkernel/intern/seqmodifier.c
@@ -140,7 +140,7 @@ static void modifier_apply_threaded(ImBuf *ibuf, ImBuf *mask, modifier_apply_thr
/* **** Color Balance Modifier **** */
-void colorBalance_init_data(SequenceModifierData *smd)
+static void colorBalance_init_data(SequenceModifierData *smd)
{
ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd;
int c;
@@ -154,7 +154,7 @@ void colorBalance_init_data(SequenceModifierData *smd)
}
}
-void colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
+static void colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
{
ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd;
@@ -173,21 +173,21 @@ static SequenceModifierTypeInfo seqModifier_ColorBalance = {
/* **** Curves Modifier **** */
-void curves_init_data(SequenceModifierData *smd)
+static void curves_init_data(SequenceModifierData *smd)
{
CurvesModifierData *cmd = (CurvesModifierData *) smd;
curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f);
}
-void curves_free_data(SequenceModifierData *smd)
+static void curves_free_data(SequenceModifierData *smd)
{
CurvesModifierData *cmd = (CurvesModifierData *) smd;
curvemapping_free_data(&cmd->curve_mapping);
}
-void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd)
+static void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd)
{
CurvesModifierData *cmd = (CurvesModifierData *) smd;
CurvesModifierData *cmd_target = (CurvesModifierData *) target;
@@ -195,8 +195,8 @@ void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd)
curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping);
}
-void curves_apply_threaded(int width, int height, unsigned char *rect, float *rect_float,
- unsigned char *mask_rect, float *mask_rect_float, void *data_v)
+static void curves_apply_threaded(int width, int height, unsigned char *rect, float *rect_float,
+ unsigned char *mask_rect, float *mask_rect_float, void *data_v)
{
CurveMapping *curve_mapping = (CurveMapping *) data_v;
int x, y;
@@ -249,7 +249,7 @@ void curves_apply_threaded(int width, int height, unsigned char *rect, float *re
}
}
-void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
+static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
{
CurvesModifierData *cmd = (CurvesModifierData *) smd;
@@ -278,7 +278,7 @@ static SequenceModifierTypeInfo seqModifier_Curves = {
/* **** Hue Correct Modifier **** */
-void hue_correct_init_data(SequenceModifierData *smd)
+static void hue_correct_init_data(SequenceModifierData *smd)
{
HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd;
int c;
@@ -296,14 +296,14 @@ void hue_correct_init_data(SequenceModifierData *smd)
hcmd->curve_mapping.cur = 1;
}
-void hue_correct_free_data(SequenceModifierData *smd)
+static void hue_correct_free_data(SequenceModifierData *smd)
{
HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd;
curvemapping_free_data(&hcmd->curve_mapping);
}
-void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd)
+static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd)
{
HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd;
HueCorrectModifierData *hcmd_target = (HueCorrectModifierData *) target;
@@ -311,7 +311,7 @@ void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *s
curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping);
}
-void hue_correct_apply_threaded(int width, int height, unsigned char *rect, float *rect_float,
+static void hue_correct_apply_threaded(int width, int height, unsigned char *rect, float *rect_float,
unsigned char *mask_rect, float *mask_rect_float, void *data_v)
{
CurveMapping *curve_mapping = (CurveMapping *) data_v;
@@ -365,7 +365,7 @@ void hue_correct_apply_threaded(int width, int height, unsigned char *rect, floa
}
}
-void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
+static void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
{
HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd;
@@ -391,8 +391,8 @@ typedef struct BrightContrastThreadData {
float contrast;
} BrightContrastThreadData;
-void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, float *rect_float,
- unsigned char *mask_rect, float *mask_rect_float, void *data_v)
+static void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, float *rect_float,
+ unsigned char *mask_rect, float *mask_rect_float, void *data_v)
{
BrightContrastThreadData *data = (BrightContrastThreadData *) data_v;
int x, y;
@@ -460,7 +460,7 @@ void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, f
}
}
-void brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
+static void brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
{
BrightContrastModifierData *bcmd = (BrightContrastModifierData *) smd;
BrightContrastThreadData data;
@@ -581,6 +581,11 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I
SequenceModifierData *smd;
ImBuf *processed_ibuf = ibuf;
+ if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
+ processed_ibuf = IMB_dupImBuf(ibuf);
+ BKE_sequencer_imbuf_from_sequencer_space(context.scene, processed_ibuf);
+ }
+
for (smd = seq->modifiers.first; smd; smd = smd->next) {
SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
@@ -605,6 +610,10 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I
}
}
+ if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, processed_ibuf, FALSE);
+ }
+
return processed_ibuf;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 2596bf57f05..8d7ca94ed48 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -71,6 +71,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BKE_context.h"
#include "BKE_sound.h"
@@ -308,6 +309,81 @@ void BKE_sequencer_editing_free(Scene *scene)
scene->ed = NULL;
}
+/*********************** Sequencer color space functions *************************/
+
+static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
+{
+ IMB_colormanagement_imbuf_assign_float_space(ibuf, &scene->sequencer_colorspace_settings);
+}
+
+void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_float)
+{
+ const char *from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+ const char *to_colorspace = scene->sequencer_colorspace_settings.name;
+ int predivide = ibuf->flags & IB_cm_predivide;
+
+ if (!ibuf->rect_float) {
+ if (make_float && ibuf->rect) {
+ /* when converting byte buffer to float in sequencer we need to make float
+ * buffer be in sequencer's working space, which is currently only doable
+ * from linear space.
+ *
+ */
+
+ /*
+ * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's
+ */
+
+ IMB_float_from_rect(ibuf);
+ }
+ else {
+ /* if there's only byte buffer in image it's already in compositor's working space,
+ * nothing to do here
+ */
+
+ return;
+ }
+ }
+
+ if (from_colorspace && from_colorspace[0] != '\0') {
+ if (ibuf->rect)
+ imb_freerectImBuf(ibuf);
+
+ IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
+ from_colorspace, to_colorspace, predivide);
+ }
+}
+
+void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
+{
+ const char *from_colorspace = scene->sequencer_colorspace_settings.name;
+ const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+
+ if (!ibuf->rect_float)
+ return;
+
+ if (to_colorspace && to_colorspace[0] != '\0') {
+ int predivide = ibuf->flags & IB_cm_predivide;
+
+ IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
+ from_colorspace, to_colorspace, predivide);
+ }
+}
+
+void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4])
+{
+ const char *from_colorspace = scene->sequencer_colorspace_settings.name;
+ const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+
+ if (to_colorspace && to_colorspace[0] != '\0') {
+ IMB_colormanagement_transform_v4(pixel, from_colorspace, to_colorspace);
+ }
+ else {
+ /* if no color management enables fallback to legacy conversion */
+ srgb_to_linearrgb_v4(pixel, pixel);
+ }
+}
+
/*********************** sequencer pipeline functions *************************/
SeqRenderData BKE_sequencer_new_render_data(Main *bmain, Scene *scene, int rectx, int recty, int preview_render_size)
@@ -597,7 +673,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
BLI_path_abs(str, G.main->name);
if (seq->anim) IMB_free_anim(seq->anim);
- seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex);
+
+ /* OCIO_TODO: support configurable input space for strips */
+ seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
if (!seq->anim) {
return;
@@ -1094,7 +1172,8 @@ static void seq_open_anim_file(Sequence *seq)
seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
- seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex);
+ /* OCIO_TODO: support configurable input space for strips */
+ seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
if (seq->anim == NULL) {
return;
@@ -1200,8 +1279,9 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra)
if (seq_proxy_get_fname(seq, cfra, render_size, name) == 0) {
return NULL;
}
-
- seq->strip->proxy->anim = openanim(name, IB_rect, 0);
+
+ /* proxies are generated in default color space */
+ seq->strip->proxy->anim = openanim(name, IB_rect, 0, NULL);
}
if (seq->strip->proxy->anim == NULL) {
return NULL;
@@ -1219,7 +1299,13 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra)
}
if (BLI_exists(name)) {
- return IMB_loadiffname(name, IB_rect);
+ /* OCIO_TODO: support configurable spaces for strips */
+ ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
+
+ if (ibuf)
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
+
+ return ibuf;
}
else {
return NULL;
@@ -1257,7 +1343,8 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra
ibuf->planes = 24;
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);
@@ -1706,7 +1793,7 @@ int BKE_sequencer_input_have_to_preprocess(SeqRenderData UNUSED(context), Sequen
{
float mul;
- if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL)) {
+ if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL | SEQ_MAKE_FLOAT)) {
return TRUE;
}
@@ -1826,8 +1913,9 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra,
}
if (seq->flag & SEQ_MAKE_FLOAT) {
- if (!ibuf->rect_float)
- IMB_float_from_rect_simple(ibuf);
+ if (!ibuf->rect_float) {
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, TRUE);
+ }
if (ibuf->rect) {
imb_freerectImBuf(ibuf);
@@ -1893,6 +1981,8 @@ static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, I
* changing the cached image... */
ibuf = IMB_dupImBuf(ibuf);
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
+
if (nr == 0) {
BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf);
}
@@ -2307,7 +2397,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
/* opengl offscreen render */
BKE_scene_update_for_newframe(context.bmain, scene, scene->lay);
ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty,
- IB_rect, context.scene->r.seq_prev_type, TRUE, err_out);
+ IB_rect, context.scene->r.seq_prev_type, TRUE, FALSE, err_out);
if (ibuf == NULL) {
fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out);
}
@@ -2338,11 +2428,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
}
/* float buffers in the sequencer are not linear */
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- else
- ibuf->profile = IB_PROFILE_NONE;
- IMB_convert_profile(ibuf, IB_PROFILE_SRGB);
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE);
}
else if (rres.rect32) {
ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect);
@@ -2442,14 +2528,14 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
BLI_path_abs(name, G.main->name);
}
- if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect))) {
+ /* OCIO_TODO: support configurable space for image strips */
+ if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) {
/* we don't need both (speed reasons)! */
if (ibuf->rect_float && ibuf->rect)
imb_freerectImBuf(ibuf);
/* all sequencer color is done in SRGB space, linear gives odd crossfades */
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
- IMB_convert_profile(ibuf, IB_PROFILE_NONE);
+ BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE);
copy_to_ibuf_still(context, seq, nr, ibuf);
@@ -2497,6 +2583,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
case SEQ_TYPE_MOVIECLIP:
{
ibuf = seq_render_movieclip_strip(context, seq, nr);
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
if (ibuf && use_preprocess) {
ImBuf *i = IMB_dupImBuf(ibuf);
@@ -2520,6 +2607,9 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
}
}
+ if (ibuf)
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
+
return ibuf;
}
@@ -2561,8 +2651,10 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra)
}
}
- if (ibuf == NULL)
+ if (ibuf == NULL) {
ibuf = IMB_allocImBuf(context.rectx, context.recty, 32, IB_rect);
+ sequencer_imbuf_assign_spaces(context.scene, ibuf);
+ }
if (ibuf->x != context.rectx || ibuf->y != context.recty)
use_preprocess = TRUE;
@@ -2641,12 +2733,12 @@ static ImBuf *seq_render_strip_stack(SeqRenderData context, ListBase *seqbasep,
if (count == 1) {
out = seq_render_strip(context, seq_arr[0], cfra);
+
BKE_sequencer_cache_put(context, seq_arr[0], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
return out;
}
-
for (i = count - 1; i >= 0; i--) {
int early_out;
Sequence *seq = seq_arr[i];
@@ -3946,7 +4038,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
BLI_strncpy(path, seq_load->path, sizeof(path));
BLI_path_abs(path, G.main->name);
- an = openanim(path, IB_rect, 0);
+ /* OCIO_TODO: support configurable input space for strips */
+ an = openanim(path, IB_rect, 0, NULL);
if (an == NULL)
return NULL;
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index ddcba509301..5e67e094e43 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -80,10 +80,10 @@
/* UNUSED so far, may be enabled later */
/* #define USE_SMOKE_COLLISION_DM */
-#ifdef WITH_SMOKE
-
#include "smoke_API.h"
+#ifdef WITH_SMOKE
+
#ifdef _WIN32
#include <time.h>
#include <stdio.h>
@@ -148,7 +148,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
/* 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 FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { 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)) {}
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 4a88bfbfdad..4c28fe01895 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -143,7 +143,9 @@ typedef struct SB_thread_context {
} SB_thread_context;
#define NLF_BUILD 1
-#define NLF_SOLVE 2
+#if 0
+# define NLF_SOLVE 2
+#endif
#define MID_PRESERVE 1
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index f340bcb5b1e..385d1bb6fc5 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -792,7 +792,6 @@ void sound_stop_scene(struct Scene *UNUSED(scene)) {}
void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; }
int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
-int sound_read_sound_buffer(struct bSound *UNUSED(sound), float *UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
void sound_read_waveform(struct bSound *sound) { (void)sound; }
void sound_init_main(struct Main *bmain) { (void)bmain; }
void sound_set_cfra(int cfra) { (void)cfra; }
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 5c8192b2a62..facf0793f87 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -513,10 +513,14 @@ static float *get_ss_weights(WeightTable *wtable, int gridCuts, int faceLen)
w2 = (1.0f - fx + fac2 * fx * -fac) * (fy);
w4 = (fx) * (1.0f - fy + -fac2 * fy * fac);
- fac2 = 1.0f - (w1 + w2 + w4);
- fac2 = fac2 / (float)(faceLen - 3);
- for (j = 0; j < faceLen; j++)
- w[j] = fac2;
+ /* these values aren't used for tri's and cause divide by zero */
+ if (faceLen > 3) {
+ fac2 = 1.0f - (w1 + w2 + w4);
+ fac2 = fac2 / (float)(faceLen - 3);
+ for (j = 0; j < faceLen; j++) {
+ w[j] = fac2;
+ }
+ }
w[i] = w1;
w[(i - 1 + faceLen) % faceLen] = w2;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 787def5c20b..1f1d609ae42 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1919,6 +1919,7 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s
break;
case 4: /* 32-bit unicode symbol */
unicode = txt_undo_read_uint32(undo_buf, undo_pos);
+ break;
default:
/* should never happen */
BLI_assert(0);
@@ -1970,6 +1971,7 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s
break;
case 4: /* 32-bit unicode symbol */
unicode = txt_undo_read_uint32(undo_buf, undo_pos);
+ break;
default:
/* should never happen */
BLI_assert(0);
@@ -3031,30 +3033,6 @@ void txt_uncomment(Text *text)
}
}
-
-void txt_move_lines_up(struct Text *text)
-{
- TextLine *prev_line;
-
- if (!text || !text->curl || !text->sell) return;
-
- txt_order_cursors(text);
-
- prev_line = text->curl->prev;
-
- if (!prev_line) return;
-
- BLI_remlink(&text->lines, prev_line);
- BLI_insertlinkafter(&text->lines, text->sell, prev_line);
-
- txt_make_dirty(text);
- txt_clean_text(text);
-
- if (!undoing) {
- txt_undo_add_op(text, UNDO_MOVE_LINES_UP);
- }
-}
-
void txt_move_lines(struct Text *text, const int direction)
{
TextLine *line_other;
@@ -3094,7 +3072,6 @@ int setcurr_tab_spaces(Text *text, int space)
const char *comm = "#";
const char indent = (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t';
static const char *back_words[] = {"return", "break", "continue", "pass", "yield", NULL};
- if (!text) return 0;
if (!text->curl) return 0;
while (text->curl->line[i] == indent) {
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index ee904de4af6..bdd9b424f3b 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -338,7 +338,7 @@ void colorband_table_RGBA(ColorBand *coba, float **array, int *size)
do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]);
}
-int vergcband(const void *a1, const void *a2)
+static int vergcband(const void *a1, const void *a2)
{
const CBData *x1 = a1, *x2 = a2;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 2ed9d992c3f..337f1b5d248 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -856,7 +856,7 @@ static void track_mask_gpencil_layer_rasterize(int frame_width, int frame_height
}
/* TODO: add an option to control whether AA is enabled or not */
- PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, mask_width, mask_height, FALSE);
+ PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, mask_width, mask_height);
MEM_freeN(mask_points);
}
@@ -1043,14 +1043,6 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event)
}
}
}
- else if (event == CLAMP_SEARCH_DIM) {
- float dim[2];
- sub_v2_v2v2(dim, pat_max, pat_min);
- for (a = 0; a < 2; a++) {
- marker->search_min[a] = pat_min[a];
- marker->search_max[a] = pat_max[a];
- }
- }
}
MovieTrackingMarker *BKE_tracking_marker_get(MovieTrackingTrack *track, int framenr)
@@ -1627,7 +1619,6 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
float *mask = NULL;
pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
- pattern_ibuf->profile = IB_PROFILE_LINEAR_RGB;
if (!search_ibuf->rect_float) {
IMB_float_from_rect(search_ibuf);
@@ -1722,7 +1713,6 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov
h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
- searchibuf->profile = ibuf->profile;
IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
@@ -2031,7 +2021,7 @@ static void track_context_free(void *customdata)
{
TrackContext *track_context = (TrackContext *)customdata;
-#if WITH_LIBMV
+#ifdef WITH_LIBMV
if (track_context->search_area)
MEM_freeN(track_context->search_area);
@@ -2225,8 +2215,8 @@ static ImBuf *tracking_context_get_frame_ibuf(MovieTrackingContext *context, int
return ibuf;
}
-MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingContext *context, MovieTrackingTrack *track,
- MovieTrackingMarker *marker)
+static MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingContext *context, MovieTrackingTrack *track,
+ MovieTrackingMarker *marker)
{
int a = marker - track->markers;
MovieTrackingMarker *marker_keyed = marker;
@@ -2291,9 +2281,9 @@ static ImBuf *tracking_context_get_reference_ibuf(MovieTrackingContext *context,
return ibuf;
}
-static void track_context_update_reference(MovieTrackingContext *context, TrackContext *track_context,
- MovieTrackingTrack *track, MovieTrackingMarker *marker, int curfra,
- int frame_width, int frame_height)
+static int track_context_update_reference(MovieTrackingContext *context, TrackContext *track_context,
+ MovieTrackingTrack *track, MovieTrackingMarker *marker, int curfra,
+ int frame_width, int frame_height)
{
MovieTrackingMarker *marker_keyed = NULL;
ImBuf *reference_ibuf = NULL;
@@ -2301,6 +2291,10 @@ static void track_context_update_reference(MovieTrackingContext *context, TrackC
/* calculate patch for keyframed position */
reference_ibuf = tracking_context_get_reference_ibuf(context, track, marker, curfra, &marker_keyed);
+
+ if (!reference_ibuf)
+ return FALSE;
+
track_context->marker = *marker_keyed;
if (track_context->search_area) {
@@ -2319,6 +2313,8 @@ static void track_context_update_reference(MovieTrackingContext *context, TrackC
}
IMB_freeImBuf(reference_ibuf);
+
+ return TRUE;
}
static void tracking_configure_tracker(TrackContext *track_context, MovieTrackingTrack *track,
@@ -2483,8 +2479,12 @@ int BKE_tracking_context_step(MovieTrackingContext *context)
float *patch_new;
if (need_readjust) {
- track_context_update_reference(context, track_context, track, marker,
- curfra, frame_width, frame_height);
+ if (track_context_update_reference(context, track_context, track, marker,
+ curfra, frame_width, frame_height) == FALSE)
+ {
+ /* happens when reference frame fails to be loaded */
+ continue;
+ }
}
/* for now track to the same search area dimension as marker has got for current frame
@@ -2778,7 +2778,7 @@ 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)
{
-#if WITH_LIBMV
+#ifdef WITH_LIBMV
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) {
@@ -3317,7 +3317,6 @@ static ImBuf *stabilization_allocate_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int
}
else {
cacheibuf = IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags);
- cacheibuf->profile = srcibuf->profile;
}
return cacheibuf;
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index bd25ff8c6e6..4019eba5177 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -847,7 +847,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
* parameter.
* </p>
*/
-void flush_ffmpeg(void)
+static void flush_ffmpeg(void)
{
int outsize = 0;
int ret = 0;
diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h
index 3b7f2d6bbaf..833c416c1c1 100644
--- a/source/blender/blenlib/BLI_dynstr.h
+++ b/source/blender/blenlib/BLI_dynstr.h
@@ -80,7 +80,11 @@ void BLI_dynstr_appendf(DynStr *ds, const char *format, ...)
__attribute__ ((format(printf, 2, 3)))
#endif
;
-void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args);
+void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
+#ifdef __GNUC__
+__attribute__ ((format(printf, 2, 0)))
+#endif
+;
/**
* Find the length of a DynStr.
@@ -107,7 +111,6 @@ char *BLI_dynstr_get_cstring(DynStr *ds);
*
* \param ds The DynStr of interest.
* \param str The string to fill.
- * \return The contents of \a ds as a c-string.
*/
void BLI_dynstr_get_cstring_ex(DynStr *ds, char *str);
diff --git a/source/blender/blenlib/BLI_endian_switch.h b/source/blender/blenlib/BLI_endian_switch.h
index 7017e7ba789..7cb2790525d 100644
--- a/source/blender/blenlib/BLI_endian_switch.h
+++ b/source/blender/blenlib/BLI_endian_switch.h
@@ -27,16 +27,36 @@
* \ingroup bli
*/
-#include "BLI_endian_switch_inline.h"
+#ifdef __GNUC__
+# define ATTR_ENDIAN_SWITCH \
+ __attribute__((nonnull(1))) \
+ __attribute__((pure))
+#else
+# define ATTR_ENDIAN_SWITCH
+#endif
+
+/* BLI_endian_switch_inline.h */
+BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_float(float *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_int64(int64_t *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) ATTR_ENDIAN_SWITCH;
+BLI_INLINE void BLI_endian_switch_double(double *val) ATTR_ENDIAN_SWITCH;
/* endian_switch.c */
-void BLI_endian_switch_int16_array(short *val, const int size);
-void BLI_endian_switch_uint16_array(unsigned short *val, const int size);
-void BLI_endian_switch_int32_array(int *val, const int size);
-void BLI_endian_switch_uint32_array(unsigned int *val, const int size);
-void BLI_endian_switch_float_array(float *val, const int size);
-void BLI_endian_switch_int64_array(int64_t *val, const int size);
-void BLI_endian_switch_uint64_array(uint64_t *val, const int size);
-void BLI_endian_switch_double_array(double *val, const int size);
+void BLI_endian_switch_int16_array(short *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_uint16_array(unsigned short *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_int32_array(int *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_uint32_array(unsigned int *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_float_array(float *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_int64_array(int64_t *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_uint64_array(uint64_t *val, const int size) ATTR_ENDIAN_SWITCH;
+void BLI_endian_switch_double_array(double *val, const int size) ATTR_ENDIAN_SWITCH;
+
+#include "BLI_endian_switch_inline.h"
+
+#undef ATTR_ENDIAN_SWITCH
#endif /* __BLI_ENDIAN_SWITCH_H__ */
diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index a19909a8f26..1c6463eb6ea 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -46,7 +46,7 @@ struct direntry {
mode_t type;
char *relname;
char *path;
-#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER >= 1500)
+#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__) && (_MSC_VER >= 1500)
struct _stat64 s;
#elif defined(__MINGW32__)
struct _stati64 s;
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 886ed6f495d..6ee1498c855 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -30,8 +30,8 @@
* \ingroup bli
*/
-#ifdef WIN32
-#define _USE_MATH_DEFINES
+#ifdef _MSC_VER
+# define _USE_MATH_DEFINES
#endif
#include <math.h>
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 7520f09fe95..7c8bf88943d 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -67,6 +67,8 @@ void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv);
void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, int colorspace);
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3]);
+void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll);
+void rgb_to_hsl_v(const float rgb[3], float r_hsl[3]);
void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv);
void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3]);
void rgb_to_lab(float r, float g, float b, float *ll, float *la, float *lb);
@@ -113,6 +115,8 @@ void rgba_float_to_uchar(unsigned char col_r[4], const float col_f[4]);
void xyz_to_lab(float x, float y, float z, float *l, float *a, float *b);
+MINLINE int compare_rgb_uchar(const unsigned char a[3], const unsigned char b[3], const int limit);
+
/***************** lift/gamma/gain / ASC-CDL conversion *****************/
void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 6c81ca3f0a9..de1d423bfad 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -173,6 +173,7 @@ MINLINE int is_one_v3(const float a[3]);
MINLINE int equals_v2v2(const float v1[2], const float v2[2]);
MINLINE int equals_v3v3(const float a[3], const float b[3]);
+MINLINE int compare_v2v2(const float a[3], const float b[3], const float limit);
MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit);
MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit);
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index eb9915d6c9b..de4c2cf3a86 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -55,6 +55,8 @@ void BLI_rcti_resize(struct rcti *rect, int x, int y);
void BLI_rctf_resize(struct rctf *rect, float x, float y);
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, const float fac);
//void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
+int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
+int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]);
int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit);
int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b);
int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
@@ -75,14 +77,28 @@ void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
void print_rctf(const char *str, const struct rctf *rect);
void print_rcti(const char *str, const struct rcti *rect);
-#define BLI_RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin)
-#define BLI_RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin)
+/* hrmf, we need to work out this inline stuff */
+#if defined(_MSC_VER)
+# define BLI_INLINE static __forceinline
+#elif defined(__GNUC__)
+# define BLI_INLINE static inline __attribute((always_inline))
+#else
+/* #warning "MSC/GNUC defines not found, inline non-functional" */
+# define BLI_INLINE static
+#endif
-#define BLI_RCT_CENTER_X(rct) (((rct)->xmin + (rct)->xmax) / 2)
-#define BLI_RCT_CENTER_Y(rct) (((rct)->ymin + (rct)->ymax) / 2)
+#include "DNA_vec_types.h"
+BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct) { return (float)(rct->xmin + rct->xmax) / 2.0f; }
+BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct) { return (float)(rct->ymin + rct->ymax) / 2.0f; }
+BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct) { return (rct->xmin + rct->xmax) / 2; }
+BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct) { return (rct->ymin + rct->ymax) / 2; }
+BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct) { return (rct->xmin + rct->xmax) / 2.0f; }
+BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct) { return (rct->ymin + rct->ymax) / 2.0f; }
-#define BLI_RCT_CENTER_X_FL(rct) ((float)((rct)->xmin + (rct)->xmax) / 2.0f)
-#define BLI_RCT_CENTER_Y_FL(rct) ((float)((rct)->ymin + (rct)->ymax) / 2.0f)
+BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct) { return (rct->xmax - rct->xmin); }
+BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct) { return (rct->ymax - rct->ymin); }
+BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct) { return (rct->xmax - rct->xmin); }
+BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct) { return (rct->ymax - rct->ymin); }
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index b3d0df04eb1..666c74ca36f 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -144,7 +144,11 @@ __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 *buffer, size_t count, const char *format, va_list arg)
+#ifdef __GNUC__
+__attribute__ ((format(printf, 3, 0)))
+#endif
+;
/*
* Print formatted string into a newly mallocN'd string
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 902373bcd6b..9cd801f819d 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -77,6 +77,7 @@ int BLI_system_thread_count(void); /* gets the number of threads the system
#define LOCK_OPENGL 5
#define LOCK_NODES 6
#define LOCK_MOVIECLIP 7
+#define LOCK_COLORMANAGE 8
void BLI_lock_thread(int type);
void BLI_unlock_thread(int type);
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index c1175192434..ee7d93ea1a9 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -58,7 +58,7 @@ struct Heap {
#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)
+// #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); \
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 2b3c314131b..167797946bc 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -42,7 +42,6 @@
#endif
#define MAX_TREETYPE 32
-#define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024
typedef struct BVHNode {
struct BVHNode **children;
@@ -114,6 +113,8 @@ static float KDOP_AXES[13][3] = {
{0, 1.0, -1.0}
};
+#if 0
+
/*
* Generic push and pop heap
*/
@@ -153,7 +154,6 @@ static float KDOP_AXES[13][3] = {
heap[parent] = element; \
} (void)0
-#if 0
static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_size, int size_per_item)
{
int new_max_size = *max_size * 2;
@@ -1167,8 +1167,6 @@ typedef struct NodeDistance {
} NodeDistance;
-#define NodeDistance_priority(a, b) ( (a).dist < (b).dist)
-
// TODO: use a priority queue to reduce the number of nodes looked on
static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node)
{
@@ -1211,6 +1209,11 @@ static void dfs_find_nearest_begin(BVHNearestData *data, BVHNode *node)
#if 0
+
+#define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024
+
+#define NodeDistance_priority(a, b) ( (a).dist < (b).dist)
+
static void NodeDistance_push_heap(NodeDistance *heap, int heap_size)
PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size)
diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c
index 5da719cd500..1c70a612c4f 100644
--- a/source/blender/blenlib/intern/boxpack2d.c
+++ b/source/blender/blenlib/intern/boxpack2d.c
@@ -73,7 +73,9 @@ 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)
-#define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b)
+
+/* UNUSED */
+// #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b)
#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \
(b)->v[BL]->x = f; \
@@ -93,8 +95,8 @@ typedef struct BoxVert {
BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \
BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2))
-#define MIN2(x, y) ((x) < (y) ? (x) : (y))
-#define MAX2(x, y) ((x) > (y) ? (x) : (y))
+/* compiler should inline */
+static float maxf(const float a, const float b) { return b > a ? b : a; }
#if 0
#define BOXDEBUG(b) \
@@ -131,8 +133,8 @@ static int vertex_sort(const void *p1, const void *p2)
v1 = vertarray + ((int *)p1)[0];
v2 = vertarray + ((int *)p2)[0];
- a1 = MAX2(v1->x + box_width, v1->y + box_height);
- a2 = MAX2(v2->x + box_width, v2->y + box_height);
+ a1 = maxf(v1->x + box_width, v1->y + box_height);
+ a2 = maxf(v2->x + box_width, v2->y + box_height);
/* sort largest to smallest */
if (a1 > a2) return 1;
@@ -312,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) = MAX2(BOXRIGHT(box), (*tot_width));
- (*tot_height) = MAX2(BOXTOP(box), (*tot_height));
+ (*tot_width) = maxf(BOXRIGHT(box), (*tot_width));
+ (*tot_height) = maxf(BOXTOP(box), (*tot_height));
/* Place the box */
vert->free &= ~quad_flags[j];
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index f3107b565b9..c2f0c38247a 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -341,7 +341,7 @@ void BLI_dir_create_recursive(const char *dirname)
{
char *lslash;
char tmp[MAXPATHLEN];
-
+
/* First remove possible slash at the end of the dirname.
* This routine otherwise tries to create
* blah1/blah2/ (with slash) after creating
@@ -349,23 +349,29 @@ void BLI_dir_create_recursive(const char *dirname)
BLI_strncpy(tmp, dirname, sizeof(tmp));
lslash = BLI_last_slash(tmp);
-
- if (lslash == tmp + strlen(tmp) - 1) {
- *lslash = 0;
+
+ if (lslash && (*(lslash + 1) == '\0')) {
+ *lslash = '\0';
}
-
+
+ /* check special case "c:\foo", don't try create "c:", harmless but prints an error below */
+ if (isalpha(tmp[0]) && (tmp[1] == ':') && tmp[2] == '\0') return;
+
if (BLI_exists(tmp)) return;
lslash = BLI_last_slash(tmp);
+
if (lslash) {
/* Split about the last slash and recurse */
*lslash = 0;
BLI_dir_create_recursive(tmp);
}
-
- if (dirname[0]) /* patch, this recursive loop tries to create a nameless directory */
- if (umkdir(dirname) == -1)
+
+ if (dirname[0]) { /* patch, this recursive loop tries to create a nameless directory */
+ if (umkdir(dirname) == -1) {
printf("Unable to create directory %s\n", dirname);
+ }
+ }
}
int BLI_rename(const char *from, const char *to)
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 597a645eb9c..85239270541 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -58,9 +58,6 @@
#include "DNA_packedFile_types.h"
#include "DNA_curve_types.h"
-#define myMIN_ASCII 32
-#define myMAX_ASCII 255
-
/* local variables */
static FT_Library library;
static FT_Error err;
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index b93597bf107..64851dbf12c 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -293,6 +293,12 @@ void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll)
*ll = l;
}
+/* convenience function for now */
+void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
+{
+ rgb_to_hsl(rgb[0], rgb[1], rgb[2], &r_hsl[0], &r_hsl[1], &r_hsl[2]);
+}
+
void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv)
{
float orig_h = *lh;
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 6b90cbfe9c3..f520b2318e5 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -273,5 +273,20 @@ MINLINE float rgb_to_luma_y(const float rgb[3])
return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2];
}
+MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit)
+{
+ int r = (int)col_a[0] - (int)col_b[0];
+ if (ABS(r) < limit) {
+ int g = (int)col_a[1] - (int)col_b[1];
+ if (ABS(g) < limit) {
+ int b = (int)col_a[2] - (int)col_b[2];
+ if (ABS(b) < limit) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
#endif /* __MATH_COLOR_INLINE_C__ */
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 3fb3d2b58ff..1f61b37a1af 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -195,7 +195,7 @@ void mul_m3_m3m3(float m1[][3], float m3_[][3], float m2_[][3])
m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
}
-void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3])
+void mul_m4_m4m3(float m1[][4], float m3_[][4], float m2_[][3])
{
float m2[3][3], m3[4][4];
@@ -215,8 +215,14 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3])
}
/* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */
-void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3])
+void mult_m3_m3m4(float m1[][3], float m3_[][4], float m2_[][3])
{
+ float m2[3][3], m3[4][4];
+
+ /* copy so it works when m1 is the same pointer as m2 or m3 */
+ copy_m3_m3(m2, m2_);
+ copy_m4_m4(m3, m3_);
+
/* m1[i][j] = m2[i][k] * m3[k][j] */
m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
@@ -231,8 +237,14 @@ void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3])
m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
}
-void mul_m4_m3m4(float (*m1)[4], float (*m3)[3], float (*m2)[4])
+void mul_m4_m3m4(float m1[][4], float m3_[][3], float m2_[][4])
{
+ float m2[4][4], m3[3][3];
+
+ /* copy so it works when m1 is the same pointer as m2 or m3 */
+ copy_m4_m4(m2, m2_);
+ copy_m3_m3(m3, m3_);
+
m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index f0ed23aabc9..e10b0b3298c 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -35,7 +35,9 @@
/******************************** Quaternions ********************************/
/* used to test is a quat is not normalized (only used for debug prints) */
-#define QUAT_EPSILON 0.0001
+#ifdef DEBUG
+# define QUAT_EPSILON 0.0001
+#endif
/* convenience, avoids setting Y axis everywhere */
void unit_axis_angle(float axis[3], float *angle)
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 0a8f57214d7..c409e536b45 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -724,6 +724,15 @@ MINLINE int equals_v4v4(const float v1[4], const float v2[4])
return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]) && (v1[3] == v2[3]));
}
+MINLINE int compare_v2v2(const float v1[2], const float v2[2], const float limit)
+{
+ if (fabsf(v1[0] - v2[0]) < limit)
+ if (fabsf(v1[1] - v2[1]) < limit)
+ return 1;
+
+ return 0;
+}
+
MINLINE int compare_v3v3(const float v1[3], const float v2[3], const float limit)
{
if (fabsf(v1[0] - v2[0]) < limit)
diff --git a/source/blender/blenlib/intern/md5.c b/source/blender/blenlib/intern/md5.c
index a521d0e523b..4a09afe2e3d 100644
--- a/source/blender/blenlib/intern/md5.c
+++ b/source/blender/blenlib/intern/md5.c
@@ -2,6 +2,8 @@
* \ingroup imbuf
*/
+#include "BLI_md5.h" /* own include */
+
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
according to the definition of MD5 in RFC 1321 from April 1992.
Copyright (C) 1995 Software Foundation, Inc.
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index bd83c5e018c..792bf929182 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -45,7 +45,8 @@ static float noise3_perlin(float vec[3]);
//static float turbulence_perlin(float *point, float lofreq, float hifreq);
//static float turbulencep(float noisesize, float x, float y, float z, int nr);
-#define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255]
+/* UNUSED */
+// #define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255]
/* needed for voronoi */
#define HASHPNT(x, y, z) hashpntf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255]
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index a7a66718445..cc482e2d3d8 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1368,7 +1368,7 @@ int BLI_testextensie(const char *str, const char *ext)
retval = 0;
}
else if (BLI_strcasecmp(ext, str + a - b)) {
- retval = 0;
+ retval = 0;
}
else {
retval = 1;
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index 22597c9f8e6..0bd9e68cb71 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -487,7 +487,7 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc,
/* Return zero if all primitives in the node can be drawn with the
* same material (including flat/smooth shading), non-zerootherwise */
-int leaf_needs_material_split(PBVH *bvh, int offset, int count)
+static int leaf_needs_material_split(PBVH *bvh, int offset, int count)
{
int i, prim;
@@ -1169,10 +1169,14 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
break;
case PBVH_FACES:
GPU_update_mesh_buffers(node->draw_buffers,
+ bvh->faces,
+ node->prim_indices,
+ node->totprim,
bvh->verts,
node->vert_indices,
node->uniq_verts +
node->face_verts,
+ node->face_vert_indices,
CustomData_get_layer(bvh->vdata,
CD_PAINT_MASK));
break;
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 225ede8a8ef..cab383b60f3 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -252,8 +252,8 @@ void BLI_rctf_translate(rctf *rect, float x, float y)
/* change width & height around the central location */
void BLI_rcti_resize(rcti *rect, int x, int y)
{
- rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect);
- rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect);
+ rect->xmin = rect->xmax = BLI_rcti_cent_x(rect);
+ rect->ymin = rect->ymax = BLI_rcti_cent_y(rect);
rect->xmin -= x / 2;
rect->ymin -= y / 2;
rect->xmax = rect->xmin + x;
@@ -262,8 +262,8 @@ void BLI_rcti_resize(rcti *rect, int x, int y)
void BLI_rctf_resize(rctf *rect, float x, float y)
{
- rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect);
- rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect);
+ rect->xmin = rect->xmax = BLI_rctf_cent_x(rect);
+ rect->ymin = rect->ymax = BLI_rctf_cent_y(rect);
rect->xmin -= x * 0.5f;
rect->ymin -= y * 0.5f;
rect->xmax = rect->xmin + x;
@@ -281,6 +281,27 @@ void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const f
/* BLI_rcti_interp() not needed yet */
+
+int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2])
+{
+ int change = 0;
+ if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; }
+ if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; }
+ if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; }
+ if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; }
+ return change;
+}
+
+int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
+{
+ int change = 0;
+ if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; }
+ if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; }
+ if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; }
+ if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; }
+ return change;
+}
+
int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit)
{
if (fabsf(rect_a->xmin - rect_b->xmin) < limit)
@@ -366,9 +387,9 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
{
dst->xmin = floorf(src->xmin + 0.5f);
- dst->xmax = dst->xmin + floorf(BLI_RCT_SIZE_X(src) + 0.5f);
+ dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f);
dst->ymin = floorf(src->ymin + 0.5f);
- dst->ymax = dst->ymin + floorf(BLI_RCT_SIZE_Y(src) + 0.5f);
+ dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f);
}
void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
@@ -382,11 +403,11 @@ void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
void print_rctf(const char *str, const rctf *rect)
{
printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str,
- rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
+ rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rctf_size_x(rect), BLI_rctf_size_y(rect));
}
void print_rcti(const char *str, const rcti *rect)
{
printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str,
- rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
+ rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
}
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 32afaba2b5c..7ae27b83e67 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -211,7 +211,7 @@ ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
copy_v3_v3(eve->co, vec);
- return eve;
+ return eve;
}
ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2)
@@ -521,7 +521,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
while (eve) {
printf("vert: %x co: %f %f\n", eve, eve->xy[0], eve->xy[1]);
eve = eve->next;
- }
+ }
eed = sf_ctx->filledgebase.first;
while (eed) {
printf("edge: %x verts: %x %x\n", eed, eed->v1, eed->v2);
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 0fccd91fc02..0d3f6aee30f 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -34,7 +34,7 @@
#include <sys/types.h>
#include <stdio.h>
-#include <stdlib.h>
+#include <stdlib.h>
#ifndef WIN32
#include <dirent.h>
diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c
index 422a600e51c..bab144266a4 100644
--- a/source/blender/blenlib/intern/string_cursor_utf8.c
+++ b/source/blender/blenlib/intern/string_cursor_utf8.c
@@ -147,7 +147,7 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
int *pos, strCursorJumpDirection direction,
strCursorJumpType jump)
{
- const short pos_prev = *pos;
+ const int pos_prev = *pos;
if (direction == STRCUR_DIR_NEXT) {
BLI_str_cursor_step_next_utf8(str, maxlen, pos);
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 9994f89acd5..66527b9b92a 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -113,6 +113,7 @@ static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _opengl_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _nodes_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _movieclip_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _colormanage_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t mainid;
static int thread_levels = 0; /* threads can be invoked inside threads */
@@ -351,6 +352,8 @@ void BLI_lock_thread(int type)
pthread_mutex_lock(&_nodes_lock);
else if (type == LOCK_MOVIECLIP)
pthread_mutex_lock(&_movieclip_lock);
+ else if (type == LOCK_COLORMANAGE)
+ pthread_mutex_lock(&_colormanage_lock);
}
void BLI_unlock_thread(int type)
@@ -371,6 +374,8 @@ void BLI_unlock_thread(int type)
pthread_mutex_unlock(&_nodes_lock);
else if (type == LOCK_MOVIECLIP)
pthread_mutex_unlock(&_movieclip_lock);
+ else if (type == LOCK_COLORMANAGE)
+ pthread_mutex_unlock(&_colormanage_lock);
}
/* Mutex Locks */
diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index 1b59dc6a3f5..05ebc9500a1 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -105,7 +105,7 @@ void BLI_uvproject_from_view(float target[2], float source[3], float persmat[4][
/* rotmat is the object matrix in this case */
mul_m4_v4(rotmat, pv4);
- /* almost project_short */
+ /* almost ED_view3d_project_short */
mul_m4_v4(persmat, pv4);
if (fabsf(pv4[3]) > 0.00001f) { /* avoid division by zero */
target[0] = winx / 2.0f + (winx / 2.0f) * pv4[0] / pv4[3];
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c
index 80a4da5cace..3030e54eb78 100644
--- a/source/blender/blenlib/intern/voronoi.c
+++ b/source/blender/blenlib/intern/voronoi.c
@@ -480,7 +480,7 @@ static void voronoi_removeParabola(VoronoiProcess *process, VoronoiEvent *event)
voronoi_checkCircle(process, p2);
}
-void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola)
+static void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola)
{
float mx;
@@ -503,12 +503,12 @@ void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola)
MEM_freeN(parabola);
}
-void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord)
+static void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord)
{
const float corners[4][2] = {{0.0f, 0.0f},
- {width - 1, 0.0f},
- {width - 1, height - 1},
- {0.0f, height - 1}};
+ {width - 1, 0.0f},
+ {width - 1, height - 1},
+ {0.0f, height - 1}};
int i;
if (IN_RANGE_INCL(coord[0], 0, width - 1) && IN_RANGE_INCL(coord[1], 0, height - 1)) {
@@ -541,7 +541,7 @@ void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_c
}
}
-void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges)
+static void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges)
{
VoronoiEdge *edge;
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index 5b5f4cf8b80..a0b31f8d5b8 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -68,7 +68,7 @@ int BLI_getInstallationDir(char *str)
return 1;
}
-void RegisterBlendExtension_Fail(HKEY root)
+static void RegisterBlendExtension_Fail(HKEY root)
{
printf("failed\n");
if (root)
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index f0bf7e99758..16a4d8d46ec 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -244,6 +244,9 @@ void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char
BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports);
+/* internal function but we need to expose it */
+void blo_lib_link_screen_restore(struct Main *newmain, struct bScreen *curscreen, struct Scene *curscene);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 845228fb1b9..9a2a09a98ae 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -134,7 +134,7 @@
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_property.h" // for get_ob_property
+#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_report.h"
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
@@ -249,6 +249,12 @@ static void convert_tface_mt(FileData *fd, Main *main);
* bit kludge but better then doubling up on prints,
* we could alternatively have a versions of a report function which forces printing - campbell
*/
+
+static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format(printf, 3, 4)))
+#endif
+;
static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
{
char fixed_buf[1024]; /* should be long enough */
@@ -590,11 +596,7 @@ static void switch_endian_bh8(BHead8 *bhead)
static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
{
BHead4 *bhead4 = (BHead4 *) bhead;
-#if defined(WIN32) && !defined(FREE_WINDOWS)
- __int64 old;
-#else
- long long old;
-#endif
+ int64_t old;
bhead4->code = bhead8->code;
bhead4->len = bhead8->len;
@@ -2716,6 +2718,16 @@ static void direct_link_lamp(FileData *fd, Lamp *la)
/* ************ READ keys ***************** */
+static void do_versions_key_uidgen(Key *key)
+{
+ KeyBlock *block;
+
+ key->uidgen = 1;
+ for (block = key->block.first; block; block = block->next) {
+ block->uid = key->uidgen++;
+ }
+}
+
static void lib_link_key(FileData *fd, Main *main)
{
Key *key;
@@ -2723,12 +2735,7 @@ static void lib_link_key(FileData *fd, Main *main)
for (key = main->key.first; key; key = key->id.next) {
/*check if we need to generate unique ids for the shapekeys*/
if (!key->uidgen) {
- KeyBlock *block;
-
- key->uidgen = 1;
- for (block=key->block.first; block; block=block->next) {
- block->uid = key->uidgen++;
- }
+ do_versions_key_uidgen(key);
}
if (key->id.flag & LIB_NEED_LINK) {
@@ -3815,7 +3822,6 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
mesh->tface = newdataadr(fd, mesh->tface);
mesh->mtface = newdataadr(fd, mesh->mtface);
mesh->mcol = newdataadr(fd, mesh->mcol);
- mesh->msticky = newdataadr(fd, mesh->msticky);
mesh->dvert = newdataadr(fd, mesh->dvert);
mesh->mloopcol = newdataadr(fd, mesh->mloopcol);
mesh->mloopuv = newdataadr(fd, mesh->mloopuv);
@@ -4910,6 +4916,14 @@ static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb)
}
}
+static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *view_settings)
+{
+ view_settings->curve_mapping = newdataadr(fd, view_settings->curve_mapping);
+
+ if (view_settings->curve_mapping)
+ direct_link_curvemapping(fd, view_settings->curve_mapping);
+}
+
static void direct_link_scene(FileData *fd, Scene *sce)
{
Editing *ed;
@@ -5095,6 +5109,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->nodetree = newdataadr(fd, sce->nodetree);
if (sce->nodetree)
direct_link_nodetree(fd, sce->nodetree);
+
+ direct_link_view_settings(fd, &sce->view_settings);
}
/* ************ READ WM ***************** */
@@ -5308,6 +5324,13 @@ static void lib_link_screen(FileData *fd, Main *main)
* so fingers crossed this works fine!
*/
sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
+
+ sseq->scopes.reference_ibuf = NULL;
+ sseq->scopes.zebra_ibuf = NULL;
+ sseq->scopes.waveform_ibuf = NULL;
+ sseq->scopes.sep_waveform_ibuf = NULL;
+ sseq->scopes.vector_ibuf = NULL;
+ sseq->scopes.histogram_ibuf = NULL;
}
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)sl;
@@ -5452,7 +5475,7 @@ static void lib_link_clipboard_restore(Main *newmain)
/* called from kernel/blender.c */
/* used to link a file (without UI) to the current UI */
/* note that it assumes the old pointers in UI are still valid, so old Main is not freed */
-void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
+void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
{
wmWindow *win;
wmWindowManager *wm;
@@ -6284,6 +6307,14 @@ static void direct_link_mask(FileData *fd, Mask *mask)
for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
masklay_shape->data = newdataadr(fd, masklay_shape->data);
+
+ if (masklay_shape->tot_vert) {
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_float_array(masklay_shape->data,
+ masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE);
+
+ }
+ }
}
masklay->act_spline = newdataadr(fd, masklay->act_spline);
@@ -6872,7 +6903,7 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
}
}
-void do_versions_image_settings_2_60(Scene *sce)
+static void do_versions_image_settings_2_60(Scene *sce)
{
/* note: rd->subimtype is moved into individual settings now and no longer
* exists */
@@ -7544,7 +7575,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
for (ob= main->object.first; ob; ob= ob->id.next) {
if (ob->type == OB_FONT) {
- prop = get_ob_property(ob, "Text");
+ 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 "
@@ -7997,7 +8028,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
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[3]) && is_zero_v2(marker->pattern_corners[3]))
+ 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];
@@ -8095,6 +8126,76 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ /* color management pipeline changes compatibility code */
+ if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 19)) {
+ Scene *scene;
+ Image *ima;
+ int colormanagement_disabled = FALSE;
+
+ /* make scenes which are not using color management have got None as display device,
+ * so they wouldn't perform linear-to-sRGB conversion on display
+ */
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) {
+ ColorManagedDisplaySettings *display_settings = &scene->display_settings;
+
+ if (display_settings->display_device[0] == 0) {
+ BKE_scene_disable_color_management(scene);
+
+ }
+
+ colormanagement_disabled = TRUE;
+ }
+ }
+
+ for (ima = main->image.first; ima; ima = ima->id.next) {
+ if (ima->source == IMA_SRC_VIEWER) {
+ ima->flag |= IMA_VIEW_AS_RENDER;
+ }
+ else if (colormanagement_disabled) {
+ /* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion
+ * would happen on display and render
+ * there's no clear way to check whether color management is enabled or not in render engine
+ * so set all images to raw if there's at least one scene with color management disabled
+ * this would still behave incorrect in cases when color management was used for only some
+ * of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility
+ * in that cases
+ */
+
+ BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name));
+ }
+ }
+ }
+
+ if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 20)) {
+ Key *key;
+ for (key = main->key.first; key; key = key->id.next) {
+ do_versions_key_uidgen(key);
+ }
+ }
+
+ /* remove texco */
+ if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 21)) {
+ Material *ma;
+ for (ma = main->mat.first; ma; ma = ma->id.next) {
+ int a;
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
+ if (ma->mtex[a]->texco == TEXCO_STICKY_) {
+ ma->mtex[a]->texco = TEXCO_UV;
+ }
+ }
+ }
+ }
+
+ {
+ Mesh *me;
+ for (me = main->mesh.first; me; me = me->id.next) {
+ CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert);
+ }
+ }
+ }
+
/* default values in Freestyle settings */
{
Scene *sce;
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 1cc0d4180ab..d8333e7c8f4 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -92,7 +92,7 @@
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_property.h" // for get_ob_property
+#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -387,8 +387,6 @@ static void customdata_version_242(Mesh *me)
if (!me->vdata.totlayer) {
CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
- if (me->msticky)
- CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_ASSIGN, me->msticky, me->totvert);
if (me->dvert)
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
}
@@ -945,7 +943,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
while (act) {
if (act->type == ACT_IPO) {
ia = act->data;
- prop = get_ob_property(ob, ia->name);
+ prop = BKE_bproperty_object_get(ob, ia->name);
if (prop) {
ia->type = ACT_IPO_FROM_PROP;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index b2d4e905dc9..6fb7faae69c 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2120,6 +2120,13 @@ static void write_sequence_modifiers(WriteData *wd, ListBase *modbase)
}
}
+static void write_view_settings(WriteData *wd, ColorManagedViewSettings *view_settings)
+{
+ if (view_settings->curve_mapping) {
+ write_curvemapping(wd, view_settings->curve_mapping);
+ }
+}
+
static void write_scenes(WriteData *wd, ListBase *scebase)
{
Scene *sce;
@@ -2274,7 +2281,9 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
write_nodetree(wd, sce->nodetree);
}
-
+
+ write_view_settings(wd, &sce->view_settings);
+
sce= sce->id.next;
}
/* flush helps the compression for undo-save */
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index a74053a4697..691465388e9 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -380,7 +380,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n
}
sub_v3_v3v3(far_vec, far, cent);
- far_dist = len_v3(far_vec); /* real dist */
+ // far_dist = len_v3(far_vec); /* real dist */ /* UNUSED */
/* --- */
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index f03ce9b8543..ccbbb6f170b 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -836,8 +836,6 @@ static void bm_elements_systag_disable(void *veles, int tot, int flag)
}
}
-#define FACE_MARK (1 << 10)
-
static int count_flagged_radial(BMesh *bm, BMLoop *l, int flag)
{
BMLoop *l2 = l;
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 9033436d1b2..12fcd51c069 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -424,7 +424,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
float axis_x[3], axis_y[3];
/* ignore 2-edged faces */
- if (target->f->len < 3)
+ if (UNLIKELY(target->f->len < 3))
return;
if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index c0439311104..e4a838fe893 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -672,7 +672,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
* we cant make a crossvec from a vec thats the same as the vec
* unlikely but possible, so make sure if the normal is (0, 0, 1)
* that vec isn't the same or in the same direction even. */
- if (efa->len < 3) {
+ if (UNLIKELY(efa->len < 3)) {
/* crappy fallback method */
if (efa->no[0] < 0.5f) vec[0] = 1.0f;
else if (efa->no[1] < 0.5f) vec[1] = 1.0f;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index cf593627e8d..734f08142b1 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -282,7 +282,7 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN))
continue;
- if (normalize_v3(v->no) == 0.0f) {
+ if (UNLIKELY(normalize_v3(v->no) == 0.0f)) {
normalize_v3_v3(v->no, v->co);
}
}
@@ -356,7 +356,7 @@ void bmesh_edit_begin(BMesh *UNUSED(bm), int UNUSED(type_flag))
* (loop cuts, edge subdivides, etc) are not reflected in the higher levels of
* the mesh at all, which doesn't seem right. Turning off completely for now,
* until this is shown to be better for certain types of mesh edits. */
-#if BMOP_UNTAN_MULTIRES_ENABLED
+#ifdef BMOP_UNTAN_MULTIRES_ENABLED
/* switch multires data out of tangent space */
if ((type_flag & BMO_OP_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
bmesh_mdisps_space_set(bm, MULTIRES_SPACE_TANGENT, MULTIRES_SPACE_ABSOLUTE);
@@ -374,7 +374,7 @@ void bmesh_edit_begin(BMesh *UNUSED(bm), int UNUSED(type_flag))
void bmesh_edit_end(BMesh *bm, int UNUSED(flag))
{
/* BMO_OP_FLAG_UNTAN_MULTIRES disabled for now, see comment above in bmesh_edit_begin. */
-#if BMOP_UNTAN_MULTIRES_ENABLED
+#ifdef BMOP_UNTAN_MULTIRES_ENABLED
/* switch multires data into tangent space */
if ((flag & BMO_OP_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
/* set normals to their previous winding */
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 51c8b5d3bd8..e6827b1f2cd 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -758,7 +758,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
}
if (!currkey) {
- currkey = add_keyblock(me->key, bm->vdata.layers[i].name);
+ currkey = BKE_keyblock_add(me->key, bm->vdata.layers[i].name);
currkey->uid = bm->vdata.layers[i].uid;
}
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 73e2d83520c..3195899ef01 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -558,7 +558,7 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
/* cant kill data we loop on, build a list and remove those */
BLI_array_empty(bad_faces);
BM_ITER_ELEM (f, &fiter, verts[i], BM_FACES_OF_VERT) {
- if (f->len < 3) {
+ if (UNLIKELY(f->len < 3)) {
BLI_array_append(bad_faces, f);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 53b95c97c8b..2100cd2bd0b 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -1253,7 +1253,7 @@ int BMO_error_occurred(BMesh *bm)
return bm->errorstack.first != NULL;
}
-/* returns error code or 0 if no erro */
+/* returns error code or 0 if no error */
int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op)
{
BMOpError *err = bm->errorstack.first;
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index 4723b631c5f..1567455e354 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -364,8 +364,6 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
/* BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE); */ /* UNUSE */
int i;
-#define SIGN(n) ((n) < 0.0f)
-
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
BMIter eiter;
float no[3], cent[3];
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index b10556af04e..84f6cb27b3b 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -484,7 +484,7 @@ void dummy_exec(BMesh *bm, BMOperator *op)
/* 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. */
-float bm_vert_edge_face_angle(BMVert *v)
+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 */
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index 4d4d7e30a4e..32270007a0b 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -37,7 +37,7 @@
#define DUPE_INPUT 1 /* input from operator */
#define DUPE_NEW 2
#define DUPE_DONE 4
-#define DUPE_MAPPED 8
+// #define DUPE_MAPPED 8 // UNUSED
/**
* COPY VERTEX
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index 87ba216d5cf..d97d901777c 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -44,6 +44,8 @@
#include "bmesh.h"
+#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] */
@@ -628,7 +630,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op)
}
}
-void hull_tag_holes(BMesh *bm, BMOperator *op)
+static void hull_tag_holes(BMesh *bm, BMOperator *op)
{
BMIter iter;
BMOIter oiter;
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index d780e309118..0d8b397110e 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -37,11 +37,6 @@
#include "intern/bmesh_operators_private.h" /* own include */
-/* Bitflags for edges */
-#define T2QDELETE 1
-#define T2QCOMPLEX 2
-#define T2QJOIN 4
-
/* assumes edges are validated before reaching this poin */
static float measure_facepair(BMVert *v1, BMVert *v2,
BMVert *v3, BMVert *v4, float limit)
@@ -110,93 +105,73 @@ static float measure_facepair(BMVert *v1, BMVert *v2,
#define T2QUV_LIMIT 0.005f
#define T2QCOL_LIMIT 3
-static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols)
+static int bm_edge_faces_cmp(BMesh *bm, BMEdge *e, const int do_uv, const int do_tf, const int do_vcol)
{
- MTexPoly *tp1, *tp2;
- MLoopCol *lcol1, *lcol2, *lcol3, *lcol4;
- MLoopUV *luv1, *luv2, *luv3, *luv4;
- BMLoop *l1, *l2, *l3, *l4;
- int mergeok_uvs = !douvs, mergeok_vcols = !dovcols;
-
- l1 = e->l;
- l3 = e->l->radial_next;
+ /* first get loops */
+ BMLoop *l[4];
+
+ l[0] = e->l;
+ l[2] = e->l->radial_next;
- /* match up loops on each side of an edge corresponding to each ver */
- if (l1->v == l3->v) {
- l2 = l1->next;
- l4 = l2->next;
+ /* match up loops on each side of an edge corresponding to each vert */
+ if (l[0]->v == l[2]->v) {
+ l[1] = l[0]->next;
+ l[3] = l[1]->next;
}
else {
- l2 = l1->next;
+ l[1] = l[0]->next;
- l4 = l3;
- l3 = l4->next;
+ l[3] = l[2];
+ l[2] = l[3]->next;
}
- lcol1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
- lcol2 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
- lcol3 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
- lcol4 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
-
- luv1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
- luv2 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
- luv3 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
- luv4 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
-
- tp1 = CustomData_bmesh_get(&bm->pdata, l1->f->head.data, CD_MTEXPOLY);
- tp2 = CustomData_bmesh_get(&bm->pdata, l2->f->head.data, CD_MTEXPOLY);
-
- if (!lcol1)
- mergeok_vcols = 1;
-
- if (!luv1)
- mergeok_uvs = 1;
-
- /* compare faceedges for each face attribute. Additional per face attributes can be added late */
-
- /* do VCOL */
- if (lcol1 && dovcols) {
- char *cols[4] = {(char *)lcol1, (char *)lcol2, (char *)lcol3, (char *)lcol4};
- int i;
-
- for (i = 0; i < 3; i++) {
- if (cols[0][i] + T2QCOL_LIMIT < cols[2][i] - T2QCOL_LIMIT)
- break;
- if (cols[1][i] + T2QCOL_LIMIT < cols[3][i] - T2QCOL_LIMIT)
- break;
+ /* Test UV's */
+ if (do_uv) {
+ const MLoopUV *luv[4] = {
+ CustomData_bmesh_get(&bm->ldata, l[0]->head.data, CD_MLOOPUV),
+ CustomData_bmesh_get(&bm->ldata, l[1]->head.data, CD_MLOOPUV),
+ CustomData_bmesh_get(&bm->ldata, l[2]->head.data, CD_MLOOPUV),
+ CustomData_bmesh_get(&bm->ldata, l[3]->head.data, CD_MLOOPUV),
+ };
+
+ /* do UV */
+ if (luv[0] && (!compare_v2v2(luv[0]->uv, luv[2]->uv, T2QUV_LIMIT) ||
+ !compare_v2v2(luv[1]->uv, luv[3]->uv, T2QUV_LIMIT)))
+ {
+ return FALSE;
}
-
- if (i == 3)
- mergeok_vcols = 1;
}
- /* do UV */
- if (luv1 && douvs) {
- if (tp1->tpage != tp2->tpage) {
- /* do nothing */
- }
- else {
- int i;
+ if (do_tf) {
+ const MTexPoly *tp[2] = {
+ CustomData_bmesh_get(&bm->pdata, l[0]->f->head.data, CD_MTEXPOLY),
+ CustomData_bmesh_get(&bm->pdata, l[1]->f->head.data, CD_MTEXPOLY),
+ };
- for (i = 0; i < 2; i++) {
- if (luv1->uv[0] + T2QUV_LIMIT > luv3->uv[0] && luv1->uv[0] - T2QUV_LIMIT < luv3->uv[0] &&
- luv1->uv[1] + T2QUV_LIMIT > luv3->uv[1] && luv1->uv[1] - T2QUV_LIMIT < luv3->uv[1])
- {
- if (luv2->uv[0] + T2QUV_LIMIT > luv4->uv[0] && luv2->uv[0] - T2QUV_LIMIT < luv4->uv[0] &&
- luv2->uv[1] + T2QUV_LIMIT > luv4->uv[1] && luv2->uv[1] - T2QUV_LIMIT < luv4->uv[1])
- {
- mergeok_uvs = 1;
- }
- }
- }
+ if (tp[0] && (tp[0]->tpage != tp[1]->tpage)) {
+ return FALSE;
}
}
- if (douvs == mergeok_uvs && dovcols == mergeok_vcols) {
- return TRUE;
+ /* Test Vertex Colors */
+ if (do_vcol) {
+ const MLoopCol *lcol[4] = {
+ CustomData_bmesh_get(&bm->ldata, l[0]->head.data, CD_MLOOPCOL),
+ CustomData_bmesh_get(&bm->ldata, l[1]->head.data, CD_MLOOPCOL),
+ CustomData_bmesh_get(&bm->ldata, l[2]->head.data, CD_MLOOPCOL),
+ CustomData_bmesh_get(&bm->ldata, l[3]->head.data, CD_MLOOPCOL),
+ };
+
+ if (lcol[0]) {
+ if (!compare_rgb_uchar((unsigned char*)&lcol[0]->r, (unsigned char*)&lcol[2]->r, T2QCOL_LIMIT) ||
+ !compare_rgb_uchar((unsigned char*)&lcol[1]->r, (unsigned char*)&lcol[3]->r, T2QCOL_LIMIT))
+ {
+ return FALSE;
+ }
+ }
}
- return FALSE;
+ return TRUE;
}
typedef struct JoinEdge {
@@ -229,11 +204,12 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
BLI_array_declare(jedges);
JoinEdge *jedges = NULL;
- int dosharp = BMO_slot_bool_get(op, "cmp_sharp");
- int douvs = BMO_slot_bool_get(op, "cmp_uvs");
- int dovcols = BMO_slot_bool_get(op, "cmp_vcols");
- int domat = BMO_slot_bool_get(op, "cmp_materials");
- float limit = BMO_slot_float_get(op, "limit");
+ int do_sharp = BMO_slot_bool_get(op, "cmp_sharp");
+ int do_uv = BMO_slot_bool_get(op, "cmp_uvs");
+ int do_tf = do_uv; /* texture face, make make its own option eventually */
+ int do_vcol = BMO_slot_bool_get(op, "cmp_vcols");
+ int do_mat = BMO_slot_bool_get(op, "cmp_materials");
+ float limit = BMO_slot_float_get(op, "limit");
int i, totedge;
/* flag all edges of all input face */
@@ -282,13 +258,13 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
v3 = e->l->next->v;
v4 = e->l->radial_next->prev->v;
- if (dosharp && !BM_elem_flag_test(e, BM_ELEM_SMOOTH))
+ if (do_sharp && !BM_elem_flag_test(e, BM_ELEM_SMOOTH))
continue;
-
- if ((douvs || dovcols) && compareFaceAttribs(bm, e, douvs, dovcols))
+
+ if (do_mat && f1->mat_nr != f2->mat_nr)
continue;
- if (domat && f1->mat_nr != f2->mat_nr)
+ if ((do_uv || do_tf || do_vcol) && (bm_edge_faces_cmp(bm, e, do_uv, do_tf, do_vcol) == FALSE))
continue;
measure = measure_facepair(v1, v2, v3, v4, limit);
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index e1a5ef9f905..d3e98dd96c1 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -244,11 +244,11 @@ static int vergaverco(const void *e1, const void *e2)
else return 0;
}
-#define VERT_TESTED 1
+// #define VERT_TESTED 1 // UNUSED
#define VERT_DOUBLE 2
#define VERT_TARGET 4
#define VERT_KEEP 8
-#define VERT_MARK 16
+// #define VERT_MARK 16 // UNUSED
#define VERT_IN 32
#define EDGE_MARK 1
@@ -487,7 +487,7 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op)
}
}
-void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname)
+static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname)
{
BMOIter oiter;
BMVert *v, *v2;
diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c
index e0dc5cf48c7..d572a1c5863 100644
--- a/source/blender/bmesh/operators/bmo_wireframe.c
+++ b/source/blender/bmesh/operators/bmo_wireframe.c
@@ -34,7 +34,7 @@
#include "intern/bmesh_operators_private.h" /* own include */
-BMLoop *bm_edge_tag_faceloop(BMEdge *e)
+static BMLoop *bm_edge_tag_faceloop(BMEdge *e)
{
BMLoop *l, *l_first;
diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c
index 91527313972..98f270abd16 100644
--- a/source/blender/bmesh/tools/BME_bevel.c
+++ b/source/blender/bmesh/tools/BME_bevel.c
@@ -66,7 +66,7 @@
/* ------- Bevel code starts here -------- */
-BME_TransData_Head *BME_init_transdata(int bufsize)
+static BME_TransData_Head *BME_init_transdata(int bufsize)
{
BME_TransData_Head *td;
@@ -85,9 +85,9 @@ void BME_free_transdata(BME_TransData_Head *td)
MEM_freeN(td);
}
-BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BMesh *bm, BMVert *v,
- float *co, float *org, float *vec, float *loc,
- float factor, float weight, float maxfactor, float *max)
+static BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BMesh *bm, BMVert *v,
+ float *co, float *org, float *vec, float *loc,
+ float factor, float weight, float maxfactor, float *max)
{
BME_TransData *vtd;
int is_new = 0;
@@ -140,7 +140,7 @@ BME_TransData *BME_get_transdata(BME_TransData_Head *td, BMVert *v)
}
/* a hack (?) to use the transdata memarena to allocate floats for use with the max limits */
-float *BME_new_transdata_float(BME_TransData_Head *td)
+static float *BME_new_transdata_float(BME_TransData_Head *td)
{
return BLI_memarena_alloc(td->ma, sizeof(float));
}
diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp
index f7e0f75ec5c..fbb18887d1b 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -76,6 +76,7 @@ int collada_export(Scene *sce,
if (!BLI_exists(filepath)) {
BLI_make_existing_file(filepath); /* makes the dir if its not there */
if (BLI_file_touch(filepath) == 0) {
+ fprintf(stdout, "Collada export: Can not create: %s\n", filepath);
return 0;
}
}
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index f35bf71392c..a64583b68ff 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -24,6 +24,7 @@
extern "C" {
#endif
+#include "DNA_color_types.h"
#include "DNA_node_types.h"
/**
@@ -299,8 +300,20 @@ extern "C" {
*
* - output nodes can have different priorities in the WorkScheduler.
* This is implemented in the COM_execute function.
+ *
+ * @param viewSettings
+ * reference to view settings used for color management
+ *
+ * @param displaySettings
+ * reference to display settings used for color management
+ *
+ * OCIO_TODO: this options only used in rare cases, namely in output file node,
+ * so probably this settings could be passed in a nicer way.
+ * should be checked further, probably it'll be also needed for preview
+ * generation in display space
*/
-void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering);
+void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
/**
* @brief Deinitialize the compositor caches and allocated memory.
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index fbdb4cd6b28..e1cc25d028a 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -31,6 +31,8 @@ CompositorContext::CompositorContext()
this->m_hasActiveOpenCLDevices = false;
this->m_activegNode = NULL;
this->m_fastCalculation = false;
+ this->m_viewSettings = NULL;
+ this->m_displaySettings = NULL;
}
const int CompositorContext::getFramenumber() const
@@ -42,13 +44,3 @@ const int CompositorContext::getFramenumber() const
return -1; /* this should never happen */
}
}
-
-const int CompositorContext::isColorManaged() const
-{
- if (this->m_rd) {
- return this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT;
- }
- else {
- return 0; /* this should never happen */
- }
-}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 2f6abf39985..2f5e8c0648d 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -27,6 +27,7 @@
#include "BKE_text.h"
#include <string>
#include "DNA_node_types.h"
+#include "DNA_color_types.h"
#include "BLI_rect.h"
#include "DNA_scene_types.h"
#include "COM_defines.h"
@@ -79,6 +80,9 @@ private:
*/
bool m_fastCalculation;
+ /* @brief color management settings */
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
/**
* @brief constructor initializes the context with default values.
@@ -126,6 +130,26 @@ public:
const RenderData *getRenderData() const { return this->m_rd; }
/**
+ * @brief set view settings of color color management
+ */
+ void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
+
+ /**
+ * @brief get view settings of color color management
+ */
+ const ColorManagedViewSettings *getViewSettings() const { return this->m_viewSettings; }
+
+ /**
+ * @brief set display settings of color color management
+ */
+ void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
+
+ /**
+ * @brief get display settings of color color management
+ */
+ const ColorManagedDisplaySettings *getDisplaySettings() const { return this->m_displaySettings; }
+
+ /**
* @brief set the quality
*/
void setQuality(CompositorQuality quality) { this->m_quality = quality; }
@@ -152,8 +176,6 @@ public:
int getChunksize() { return this->getbNodeTree()->chunksize; }
- const int isColorManaged() const;
-
void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;}
bool isFastCalculation() {return this->m_fastCalculation;}
};
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 801505e9d39..a13717c9d86 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -44,7 +44,8 @@
#include "MEM_guardedalloc.h"
#endif
-ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation)
+ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings)
{
this->m_context.setbNodeTree(editingtree);
this->m_context.setFastCalculation(fastcalculation);
@@ -69,6 +70,9 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool re
ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL);
this->m_context.setRenderData(rd);
+ this->m_context.setViewSettings(viewSettings);
+ this->m_context.setDisplaySettings(displaySettings);
+
this->convertToOperations();
this->groupOperations(); /* group operations in ExecutionGroups */
unsigned int index;
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 39e7bc80279..56a60bf7a03 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -25,6 +25,7 @@ class ExecutionGroup;
#ifndef _COM_ExecutionSystem_h
#define _COM_ExecutionSystem_h
+#include "DNA_color_types.h"
#include "DNA_node_types.h"
#include <vector>
#include "COM_Node.h"
@@ -156,7 +157,8 @@ public:
* @param editingtree [bNodeTree *]
* @param rendering [true false]
*/
- ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation);
+ ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
/**
* Destructor
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
index e41361fcb2e..bedbfc72722 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
@@ -79,14 +79,10 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node)
Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast)
{
- Node *node;
- node = Converter::convert(b_node, fast);
+ Node *node = Converter::convert(b_node, fast);
node->setIsInActiveGroup(inActiveGroup);
- if (node != NULL) {
- addNode(nodes, node);
- return node;
- }
- return NULL;
+ addNode(nodes, node);
+ return node;
}
void ExecutionSystemHelper::addOperation(vector<NodeOperation *>& operations, NodeOperation *operation)
{
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index 0994f3f8890..bdbe21f82ea 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -253,7 +253,7 @@ static void imp2radangle(float A, float B, float C, float F, float *a, float *b,
}
}
-float clipuv(float x, float limit)
+static float clipuv(float x, float limit)
{
x = (x < 0) ? 0 : ((x >= limit) ? (limit - 1) : x);
return x;
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 50393d14f35..5922b0e6b08 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -75,12 +75,12 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket
graph->addOperation(operation);
}
-void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket)
+void Node::addPreviewOperation(ExecutionSystem *system, CompositorContext *context, OutputSocket *outputSocket)
{
if (this->isInActiveGroup()) {
if (!(this->getbNode()->flag & NODE_HIDDEN)) { // do not calculate previews of hidden nodes.
if (this->getbNode()->flag & NODE_PREVIEW) {
- PreviewOperation *operation = new PreviewOperation();
+ PreviewOperation *operation = new PreviewOperation(context->getViewSettings(), context->getDisplaySettings());
system->addOperation(operation);
operation->setbNode(this->getbNode());
operation->setbNodeTree(system->getContext().getbNodeTree());
@@ -90,11 +90,11 @@ void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSock
}
}
-void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket)
+void Node::addPreviewOperation(ExecutionSystem *system, CompositorContext *context, InputSocket *inputSocket)
{
if (inputSocket->isConnected() && this->isInActiveGroup()) {
OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket();
- this->addPreviewOperation(system, outputsocket);
+ this->addPreviewOperation(system, context, outputsocket);
}
}
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 7ce40e3cb34..bfccd069ad1 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -135,8 +135,8 @@ public:
*/
OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket);
protected:
- void addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket);
- void addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket);
+ void addPreviewOperation(ExecutionSystem *system, CompositorContext *context, InputSocket *inputSocket);
+ void addPreviewOperation(ExecutionSystem *system, CompositorContext *context, OutputSocket *outputSocket);
bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h
index b55e444be80..64d669b5e9a 100644
--- a/source/blender/compositor/intern/COM_NodeBase.h
+++ b/source/blender/compositor/intern/COM_NodeBase.h
@@ -97,7 +97,7 @@ public:
* @return [true:false]
* @see NodeOperation
*/
- virtual const int isOperation() const { return false; }
+ virtual const bool isOperation() const { return false; }
/**
* @brief check if this is an input node
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 93a19529d34..dfa22a29e41 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -88,7 +88,7 @@ public:
* @return [true:false]
* @see NodeBase
*/
- const int isOperation() const { return true; }
+ const bool isOperation() const { return true; }
/**
* @brief determine the resolution of this node
diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h
index dc5ca27cbda..c6b7993c561 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.h
+++ b/source/blender/compositor/intern/COM_OutputSocket.h
@@ -64,7 +64,7 @@ public:
/**
* @brief determine the actual data type and channel info.
*/
- void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); };
+ void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); }
void relinkConnections(OutputSocket *relinkToSocket, bool single);
const int getNumberOfConnections() { return this->m_connections.size(); }
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index f732a40e768..eb9c26d4f43 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -25,6 +25,7 @@
#include "BKE_global.h"
+#include "COM_compositor.h"
#include "COM_WorkScheduler.h"
#include "COM_CPUDevice.h"
#include "COM_OpenCLDevice.h"
@@ -265,7 +266,7 @@ bool WorkScheduler::hasGPUDevices()
#endif
}
-extern void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data)
+static void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data)
{
printf("OPENCL error: %s\n", errinfo);
}
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index cb9166c929d..49ab9db5dd8 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -37,12 +37,14 @@ extern "C" {
static ThreadMutex s_compositorMutex;
static char is_compositorMutex_init = FALSE;
-void intern_freeCompositorCaches()
+static void intern_freeCompositorCaches()
{
deintializeDistortionCache();
}
-void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
+void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings)
{
/* initialize mutex, TODO this mutex init is actually not thread safe and
* should be done somewhere as part of blender startup, all the other
@@ -71,7 +73,7 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
bool twopass = (editingtree->flag & NTREE_TWO_PASS) > 0 && !rendering;
/* initialize execution system */
if (twopass) {
- ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass);
+ ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass, viewSettings, displaySettings);
system->execute();
delete system;
@@ -84,14 +86,14 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
}
- ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false);
+ ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false, viewSettings, displaySettings);
system->execute();
delete system;
BLI_mutex_unlock(&s_compositorMutex);
}
-void COM_freeCaches()
+static void UNUSED_FUNCTION(COM_freeCaches)()
{
if (is_compositorMutex_init) {
BLI_mutex_lock(&s_compositorMutex);
@@ -100,7 +102,7 @@ void COM_freeCaches()
}
}
-void COM_deinitialize()
+void COM_deinitialize()
{
if (is_compositorMutex_init) {
BLI_mutex_lock(&s_compositorMutex);
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index e39ef2b3f23..4f120ea5a6e 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -57,7 +57,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph);
this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0));
graph->addOperation(operationfgb);
- addPreviewOperation(graph, operationfgb->getOutputSocket());
+ addPreviewOperation(graph, context, operationfgb->getOutputSocket());
}
else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
MathAddOperation *clamp = new MathAddOperation();
@@ -97,7 +97,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
addLink(graph, operationy->getOutputSocket(), operation->getInputSocket(1));
graph->addOperation(operation);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, operation->getOutputSocket());
+ addPreviewOperation(graph, context, operation->getOutputSocket());
}
else if (!data->bokeh) {
GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
@@ -115,7 +115,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
graph->addOperation(operationy);
addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1));
- addPreviewOperation(graph, operationy->getOutputSocket());
+ addPreviewOperation(graph, context, operationy->getOutputSocket());
if (!connectedSizeSocket) {
operationx->setSize(size);
@@ -131,7 +131,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation->setQuality(quality);
graph->addOperation(operation);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, operation->getOutputSocket());
+ addPreviewOperation(graph, context, operation->getOutputSocket());
if (!connectedSizeSocket) {
operation->setSize(size);
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
index f6abbbb9a9a..a89ed9e0c64 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
@@ -35,5 +35,5 @@ void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorConte
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
graph->addOperation(operation);
operation->setData((NodeBokehImage *)this->getbNode()->storage);
- addPreviewOperation(graph, operation->getOutputSocket(0));
+ addPreviewOperation(graph, context, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index eab921863e9..c1511ee611b 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -84,7 +84,7 @@ void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCon
graph->addOperation(operationAlpha);
addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
- addPreviewOperation(graph, operationAlpha->getOutputSocket());
+ addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
if (outputSocketImage->isConnected()) {
outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
index 0fb09157351..4c4b77ba6cc 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
@@ -65,7 +65,7 @@ void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCont
addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
graph->addOperation(operationAlpha);
- addPreviewOperation(graph, operationAlpha->getOutputSocket());
+ addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
if (outputSocketImage->isConnected()) {
outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
index 38ab6ba8da2..54e6762961b 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
@@ -62,7 +62,7 @@ void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorConte
addLink(graph, operationRGBToHSV_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
graph->addOperation(operationAlpha);
- addPreviewOperation(graph, operationAlpha->getOutputSocket());
+ addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
if (outputSocketImage->isConnected()) {
outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index d0d66a81c77..e3313750e66 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -45,5 +45,5 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte
alphaSocket->relinkConnections(compositorOperation->getInputSocket(1));
depthSocket->relinkConnections(compositorOperation->getInputSocket(2));
graph->addOperation(compositorOperation);
- addPreviewOperation(graph, compositorOperation->getInputSocket(0));
+ addPreviewOperation(graph, context, compositorOperation->getInputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
index 603ddcd1389..a97714c870e 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
@@ -44,7 +44,7 @@ void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContex
inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
outputSocket->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, operation->getOutputSocket(0));
+ addPreviewOperation(graph, context, operation->getOutputSocket(0));
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
index 6dca049a6ae..b5ad07be319 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -51,5 +51,5 @@ void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, Compositor
addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
outputSocketImage->relinkConnections(operation->getOutputSocket());
graph->addOperation(operation);
- addPreviewOperation(graph, operation->getOutputSocket());
+ addPreviewOperation(graph, context, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index cecc3bf6e86..5bd2f78d8a6 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -106,7 +106,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
graph->addOperation(operationy);
addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
// addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); // no size input yet
- addPreviewOperation(graph, operationy->getOutputSocket());
+ addPreviewOperation(graph, context, operationy->getOutputSocket());
/* TODO? */
/* see gaussian blue node for original usage */
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 87e7b9d0788..782c897f6fb 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -77,7 +77,7 @@ void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCo
addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
graph->addOperation(operationAlpha);
- addPreviewOperation(graph, operationAlpha->getOutputSocket());
+ addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
if (outputSocketImage->isConnected()) {
outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
index 021ec6c2508..990cdb480ca 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cpp
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -77,7 +77,7 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
outputSocket->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, operation->getOutputSocket(0));
+ addPreviewOperation(graph, context, operation->getOutputSocket(0));
graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index 2d13ffb82b6..4ebd28d710a 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -111,7 +111,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
break;
}
if (index == 0 && operation) {
- addPreviewOperation(graph, operation->getOutputSocket());
+ addPreviewOperation(graph, context, operation->getOutputSocket());
}
}
}
@@ -134,7 +134,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
operation->setImageUser(imageuser);
operation->setFramenumber(framenumber);
graph->addOperation(operation);
- addPreviewOperation(graph, operation->getOutputSocket());
+ addPreviewOperation(graph, context, operation->getOutputSocket());
}
if (numberOfOutputs > 1) {
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
index be949e2cacb..4656e00b006 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
@@ -55,7 +55,7 @@ void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorC
addLink(graph, rgbToYUV->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0));
addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
graph->addOperation(operation);
- addPreviewOperation(graph, operation->getOutputSocket());
+ addPreviewOperation(graph, context, operation->getOutputSocket());
if (outputSocketImage->isConnected()) {
outputSocketImage->relinkConnections(operation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
index 7aeaaf56c98..ab4e464327d 100644
--- a/source/blender/compositor/nodes/COM_MixNode.cpp
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -128,7 +128,7 @@ void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *con
color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph);
color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph);
outputSocket->relinkConnections(convertProg->getOutputSocket(0));
- addPreviewOperation(graph, convertProg->getOutputSocket(0));
+ addPreviewOperation(graph, context, convertProg->getOutputSocket(0));
convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode());
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index 6d5b9bba8aa..5d5e68fba37 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -62,25 +62,9 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex
// always connect the output image
MovieClipOperation *operation = new MovieClipOperation();
- if (ibuf && context->isColorManaged() && ibuf->profile == IB_PROFILE_NONE) {
- ConvertColorProfileOperation *converter = new ConvertColorProfileOperation();
- converter->setFromColorProfile(IB_PROFILE_LINEAR_RGB);
- converter->setToColorProfile(IB_PROFILE_SRGB);
- addLink(graph, operation->getOutputSocket(), converter->getInputSocket(0));
- addPreviewOperation(graph, converter->getOutputSocket());
- if (outputMovieClip->isConnected()) {
- outputMovieClip->relinkConnections(converter->getOutputSocket());
- }
- graph->addOperation(converter);
- if (ibuf) {
- converter->setPredivided(ibuf->flags & IB_cm_predivide);
- }
- }
- else {
- addPreviewOperation(graph, operation->getOutputSocket());
- if (outputMovieClip->isConnected()) {
- outputMovieClip->relinkConnections(operation->getOutputSocket());
- }
+ addPreviewOperation(graph, context, operation->getOutputSocket());
+ if (outputMovieClip->isConnected()) {
+ outputMovieClip->relinkConnections(operation->getOutputSocket());
}
operation->setMovieClip(movieClip);
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index b8cee29fee6..921b9e63a73 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -62,7 +62,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
input->relinkConnections(outputOperation->getInputSocket(i));
}
}
- if (hasConnections) addPreviewOperation(graph, outputOperation->getInputSocket(0));
+ if (hasConnections) addPreviewOperation(graph, context, outputOperation->getInputSocket(0));
graph->addOperation(outputOperation);
}
@@ -80,11 +80,12 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation(
- context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path);
+ context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path,
+ context->getViewSettings(), context->getDisplaySettings());
input->relinkConnections(outputOperation->getInputSocket(0));
graph->addOperation(outputOperation);
if (!previewAdded) {
- addPreviewOperation(graph, outputOperation->getInputSocket(0));
+ addPreviewOperation(graph, context, outputOperation->getInputSocket(0));
previewAdded = true;
}
}
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index dfb46af841c..b57e99754d6 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -52,7 +52,7 @@ RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputSocketNumber, RenderLayersBaseProg *operation)
+void RenderLayersNode::testSocketConnection(ExecutionSystem *system, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation)
{
OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber);
Scene *scene = (Scene *)this->getbNode()->id;
@@ -64,7 +64,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS
outputSocket->relinkConnections(operation->getOutputSocket());
system->addOperation(operation);
if (outputSocketNumber == 0) { // only do for image socket if connected
- addPreviewOperation(system, operation->getOutputSocket());
+ addPreviewOperation(system, context, operation->getOutputSocket());
}
}
else {
@@ -72,7 +72,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS
system->addOperation(operation);
operation->setScene(scene);
operation->setLayerId(layerId);
- addPreviewOperation(system, operation->getOutputSocket());
+ addPreviewOperation(system, context, operation->getOutputSocket());
}
else {
delete operation;
@@ -82,34 +82,34 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS
void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- testSocketConnection(graph, 0, new RenderLayersColorProg());
- testSocketConnection(graph, 1, new RenderLayersAlphaProg());
- testSocketConnection(graph, 2, new RenderLayersDepthProg());
- testSocketConnection(graph, 3, new RenderLayersNormalOperation());
- testSocketConnection(graph, 4, new RenderLayersUVOperation());
- testSocketConnection(graph, 5, new RenderLayersSpeedOperation());
- testSocketConnection(graph, 6, new RenderLayersColorOperation());
- testSocketConnection(graph, 7, new RenderLayersDiffuseOperation());
- testSocketConnection(graph, 8, new RenderLayersSpecularOperation());
- testSocketConnection(graph, 9, new RenderLayersShadowOperation());
- testSocketConnection(graph, 10, new RenderLayersAOOperation());
- testSocketConnection(graph, 11, new RenderLayersReflectionOperation());
- testSocketConnection(graph, 12, new RenderLayersRefractionOperation());
- testSocketConnection(graph, 13, new RenderLayersIndirectOperation());
- testSocketConnection(graph, 14, new RenderLayersObjectIndexOperation());
- testSocketConnection(graph, 15, new RenderLayersMaterialIndexOperation());
- testSocketConnection(graph, 16, new RenderLayersMistOperation());
- testSocketConnection(graph, 17, new RenderLayersEmitOperation());
- testSocketConnection(graph, 18, new RenderLayersEnvironmentOperation());
+ testSocketConnection(graph, context, 0, new RenderLayersColorProg());
+ testSocketConnection(graph, context, 1, new RenderLayersAlphaProg());
+ testSocketConnection(graph, context, 2, new RenderLayersDepthProg());
+ testSocketConnection(graph, context, 3, new RenderLayersNormalOperation());
+ testSocketConnection(graph, context, 4, new RenderLayersUVOperation());
+ testSocketConnection(graph, context, 5, new RenderLayersSpeedOperation());
+ testSocketConnection(graph, context, 6, new RenderLayersColorOperation());
+ testSocketConnection(graph, context, 7, new RenderLayersDiffuseOperation());
+ testSocketConnection(graph, context, 8, new RenderLayersSpecularOperation());
+ testSocketConnection(graph, context, 9, new RenderLayersShadowOperation());
+ testSocketConnection(graph, context, 10, new RenderLayersAOOperation());
+ testSocketConnection(graph, context, 11, new RenderLayersReflectionOperation());
+ testSocketConnection(graph, context, 12, new RenderLayersRefractionOperation());
+ testSocketConnection(graph, context, 13, new RenderLayersIndirectOperation());
+ testSocketConnection(graph, context, 14, new RenderLayersObjectIndexOperation());
+ testSocketConnection(graph, context, 15, new RenderLayersMaterialIndexOperation());
+ testSocketConnection(graph, context, 16, new RenderLayersMistOperation());
+ testSocketConnection(graph, context, 17, new RenderLayersEmitOperation());
+ testSocketConnection(graph, context, 18, new RenderLayersEnvironmentOperation());
// cycles passes
- testSocketConnection(graph, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
- testSocketConnection(graph, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
- testSocketConnection(graph, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
- testSocketConnection(graph, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
- testSocketConnection(graph, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
- testSocketConnection(graph, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
- testSocketConnection(graph, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
- testSocketConnection(graph, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
- testSocketConnection(graph, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
+ testSocketConnection(graph, context, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
+ testSocketConnection(graph, context, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
+ testSocketConnection(graph, context, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
+ testSocketConnection(graph, context, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
+ testSocketConnection(graph, context, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
+ testSocketConnection(graph, context, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
+ testSocketConnection(graph, context, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
+ testSocketConnection(graph, context, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
+ testSocketConnection(graph, context, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
}
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index 32672c8ba2d..9bd74624b0c 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -33,5 +33,5 @@ public:
RenderLayersNode(bNode *editorNode);
void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
private:
- void testSocketConnection(ExecutionSystem *graph, int outputSocketNumber, RenderLayersBaseProg *operation);
+ void testSocketConnection(ExecutionSystem *graph, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation);
};
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
index 388466cee3c..37b888becca 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -39,13 +39,14 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
if (image1Socket->isConnected() && image2Socket->isConnected()) {
SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
- splitViewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT);
- splitViewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
splitViewerOperation->setImage(image);
splitViewerOperation->setImageUser(imageUser);
splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
+ splitViewerOperation->setViewSettings(context->getViewSettings());
+ splitViewerOperation->setDisplaySettings(context->getDisplaySettings());
+
/* defaults - the viewer node has these options but not exposed for split view
* we could use the split to define an area of interest on one axis at least */
splitViewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
@@ -55,7 +56,7 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
splitViewerOperation->setXSplit(!this->getbNode()->custom2);
image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);
image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph);
- addPreviewOperation(graph, splitViewerOperation->getInputSocket(0));
+ addPreviewOperation(graph, context, splitViewerOperation->getInputSocket(0));
graph->addOperation(splitViewerOperation);
}
}
diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp
index b035e0a392c..5b386a504e4 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.cpp
+++ b/source/blender/compositor/nodes/COM_TextureNode.cpp
@@ -40,7 +40,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
operation->setTexture(texture);
operation->setRenderData(context->getRenderData());
system->addOperation(operation);
- addPreviewOperation(system, operation->getOutputSocket());
+ addPreviewOperation(system, context, operation->getOutputSocket());
if (this->getOutputSocket(0)->isConnected()) {
TextureAlphaOperation *alphaOperation = new TextureAlphaOperation();
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index 88ce0ff2016..d67e9e274b0 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -40,8 +40,6 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
bNode *editorNode = this->getbNode();
ViewerOperation *viewerOperation = new ViewerOperation();
- viewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT);
- viewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
viewerOperation->setbNodeTree(context->getbNodeTree());
viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser);
@@ -50,6 +48,9 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
viewerOperation->setCenterX(editorNode->custom3);
viewerOperation->setCenterY(editorNode->custom4);
+ viewerOperation->setViewSettings(context->getViewSettings());
+ viewerOperation->setDisplaySettings(context->getDisplaySettings());
+
viewerOperation->setResolutionInputSocketIndex(0);
if (!imageSocket->isConnected())
{
@@ -62,5 +63,5 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
alphaSocket->relinkConnections(viewerOperation->getInputSocket(1));
depthSocket->relinkConnections(viewerOperation->getInputSocket(2));
graph->addOperation(viewerOperation);
- addPreviewOperation(graph, viewerOperation->getInputSocket(0));
+ addPreviewOperation(graph, context, viewerOperation->getInputSocket(0));
}
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h
index 5b79d7cb7e0..99635e61544 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.h
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.h
@@ -27,8 +27,8 @@ private:
float m_threshold;
float m_threshold_neighbour;
- int m_filterWidth;
- int m_filterHeight;
+ // int m_filterWidth;
+ // int m_filterHeight;
protected:
SocketReader *m_inputOperation;
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index c4b4452fbb0..9c09c9bf034 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -79,7 +79,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = BLI_RCT_SIZE_X(rect);
+ const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
this->m_inputProgram->read(inputValue, x, y, NULL);
@@ -199,7 +199,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = BLI_RCT_SIZE_X(rect);
+ const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
float value = 0.0f;
@@ -273,7 +273,7 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = BLI_RCT_SIZE_X(rect);
+ const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
float value = 1.0f;
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
index 560bbbdd244..c8ebb845bb6 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
@@ -51,7 +51,7 @@ void DisplaceSimpleOperation::initExecution()
/* minimum distance (in pixels) a pixel has to be displaced
* in order to take effect */
-#define DISPLACE_EPSILON 0.01f
+// #define DISPLACE_EPSILON 0.01f
void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
index 7f7429bf2e6..efdf0134c4b 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
@@ -244,7 +244,7 @@ static void fht_convolve(fREAL *d1, fREAL *d2, unsigned int M, unsigned int N)
}
//------------------------------------------------------------------------------
-void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
+static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
{
fREAL *data1, *data2, *fp;
unsigned int w2, h2, hw, hh, log2_w, log2_h;
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index 4ec5643c0bb..fb3efbb67ed 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -33,6 +33,7 @@ extern "C" {
#include "RE_render_ext.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+ #include "IMB_colormanagement.h"
}
BaseImageOperation::BaseImageOperation() : NodeOperation()
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index 7e62de7b9f1..f3eeb2f48ba 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -99,8 +99,8 @@ public:
this->m_inverted == inverted &&
this->m_width == width &&
this->m_height == height &&
- this->m_calibration_width == this->m_calibration_width &&
- this->m_calibration_height == this->m_calibration_height;
+ this->m_calibration_width == calibration_width &&
+ this->m_calibration_height == claibration_height;
}
void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v)
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index b72875ab2f9..21ecfdb5272 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -31,9 +31,12 @@
#include "BKE_global.h"
#include "BKE_main.h"
+#include "DNA_color_types.h"
+
extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
+ #include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
}
@@ -91,7 +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 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;
@@ -104,6 +108,9 @@ OutputSingleLayerOperation::OutputSingleLayerOperation(
this->m_format = format;
BLI_strncpy(this->m_path, path, sizeof(this->m_path));
+
+ this->m_viewSettings = viewSettings;
+ this->m_displaySettings = displaySettings;
}
void OutputSingleLayerOperation::initExecution()
@@ -131,8 +138,7 @@ void OutputSingleLayerOperation::deinitExecution()
ibuf->mall |= IB_rectfloat;
ibuf->dither = this->m_rd->dither_intensity;
- if (this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
+ IMB_display_buffer_to_imbuf_rect(ibuf, m_viewSettings, m_displaySettings);
BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format->imtype,
(this->m_rd->scemode & R_EXTENSION), true);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index 532242c97ce..69d1ad48ced 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -28,6 +28,8 @@
#include "BLI_rect.h"
#include "BLI_path_util.h"
+#include "DNA_color_types.h"
+
#include "intern/openexr/openexr_multi.h"
/* Writes the image to a single-layer file. */
@@ -43,8 +45,11 @@ private:
DataType m_datatype;
SocketReader *m_imageInput;
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
- OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path);
+ OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
void executeRegion(rcti *rect, unsigned int tileNumber);
bool isOutputOperation(bool rendering) const { return true; }
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index aff374cdded..6e58b277f66 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -35,16 +35,19 @@ extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+ #include "IMB_colormanagement.h"
}
-PreviewOperation::PreviewOperation() : NodeOperation()
+PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->m_outputBuffer = NULL;
this->m_input = NULL;
this->m_divider = 1.0f;
this->m_node = NULL;
+ this->m_viewSettings = viewSettings;
+ this->m_displaySettings = displaySettings;
}
void PreviewOperation::initExecution()
@@ -82,6 +85,10 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber)
{
int offset;
float color[4];
+ struct ColormanageProcessor *cm_processor;
+
+ cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings, this->m_displaySettings);
+
for (int y = rect->ymin; y < rect->ymax; y++) {
offset = (y * getWidth() + rect->xmin) * 4;
for (int x = rect->xmin; x < rect->xmax; x++) {
@@ -93,11 +100,13 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber)
color[2] = 0.0f;
color[3] = 1.0f;
this->m_input->read(color, rx, ry, COM_PS_NEAREST);
- linearrgb_to_srgb_v4(color, color);
+ IMB_colormanagement_processor_apply_v4(cm_processor, color);
F4TOCHAR4(color, this->m_outputBuffer + offset);
offset += 4;
}
}
+
+ IMB_colormanagement_processor_free(cm_processor);
}
bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index ffd80ff27af..9e774d0e41b 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -24,6 +24,7 @@
#define _COM_PreviewOperation_h
#include "COM_NodeOperation.h"
#include "DNA_image_types.h"
+#include "DNA_color_types.h"
#include "BLI_rect.h"
class PreviewOperation : public NodeOperation {
@@ -37,8 +38,10 @@ protected:
SocketReader *m_input;
float m_divider;
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
- PreviewOperation();
+ PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
index d59d1f9f10d..7325e32a863 100644
--- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
@@ -62,7 +62,6 @@ void SplitViewerOperation::deinitExecution()
void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
{
float *buffer = this->m_outputBuffer;
- unsigned char *bufferDisplay = this->m_outputBufferDisplay;
if (!buffer) return;
int x1 = rect->xmin;
@@ -76,7 +75,6 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
for (y = y1; y < y2; y++) {
for (x = x1; x < x2; x++) {
bool image1;
- float srgb[4];
image1 = this->m_xSplit ? x > perc : y > perc;
if (image1) {
this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
@@ -84,21 +82,7 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
else {
this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
}
- /// @todo: linear conversion only when scene color management is selected, also check predivide.
- if (this->m_doColorManagement) {
- if (this->m_doColorPredivide) {
- linearrgb_to_srgb_predivide_v4(srgb, buffer + offset);
- }
- else {
- linearrgb_to_srgb_v4(srgb, buffer + offset);
- }
- }
- else {
- copy_v4_v4(srgb, buffer + offset);
- }
-
- rgba_float_to_uchar(bufferDisplay + offset, srgb);
-
+
offset += 4;
}
offset += (this->getWidth() - (x2 - x1)) * 4;
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
index f443c33cd54..d9ca131721f 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
@@ -34,6 +34,7 @@ extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+ #include "IMB_colormanagement.h"
}
@@ -43,10 +44,10 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation()
this->setImageUser(NULL);
this->m_outputBuffer = NULL;
this->m_depthBuffer = NULL;
- this->m_outputBufferDisplay = NULL;
this->m_active = false;
- this->m_doColorManagement = true;
this->m_doDepthBuffer = false;
+ this->m_viewSettings = NULL;
+ this->m_displaySettings = NULL;
}
void ViewerBaseOperation::initExecution()
@@ -60,7 +61,7 @@ void ViewerBaseOperation::initImage()
{
Image *anImage = this->m_image;
ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock);
-
+
if (!ibuf) return;
BLI_lock_thread(LOCK_DRAW_IMAGE);
if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
@@ -70,30 +71,44 @@ void ViewerBaseOperation::initImage()
IMB_freezbuffloatImBuf(ibuf);
ibuf->x = getWidth();
ibuf->y = getHeight();
- imb_addrectImBuf(ibuf);
imb_addrectfloatImBuf(ibuf);
anImage->ok = IMA_OK_LOADED;
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+
+ BLI_unlock_thread(LOCK_DRAW_IMAGE);
}
+
if (m_doDepthBuffer)
{
addzbuffloatImBuf(ibuf);
}
BLI_unlock_thread(LOCK_DRAW_IMAGE);
-
-
+
/* now we combine the input with ibuf */
this->m_outputBuffer = ibuf->rect_float;
- this->m_outputBufferDisplay = (unsigned char *)ibuf->rect;
+
+ /* needed for display buffer update
+ *
+ * no need to lock / reference the image buffer because it's seems
+ * to be the single place which changes buffers of viewer image
+ * which is this node
+ */
+ this->m_ibuf = ibuf;
+
if (m_doDepthBuffer)
{
this->m_depthBuffer = ibuf->zbuf_float;
}
-
+
BKE_image_release_ibuf(this->m_image, this->m_lock);
}
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);
+
WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
}
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
index d90eb343f6c..f7d479eb3b8 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
@@ -30,7 +30,6 @@ class ViewerBaseOperation : public NodeOperation {
protected:
float *m_outputBuffer;
float *m_depthBuffer;
- unsigned char *m_outputBufferDisplay;
Image *m_image;
ImageUser *m_imageUser;
void *m_lock;
@@ -38,9 +37,11 @@ protected:
float m_centerX;
float m_centerY;
OrderOfChunks m_chunkOrder;
- bool m_doColorManagement;
- bool m_doColorPredivide;
bool m_doDepthBuffer;
+ ImBuf *m_ibuf;
+
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
bool isOutputOperation(bool rendering) const { return isActiveViewerOutput(); }
@@ -57,10 +58,10 @@ public:
float getCenterY() { return this->m_centerY; }
OrderOfChunks getChunkOrder() { return this->m_chunkOrder; }
const CompositorPriority getRenderPriority() const;
- void setColorManagement(bool doColorManagement) { this->m_doColorManagement = doColorManagement; }
- void setColorPredivide(bool doColorPredivide) { this->m_doColorPredivide = doColorPredivide; }
bool isViewerOperation() { return true; }
-
+
+ void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
+ void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
protected:
ViewerBaseOperation();
void updateImage(rcti *rect);
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index b85b86bddc3..576d5da4d74 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -72,7 +72,6 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
{
float *buffer = this->m_outputBuffer;
float *depthbuffer = this->m_depthBuffer;
- unsigned char *bufferDisplay = this->m_outputBufferDisplay;
if (!buffer) return;
const int x1 = rect->xmin;
const int y1 = rect->ymin;
@@ -82,7 +81,7 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
const int offsetadd4 = offsetadd * 4;
int offset = (y1 * this->getWidth() + x1);
int offset4 = offset * 4;
- float alpha[4], srgb[4], depth[4];
+ float alpha[4], depth[4];
int x;
int y;
bool breaked = false;
@@ -98,19 +97,6 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
this->m_depthInput->read(depth, x, y, COM_PS_NEAREST);
depthbuffer[offset] = depth[0];
}
- if (this->m_doColorManagement) {
- if (this->m_doColorPredivide) {
- linearrgb_to_srgb_predivide_v4(srgb, buffer + offset4);
- }
- else {
- linearrgb_to_srgb_v4(srgb, buffer + offset4);
- }
- }
- else {
- copy_v4_v4(srgb, buffer + offset4);
- }
-
- rgba_float_to_uchar(bufferDisplay + offset4, srgb);
offset ++;
offset4 += 4;
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index f220f0ee762..12c0e851f88 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -85,6 +85,7 @@
/* size of indent steps */
#define INDENT_STEP_SIZE 7
+/* size of string buffers used for animation channel displayed names */
#define ANIM_CHAN_NAME_SIZE 256
/* get the pointer used for some flag */
@@ -293,7 +294,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree)
}
}
- // unknown
+ /* unknown */
return 0;
}
@@ -423,7 +424,7 @@ static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
BLI_strncpy(name, "DopeSheet Summary", ANIM_CHAN_NAME_SIZE);
}
-// TODO: this is really a temp icon I think
+// FIXME: this is really a temp icon I think
static int acf_summary_icon(bAnimListElem *UNUSED(ale))
{
return ICON_BORDERMOVE;
@@ -602,7 +603,6 @@ static int acf_object_icon(bAnimListElem *ale)
Object *ob = base->object;
/* icon depends on object-type */
-
switch (ob->type) {
case OB_LAMP:
return ICON_OUTLINER_OB_LAMP;
@@ -629,7 +629,6 @@ static int acf_object_icon(bAnimListElem *ale)
default:
return ICON_OBJECT_DATA;
}
-
}
/* name for object */
@@ -2256,7 +2255,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
{
/* clear extra return data first */
*neg = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return SPK_DS_EXPAND;
@@ -2280,10 +2279,10 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type)
{
Speaker *spk = (Speaker *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(spk->flag, type);
@@ -2555,7 +2554,7 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne
return GP_LAYER_HIDE;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to edtiability
+ // *neg = 1; - if we change this to editability
return GP_LAYER_LOCKED;
default: /* unsupported */
@@ -2604,7 +2603,7 @@ static void acf_mask_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale),
// TODO: just get this from RNA?
static int acf_mask_icon(bAnimListElem *UNUSED(ale))
{
- return ICON_GREASEPENCIL; // MASK_TODO - need real icon
+ return ICON_MOD_MASK;
}
/* check if some setting exists for this channel */
@@ -2651,15 +2650,15 @@ static void *acf_mask_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short
/* mask datablock type define */
static bAnimChannelType ACF_MASKDATA =
{
- "Mask Datablock", /* type name */
+ "Mask Datablock", /* type name */
acf_mask_color, /* backdrop color */
- acf_group_backdrop, /* backdrop */
- acf_generic_indention_0, /* indent level */
- acf_generic_group_offset, /* offset */
+ acf_group_backdrop, /* backdrop */
+ acf_generic_indention_0, /* indent level */
+ acf_generic_group_offset, /* offset */
- acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idblock_name, /* name */
+ acf_generic_idfill_nameprop, /* name prop */
acf_mask_icon, /* icon */
acf_mask_setting_valid, /* has setting */
@@ -2720,7 +2719,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short
// return GP_LAYER_HIDE;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to edtiability
+ // *neg = 1; - if we change this to editability
return MASK_LAYERFLAG_LOCKED;
default: /* unsupported */
@@ -2732,7 +2731,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short
static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
/* all flags are just in agrp->flag for now... */
return GET_ACF_FLAG_PTR(masklay->flag, type);
}
@@ -2740,20 +2739,20 @@ static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sh
/* grease pencil layer type define */
static bAnimChannelType ACF_MASKLAYER =
{
- "Mask Layer", /* type name */
-
+ "Mask Layer", /* type name */
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */
-
- acf_masklay_name, /* name */
- acf_masklay_name_prop, /* name prop */
+
+ acf_masklay_name, /* name */
+ acf_masklay_name_prop, /* name prop */
NULL, /* icon */
-
- acf_masklay_setting_valid, /* has setting */
- acf_masklay_setting_flag, /* flag for setting */
- acf_masklay_setting_ptr /* pointer for setting */
+
+ acf_masklay_setting_valid, /* has setting */
+ acf_masklay_setting_flag, /* flag for setting */
+ acf_masklay_setting_ptr /* pointer for setting */
};
@@ -2855,7 +2854,7 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
acf->name(ale, name);
else
BLI_strncpy(name, "<No name>", sizeof(name));
-
+
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
@@ -2999,7 +2998,6 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting,
#define RENAME_TEXT_WIDTH 100
/* Draw the given channel */
-// TODO: make this use UI controls for the buttons
void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
@@ -3089,20 +3087,20 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel */
if (acf->name) {
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
-
+
/* set text color */
/* XXX: if active, highlight differently? */
if (selected)
UI_ThemeColor(TH_TEXT_HI);
else
UI_ThemeColor(TH_TEXT);
-
+
/* get name */
acf->name(ale, name);
-
+
offset += 3;
UI_DrawString(offset, ytext, name);
-
+
/* draw red underline if channel is disabled */
if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) {
/* FIXME: replace hardcoded color here, and check on extents! */
@@ -3147,7 +3145,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
}
/* check if there's enough space for the toggles if the sliders are drawn too */
- if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
+ if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
offset += ICON_WIDTH;
@@ -3232,7 +3230,6 @@ static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *U
ads->renameIndex = 0;
/* send notifiers */
- // XXX: right notifier?
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL);
}
@@ -3278,7 +3275,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
{
Key *key = (Key *)key_poin;
KeyBlock *kb = (KeyBlock *)kb_poin;
- char *rna_path = key_get_curValue_rnaPath(key, kb);
+ char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
@@ -3516,7 +3513,6 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
offset = 0;
// TODO: when drawing sliders, make those draw instead of these toggles if not enough space
-
if (v2d) {
short draw_sliders = 0;
@@ -3539,7 +3535,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
}
/* check if there's enough space for the toggles if the sliders are drawn too */
- if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
+ if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
offset += ICON_WIDTH;
@@ -3586,7 +3582,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
KeyBlock *kb = (KeyBlock *)ale->data;
Key *key = (Key *)ale->id;
- rna_path = key_get_curValue_rnaPath(key, kb);
+ rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
free_path = 1;
}
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 6ce9fc638be..98071fafc1e 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -142,7 +142,6 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
/* check if there are bones, and whether the name matches any
* NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone
*/
- // TODO: if bone gets renamed, it would be best to be able to rename the group
if (ob->pose) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
bArmature *arm = ob->data;
@@ -319,7 +318,6 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
FCurve *active_fcurve = NULL;
/* get animation context info for filtering the channels */
- // TODO: check on whether we need to set the area specially instead, since active area might not be ok?
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 7a80cab93e5..eb7bc68ff8f 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -100,7 +100,7 @@
/* ----------- Private Stuff - Action Editor ------------- */
/* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */
-/* Note: there's a similar function in key.c (ob_get_key) */
+/* Note: there's a similar function in key.c (BKE_key_from_object) */
static Key *actedit_get_shapekeys(bAnimContext *ac)
{
Scene *scene = ac->scene;
@@ -115,7 +115,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
//if (saction->pin) return NULL;
/* shapekey data is stored with geometry data */
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key) {
if (key->type == KEY_RELATIVE)
@@ -164,30 +164,30 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return 1;
-
+
case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_GPENCIL;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return 1;
-
- case SACTCONT_MASK: /* Grease Pencil */ /* XXX review how this mode is handled... */
- /* update scene-pointer (no need to check for pinning yet, as not implemented) */
+
+ 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;
// struct Mask *mask = seq ? seq->mask : NULL;
-
+
+ /* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_MASK;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return 1;
}
@@ -689,12 +689,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Speaker *spk = (Speaker *)data;
AnimData *adt = spk->adt;
-
+
ale->flag = FILTER_SPK_OBJD(spk);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
}
break;
@@ -813,7 +813,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
/* the corresponding keyframes are from the animdata */
if (ale->adt && ale->adt->action) {
bAction *act = ale->adt->action;
- char *rna_path = key_get_curValue_rnaPath(key, kb);
+ char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
/* try to find the F-Curve which corresponds to this exactly,
* then free the MEM_alloc'd string
@@ -838,18 +838,18 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
ale->datatype = ALE_GPFRAME;
}
break;
-
+
case ANIMTYPE_MASKLAYER:
{
MaskLayer *masklay = (MaskLayer *)data;
-
+
ale->flag = masklay->flag;
-
+
ale->key_data = NULL;
ale->datatype = ALE_MASKLAY;
}
break;
-
+
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)data;
@@ -1152,7 +1152,6 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
- // TODO: need a way of tagging other channels that may also be affected...
if ((filter_mode & ANIMFILTER_FOREDIT) && (act->id.lib))
return 0;
@@ -1254,11 +1253,11 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
{
AnimData *adt = BKE_animdata_from_id(id);
size_t items = 0;
-
+
/* image object datablocks have no anim-data so check for NULL */
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id;
-
+
/* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed
* in a few places in he rest of the code still - notably for the few cases where special mode-based
* different types of data expanders are required.
@@ -1279,7 +1278,7 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
}
);
}
-
+
return items;
}
@@ -1297,7 +1296,6 @@ static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Ke
/* loop through the channels adding ShapeKeys as appropriate */
for (kb = key->block.first; kb; kb = kb->next) {
/* skip the first one, since that's the non-animatable basis */
- // XXX maybe in future this may become handy?
if (kb == key->block.first) continue;
/* only work with this channel and its subchannels if it is editable */
@@ -1659,7 +1657,6 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data,
/* did we find anything? */
if (tmp_items) {
/* include material-expand widget first */
- // hmm... do we need to store the index of this material in the array anywhere?
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* check if filtering by active status */
if (ANIMCHANNEL_ACTIVEOK(ma)) {
@@ -1871,11 +1868,11 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
{
Lamp *la = ob->data;
bNodeTree *ntree = la->nodetree;
-
+
/* nodetree */
if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE))
tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, &la->id, ntree, filter_mode);
-
+
/* textures */
if (!(ads->filterflag & ADS_FILTER_NOTEX))
tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, &la->id, filter_mode);
@@ -2005,7 +2002,7 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data
/* filter data contained under object first */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob))
{
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
/* object-level animation */
if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
@@ -2344,7 +2341,7 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD
size_t items = 0;
/* data to filter depends on channel type */
- // XXX: only common channel-types have been handled for now
+ /* NOTE: only common channel-types have been handled for now. More can be added as necessary */
switch (channel->type) {
case ANIMTYPE_SUMMARY:
items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode);
@@ -2357,6 +2354,10 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD
case ANIMTYPE_OBJECT:
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode);
break;
+
+ default:
+ printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", channel->type);
+ break;
}
return items;
@@ -2481,9 +2482,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
}
break;
- case ANIMCONT_FCURVES: /* Graph Editor -> FCurves/Animation Editing */
+ case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */
case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */
- case ANIMCONT_NLA: /* NLA Editor */
+ case ANIMCONT_NLA: /* NLA Editor */
{
/* all of these editors use the basic DopeSheet data for filtering options, but don't have all the same features */
items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 445b684c261..270e7fc8f90 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -354,7 +354,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
xpos = marker->frame;
/* no time correction for framelen! space is drawn with old values */
- ypixels = BLI_RCT_SIZE_Y(&v2d->mask);
+ ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_getscale(v2d, &xscale, &yscale);
glScalef(1.0f / xscale, 1.0f, 1.0f);
@@ -773,7 +773,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
if (hasNumInput(&mm->num))
break;
- dx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ dx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
if (evt->x != mm->evtx) { /* XXX maybe init for first time */
int a, offs, totmark = 0;
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index e254fb7a3c4..30e4d8570cb 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -74,13 +74,6 @@
#define B_REDR 1
#define B_FMODIFIER_REDRAW 20
-/* macro for use here to draw background box and set height */
-// XXX for now, roundbox has it's callback func set to NULL to not intercept events
-#define DRAW_BACKDROP(height) \
- { \
- uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco - height, width + 3, height - 1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \
- } (void)0
-
/* callback to verify modifier data */
static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg))
{
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 8cd8cfaea51..1791d84d90b 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1086,7 +1086,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
* The flag argument is used for special settings that alter the behavior of
* the keyframe deletion. These include the quick refresh options.
*/
-short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag))
+static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag))
{
AnimData *adt = BKE_animdata_from_id(id);
PointerRNA id_ptr, ptr;
@@ -1836,7 +1836,7 @@ static short object_frame_has_keyframe(Object *ob, float frame, short filter)
/* try shapekey keyframes (if available, and allowed by filter) */
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) {
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
/* shapekeys can have keyframes ('Relative Shape Keys')
* or depend on time (old 'Absolute Shape Keys')
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 738fdc229fb..cb52d88f985 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -4589,7 +4589,9 @@ void ED_pose_deselectall(Object *ob, int test)
int selectmode = 0;
/* we call this from outliner too */
- if (ELEM(NULL, ob, ob->pose)) return;
+ if (ob->pose == NULL) {
+ return;
+ }
/* Determine if we're selecting or deselecting */
if (test == 1) {
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 78d3d8dc64d..f3f985fa97d 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -644,7 +644,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
short pval[2];
int pdist;
- project_short_noclip(ar, stk->points[i].p, pval);
+ ED_view3d_project_short_noclip(ar, stk->points[i].p, pval);
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -679,7 +679,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
{
copy_v3_v3(vec, bone->head);
mul_m4_v3(ob->obmat, vec);
- project_short_noclip(ar, vec, pval);
+ ED_view3d_project_short_noclip(ar, vec, pval);
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -695,7 +695,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
copy_v3_v3(vec, bone->tail);
mul_m4_v3(ob->obmat, vec);
- project_short_noclip(ar, vec, pval);
+ ED_view3d_project_short_noclip(ar, vec, pval);
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -907,7 +907,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p);
float pval[2];
- project_float(ar, stk->points[i].p, pval);
+ ED_view3d_project_float(ar, stk->points[i].p, pval);
ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal);
mul_v3_fl(ray_normal, distance * progress / length);
@@ -934,7 +934,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() */
- project_short_noclip(ar, fp, cval);
+ ED_view3d_project_short_noclip(ar, fp, cval);
VECSUB2D(mval_f, cval, dd->mval);
ED_view3d_win_to_delta(ar, mval_f, dvec);
sub_v3_v3v3(vec, fp, dvec);
@@ -1453,8 +1453,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
float s_p2[3] = {0, 0, 0};
int g_i;
- project_float(ar, gesture->points[s_i].p, s_p1);
- project_float(ar, gesture->points[s_i + 1].p, s_p2);
+ ED_view3d_project_float(ar, gesture->points[s_i].p, s_p1);
+ ED_view3d_project_float(ar, gesture->points[s_i + 1].p, s_p2);
/* start checking from second next, because two consecutive cannot intersect */
for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++) {
@@ -1463,8 +1463,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
float vi[3];
float lambda;
- project_float(ar, gesture->points[g_i].p, g_p1);
- project_float(ar, gesture->points[g_i + 1].p, g_p2);
+ ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1);
+ ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2);
if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
@@ -1531,8 +1531,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
float s_p2[3] = {0, 0, 0};
int g_i;
- project_float(ar, stk->points[s_i].p, s_p1);
- project_float(ar, stk->points[s_i + 1].p, s_p2);
+ ED_view3d_project_float(ar, stk->points[s_i].p, s_p1);
+ ED_view3d_project_float(ar, stk->points[s_i + 1].p, s_p2);
for (g_i = 0; g_i < gesture->nb_points - 1; g_i++) {
float g_p1[3] = {0, 0, 0};
@@ -1540,8 +1540,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
float vi[3];
float lambda;
- project_float(ar, gesture->points[g_i].p, g_p1);
- project_float(ar, gesture->points[g_i + 1].p, g_p2);
+ ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1);
+ ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2);
if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
@@ -1784,8 +1784,8 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc
short start_val[2], end_val[2];
short dist;
- project_short_noclip(ar, gest->stk->points[0].p, start_val);
- project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val);
+ ED_view3d_project_short_noclip(ar, gest->stk->points[0].p, start_val);
+ ED_view3d_project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val);
dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1]));
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 6b6d2a1505f..346ed0002bd 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -667,7 +667,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
*err_str = NULL;
/* count triangles and create mask */
- if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) ||
+ if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_MASK) != 0)) ||
(use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
{
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index e9424a08b0c..2f5eaabc12b 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -74,12 +74,30 @@
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_object.h"
+#include "ED_util.h" /* clipboard */
#include "UI_interface.h"
#include "UI_resources.h"
#include "armature_intern.h"
+/* matches logic with ED_operator_posemode_context() */
+Object *ED_pose_object_from_context(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa && sa->spacetype == SPACE_BUTS) {
+ ob = ED_object_context(C);
+ }
+ else {
+ ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ }
+
+ return ob;
+}
+
/* This function is used to process the necessary updates for */
void ED_armature_enter_posemode(bContext *C, Base *base)
{
@@ -727,7 +745,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
short changed = 0;
/* sanity check */
- if (ELEM(NULL, ob, ob->pose))
+ if (ob->pose == NULL)
return OPERATOR_CANCELLED;
/* selection types
@@ -1049,7 +1067,7 @@ static void pose_copy_menu(Scene *scene)
/* Global copy/paste buffer for pose - cleared on start/end session + before every copy operation */
static bPose *g_posebuf = NULL;
-void free_posebuf(void)
+void ED_clipboard_posebuf_free(void)
{
if (g_posebuf) {
bPoseChannel *pchan;
@@ -1225,7 +1243,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op)
}
/* free existing pose buffer */
- free_posebuf();
+ ED_clipboard_posebuf_free();
/* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */
set_pose_keys(ob);
@@ -1330,15 +1348,8 @@ void POSE_OT_paste(wmOperatorType *ot)
static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+ Object *ob = ED_pose_object_from_context(C);
+
/* only continue if there's an object */
if (ob == NULL)
return OPERATOR_CANCELLED;
@@ -1361,7 +1372,7 @@ void POSE_OT_group_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_add_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1370,14 +1381,7 @@ void POSE_OT_group_add(wmOperatorType *ot)
static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object */
if (ob == NULL)
@@ -1401,7 +1405,7 @@ void POSE_OT_group_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_remove_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1412,8 +1416,7 @@ void POSE_OT_group_remove(wmOperatorType *ot)
/* invoke callback which presents a list of bone-groups for the user to choose from */
static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose;
uiPopupMenu *pup;
@@ -1421,12 +1424,6 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
bActionGroup *grp;
int i;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1465,17 +1462,10 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
/* Assign selected pchans to the bone group that the user selects */
static int pose_group_assign_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose;
short done = FALSE;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1517,7 +1507,7 @@ void POSE_OT_group_assign(wmOperatorType *ot)
/* api callbacks */
ot->invoke = pose_groups_menu_invoke;
ot->exec = pose_group_assign_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1529,16 +1519,9 @@ void POSE_OT_group_assign(wmOperatorType *ot)
static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
short done = FALSE;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1572,7 +1555,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_unassign_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1580,7 +1563,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
static int group_move_exec(bContext *C, wmOperator *op)
{
- Object *ob = ED_object_context(C);
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan;
bActionGroup *grp;
@@ -1653,7 +1636,7 @@ void POSE_OT_group_move(wmOperatorType *ot)
/* api callbacks */
ot->exec = group_move_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1678,7 +1661,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr)
static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob = ED_object_context(C);
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan;
tSortActionGroup *agrp_array;
@@ -1737,7 +1720,7 @@ void POSE_OT_group_sort(wmOperatorType *ot)
/* api callbacks */
ot->exec = group_sort_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1765,14 +1748,7 @@ static void pose_group_select(bContext *C, Object *ob, int select)
static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@@ -1795,7 +1771,7 @@ void POSE_OT_group_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_select_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1803,14 +1779,7 @@ void POSE_OT_group_select(wmOperatorType *ot)
static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@@ -1833,7 +1802,7 @@ void POSE_OT_group_deselect(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_deselect_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index d780429784f..9c13f4be6a9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1233,12 +1233,12 @@ void make_editNurb(Object *obedit)
set_actNurb(obedit, NULL);
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
- actkey = ob_get_keyblock(obedit);
+ actkey = BKE_keyblock_from_object(obedit);
if (actkey) {
// XXX strcpy(G.editModeTitleExtra, "(Key) ");
undo_editmode_clear();
- key_to_curve(actkey, cu, &cu->nurb);
+ BKE_key_convert_to_curve(actkey, cu, &cu->nurb);
}
if (editnurb) {
@@ -6070,7 +6070,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
}
/************** join operator, to be used externally? ****************/
-
+/* TODO: shape keys - as with meshes */
int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
@@ -6191,10 +6191,9 @@ static const char *get_surf_defname(int type)
}
-Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
+Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type, int newob)
{
static int xzproj = 0; /* this function calls itself... */
- Object *obedit = CTX_data_edit_object(C);
ListBase *editnurb = object_editcurve_get(obedit);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
@@ -6431,7 +6430,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
break;
case CU_PRIM_TUBE: /* Cylinder */
if (cutype == CU_NURBS) {
- nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
+ nu = add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
nu->resolu = cu->resolu;
nu->flag = CU_SMOOTH;
BLI_addtail(editnurb, nu); /* temporal for extrude and translate */
@@ -6510,7 +6509,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
float tmp_vec[3] = {0.f, 0.f, 1.f};
xzproj = 1;
- nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
+ nu = add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
xzproj = 0;
nu->resolu = cu->resolu;
nu->resolv = cu->resolv;
@@ -6607,7 +6606,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
- nu = add_nurbs_primitive(C, mat, type, newob);
+ nu = add_nurbs_primitive(C, obedit, mat, type, newob);
editnurb = object_editcurve_get(obedit);
BLI_addtail(editnurb, nu);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 5d67b63af18..659e99607f0 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -422,8 +422,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
}
else {
if (subrect) {
- mvalf[0] = (((float)pt->x / 100.0f) * BLI_RCT_SIZE_X(subrect)) + subrect->xmin;
- mvalf[1] = (((float)pt->y / 100.0f) * BLI_RCT_SIZE_Y(subrect)) + subrect->ymin;
+ mvalf[0] = (((float)pt->x / 100.0f) * BLI_rctf_size_x(subrect)) + subrect->xmin;
+ mvalf[1] = (((float)pt->y / 100.0f) * BLI_rctf_size_y(subrect)) + subrect->ymin;
}
else {
mvalf[0] = (float)pt->x / 100.0f * ar->winx;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 4e281b96fc3..8ba4985ffc4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -278,7 +278,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
gp_get_3d_reference(p, rvec);
/* method taken from editview.c - mouse_cursor() */
- project_int_noclip(p->ar, rvec, mval_prj);
+ ED_view3d_project_int_noclip(p->ar, rvec, mval_prj);
VECSUB2D(mval_f, mval_prj, mval);
ED_view3d_win_to_delta(p->ar, mval_f, dvec);
@@ -299,8 +299,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100;
}
else { /* camera view, use subrect */
- out[0] = ((mval[0] - p->subrect->xmin) / BLI_RCT_SIZE_X(p->subrect)) * 100;
- out[1] = ((mval[1] - p->subrect->ymin) / BLI_RCT_SIZE_Y(p->subrect)) * 100;
+ out[0] = ((mval[0] - p->subrect->xmin) / BLI_rctf_size_x(p->subrect)) * 100;
+ out[1] = ((mval[1] - p->subrect->ymin) / BLI_rctf_size_y(p->subrect)) * 100;
}
}
}
@@ -808,7 +808,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
else if (gps->totpoints == 1) {
/* get coordinates */
if (gps->flag & GP_STROKE_3DSPACE) {
- project_int(p->ar, &gps->points->x, xyval);
+ ED_view3d_project_int(p->ar, &gps->points->x, xyval);
x0 = xyval[0];
y0 = xyval[1];
}
@@ -821,8 +821,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
y0 = (int)(gps->points->y / 100 * p->ar->winy);
}
else { /* camera view, use subrect */
- x0 = (int)((gps->points->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
- y0 = (int)((gps->points->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
+ 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;
}
}
@@ -847,11 +847,11 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* get coordinates */
if (gps->flag & GP_STROKE_3DSPACE) {
- project_int(p->ar, &pt1->x, xyval);
+ ED_view3d_project_int(p->ar, &pt1->x, xyval);
x0 = xyval[0];
y0 = xyval[1];
- project_int(p->ar, &pt2->x, xyval);
+ ED_view3d_project_int(p->ar, &pt2->x, xyval);
x1 = xyval[0];
y1 = xyval[1];
}
@@ -868,10 +868,10 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
y1 = (int)(pt2->y / 100 * p->ar->winy);
}
else { /* camera view, use subrect */
- x0 = (int)((pt1->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
- y0 = (int)((pt1->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
- x1 = (int)((pt2->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
- y1 = (int)((pt2->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
+ 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;
}
}
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 07f3498580c..4e33404be7e 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -148,6 +148,7 @@ void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
void ED_pose_deselectall(struct Object *ob, int test);
void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
+struct Object *ED_pose_object_from_context(struct bContext *C);
/* sketch */
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 13c3b180230..28727c913cb 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -83,7 +83,7 @@ void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mas
/* textures buffer */
int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc);
-int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf);
+int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf, const unsigned char *display_buffer);
void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc);
void ED_space_clip_free_texture_buffer(struct SpaceClip *sc);
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index ac8d82e9060..d66cc49a5d0 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -67,7 +67,7 @@ void BKE_curve_editNurb_free(struct Curve *cu);
int mouse_nurb(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
-struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob);
+struct Nurb *add_nurbs_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob);
int isNurbsel(struct Nurb *nu);
void ED_nurb_set_spline_type(struct Nurb *nu, int type);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 87f12b8ac9c..a50b33966c6 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -39,6 +39,7 @@ struct ToolSettings;
struct uiBlock;
struct wmWindowManager;
struct ARegion;
+struct Scene;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
@@ -77,7 +78,7 @@ int ED_space_image_maskedit_mask_poll(struct bContext *C);
/* UI level image (texture) updating... render calls own stuff (too) */
void ED_image_update_frame(const struct Main *mainp, int cfra);
-void ED_image_draw_info(struct ARegion *ar, int color_manage, int channels, int x, int y,
+void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
const unsigned char cp[4], const float fp[4], int *zp, float *zpf);
#endif /* __ED_IMAGE_H__ */
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 8ebf932fd96..dc40b687dfd 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -53,14 +53,14 @@ void ED_keymap_mask(struct wmKeyConfig *keyconf);
void ED_operatormacros_mask(void);
/* mask_draw.c */
-void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type);
+void ED_mask_draw(const struct bContext *C, const char draw_flag, const char draw_type);
void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar,
const char draw_flag, const char draw_type,
const int width_i, const int height_i,
const float aspx, const float aspy,
const short do_scale_applied, const short do_post_draw,
float stabmat[4][4],
- const bContext *C);
+ const struct bContext *C);
void ED_mask_draw_frames(struct Mask *mask, struct ARegion *ar, const int cfra, const int sfra, const int efra);
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index b4b739e4d06..5ce6db97305 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, float mat[4][4], int type, int newname);
+struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], 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 1d4fbe81e02..3d15f349f9b 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -148,7 +148,7 @@ struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, int *dist);
int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle);
void EDBM_selectmode_set(struct BMEditMesh *em);
-void EDBM_selectmode_convert(struct BMEditMesh *em, short oldmode, const short selectmode);
+void EDBM_selectmode_convert(struct BMEditMesh *em, short selectmode_old, const short selectmode_new);
void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index fc20bdfb9c5..860d176ffb3 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -111,6 +111,7 @@ ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa);
void ED_screen_full_restore(struct bContext *C, ScrArea *sa);
struct ScrArea *ED_screen_full_toggle(struct bContext *C, struct wmWindow *win, struct ScrArea *sa);
+void ED_screens_header_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg);
/* anim */
void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, int mute);
@@ -170,6 +171,7 @@ int ED_operator_editmball(struct bContext *C);
int ED_operator_uvedit(struct bContext *C);
int ED_operator_uvmap(struct bContext *C);
int ED_operator_posemode_exclusive(struct bContext *C);
+int ED_operator_posemode_context(struct bContext *C);
int ED_operator_posemode(struct bContext *C);
int ED_operator_mask(struct bContext *C);
diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h
index 7807f06594e..84fd5332316 100644
--- a/source/blender/editors/include/ED_sequencer.h
+++ b/source/blender/editors/include/ED_sequencer.h
@@ -36,7 +36,7 @@ void ED_sequencer_deselect_all(struct Scene *scene);
int ED_space_sequencer_maskedit_mask_poll(struct bContext *C);
int ED_space_sequencer_check_show_maskedit(struct SpaceSeq *sseq, struct Scene *scene);
-int ED_space_sequencer_maskedit_poll(bContext *C);
+int ED_space_sequencer_maskedit_poll(struct bContext *C);
void ED_operatormacros_sequencer(void);
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index e10f049d0bc..d0ca079b8c9 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -84,6 +84,8 @@ void crazyspace_set_quats_mesh(struct Mesh *me, float *origcos, float *mappedcos
int sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
void crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
+/* cut-paste buffer free */
+void ED_clipboard_posebuf_free(void);
/* ************** XXX OLD CRUFT WARNING ************* */
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 7f40024a056..9536dd76581 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -89,139 +89,45 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d);
int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
-/**
- * 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(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]);
-
-/**
- * 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(struct ARegion *ar, const float mval[2], float out[3]);
-
-/**
- * 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.
- * \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(struct ARegion *ar, const float mval[2], float out[3]);
-
-/**
- * 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(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
-
-/**
- * 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(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
-/**
- * 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(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
-
-/**
- * Calculate the view transformation matrix from RegionView3D input.
- * The resulting matrix is equivalent to RegionView3D.viewinv
- * \param mat The view 4x4 transformation matrix to calculate.
- * \param ofs The view offset, normally from RegionView3D.ofs.
- * \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
- * \param dist The view distance from ofs, normally from RegionView3D.dist.
- */
void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist);
-
-/**
- * Set the view transformation from a 4x4 matrix.
- * \param mat The view 4x4 transformation matrix to assign.
- * \param ofs The view offset, normally from RegionView3D.ofs.
- * \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
- * \param dist The view distance from ofs, normally from RegionView3D.dist.
- */
void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist);
-/**
- * Set the RegionView3D members from an objects transformation and optionally lens.
- * \param ob The object to set the view to.
- * \param ofs The view offset to be set, normally from RegionView3D.ofs.
- * \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat.
- * \param dist The view distance from ofs to be set, normally from RegionView3D.dist.
- * \param lens The view lens angle set for cameras and lamps, normally from View3D.lens.
- */
void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens);
-
-/**
- * Set the object transformation from RegionView3D members.
- * \param ob The object which has the transformation assigned.
- * \param ofs The view offset, normally from RegionView3D.ofs.
- * \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
- * \param dist The view distance from ofs, normally from RegionView3D.dist.
- */
void ED_view3d_to_object(struct Object *ob, const float ofs[3], const float quat[4], const float dist);
-//#if 0 /* UNUSED */
-void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
-//#endif
-
/* Depth buffer */
-void ED_view3d_depth_update(struct ARegion *ar);
+void ED_view3d_depth_update(struct ARegion *ar);
float ED_view3d_depth_read_cached(struct ViewContext *vc, int x, int y);
-void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
+void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
/* Projection */
#define IS_CLIPPED 12000
-void ED_view3d_calc_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect);
-
-void project_short(struct ARegion *ar, const float vec[3], short adr[2]);
-void project_short_noclip(struct ARegion *ar, const float vec[3], short adr[2]);
-
-void project_int(struct ARegion *ar, const float vec[3], int adr[2]);
-void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]);
-
-void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[], float adr[2]);
-void project_float(struct ARegion *ar, const float vec[3], float adr[2]);
-void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]);
-
-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);
+/* TODO, these functions work quite differently, we should make them behave in a uniform way
+ * otherwise we can't be sure bugs are not added when we need to move from short->float types for eg
+ * - Campbell */
+void ED_view3d_project_short(struct ARegion *ar, const float co[3], short r_co[2]);
+void ED_view3d_project_short_noclip(struct ARegion *ar, const float vec[3], short r_co[2]);
+void ED_view3d_project_int(struct ARegion *ar, const float co[3], int r_co[2]);
+void ED_view3d_project_int_noclip(struct ARegion *ar, const float co[3], int r_co[2]);
+void ED_view3d_project_float(struct ARegion *ar, const float co[3], float r_co[2]);
+void ED_view3d_project_float_noclip(struct ARegion *ar, const float co[3], float r_co[2]);
+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]);
+
+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_project_float_v2(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]);
-void ED_view3d_project_float_v3(struct ARegion *a, const float vec[3], float adr[3], float mat[4][4]);
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 */
@@ -231,6 +137,7 @@ void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(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 lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), 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);
void ED_view3d_clipping_set(struct RegionView3D *rv3d);
@@ -282,10 +189,12 @@ 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(struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
- int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic);
+ int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic, int colormanage_background);
-struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256]);
-struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, int draw_background, char err_out[256]);
+struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag,
+ int draw_background, int colormanage_background, char err_out[256]);
+struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype,
+ int draw_background, int colormanage_background, char err_out[256]);
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index c6f58fdd70b..32132f497a8 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -120,11 +120,12 @@ typedef struct uiLayout uiLayout;
#define UI_BLOCK_CLIP_EVENTS 8192 /* stop handling mouse events */
/* uiPopupBlockHandle->menuretval */
-#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
-#define UI_RETURN_OK 2 /* choice made */
-#define UI_RETURN_OUT 4 /* left the menu */
-#define UI_RETURN_UPDATE 8 /* update the button that opened */
-#define UI_RETURN_POPUP_OK 16 /* popup is ok to be handled */
+#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
+#define UI_RETURN_OK 2 /* choice made */
+#define UI_RETURN_OUT 4 /* left the menu */
+#define UI_RETURN_OUT_PARENT 8 /* let the parent handle this event */
+#define UI_RETURN_UPDATE 16 /* update the button that opened */
+#define UI_RETURN_POPUP_OK 32 /* popup is ok to be handled */
/* block->flag bits 12-15 are identical to but->flag bits */
@@ -810,8 +811,10 @@ void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char
void uiTemplateColorWheel(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,
+ PointerRNA *used_ptr, const char *used_propname, int active_state);
void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
-void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr);
+void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management);
void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void uiTemplateOperatorSearch(uiLayout *layout);
@@ -831,6 +834,9 @@ void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct Poi
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int cmpact);
+void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
+void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname);
+
/* items */
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value);
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 792c96fe7c8..24759fa778a 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -163,7 +163,8 @@ void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, short x
void UI_view2d_view_restore(const struct bContext *C);
/* grid drawing */
-View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
+View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag);
void UI_view2d_constant_grid_draw(struct View2D *v2d);
void UI_view2d_multi_grid_draw(struct View2D *v2d, float step, int level_size, int totlevels);
@@ -171,14 +172,21 @@ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy);
void UI_view2d_grid_free(View2DGrid *grid);
/* scrollbar drawing */
-View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
+View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp);
void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
/* list view tools */
-void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, struct rctf *rect);
-void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, float viewx, float viewy, int *column, int *row);
-void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int *column_min, int *column_max, int *row_min, int *row_max);
+void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty, int column, int row,
+ struct rctf *rect);
+void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty, float viewx, float viewy,
+ int *column, int *row);
+void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty, int *column_min, int *column_max,
+ int *row_min, int *row_max);
/* coordinate conversion */
void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 823f8d7be39..810cbc25862 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -75,11 +75,9 @@
#include "BPY_extern.h"
-#include "interface_intern.h"
+#include "IMB_colormanagement.h"
-#define MENU_WIDTH 120
-#define MENU_ITEM_HEIGHT 20
-#define MENU_SEP_HEIGHT 6
+#include "interface_intern.h"
#define PRECISION_FLOAT_MAX 6
#define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */
@@ -104,8 +102,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float gx, gy;
int sx, sy, getsizex, getsizey;
- getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ getsizex = BLI_rcti_size_x(&ar->winrct) + 1;
+ getsizey = BLI_rcti_size_y(&ar->winrct) + 1;
sx = ar->winrct.xmin;
sy = ar->winrct.ymin;
@@ -150,8 +148,8 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float a, b, c, d, e, f, px, py;
int sx, sy, getsizex, getsizey;
- getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ getsizex = BLI_rcti_size_x(&ar->winrct) + 1;
+ getsizey = BLI_rcti_size_y(&ar->winrct) + 1;
sx = ar->winrct.xmin;
sy = ar->winrct.ymin;
@@ -277,7 +275,7 @@ void ui_bounds_block(uiBlock *block)
block->rect.ymax += block->bounds;
}
- block->rect.xmax = block->rect.xmin + maxf(BLI_RCT_SIZE_X(&block->rect), block->minbounds);
+ block->rect.xmax = block->rect.xmin + maxf(BLI_rctf_size_x(&block->rect), block->minbounds);
/* hardcoded exception... but that one is annoying with larger safety */
bt = block->buttons.first;
@@ -305,8 +303,8 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
ui_bounds_block(block);
- width = BLI_RCT_SIZE_X(&block->rect);
- height = BLI_RCT_SIZE_Y(&block->rect);
+ width = BLI_rctf_size_x(&block->rect);
+ height = BLI_rctf_size_y(&block->rect);
startx = (xmax * 0.5f) - (width * 0.5f);
starty = (ymax * 0.5f) - (height * 0.5f);
@@ -330,8 +328,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound
wm_window_get_size(window, &xmax, &ymax);
- oldwidth = BLI_RCT_SIZE_X(&block->rect);
- oldheight = BLI_RCT_SIZE_Y(&block->rect);
+ oldwidth = BLI_rctf_size_x(&block->rect);
+ oldheight = BLI_rctf_size_y(&block->rect);
/* first we ensure wide enough text bounds */
if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) {
@@ -346,8 +344,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound
ui_bounds_block(block);
/* and we adjust the position to fit within window */
- width = BLI_RCT_SIZE_X(&block->rect);
- height = BLI_RCT_SIZE_Y(&block->rect);
+ width = BLI_rctf_size_x(&block->rect);
+ height = BLI_rctf_size_y(&block->rect);
/* avoid divide by zero below, caused by calling with no UI, but better not crash */
oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width);
@@ -493,10 +491,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
if (line->from == NULL || line->to == NULL) return;
- rect.xmin = BLI_RCT_CENTER_X(&line->from->rect);
- rect.ymin = BLI_RCT_CENTER_Y(&line->from->rect);
- rect.xmax = BLI_RCT_CENTER_X(&line->to->rect);
- rect.ymax = BLI_RCT_CENTER_Y(&line->to->rect);
+ rect.xmin = BLI_rctf_cent_x(&line->from->rect);
+ rect.ymin = BLI_rctf_cent_y(&line->from->rect);
+ rect.xmax = BLI_rctf_cent_x(&line->to->rect);
+ rect.ymax = BLI_rctf_cent_y(&line->to->rect);
if (line->flag & UI_SELECT)
glColor3ub(100, 100, 100);
@@ -2138,7 +2136,14 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
block->evil_C = (void *)C; /* XXX */
if (scn) {
- block->color_profile = (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ block->color_profile = TRUE;
+
+ /* store display device name, don't lookup for transformations yet
+ * block could be used for non-color displays where looking up for transformation
+ * would slow down redraw, so only lookup for actual transform when it's indeed
+ * needed
+ */
+ block->display_device = scn->display_settings.display_device;
/* copy to avoid crash when scene gets deleted with ui still open */
block->unit = MEM_mallocN(sizeof(scn->unit), "UI UnitSettings");
@@ -2248,7 +2253,7 @@ void ui_check_but(uiBut *but)
/* safety is 4 to enable small number buttons (like 'users') */
- // okwidth= -4 + (BLI_RCT_SIZE_X(&but->rect)); // UNUSED
+ // okwidth= -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
/* name: */
switch (but->type) {
@@ -2256,7 +2261,7 @@ void ui_check_but(uiBut *but)
case MENU:
case ICONTEXTROW:
- if (BLI_RCT_SIZE_X(&but->rect) > 24.0f) {
+ if (BLI_rctf_size_x(&but->rect) > 24.0f) {
UI_GET_BUT_VALUE_INIT(but, value);
ui_set_name_menu(but, (int)value);
}
@@ -2563,7 +2568,9 @@ void ui_block_do_align(uiBlock *block)
ui_block_do_align_but(but, nr);
/* skip with same number */
- for (; but && but->alignnr == nr; but = but->next) ;
+ for (; but && but->alignnr == nr; but = but->next) {
+ /* pass */
+ }
if (!but) {
break;
@@ -2575,6 +2582,25 @@ void ui_block_do_align(uiBlock *block)
}
}
+struct ColorManagedDisplay *ui_block_display_get(uiBlock *block)
+{
+ return IMB_colormanagement_display_get_named(block->display_device);
+}
+
+void ui_block_to_display_space_v3(uiBlock *block, float pixel[3])
+{
+ struct ColorManagedDisplay *display = ui_block_display_get(block);
+
+ IMB_colormanagement_scene_linear_to_display_v3(pixel, display);
+}
+
+void ui_block_to_scene_linear_v3(uiBlock *block, float pixel[3])
+{
+ struct ColorManagedDisplay *display = ui_block_display_get(block);
+
+ IMB_colormanagement_display_to_scene_linear_v3(pixel, display);
+}
+
/**
* \brief ui_def_but is the function that draws many button types
*
@@ -2593,6 +2619,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
uiBut *but;
int slen;
+ BLI_assert(width >= 0);
+ BLI_assert(height >= 0);
+
/* we could do some more error checks here */
if ((type & BUTTYPE) == LABEL) {
BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE);
@@ -3760,15 +3789,16 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...)
if (type == BUT_GET_LABEL) {
if (but->str) {
/* Menu labels can have some complex formating stuff marked by pipes or %t, we don't want those here! */
- const char *tc;
-
- if (but->type == MENU)
- tc = strstr(but->str, "%t");
- else
- tc = strchr(but->str, '|');
-
- if (tc)
- tmp = BLI_strdupn(but->str, tc - but->str);
+ const char *tc1, *tc2;
+
+ tc1 = strstr(but->str, "%t");
+ tc2 = strstr(but->str, "|"); /* XXX For some reason strchr seems to not work here? */
+
+ if (tc2 && (!tc1 || tc1 > tc2))
+ tc1 = tc2;
+
+ if (tc1)
+ tmp = BLI_strdupn(but->str, tc1 - but->str);
else
tmp = BLI_strdup(but->str);
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 77dbbc878a7..e7c7d934f9f 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -48,6 +48,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -59,8 +60,6 @@
/* own include */
#include "interface_intern.h"
-#define UI_DISABLED_ALPHA_OFFS -160
-
static int roundboxtype = UI_CNR_ALL;
void uiSetRoundBox(int type)
@@ -85,7 +84,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r
/* mult */
for (a = 0; a < 7; a++) {
- vec[a][0] *= rad; vec[a][1] *= rad;
+ mul_v2_fl(vec[a], rad);
}
glBegin(mode);
@@ -156,18 +155,18 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
/* mult */
for (a = 0; a < 7; a++) {
- vec[a][0] *= rad; vec[a][1] *= rad;
+ mul_v2_fl(vec[a], rad);
}
/* get current color, needs to be outside of glBegin/End */
glGetFloatv(GL_CURRENT_COLOR, color);
/* 'shade' defines strength of shading */
- coltop[0] = color[0] + shadetop; if (coltop[0] > 1.0f) coltop[0] = 1.0f;
- coltop[1] = color[1] + shadetop; if (coltop[1] > 1.0f) coltop[1] = 1.0f;
- coltop[2] = color[2] + shadetop; if (coltop[2] > 1.0f) coltop[2] = 1.0f;
- coldown[0] = color[0] + shadedown; if (coldown[0] < 0.0f) coldown[0] = 0.0f;
- coldown[1] = color[1] + shadedown; if (coldown[1] < 0.0f) coldown[1] = 0.0f;
- coldown[2] = color[2] + shadedown; if (coldown[2] < 0.0f) coldown[2] = 0.0f;
+ 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);
glShadeModel(GL_SMOOTH);
glBegin(mode);
@@ -265,18 +264,18 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* mult */
for (a = 0; a < 7; a++) {
- vec[a][0] *= rad; vec[a][1] *= rad;
+ mul_v2_fl(vec[a], rad);
}
/* get current color, needs to be outside of glBegin/End */
glGetFloatv(GL_CURRENT_COLOR, color);
/* 'shade' defines strength of shading */
- colLeft[0] = color[0] + shadeLeft; if (colLeft[0] > 1.0f) colLeft[0] = 1.0f;
- colLeft[1] = color[1] + shadeLeft; if (colLeft[1] > 1.0f) colLeft[1] = 1.0f;
- colLeft[2] = color[2] + shadeLeft; if (colLeft[2] > 1.0f) colLeft[2] = 1.0f;
- colRight[0] = color[0] + shadeRight; if (colRight[0] < 0.0f) colRight[0] = 0.0f;
- colRight[1] = color[1] + shadeRight; if (colRight[1] < 0.0f) colRight[1] = 0.0f;
- colRight[2] = color[2] + shadeRight; if (colRight[2] < 0.0f) colRight[2] = 0.0f;
+ 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);
glShadeModel(GL_SMOOTH);
glBegin(mode);
@@ -439,8 +438,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
//glColor4f(1.0, 0.f, 0.f, 1.f);
//fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
- w = BLI_RCT_SIZE_X(rect);
- h = BLI_RCT_SIZE_Y(rect);
+ w = BLI_rcti_size_x(rect);
+ h = BLI_rcti_size_y(rect);
/* prevent drawing outside widget area */
glGetIntegerv(GL_SCISSOR_BOX, scissor);
glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
@@ -493,8 +492,8 @@ static void ui_draw_but_CHARTAB(uiBut *but)
charmax = G.charmax = 0xffff;
/* Calculate the size of the button */
- width = abs(BLI_RCT_SIZE_X(rect));
- height = abs(BLI_RCT_SIZE_Y(rect));
+ width = abs(BLI_rcti_size_x(rect));
+ height = abs(BLI_rcti_size_y(rect));
butw = floor(width / 12);
buth = floor(height / 6);
@@ -600,7 +599,8 @@ static void ui_draw_but_CHARTAB(uiBut *but)
}
/* Calculate the next position and character */
- sx += butw; ex += butw;
+ sx += butw;
+ ex += butw;
cs++;
}
/* Add the y position and reset x position */
@@ -632,7 +632,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
#endif /* WITH_INTERNATIONAL */
#endif
-static void draw_scope_end(rctf *rect, GLint *scissor)
+static void draw_scope_end(const rctf *rect, GLint *scissor)
{
float scaler_x1, scaler_x2;
@@ -642,8 +642,8 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* scale widget */
- scaler_x1 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 - SCOPE_RESIZE_PAD;
- scaler_x2 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 + SCOPE_RESIZE_PAD;
+ 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;
glColor4f(0.f, 0.f, 0.f, 0.25f);
fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
@@ -732,8 +732,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- w = BLI_RCT_SIZE_X(&rect);
- h = BLI_RCT_SIZE_Y(&rect) * hist->ymax;
+ w = BLI_rctf_size_x(&rect);
+ h = BLI_rctf_size_y(&rect) * hist->ymax;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -805,9 +805,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
if (scopes->wavefrm_yfac < 0.5f)
scopes->wavefrm_yfac = 0.98f;
- w = BLI_RCT_SIZE_X(&rect) - 7;
- h = BLI_RCT_SIZE_Y(&rect) * scopes->wavefrm_yfac;
- yofs = rect.ymin + (BLI_RCT_SIZE_Y(&rect) - h) / 2.0f;
+ w = BLI_rctf_size_x(&rect) - 7;
+ h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
+ yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
w3 = w / 3.0f;
/* log scale for alpha */
@@ -1033,8 +1033,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- w = BLI_RCT_SIZE_X(&rect);
- h = BLI_RCT_SIZE_Y(&rect);
+ w = BLI_rctf_size_x(&rect);
+ h = BLI_rctf_size_y(&rect);
centerx = rect.xmin + w / 2;
centery = rect.ymin + h / 2;
diam = (w < h) ? w : h;
@@ -1110,10 +1110,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
float v3[2], v1[2], v2[2], v1a[2], v2a[2];
int a;
float pos, colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
-
+ struct ColorManagedDisplay *display = NULL;
+
coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
if (coba == NULL) return;
-
+
+ if (but->block->color_profile)
+ display = ui_block_display_get(but->block);
+
x1 = rect->xmin;
y1 = rect->ymin;
sizex = rect->xmax - x1;
@@ -1141,18 +1145,20 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
glBegin(GL_QUAD_STRIP);
glColor4fv(&cbd->r);
- glVertex2fv(v1); glVertex2fv(v2);
-
+ glVertex2fv(v1);
+ glVertex2fv(v2);
+
for (a = 1; a <= sizex; a++) {
pos = ((float)a) / (sizex - 1);
do_colorband(coba, pos, colf);
- if (but->block->color_profile != BLI_PR_NONE)
- linearrgb_to_srgb_v3_v3(colf, colf);
+ if (display)
+ IMB_colormanagement_scene_linear_to_display_v3(colf, display);
v1[0] = v2[0] = x1 + a;
glColor4fv(colf);
- glVertex2fv(v1); glVertex2fv(v2);
+ glVertex2fv(v1);
+ glVertex2fv(v2);
}
glEnd();
@@ -1239,7 +1245,8 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* sphere color */
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn);
- glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
/* disable blender light */
for (a = 0; a < 8; a++) {
@@ -1262,12 +1269,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* transform to button */
glPushMatrix();
- glTranslatef(rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect), rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect), 0.0f);
+ glTranslatef(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
- if (BLI_RCT_SIZE_X(rect) < BLI_RCT_SIZE_Y(rect))
- size = BLI_RCT_SIZE_X(rect) / 200.f;
+ if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
+ size = BLI_rcti_size_x(rect) / 200.f;
else
- size = BLI_RCT_SIZE_Y(rect) / 200.f;
+ size = BLI_rcti_size_y(rect) / 200.f;
glScalef(size, size, size);
@@ -1373,12 +1380,12 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
glScissor(scissor_new.xmin,
scissor_new.ymin,
- BLI_RCT_SIZE_X(&scissor_new),
- BLI_RCT_SIZE_Y(&scissor_new));
+ BLI_rcti_size_x(&scissor_new),
+ BLI_rcti_size_y(&scissor_new));
/* calculate offset and zoom */
- zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr);
- zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr);
+ zoomx = (BLI_rcti_size_x(rect) - 2.0f * but->aspect) / BLI_rctf_size_x(&cumap->curr);
+ zoomy = (BLI_rcti_size_y(rect) - 2.0f * but->aspect) / BLI_rctf_size_y(&cumap->curr);
offsx = cumap->curr.xmin - but->aspect / zoomx;
offsy = cumap->curr.ymin - but->aspect / zoomy;
@@ -1556,8 +1563,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- width = BLI_RCT_SIZE_X(&rect) + 1;
- height = BLI_RCT_SIZE_Y(&rect);
+ width = BLI_rctf_size_x(&rect) + 1;
+ height = BLI_rctf_size_y(&rect);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1632,8 +1639,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f);
glScissor(ar->winrct.xmin + rect.xmin,
ar->winrct.ymin + rect.ymin,
- BLI_RCT_SIZE_X(&rect),
- BLI_RCT_SIZE_Y(&rect));
+ BLI_rctf_size_x(&rect),
+ BLI_rctf_size_y(&rect));
for (a = 0; a < 2; a++) {
if (a == 1) {
@@ -1724,7 +1731,7 @@ void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, fl
}
-void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
+void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
{
int i;
float rad;
@@ -1733,8 +1740,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE
glEnable(GL_BLEND);
- if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f)
- rad = (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f;
+ if (radius > (BLI_rctf_size_y(rct) - 10.0f) / 2.0f)
+ rad = (BLI_rctf_size_y(rct) - 10.0f) / 2.0f;
else
rad = radius;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b8a84e1638a..593744f01e0 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -78,6 +78,9 @@
#include "WM_api.h"
#include "WM_types.h"
+/* place the mouse at the scaled down location when un-grabbing */
+#define USE_CONT_MOUSE_CORRECT
+
/* proto */
static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to);
static void ui_add_link(bContext *C, uiBut *from, uiBut *to);
@@ -152,6 +155,12 @@ typedef struct uiHandleButtonData {
float dragf, dragfstart;
CBData *dragcbd;
+#ifdef USE_CONT_MOUSE_CORRECT
+ /* when ungrabbing buttons which are #ui_is_a_warp_but(), we may want to position them
+ * FLT_MAX signifies do-nothing, use #ui_block_to_window_fl() to get this into a usable space */
+ float ungrab_mval[2];
+#endif
+
/* menu open (watch uiFreeActiveButtons) */
uiPopupBlockHandle *menu;
int menuretval;
@@ -697,10 +706,10 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event)
if (but->imb) ; /* use button size itself */
else if (but->flag & UI_ICON_LEFT) {
- rect.xmax = rect.xmin + (BLI_RCT_SIZE_Y(&rect));
+ rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
else {
- int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect);
+ int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect);
rect.xmin += delta / 2;
rect.xmax -= delta / 2;
}
@@ -721,7 +730,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
if (but->imb)
- WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_RCT_SIZE_X(&but->rect), BLI_RCT_SIZE_Y(&but->rect));
+ WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect));
return 1;
}
@@ -808,6 +817,8 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
uiLink *link = from->link;
+ PointerRNA props_ptr, object_ptr;
+
if (link->ppoin)
sens_from_links = (bController ***)(link->ppoin);
else return;
@@ -836,9 +847,15 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
/* only works if the sensor and the actuator are from the same object */
if (!act_iter) return;
+
+ /* in case the linked controller is not the active one */
+ RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
+
+ WM_operator_properties_create(&props_ptr, "LOGIC_OT_controller_add");
+ RNA_string_set(&props_ptr, "object", ob->id.name+2);
/* (3) add a new controller */
- if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) {
+ if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, &props_ptr) & OPERATOR_FINISHED) {
cont = (bController *)ob->controllers.last;
cont->type = CONT_LOGIC_AND; /* Quick fix to make sure we always have an AND controller. It might be nicer to make sure the operator gives us the right one though... */
@@ -858,6 +875,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
MEM_freeN(tmp_but->link);
MEM_freeN(tmp_but);
}
+ WM_operator_properties_free(&props_ptr);
}
static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
@@ -1309,7 +1327,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
/* XXX solve generic */
if (but->type == NUM || but->type == NUMSLI)
- startx += (int)(0.5f * (BLI_RCT_SIZE_Y(&but->rect)));
+ startx += (int)(0.5f * (BLI_rctf_size_y(&but->rect)));
else if (ELEM(but->type, TEX, SEARCH_MENU)) {
startx += 5;
if (but->flag & UI_HAS_ICON)
@@ -1386,13 +1404,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, short x)
{
- if (x > data->selstartx) data->selextend = EXTEND_RIGHT;
+ if (x > data->selstartx) data->selextend = EXTEND_RIGHT;
else if (x < data->selstartx) data->selextend = EXTEND_LEFT;
ui_textedit_set_cursor_pos(but, data, x);
- if (data->selextend == EXTEND_RIGHT) but->selend = but->pos;
- if (data->selextend == EXTEND_LEFT) but->selsta = but->pos;
+ if (data->selextend == EXTEND_RIGHT) but->selend = but->pos;
+ else if (data->selextend == EXTEND_LEFT) but->selsta = but->pos;
ui_check_but(but);
}
@@ -1596,6 +1614,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
/* paste */
if (paste) {
+ /* TODO, ensure UTF8 ui_is_but_utf8() - campbell */
/* extract the first line from the clipboard */
p = pbuf = WM_clipboard_text_get(0);
@@ -1955,8 +1974,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (changed) {
/* only update when typing for TAB key */
- if (update && data->interactive) ui_apply_button(C, block, but, data, 1);
- else ui_check_but(but);
+ if (update && data->interactive) {
+ ui_apply_button(C, block, but, data, 1);
+ }
+ else {
+ ui_check_but(but);
+ }
but->changed = TRUE;
if (data->searchbox)
@@ -2047,8 +2070,12 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
{
- if (data->interactive) ui_apply_button(C, block, but, data, 1);
- else ui_check_but(but);
+ if (data->interactive) {
+ ui_apply_button(C, block, but, data, 1);
+ }
+ else {
+ ui_check_but(but);
+ }
ED_region_tag_redraw(data->region);
}
@@ -2373,14 +2400,14 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
}
if (snap == 1) {
- if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
+ if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
else if (softrange < 21.0f) tempf = floorf(tempf);
- else tempf = 10.0f * floorf(tempf / 10.0f);
+ else tempf = 10.0f * floorf(tempf / 10.0f);
}
else if (snap == 2) {
- if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
- else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
- else tempf = floor(tempf);
+ if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
+ else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
+ else tempf = floor(tempf);
}
if (fac != 1.0f)
@@ -2459,9 +2486,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
}
}
else {
- if (softrange > 256) fac = 1.0; /* 1px == 1 */
- else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */
- else fac = 1.0 / 16.0; /* 16px == 1? */
+ if (softrange > 256) fac = 1.0; /* 1px == 1 */
+ else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */
+ else fac = 1.0 / 16.0; /* 16px == 1? */
temp = data->startvalue + (((double)mx - data->dragstartx) * (double)fac);
temp = ui_numedit_apply_snap(temp, softmin, softmax, snap);
@@ -2493,10 +2520,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
deler = 500;
if (!ui_is_but_float(but)) {
/* prevent large ranges from getting too out of control */
- if (softrange > 600) deler = powf(softrange, 0.75);
-
- if (softrange < 100) deler = 200.0;
- if (softrange < 25) deler = 50.0;
+ if (softrange > 600) deler = powf(softrange, 0.75);
+ else if (softrange < 100) deler = 200.0;
+ else if (softrange < 25) deler = 50.0;
}
deler /= fac;
@@ -2582,8 +2608,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
retval = WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) {
click = 1;
+ }
else if (event->type == MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;
@@ -2611,7 +2638,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
fac = 1.0f;
if (event->shift) fac /= 10.0f;
- if (event->alt) fac /= 20.0f;
+ if (event->alt) fac /= 20.0f;
snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0;
@@ -2639,7 +2666,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
softmax = but->softmax;
if (!ui_is_but_float(but)) {
- if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) {
+ if (mx < (but->rect.xmin + BLI_rctf_size_x(&but->rect) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value - 1;
@@ -2650,7 +2677,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > (but->rect.xmin + (2 * BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) {
+ else if (mx > (but->rect.xmin + (2 * BLI_rctf_size_x(&but->rect) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value + 1;
@@ -2661,11 +2688,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else
+ else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ }
}
else {
- if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) {
+ if (mx < (but->rect.xmin + BLI_rctf_size_x(&but->rect) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value - 0.01f * but->a1;
@@ -2674,7 +2702,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > but->rect.xmin + (2 * (BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) {
+ else if (mx > but->rect.xmin + (2 * (BLI_rctf_size_x(&but->rect) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value + 0.01f * but->a1;
@@ -2683,8 +2711,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else
+ else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ }
}
retval = WM_UI_HANDLER_BREAK;
@@ -2702,14 +2731,20 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short
softmax = but->softmax;
softrange = softmax - softmin;
- if (but->type == NUMSLI) deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect);
- else if (but->type == HSVSLI) deler = (BLI_RCT_SIZE_X(&but->rect) / 2.0f - 5.0f * but->aspect);
+ if (but->type == NUMSLI) {
+ deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect);
+ }
+ else if (but->type == HSVSLI) {
+ deler = (BLI_rctf_size_x(&but->rect) / 2.0f - 5.0f * but->aspect);
+ }
else if (but->type == SCROLL) {
- int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect));
- float size = (horizontal) ? BLI_RCT_SIZE_X(&but->rect) : -BLI_RCT_SIZE_Y(&but->rect);
+ int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
+ float size = (horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect);
deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1);
}
- else deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect);
+ else {
+ deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect);
+ }
f = (float)(mx - data->dragstartx) / deler + data->dragfstart;
@@ -2721,19 +2756,21 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short
temp = floorf(tempf + 0.5f);
if (ctrl) {
- if (tempf == softmin || tempf == softmax) ;
+ if (tempf == softmin || tempf == softmax) {
+ /* pass */
+ }
else if (ui_is_but_float(but)) {
if (shift) {
- if (tempf == softmin || tempf == softmax) ;
+ if (tempf == softmin || tempf == softmax) {}
else if (softmax - softmin < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
- else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
- else tempf = floorf(tempf);
+ else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
+ else tempf = floorf(tempf);
}
else {
- if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
+ if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
else if (softmax - softmin < 21.0f) tempf = floorf(tempf);
- else tempf = 10.0f * floorf(tempf / 10.0f);
+ else tempf = 10.0f * floorf(tempf / 10.0f);
}
}
else {
@@ -2792,7 +2829,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
/* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */
else if (event->type == LEFTMOUSE && event->alt) {
- int halfpos = BLI_RCT_CENTER_X(&but->rect);
+ int halfpos = BLI_rctf_cent_x(&but->rect);
click = 2;
if (mx < halfpos)
mx = but->rect.xmin;
@@ -2805,8 +2842,9 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
retval = WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) {
click = 1;
+ }
else if (event->type == MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;
@@ -2859,12 +2897,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
#if 0
if (but->type == SLI) {
- f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); /* same as below */
+ f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect)); /* same as below */
}
else
#endif
{
- f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect));
+ f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect));
}
f = softmin + f * softrange;
@@ -2905,7 +2943,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
{
int mx, my /*, click= 0 */;
int retval = WM_UI_HANDLER_CONTINUE;
- int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect));
+ int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
mx = event->x;
my = event->y;
@@ -3063,7 +3101,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
* else we'll get a harmless but annoying jump when first clicking */
fp = data->origvec;
- rad = BLI_RCT_SIZE_X(&but->rect);
+ rad = BLI_rctf_size_x(&but->rect);
radsq = rad * rad;
if (fp[2] > 0.0f) {
@@ -3076,7 +3114,9 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
mdx = 2.0f * mrad * fp[0] - (rad * fp[0]);
mdy = 2.0f * mrad * fp[1] - (rad * fp[1]);
}
- else mdx = mdy = 0;
+ else {
+ mdx = mdy = 0;
+ }
dx = (float)(mx + mdx - data->dragstartx);
dy = (float)(my + mdy - data->dragstarty);
@@ -3140,8 +3180,9 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -3160,19 +3201,30 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
+#ifdef USE_CONT_MOUSE_CORRECT
+ if (ui_is_a_warp_but(but)) {
+ /* OK but can go outside bounds */
+ data->ungrab_mval[0] = mx_fl;
+ data->ungrab_mval[1] = my_fl;
+ BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval);
+ }
+#endif
+
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
}
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
+ if (color_profile && (int)but->a1)
+ ui_block_to_display_space_v3(but->block, rgb);
+ rgb_to_hsv_compat_v(rgb, hsv);
/* relative position within box */
- x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect);
- y = ((float)my_fl - but->rect.ymin) / BLI_RCT_SIZE_Y(&but->rect);
+ x = ((float)mx_fl - but->rect.xmin) / BLI_rctf_size_x(&but->rect);
+ y = ((float)my_fl - but->rect.ymin) / BLI_rctf_size_y(&but->rect);
CLAMP(x, 0.0f, 1.0f);
CLAMP(y, 0.0f, 1.0f);
@@ -3204,17 +3256,16 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
/* exception only for value strip - use the range set in but->min/max */
hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
- if (color_profile)
- hsv[2] = srgb_to_linearrgb(hsv[2]);
-
- if (hsv[2] > but->softmax)
- hsv[2] = but->softmax;
break;
default:
assert(!"invalid hsv type");
}
hsv_to_rgb_v(hsv, rgb);
+
+ if (color_profile && (int)but->a1)
+ ui_block_to_scene_linear_v3(but->block, rgb);
+
copy_v3_v3(data->vec, rgb);
data->draglastx = mx;
@@ -3233,10 +3284,14 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
}
ui_get_but_vectorf(but, rgb);
+
+ if (color_profile && (int)but->a1)
+ ui_block_to_display_space_v3(but->block, rgb);
+
rgb_to_hsv_compat_v(rgb, hsv);
switch ((int)but->a1) {
@@ -3267,15 +3322,16 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
/* exception only for value strip - use the range set in but->min/max */
hsv[2] += ndof->rx * sensitivity;
- if (color_profile)
- hsv[2] = srgb_to_linearrgb(hsv[2]);
-
CLAMP(hsv[2], but->softmin, but->softmax);
default:
assert(!"invalid hsv type");
}
-
+
hsv_to_rgb_v(hsv, rgb);
+
+ if (color_profile && (int)but->a1)
+ ui_block_to_scene_linear_v3(but->block, rgb);
+
copy_v3_v3(data->vec, rgb);
ui_set_but_vectorf(but, data->vec);
}
@@ -3358,8 +3414,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -3377,6 +3434,22 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
+#ifdef USE_CONT_MOUSE_CORRECT
+ if (ui_is_a_warp_but(but)) {
+ /* OK but can go outside bounds */
+ 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 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) {
+ dist_ensure_v2_v2fl(data->ungrab_mval, cent, radius);
+ }
+ }
+ }
+#endif
+
BLI_rcti_rctf_copy(&rect, &but->rect);
ui_get_but_vectorf(but, rgb);
@@ -3569,7 +3642,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx
if (data->draglastx == mx)
return changed;
- dx = ((float)(mx - data->draglastx)) / BLI_RCT_SIZE_X(&but->rect);
+ dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
@@ -3598,7 +3671,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (event->ctrl) {
/* insert new key on mouse location */
- float pos = ((float)(mx - but->rect.xmin)) / BLI_RCT_SIZE_X(&but->rect);
+ float pos = ((float)(mx - but->rect.xmin)) / BLI_rctf_size_x(&but->rect);
colorband_element_add(coba, pos);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -3610,7 +3683,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* activate new key when mouse is close */
for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) {
- xco = but->rect.xmin + (cbd->pos * BLI_RCT_SIZE_X(&but->rect));
+ xco = but->rect.xmin + (cbd->pos * BLI_rctf_size_x(&but->rect));
xco = ABS(xco - mx);
if (a == coba->cur) xco += 5; // selected one disadvantage
if (xco < mindist) {
@@ -3633,8 +3706,9 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -3651,8 +3725,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */;
int a, changed = 0;
- zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr);
- zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr);
+ 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; */
@@ -3667,9 +3741,10 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
}
if (data->dragsel != -1) {
+ CurveMapPoint *cmp_last = NULL;
const float mval_factor = ui_mouse_scale_warp_factor(shift);
int moved_point = 0; /* for ctrl grid, can't use orig coords because of sorting */
-
+
fx = (mx - data->draglastx) / zoomx;
fy = (my - data->draglasty) / zoomy;
@@ -3687,6 +3762,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
}
if (cmp[a].x != origx || cmp[a].y != origy)
moved_point = 1;
+
+ cmp_last = &cmp[a];
}
}
@@ -3696,6 +3773,18 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
data->draglastx = mx;
data->draglasty = my;
changed = 1;
+
+#ifdef USE_CONT_MOUSE_CORRECT
+ /* note: using 'cmp_last' is weak since there may be multiple points selected,
+ * but in practice this isnt really an issue */
+ if (ui_is_a_warp_but(but)) {
+ /* OK but can go outside bounds */
+ data->ungrab_mval[0] = but->rect.xmin + ((cmp_last->x - cumap->curr.xmin) * zoomx);
+ data->ungrab_mval[1] = but->rect.ymin + ((cmp_last->y - cumap->curr.ymin) * zoomy);
+ BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval);
+ }
+#endif
+
}
data->dragchange = 1; /* mark for selection */
@@ -3747,8 +3836,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
float dist, mindist = 200.0f; // 14 pixels radius
int sel = -1;
- zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr);
- zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr);
+ 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;
@@ -3812,12 +3901,14 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
/* ok, we move a point */
/* deselect all if this one is deselect. except if we hold shift */
if (event->shift == FALSE) {
- for (a = 0; a < cuma->totpoint; a++)
+ for (a = 0; a < cuma->totpoint; a++) {
cmp[a].flag &= ~CUMA_SELECT;
+ }
cmp[sel].flag |= CUMA_SELECT;
}
- else
+ else {
cmp[sel].flag ^= CUMA_SELECT;
+ }
}
else {
/* move the view */
@@ -3893,7 +3984,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize histogram widget itself */
- hist->height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ hist->height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
else {
/* scale histogram values (dy / 10 for better control) */
@@ -3977,7 +4068,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize waveform widget itself */
- scopes->wavefrm_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ scopes->wavefrm_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
else {
/* scale waveform values */
@@ -4059,7 +4150,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize vectorscope widget itself */
- scopes->vecscope_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ scopes->vecscope_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
data->draglastx = mx;
@@ -4129,8 +4220,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
/* Calculate the size of the button */
- width = abs(BLI_RCT_SIZE_X(&but->rect));
- height = abs(BLI_RCT_SIZE_Y(&but->rect));
+ width = abs(BLI_rctf_size_x(&but->rect));
+ height = abs(BLI_rctf_size_y(&but->rect));
butw = floor(width / 12);
buth = floor(height / 6);
@@ -4262,7 +4353,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize preview widget itself */
- scopes->track_preview_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ scopes->track_preview_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
else {
if (!scopes->track_locked) {
@@ -4270,8 +4361,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr);
scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
- scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_RCT_SIZE_X(&but->block->rect);
- scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_RCT_SIZE_Y(&but->block->rect);
+ scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_rctf_size_x(&but->block->rect);
+ scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_rctf_size_y(&but->block->rect);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
}
@@ -4460,6 +4551,7 @@ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
static int ui_but_menu(bContext *C, uiBut *but)
{
+ ARegion *ar = CTX_wm_region(C);
uiPopupMenu *pup;
uiLayout *layout;
int length;
@@ -4471,17 +4563,8 @@ static int ui_but_menu(bContext *C, uiBut *but)
button_timers_tooltip_remove(C, but);
-#if 0
- if (but->rnaprop)
- name = RNA_property_ui_name(but->rnaprop);
- else if (but->optype && but->optype->srna)
- name = RNA_struct_ui_name(but->optype->srna);
- else
- name = IFACE_("<needs_name>"); // XXX - should never happen.
-#else
uiButGetStrInfo(C, but, 1, &label);
name = label.strinfo;
-#endif
pup = uiPupMenuBegin(C, name, ICON_NONE);
layout = uiPupMenuLayout(pup);
@@ -4525,7 +4608,9 @@ static int ui_but_menu(bContext *C, uiBut *but)
}
- else if (but->flag & UI_BUT_DRIVEN) ;
+ else if (but->flag & UI_BUT_DRIVEN) {
+ /* pass */
+ }
else if (is_anim) {
if (length) {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"),
@@ -4533,9 +4618,10 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"),
ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
}
- else
+ else {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"),
ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
+ }
}
if (but->flag & UI_BUT_ANIMATED) {
@@ -4561,17 +4647,21 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"),
ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0);
}
- else
+ else {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"),
ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0);
+ }
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"),
ICON_NONE, "ANIM_OT_copy_driver_button");
- if (ANIM_driver_can_paste())
+ if (ANIM_driver_can_paste()) {
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
+ }
+ }
+ else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
+ /* pass */
}
- else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) ;
else if (is_anim) {
uiItemS(layout);
@@ -4581,13 +4671,15 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single Driver"),
ICON_NONE, "ANIM_OT_driver_button_add", "all", 0);
}
- else
+ else {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
ICON_NONE, "ANIM_OT_driver_button_add", "all", 0);
+ }
- if (ANIM_driver_can_paste())
+ if (ANIM_driver_can_paste()) {
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
+ }
}
/* Keying Sets */
@@ -4624,9 +4716,10 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"),
ICON_NONE, "UI_OT_reset_default_button", "all", 0);
}
- else
+ else {
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"),
ICON_NONE, "UI_OT_reset_default_button");
+ }
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"),
ICON_NONE, "UI_OT_copy_data_path_button");
@@ -4673,7 +4766,12 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemS(layout);
}
-
+ /* Show header tools for header buttons. */
+ if (ar->regiontype == RGN_TYPE_HEADER) {
+ uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL);
+ uiItemS(layout);
+ }
+
{ /* Docs */
char buf[512];
PointerRNA ptr_props;
@@ -5231,12 +5329,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
/* automatic open pulldown block timer */
if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) {
- if ((data->used_mouse == TRUE) &&
- (data->autoopentimer == FALSE) &&
- /* don't popup the first time,
- * see description on this member for info */
- (but->block->auto_is_first_event == FALSE))
- {
+ if (data->used_mouse && !data->autoopentimer) {
int time;
if (but->block->auto_open == TRUE) { /* test for toolbox */
@@ -5256,8 +5349,6 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
data->autoopentimer = WM_event_add_timer(data->wm, data->window, TIMER, 0.02 * (double)time);
}
}
-
- but->block->auto_is_first_event = FALSE;
}
}
else {
@@ -5281,8 +5372,24 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
ui_numedit_end(but, data);
- if (ui_is_a_warp_but(but))
- WM_cursor_grab_disable(CTX_wm_window(C));
+ if (ui_is_a_warp_but(but)) {
+
+#ifdef USE_CONT_MOUSE_CORRECT
+ if (data->ungrab_mval[0] != FLT_MAX) {
+ int mouse_ungrab_xy[2];
+ ui_block_to_window_fl(data->region, but->block, &data->ungrab_mval[0], &data->ungrab_mval[1]);
+ mouse_ungrab_xy[0] = data->ungrab_mval[0];
+ mouse_ungrab_xy[1] = data->ungrab_mval[1];
+
+ WM_cursor_grab_disable(data->window, mouse_ungrab_xy);
+ }
+ else {
+ WM_cursor_grab_disable(data->window, NULL);
+ }
+#else
+ WM_cursor_grab_disable(data->window, );
+#endif
+ }
}
/* menu open */
if (state == BUTTON_STATE_MENU_OPEN)
@@ -5345,6 +5452,10 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
data->window = CTX_wm_window(C);
data->region = ar;
+#ifdef USE_CONT_MOUSE_CORRECT
+ copy_v2_fl(data->ungrab_mval, FLT_MAX);
+#endif
+
if (ELEM(but->type, BUT_CURVE, SEARCH_MENU)) {
/* XXX curve is temp */
}
@@ -5626,20 +5737,24 @@ void uiContextAnimUpdate(const bContext *C)
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
ED_region_tag_redraw(ar);
- if (but->active)
+ if (but->active) {
activebut = but;
- else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+ }
+ else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) {
activebut = but;
+ }
}
}
if (activebut) {
/* always recurse into opened menu, so all buttons update (like colorpicker) */
uiHandleButtonData *data = activebut->active;
- if (data && data->menu)
+ if (data && data->menu) {
ar = data->menu->region;
- else
+ }
+ else {
return;
+ }
}
else {
/* no active button */
@@ -5669,8 +5784,9 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
if (event->type == MOUSEMOVE) {
but = ui_but_find_mouse_over(ar, event->x, event->y);
- if (but)
+ if (but) {
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
+ }
}
else if (event->type == EVT_BUT_OPEN) {
but = uit_but_find_open_event(ar, event);
@@ -6173,7 +6289,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my)
return 0;
}
-static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int UNUSED(topmenu))
+static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level)
{
ARegion *ar;
uiBlock *block;
@@ -6218,10 +6334,22 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
/* first block own event func */
- if (block->block_event_func && block->block_event_func(C, block, event)) ;
- /* events not for active search menu button */
+ if (block->block_event_func && block->block_event_func(C, block, event)) {
+ /* pass */
+ } /* events not for active search menu button */
else if (but == NULL || but->type != SEARCH_MENU) {
switch (event->type) {
+
+
+ /* let the parent menu get the event */
+#define PASS_EVENT_TO_PARENT_IF_NONACTIVE \
+ if ((level != 0) && (but == NULL)) { \
+ menu->menuretval = UI_RETURN_OUT | UI_RETURN_OUT_PARENT; \
+ BLI_assert(retval == WM_UI_HANDLER_CONTINUE); \
+ break; \
+ } (void)0
+
+
/* closing sublevels of pulldowns */
case LEFTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP))
@@ -6234,6 +6362,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
/* opening sublevels of pulldowns */
case RIGHTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
+
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
but = ui_but_find_activated(ar);
if (!but) {
@@ -6259,6 +6390,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
else if (inside || (block->flag & UI_BLOCK_LOOP)) {
if (event->val == KM_PRESS) {
+
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
but = ui_but_find_activated(ar);
if (but) {
/* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */
@@ -6338,6 +6472,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
if (act == 0) act = 10;
if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) {
+
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
if (event->alt) act += 10;
count = 0;
@@ -6415,6 +6552,8 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
(event->ctrl == FALSE) &&
(event->oskey == FALSE))
{
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
for (but = block->buttons.first; but; but = but->next) {
if (but->menu_key == event->type) {
@@ -6504,6 +6643,10 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
retval = WM_UI_HANDLER_BREAK;
}
}
+
+ /* end switch */
+#undef PASS_EVENT_TO_PARENT_IF_NONACTIVE
+
}
}
@@ -6592,7 +6735,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
return WM_UI_HANDLER_BREAK;
}
-static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu)
+static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level)
{
uiBut *but;
uiHandleButtonData *data;
@@ -6605,14 +6748,20 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa
submenu = (data) ? data->menu : NULL;
if (submenu)
- retval = ui_handle_menus_recursive(C, event, submenu);
+ retval = ui_handle_menus_recursive(C, event, submenu, level + 1);
/* now handle events for our own menu */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
- if (submenu && submenu->menuretval)
+ if (submenu && submenu->menuretval) {
retval = ui_handle_menu_return_submenu(C, event, menu);
- else
- retval = ui_handle_menu_event(C, event, menu, (submenu == NULL));
+ /* 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)) {
+ retval = ui_handle_menu_event(C, event, menu, level);
+ }
+ }
+ else {
+ retval = ui_handle_menu_event(C, event, menu, level); /* same as above */
+ }
}
return retval;
@@ -6700,7 +6849,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
if (data->state == BUTTON_STATE_MENU_OPEN) {
/* handle events for menus and their buttons recursively,
* this will handle events from the top to the bottom menu */
- retval = ui_handle_menus_recursive(C, event, data->menu);
+ retval = ui_handle_menus_recursive(C, event, data->menu, 0);
/* handle events for the activated button */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
@@ -6744,7 +6893,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
retval = WM_UI_HANDLER_CONTINUE;
}
- ui_handle_menus_recursive(C, event, menu);
+ ui_handle_menus_recursive(C, event, menu, 0);
/* free if done, does not free handle itself */
if (menu->menuretval) {
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index f6f12f98181..0921107b8e6 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -466,7 +466,7 @@ static void init_brush_icons(void)
{ \
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \
datatoc_ ##name## _png_size, \
- IB_rect, "<brush icon>"); \
+ IB_rect, NULL, "<brush icon>"); \
def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
IMB_freeImBuf(bbuf); \
} (void)0
@@ -520,7 +520,7 @@ static void init_internal_icons(void)
char *icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
if (icondir) {
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
- bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */
+ bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL); /* if the image is missing bbuf will just be NULL */
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
IMB_freeImBuf(bbuf);
@@ -533,7 +533,7 @@ static void init_internal_icons(void)
}
if (bbuf == NULL)
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons_png,
- datatoc_blender_icons_png_size, IB_rect, "<blender icons>");
+ datatoc_blender_icons_png_size, IB_rect, NULL, "<blender icons>");
if (bbuf) {
/* free existing texture if any */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 73e6427d1cb..b48c9bcab7e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -305,17 +305,7 @@ struct uiBlock {
char direction;
char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */
char auto_open;
-
- /* this setting is used so newly opened menu's dont popout the first item under the mouse,
- * the reasoning behind this is because of muscle memory for opening menus.
- *
- * Without this, the first time opening a Submenu and activating an item in it will be 2 steps,
- * but the second time the same item is accessed the menu memory would auto activate the
- * last used menu and the key intended to select that submenu ends up being passed into the submenu.
- * - Campbell
- */
- char auto_is_first_event;
- char _pad[6];
+ char _pad[7];
double auto_open_last;
const char *lockstr;
@@ -342,7 +332,12 @@ struct uiBlock {
struct UnitSettings *unit; /* unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. */
float _hsv[3]; /* XXX, only access via ui_block_hsv_get() */
+
char color_profile; /* color profile for correcting linear colors for display */
+
+ char *display_device; /* display devide name used to display this block,
+ * used by color widgets to transform colors from/to scene linear
+ */
};
typedef struct uiSafetyRct {
@@ -392,6 +387,10 @@ extern void ui_bounds_block(uiBlock *block);
extern void ui_block_translate(uiBlock *block, int x, int y);
extern void ui_block_do_align(uiBlock *block);
+extern struct ColorManagedDisplay *ui_block_display_get(uiBlock *block);
+void ui_block_to_display_space_v3(uiBlock *block, float pixel[3]);
+void ui_block_to_scene_linear_v3(uiBlock *block, float pixel[3]);
+
/* interface_regions.c */
struct uiPopupBlockHandle {
@@ -464,7 +463,7 @@ extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *rect);
/* interface_draw.c */
-extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
+extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select);
void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha);
@@ -500,7 +499,7 @@ void ui_widget_color_init(struct ThemeUI *tui);
void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
-extern unsigned char checker_stipple_sml[];
+extern unsigned char checker_stipple_sml[32 * 32 / 8];
/* used for transp checkers */
#define UI_TRANSP_DARK 100
#define UI_TRANSP_LIGHT 160
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 803fd928085..8ffbcd6d399 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -239,10 +239,8 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h)
if (item->type == ITEM_BUTTON) {
uiButtonItem *bitem = (uiButtonItem *)item;
-
-
- if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect);
- if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect);
+ if (r_w) *r_w = BLI_rctf_size_x(&bitem->but->rect);
+ if (r_h) *r_h = BLI_rctf_size_y(&bitem->but->rect);
}
else {
uiLayout *litem = (uiLayout *)item;
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index e8b8959fd43..ded5887f7f2 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -58,6 +58,8 @@
#include "UI_interface.h"
+#include "IMB_colormanagement.h"
+
#include "interface_intern.h"
#include "WM_api.h"
@@ -75,7 +77,7 @@
/* ********************************************************** */
typedef struct Eyedropper {
- short do_color_management;
+ struct ColorManagedDisplay *display;
PointerRNA ptr;
PropertyRNA *prop;
@@ -89,8 +91,6 @@ typedef struct Eyedropper {
static int eyedropper_init(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
-
Eyedropper *eye;
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
@@ -106,7 +106,12 @@ static int eyedropper_init(bContext *C, wmOperator *op)
return FALSE;
}
- eye->do_color_management = (color_manage && RNA_property_subtype(eye->prop) == PROP_COLOR);
+ if (RNA_property_subtype(eye->prop) == PROP_COLOR) {
+ const char *display_device;
+
+ display_device = scene->display_settings.display_device;
+ eye->display = IMB_colormanagement_display_get_named(display_device);
+ }
return TRUE;
}
@@ -194,9 +199,10 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3
/* to maintain alpha */
RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv);
- /* convert from screen (srgb) space to linear rgb space */
- if (eye->do_color_management) {
- srgb_to_linearrgb_v3_v3(col_conv, col);
+ /* convert from display space to linear rgb space */
+ if (eye->display) {
+ copy_v3_v3(col_conv, col);
+ IMB_colormanagement_display_to_scene_linear_v3(col_conv, eye->display);
}
else {
copy_v3_v3(col_conv, col);
@@ -906,7 +912,7 @@ static void UI_OT_editsource(wmOperatorType *ot)
* Note: this includes utility functions and button matching checks.
* this only works in conjunction with a py operator! */
-void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen)
+static void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen)
{
char tstr[32]; /* Should be more than enough! */
/* First, full lang code. */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index fa3e04d1351..49e96bea6c6 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -357,14 +357,14 @@ void UI_DrawTriIcon(float x, float y, char dir)
}
/* triangle 'icon' inside rect */
-static void ui_draw_tria_rect(rctf *rect, char dir)
+static void ui_draw_tria_rect(const rctf *rect, char dir)
{
if (dir == 'h') {
- float half = 0.5f * BLI_RCT_SIZE_Y(rect);
+ float half = 0.5f * BLI_rctf_size_y(rect);
ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half);
}
else {
- float half = 0.5f * BLI_RCT_SIZE_X(rect);
+ float half = 0.5f * BLI_rctf_size_x(rect);
ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin);
}
}
@@ -479,12 +479,12 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r
}
}
-static void rectf_scale(rctf *rect, float scale)
+static void rectf_scale(rctf *rect, const float scale)
{
- float centx = 0.5f * (rect->xmin + rect->xmax);
- float centy = 0.5f * (rect->ymin + rect->ymax);
- float sizex = 0.5f * scale * BLI_RCT_SIZE_X(rect);
- float sizey = 0.5f * scale * BLI_RCT_SIZE_Y(rect);
+ float centx = BLI_rctf_cent_x(rect);
+ float centy = BLI_rctf_cent_y(rect);
+ float sizex = BLI_rctf_size_x(rect) * 0.5f * scale;
+ float sizey = BLI_rctf_size_y(rect) * 0.5f * scale;
rect->xmin = centx - sizex;
rect->xmax = centx + sizex;
@@ -547,7 +547,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* itemrect smaller */
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
- itemrect.xmin = itemrect.xmax - BLI_RCT_SIZE_Y(&headrect);
+ itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
@@ -596,7 +596,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* itemrect smaller */
itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
- itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect);
+ itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
@@ -985,8 +985,8 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
dx = (event->x - data->startx) & ~(PNL_GRID - 1);
dy = (event->y - data->starty) & ~(PNL_GRID - 1);
- dx *= (float)BLI_RCT_SIZE_X(&ar->v2d.cur) / (float)BLI_RCT_SIZE_X(&ar->winrct);
- dy *= (float)BLI_RCT_SIZE_Y(&ar->v2d.cur) / (float)BLI_RCT_SIZE_Y(&ar->winrct);
+ dx *= (float)BLI_rctf_size_x(&ar->v2d.cur) / (float)BLI_rcti_size_x(&ar->winrct);
+ dy *= (float)BLI_rctf_size_y(&ar->v2d.cur) / (float)BLI_rcti_size_y(&ar->winrct);
if (data->state == PANEL_STATE_DRAG_SCALE) {
panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 10a64d50887..adf839d433b 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -66,9 +66,10 @@
#include "ED_screen.h"
+#include "IMB_colormanagement.h"
+
#include "interface_intern.h"
-#define MENU_SEPR_HEIGHT 6
#define B_NOP -1
#define MENU_SHADOW_SIDE 8
#define MENU_SHADOW_BOTTOM 10
@@ -391,7 +392,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
/* draw text */
uiStyleFontSet(&data->fstyle);
- bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth);
+ bbox.ymax = bbox.ymax - 0.5f * (BLI_rcti_size_y(&bbox) - data->toth);
bbox.ymin = bbox.ymax - data->lineh;
for (i = 0; i < data->totline; i++) {
@@ -730,9 +731,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM;
/* region bigger for shadow */
ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
@@ -865,8 +866,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
{
/* thumbnail preview */
if (data->preview) {
- int butw = BLI_RCT_SIZE_X(&data->bbox) / data->prv_cols;
- int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows;
+ int butw = BLI_rcti_size_x(&data->bbox) / data->prv_cols;
+ int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows;
int row, col;
*rect = data->bbox;
@@ -882,7 +883,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
}
/* list view */
else {
- int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS;
+ int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS;
*rect = data->bbox;
rect->xmin = data->bbox.xmin + 3.0f;
@@ -1095,13 +1096,13 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
if (data->items.more) {
ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
glEnable(GL_BLEND);
- UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
+ UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
glDisable(GL_BLEND);
}
if (data->items.offset) {
ui_searchbox_butrect(&rect, data, 0);
glEnable(GL_BLEND);
- UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
+ UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
glDisable(GL_BLEND);
}
}
@@ -1176,16 +1177,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = BLI_RCT_SIZE_X(&ar->winrct) - MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_rcti_size_x(&ar->winrct) - MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = BLI_RCT_SIZE_Y(&ar->winrct) - MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_rcti_size_y(&ar->winrct) - MENU_SHADOW_BOTTOM;
/* check if button is lower half */
- if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) {
- data->bbox.ymin += BLI_RCT_SIZE_Y(&but->rect);
+ if (but->rect.ymax < BLI_rctf_cent_y(&but->block->rect)) {
+ data->bbox.ymin += BLI_rctf_size_y(&but->rect);
}
else {
- data->bbox.ymax -= BLI_RCT_SIZE_Y(&but->rect);
+ data->bbox.ymax -= BLI_rctf_size_y(&but->rect);
}
}
else {
@@ -1200,7 +1201,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
BLI_rctf_translate(&rect_fl, ofsx, ofsy);
/* minimal width */
- if (BLI_RCT_SIZE_X(&rect_fl) < 150) {
+ if (BLI_rctf_size_x(&rect_fl) < 150) {
rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */
}
@@ -1233,15 +1234,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1);
newy1 += butregion->winrct.ymin;
- rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1;
+ rect_i.ymax = BLI_rcti_size_y(&rect_i) + newy1;
rect_i.ymin = newy1;
}
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM;
/* region bigger for shadow */
ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
@@ -1356,15 +1357,15 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
}
}
- /* aspect = (float)(BLI_RCT_SIZE_X(&block->rect) + 4);*/ /*UNUSED*/
+ /* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/
ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
//block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
//block->rect.xmax += 2.0; block->rect.ymax += 2.0;
- xsize = BLI_RCT_SIZE_X(&block->rect) + 4; /* 4 for shadow */
- ysize = BLI_RCT_SIZE_Y(&block->rect) + 4;
+ xsize = BLI_rctf_size_x(&block->rect) + 4; /* 4 for shadow */
+ ysize = BLI_rctf_size_y(&block->rect) + 4;
/* aspect /= (float)xsize;*/ /*UNUSED*/
{
@@ -1494,9 +1495,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
BLI_rctf_translate(&block->rect, xof, yof);
/* safety calculus */
- if (but) {
- const float midx = BLI_RCT_CENTER_X(&butrct);
- const float midy = BLI_RCT_CENTER_Y(&butrct);
+ {
+ const float midx = BLI_rctf_cent_x(&butrct);
+ const float midy = BLI_rctf_cent_y(&butrct);
/* when you are outside parent button, safety there should be smaller */
@@ -1521,20 +1522,13 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
}
block->direction = dir1;
}
- else {
- block->safety.xmin = block->rect.xmin - 40;
- block->safety.ymin = block->rect.ymin - 40;
- block->safety.xmax = block->rect.xmax + 40;
- block->safety.ymax = block->rect.ymax + 40;
- }
/* keep a list of these, needed for pulldown menus */
saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
saferct->parent = butrct;
saferct->safety = block->safety;
BLI_freelistN(&block->saferct);
- if (but)
- BLI_duplicatelist(&block->saferct, &but->block->saferct);
+ BLI_duplicatelist(&block->saferct, &but->block->saferct);
BLI_addhead(&block->saferct, saferct);
}
@@ -1879,12 +1873,6 @@ static void ui_warp_pointer(int x, int y)
/********************* Color Button ****************/
-/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK 110.0
-#define FPICK 180.0
-#define DPICK 6.0
-#define BPICK 24.0
-
/* for picker, while editing hsv */
void ui_set_but_hsv(uiBut *but)
{
@@ -1900,11 +1888,15 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
{
uiBut *bt;
float *hsv = ui_block_hsv_get(block);
+ struct ColorManagedDisplay *display = NULL;
/* this is to keep the H and S value when V is equal to zero
* and we are working in HSV mode, of course!
*/
rgb_to_hsv_compat_v(rgb, hsv);
+
+ if (block->color_profile)
+ display = ui_block_display_get(block);
/* this updates button strings, is hackish... but button pointers are on stack of caller function */
for (bt = block->buttons.first; bt; bt = bt->next) {
@@ -1920,12 +1912,11 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
- if (block->color_profile == BLI_PR_NONE) {
- copy_v3_v3(rgb_gamma, rgb);
- }
- else {
- /* make an sRGB version, for Hex code */
- linearrgb_to_srgb_v3_v3(rgb_gamma, rgb);
+ copy_v3_v3(rgb_gamma, rgb);
+
+ if (display) {
+ /* make a display version, for Hex code */
+ IMB_colormanagement_scene_linear_to_display_v3(rgb_gamma, display);
}
if (rgb_gamma[0] > 1.0f) rgb_gamma[0] = modf(rgb_gamma[0], &intpart);
@@ -2004,9 +1995,9 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
hex_to_rgb(hexcol, rgb, rgb + 1, rgb + 2);
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
- if (but->block->color_profile != BLI_PR_NONE) {
+ if (but->block->color_profile) {
/* so we need to linearise it for Blender */
- srgb_to_linearrgb_v3_v3(rgb, rgb);
+ ui_block_to_scene_linear_v3(but->block, rgb);
}
ui_update_block_buts_rgb(but->block, rgb);
@@ -2055,10 +2046,6 @@ static void do_picker_new_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
picker_new_hide_reveal(bt->block, colormode);
}
-/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK1 150.0
-#define DPICK1 6.0
-
#define PICKER_H 150
#define PICKER_W 150
#define PICKER_SPACE 6
@@ -2114,14 +2101,16 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
/* existence of profile means storage is in linear color space, with display correction */
/* XXX That tip message is not use anywhere! */
- if (block->color_profile == BLI_PR_NONE) {
+ if (!block->color_profile) {
BLI_strncpy(tip, N_("Value in Display Color Space"), sizeof(tip));
copy_v3_v3(rgb_gamma, rgba);
}
else {
BLI_strncpy(tip, N_("Value in Linear RGB Color Space"), sizeof(tip));
- /* make an sRGB version, for Hex code */
- linearrgb_to_srgb_v3_v3(rgb_gamma, rgba);
+
+ /* make a display version, for Hex code */
+ copy_v3_v3(rgb_gamma, rgba);
+ ui_block_to_display_space_v3(block, rgb_gamma);
}
/* sneaky way to check for alpha */
@@ -2246,7 +2235,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
- block->color_profile = BLI_PR_NONE;
+ block->color_profile = FALSE;
}
}
@@ -2343,7 +2332,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
if (pup->but) {
/* minimum width to enforece */
- minwidth = BLI_RCT_SIZE_X(&pup->but->rect);
+ minwidth = BLI_rctf_size_x(&pup->but->rect);
if (pup->but->type == PULLDOWN || pup->but->menu_create_func) {
direction = UI_DOWN;
@@ -2385,7 +2374,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
* button, so it doesn't overlap the text too much, also note
* the offset is negative because we are inverse moving the
* block to be under the mouse */
- offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect));
+ offset[0] = -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect));
offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y);
}
else {
@@ -2393,7 +2382,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_RCT_SIZE_X(&bt->rect)));
+ offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)));
offset[1] = 1.5 * UI_UNIT_Y;
}
@@ -2502,7 +2491,6 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash = ui_popup_menu_hash(title);
- pup->block->auto_is_first_event = TRUE;
pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
@@ -2576,6 +2564,11 @@ static void confirm_cancel_operator(void *opv)
}
static void vconfirm_opname(bContext *C, const char *opname, const char *title, const char *itemfmt, va_list ap)
+#ifdef __GNUC__
+__attribute__ ((format(printf, 4, 0)))
+#endif
+;
+static void vconfirm_opname(bContext *C, const char *opname, const char *title, const char *itemfmt, va_list ap)
{
uiPopupBlockHandle *handle;
char *s, buf[512];
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index b16250021d3..acf7712f97b 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -152,17 +152,17 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
uiStyleFontSet(fs);
height = BLF_ascender(fs->uifont_id);
- yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height));
+ yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
if (fs->align == UI_STYLE_TEXT_CENTER) {
- xofs = floor(0.5f * (BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str)));
+ xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str)));
/* don't center text if it chops off the start of the text, 2 gives some margin */
if (xofs < 2) {
xofs = 2;
}
}
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
- xofs = BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str) - 1;
+ xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str) - 1;
}
/* clip is very strict, so we give it some space */
@@ -209,7 +209,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
height = BLF_ascender(fs->uifont_id);
/* becomes x-offset when rotated */
- xofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height));
+ xofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
/* ignore UI_STYLE, always aligned to top */
@@ -219,8 +219,8 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
angle = 90.0f;
/* translate rect to vertical */
- txtrect.xmin = rect->xmin - BLI_RCT_SIZE_Y(rect);
- txtrect.ymin = rect->ymin - BLI_RCT_SIZE_X(rect);
+ txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect);
+ txtrect.ymin = rect->ymin - BLI_rcti_size_x(rect);
txtrect.xmax = rect->xmin;
txtrect.ymax = rect->ymin;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 9f0dc4af226..37503acfeb0 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -35,6 +35,7 @@
#include "DNA_dynamicpaint_types.h"
#include "DNA_key_types.h"
#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
#include "DNA_userdef_types.h"
#include "BLI_utildefines.h"
@@ -56,6 +57,7 @@
#include "BKE_texture.h"
#include "BKE_report.h"
#include "BKE_displist.h"
+#include "BKE_sca.h"
#include "BKE_scene.h"
#include "ED_screen.h"
@@ -428,8 +430,15 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
TIP_("Display number of users of this data (click to make a single-user copy)"));
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
- if (!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable)
+ if (/* test only */
+ (id_copy(id, NULL, 1) == FALSE) ||
+ (idfrom && idfrom->lib) ||
+ (editable == FALSE) ||
+ /* object in editmode - don't change data */
+ (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT)))
+ {
uiButSetFlag(but, UI_BUT_DISABLED);
+ }
}
if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT);
@@ -930,28 +939,26 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
#include "BKE_action.h"
#include "BKE_constraint.h"
-#define REDRAWIPO 1
-#define REDRAWNLA 2
-#define REDRAWBUTSOBJECT 3
-#define REDRAWACTION 4
#define B_CONSTRAINT_TEST 5
-#define B_CONSTRAINT_CHANGETARGET 6
-#define REMAKEIPO 8
-#define B_DIFF 9
+// #define B_CONSTRAINT_CHANGETARGET 6
static void do_constraint_panels(bContext *C, void *ob_pt, int event)
{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
Object *ob = (Object *)ob_pt;
switch (event) {
case B_CONSTRAINT_TEST:
break; /* no handling */
+#if 0 /* UNUSED */
case B_CONSTRAINT_CHANGETARGET:
+ {
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */
DAG_scene_sort(bmain, scene);
break;
+ }
+#endif
default:
break;
}
@@ -1263,8 +1270,6 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
RNA_property_update(C, &cb->ptr, cb->prop);
}
-#define B_BANDCOL 1
-
static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
{
ColorBand *coba = coba_v;
@@ -1380,7 +1385,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb)
{
uiBut *bt;
- float unit = BLI_RCT_SIZE_X(butr) / 14.0f;
+ float unit = BLI_rctf_size_x(butr) / 14.0f;
float xs = butr->xmin;
uiBlockBeginAlign(block);
@@ -1406,7 +1411,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
TIP_("Set interpolation between color stops"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_RCT_SIZE_X(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
uiBlockEndAlign(block);
@@ -1481,7 +1486,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
- bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), hist->height, hist, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), hist->height, hist, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1518,7 +1523,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
- bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
(void)bt; /* UNUSED */
MEM_freeN(cb);
@@ -1555,7 +1560,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
- bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1570,11 +1575,11 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar
float d;
/* we allow 20 times zoom */
- if (BLI_RCT_SIZE_X(&cumap->curr) > 0.04f * BLI_RCT_SIZE_X(&cumap->clipr)) {
- d = 0.1154f * BLI_RCT_SIZE_X(&cumap->curr);
+ if (BLI_rctf_size_x(&cumap->curr) > 0.04f * BLI_rctf_size_x(&cumap->clipr)) {
+ d = 0.1154f * BLI_rctf_size_x(&cumap->curr);
cumap->curr.xmin += d;
cumap->curr.xmax -= d;
- d = 0.1154f * BLI_RCT_SIZE_Y(&cumap->curr);
+ d = 0.1154f * BLI_rctf_size_y(&cumap->curr);
cumap->curr.ymin += d;
cumap->curr.ymax -= d;
}
@@ -1588,8 +1593,8 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
float d, d1;
/* we allow 20 times zoom, but don't view outside clip */
- if (BLI_RCT_SIZE_X(&cumap->curr) < 20.0f * BLI_RCT_SIZE_X(&cumap->clipr)) {
- d = d1 = 0.15f * BLI_RCT_SIZE_X(&cumap->curr);
+ if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) {
+ d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr);
if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.xmin - d < cumap->clipr.xmin)
@@ -1602,7 +1607,7 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
cumap->curr.xmax += d1;
- d = d1 = 0.15f * BLI_RCT_SIZE_Y(&cumap->curr);
+ d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr);
if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.ymin - d < cumap->clipr.ymin)
@@ -1870,7 +1875,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- if (cumap->flag & CUMA_DO_CLIP) icon = ICON_CLIPUV_HLT; else icon = ICON_CLIPUV_DEHLT;
+ icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
@@ -2086,6 +2091,74 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
}
}
+void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname,
+ PointerRNA *used_ptr, const char *used_propname, int active_state)
+{
+ uiLayout *uRow, *uCol;
+ PropertyRNA *prop, *used_prop = NULL;
+ int groups, cols, states;
+ int group, col, state, row;
+ int cols_per_group = 5;
+ Object *ob = (Object *)ptr->id.data;
+
+ prop = RNA_struct_find_property(ptr, propname);
+ if (!prop) {
+ RNA_warning("states property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ /* the number of states determines the way we group them
+ * - we want 2 rows only (for now)
+ * - the number of columns (cols) is the total number of buttons per row
+ * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
+ * - for now, only split into groups if group will have at least 5 items
+ */
+ states = RNA_property_array_length(ptr, prop);
+ cols = (states / 2) + (states % 2);
+ groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
+
+ if (used_ptr && used_propname) {
+ used_prop = RNA_struct_find_property(used_ptr, used_propname);
+ if (!used_prop) {
+ RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
+ return;
+ }
+
+ if (RNA_property_array_length(used_ptr, used_prop) < states)
+ used_prop = NULL;
+ }
+
+ /* layers are laid out going across rows, with the columns being divided into groups */
+
+ for (group = 0; group < groups; group++) {
+ uCol = uiLayoutColumn(layout, TRUE);
+
+ for (row = 0; row < 2; row++) {
+ uiBlock *block;
+ uiBut *but;
+
+ uRow = uiLayoutRow(uCol, TRUE);
+ block = uiLayoutGetBlock(uRow);
+ state = groups * cols_per_group * row + cols_per_group * group;
+
+ /* add layers as toggle buts */
+ for (col = 0; (col < cols_per_group) && (state < states); col++, state++) {
+ int icon = 0;
+ int butlay = 1 << state;
+
+ if (active_state & butlay)
+ icon = ICON_LAYER_ACTIVE;
+ else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state))
+ icon = ICON_LAYER_USED;
+
+ but = uiDefIconButR_prop(block, ICONTOG, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, state, 0, 0, -1, -1, sca_state_name_get(ob, state));
+ uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state));
+ but->type = TOG;
+ }
+ }
+ }
+}
+
/************************* List Template **************************/
@@ -2802,3 +2875,56 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
}
}
+/********************************* Color management *************************************/
+
+void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname)
+{
+ PropertyRNA *prop;
+ PointerRNA colorspace_settings_ptr;
+
+ prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ printf("%s: property not found: %s.%s\n",
+ __func__, RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop);
+
+ uiItemL(layout, "Color Space:", ICON_NONE);
+ uiItemR(layout, &colorspace_settings_ptr, "name", 0, "", ICON_NONE);
+}
+
+void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr, const char *propname)
+{
+ PropertyRNA *prop;
+ PointerRNA view_transform_ptr;
+ uiLayout *col, *row;
+ ColorManagedViewSettings *view_settings;
+
+ prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ printf("%s: property not found: %s.%s\n",
+ __func__, RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ view_transform_ptr = RNA_property_pointer_get(ptr, prop);
+ view_settings = view_transform_ptr.data;
+
+ col = uiLayoutColumn(layout, FALSE);
+
+ row = uiLayoutRow(col, FALSE);
+ uiItemR(row, &view_transform_ptr, "view_transform", UI_ITEM_R_EXPAND, IFACE_("View"), ICON_NONE);
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE);
+ uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE);
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
+ if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)
+ uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', TRUE, 0);
+}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 026f02d1089..f3539af821e 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -259,8 +259,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r
rad += step;
- if (2.0f * rad > BLI_RCT_SIZE_Y(rect))
- rad = 0.5f * BLI_RCT_SIZE_Y(rect);
+ if (2.0f * rad > BLI_rcti_size_y(rect))
+ rad = 0.5f * BLI_rcti_size_y(rect);
minx = rect->xmin - step;
miny = rect->ymin - step;
@@ -345,8 +345,8 @@ 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_RCT_SIZE_X(rect) * hnum,
- BLI_RCT_SIZE_Y(rect) * vnum);
+ minsize = mini(BLI_rcti_size_x(rect) * hnum,
+ BLI_rcti_size_y(rect) * vnum);
if (2.0f * rad > minsize)
rad = 0.5f * minsize;
@@ -491,7 +491,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_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
+ minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -526,7 +526,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_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
+ minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -570,14 +570,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx = rect->xmax - 0.5f * BLI_RCT_SIZE_Y(rect);
- centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect);
- size = 0.4f * BLI_RCT_SIZE_Y(rect);
+ 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);
/* XXX exception */
- asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect));
+ 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_RCT_SIZE_Y(rect);
+ centx = rect->xmax - 0.3f * BLI_rcti_size_y(rect);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * menu_tria_vert[a][0] + centx;
@@ -594,9 +594,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx = rect->xmin + 0.5f * BLI_RCT_SIZE_Y(rect);
- centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect);
- size = 0.5f * BLI_RCT_SIZE_Y(rect);
+ centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect);
+ centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
+ size = 0.5f * BLI_rcti_size_y(rect);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * check_tria_vert[a][0] + centx;
@@ -840,8 +840,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
if (icon == ICON_NONE)
return;
- w = BLI_RCT_SIZE_X(rect);
- h = BLI_RCT_SIZE_Y(rect);
+ w = BLI_rcti_size_x(rect);
+ h = BLI_rcti_size_y(rect);
size = MIN2(w, h);
size -= PREVIEW_PAD * 2; /* padding */
@@ -965,48 +965,77 @@ static void ui_text_clip_give_next_off(uiBut *but)
but->ofs += bytes;
}
-/* sets but->ofs to make sure text is correctly visible */
-static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
+/**
+ * Cut off the start of the text to fit into the width of \a rect
+ *
+ * \note Sets but->ofs to make sure text is correctly visible.
+ * \note Clips right in some cases, this function could be cleaned up.
+ */
+static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = BLI_RCT_SIZE_X(rect) - border;
-
+ int okwidth = BLI_rcti_size_x(rect) - border;
if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
-
+
/* need to set this first */
uiStyleFontSet(fstyle);
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- /* if text editing we define ofs dynamically */
- if (but->editstr && but->pos >= 0) {
+ but->ofs = 0;
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
+
+ while (but->strwidth > okwidth) {
+ ui_text_clip_give_next_off(but);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ if (but->strwidth < 10) break;
+ }
+
+ if (fstyle->kerning == 1) {
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
+}
+
+/**
+ * Cut off the text, taking into account the cursor location (text display while editing).
+ */
+static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, rcti *rect)
+{
+ int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int okwidth = BLI_rcti_size_x(rect) - border;
+ if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
+
+ BLI_assert(but->editstr && but->pos >= 0);
+
+ /* need to set this first */
+ uiStyleFontSet(fstyle);
+
+ if (fstyle->kerning == 1) /* for BLF_width */
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+
+ if ((but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr)) <= okwidth) {
+ but->ofs = 0;
+ }
+ else {
+ /* define ofs dynamically */
if (but->ofs > but->pos)
but->ofs = but->pos;
- if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth)
- but->ofs = 0;
- }
- else but->ofs = 0;
-
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
-
- while (but->strwidth > okwidth) {
-
- /* textbut exception, clip right when... */
- if (but->editstr && but->pos >= 0) {
+ while (but->strwidth > okwidth) {
float width;
char buf[UI_MAX_DRAW_STR];
-
+
/* copy draw string */
BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf));
/* string position of cursor */
buf[but->pos] = 0;
width = BLF_width(fstyle->uifont_id, buf + but->ofs);
-
+
/* if cursor is at 20 pixels of right side button we clip left */
- if (width > okwidth - 20)
+ if (width > okwidth - 20) {
ui_text_clip_give_next_off(but);
+ }
else {
int len, bytes;
/* shift string to the left */
@@ -1016,25 +1045,30 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
but->drawstr[len - bytes] = 0;
}
- }
- else
- ui_text_clip_give_next_off(but);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
-
- if (but->strwidth < 10) break;
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+
+ if (but->strwidth < 10) break;
+ }
}
-
- if (fstyle->kerning == 1)
+
+ if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
}
-static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
+/**
+ * Cut off the end of text to fit into the width of \a rect.
+ *
+ * \note deals with ': ' especially for number buttons
+ */
+static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = BLI_RCT_SIZE_X(rect) - border;
+ int okwidth = BLI_rcti_size_x(rect) - border;
char *cpoin = NULL;
- char *cpend = but->drawstr + strlen(but->drawstr);
+ int drawstr_len = strlen(but->drawstr);
+ char *cpend = but->drawstr + drawstr_len;
/* need to set this first */
uiStyleFontSet(fstyle);
@@ -1045,6 +1079,13 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
but->ofs = 0;
+
+ /* First shorten num-buttopns eg,
+ * Translucency: 0.000
+ * becomes
+ * Trans: 0.000
+ */
+
/* find the space after ':' separator */
cpoin = strrchr(but->drawstr, ':');
@@ -1057,8 +1098,11 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
int bytes = cp2 - prev_utf8;
/* shift the text after and including cp2 back by 1 char, +1 to include null terminator */
- memmove(cp2 - bytes, cp2, strlen(cp2) + 1);
+ memmove(cp2 - bytes, cp2, drawstr_len + 1);
cp2 -= bytes;
+
+ drawstr_len -= bytes;
+ // BLI_assert(strlen(but->drawstr) == drawstr_len);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
@@ -1074,14 +1118,17 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
}
+
+ /* Now just remove trailing chars */
/* once the label's gone, chop off the least significant digits */
while (but->strwidth > okwidth) {
- int len = strlen(but->drawstr);
- int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
+ int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + drawstr_len));
if (bytes < 0)
bytes = 1;
- but->drawstr[len - bytes] = 0;
+ drawstr_len -= bytes;
+ but->drawstr[drawstr_len] = 0;
+ // BLI_assert(strlen(but->drawstr) == drawstr_len);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
@@ -1229,30 +1276,31 @@ 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) return;
+ if (but == NULL) {
+ return;
+ }
/* clip but->drawstr to fit in available space */
if (but->editstr && but->pos >= 0) {
- ui_text_leftclip(fstyle, but, rect);
+ ui_text_clip_cursor(fstyle, but, rect);
}
else if (ELEM4(but->type, NUM, NUMABS, NUMSLI, SLI)) {
- ui_text_label_rightclip(fstyle, but, rect);
+ ui_text_clip_right_label(fstyle, but, rect);
}
else if (ELEM(but->type, TEX, SEARCH_MENU)) {
- ui_text_leftclip(fstyle, but, rect);
+ ui_text_clip_left(fstyle, but, rect);
}
else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
- ui_text_leftclip(fstyle, but, rect);
+ ui_text_clip_left(fstyle, but, rect);
}
else but->ofs = 0;
-
+
/* check for button text label */
if (but->type == ICONTEXTROW) {
widget_draw_icon(but, (BIFIconID) (but->icon + but->iconadd), 1.0f, rect);
}
else {
-
+
if (but->type == BUT_TOGDUAL) {
int dualset = 0;
if (but->pointype == UI_BUT_POIN_SHORT) {
@@ -1261,30 +1309,30 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
else if (but->pointype == UI_BUT_POIN_INT) {
dualset = UI_BITBUT_TEST(*(((int *)but->poin) + 1), but->bitnr);
}
-
+
widget_draw_icon(but, ICON_DOT, dualset ? 1.0f : 0.25f, rect);
}
else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) {
int tmp = rect->xmin;
- rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1;
+ rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect);
rect->xmin = tmp;
}
-
+
/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
* and offset the text label to accommodate it */
-
+
if (but->flag & UI_HAS_ICON) {
widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect);
-
+
rect->xmin += (int)((float)UI_icon_get_width(but->icon + but->iconadd) * UI_DPI_ICON_FAC);
-
- if (but->editstr || (but->flag & UI_TEXT_LEFT))
+
+ if (but->editstr || (but->flag & UI_TEXT_LEFT))
rect->xmin += 5;
}
- else if ((but->flag & UI_TEXT_LEFT))
+ else if ((but->flag & UI_TEXT_LEFT))
rect->xmin += 5;
-
+
/* always draw text for textbutton cursor */
widget_draw_text(fstyle, wcol, but, rect);
@@ -1761,8 +1809,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
float quad_strip[WIDGET_SIZE_MAX * 2][2];
/* prevent tooltips to not show round shadow */
- if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1))
- rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1);
+ if (2.0f * radout > 0.2f * BLI_rcti_size_y(&rect1))
+ rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
else
rect1.ymax -= 2.0f * radout;
@@ -1844,14 +1892,14 @@ static void ui_hsv_cursor(float x, float y)
void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my)
{
/* duplication of code... well, simple is better now */
- float centx = BLI_RCT_CENTER_X_FL(rect);
- float centy = BLI_RCT_CENTER_Y_FL(rect);
+ float centx = BLI_rcti_cent_x_fl(rect);
+ float centy = BLI_rcti_cent_y_fl(rect);
float radius, dist;
- if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect))
- radius = (float)BLI_RCT_SIZE_Y(rect) / 2;
+ if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect))
+ radius = (float)BLI_rcti_size_y(rect) / 2;
else
- radius = (float)BLI_RCT_SIZE_X(rect) / 2;
+ radius = (float)BLI_rcti_size_x(rect) / 2;
mx -= centx;
my -= centy;
@@ -1874,30 +1922,33 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
int color_profile = but->block->color_profile;
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
radstep = 2.0f * (float)M_PI / (float)tot;
- centx = BLI_RCT_CENTER_X_FL(rect);
- centy = BLI_RCT_CENTER_Y_FL(rect);
+ centx = BLI_rcti_cent_x_fl(rect);
+ centy = BLI_rcti_cent_y_fl(rect);
- if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect))
- radius = (float)BLI_RCT_SIZE_Y(rect) / 2;
+ if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect))
+ radius = (float)BLI_rcti_size_y(rect) / 2;
else
- radius = (float)BLI_RCT_SIZE_X(rect) / 2;
+ radius = (float)BLI_rcti_size_x(rect) / 2;
/* color */
ui_get_but_vectorf(but, rgb);
- copy_v3_v3(hsv, ui_block_hsv_get(but->block));
+ /* copy_v3_v3(hsv, ui_block_hsv_get(but->block)); */ /* UNUSED */
+
+ rgb_to_hsv_compat_v(rgb, hsvo);
+
+ if (color_profile)
+ ui_block_to_display_space_v3(but->block, rgb);
+
rgb_to_hsv_compat_v(rgb, hsv);
- copy_v3_v3(hsvo, hsv);
/* exception: if 'lock' is set
* lock the value of the color wheel to 1.
* Useful for color correction tools where you're only interested in hue. */
if (but->flag & UI_BUT_COLOR_LOCK)
hsv[2] = 1.f;
- else if (color_profile)
- hsv[2] = linearrgb_to_srgb(hsv[2]);
hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2);
@@ -2059,10 +2110,10 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
}
/* rect */
- sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect);
- sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect);
+ 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_RCT_SIZE_Y(rect) / 3.0;
+ dy = BLI_rcti_size_y(rect) / 3.0;
glBegin(GL_QUADS);
for (a = 0; a < 3; a++, sy += dy) {
@@ -2117,8 +2168,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
}
/* cursor */
- x = rect->xmin + x * BLI_RCT_SIZE_X(rect);
- y = rect->ymin + y * BLI_RCT_SIZE_Y(rect);
+ x = rect->xmin + x * BLI_rcti_size_x(rect);
+ y = rect->ymin + y * BLI_rcti_size_y(rect);
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
@@ -2133,21 +2184,22 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
{
uiWidgetBase wtb;
- float rad = 0.5f * BLI_RCT_SIZE_X(rect);
+ float rad = 0.5f * BLI_rcti_size_x(rect);
float x, y;
float rgb[3], hsv[3], v, range;
int color_profile = but->block->color_profile;
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
ui_get_but_vectorf(but, rgb);
+
+ if (color_profile)
+ ui_block_to_display_space_v3(but->block, rgb);
+
rgb_to_hsv_v(rgb, hsv);
v = hsv[2];
- if (color_profile)
- v = linearrgb_to_srgb(v);
-
/* map v from property range to [0,1] */
range = but->softmax - but->softmin;
v = (v - but->softmin) / range;
@@ -2167,8 +2219,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
widgetbase_draw(&wtb, &wcol_tmp);
/* cursor */
- x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect);
- y = rect->ymin + v * BLI_RCT_SIZE_Y(rect);
+ x = rect->xmin + 0.5f * BLI_rcti_size_x(rect);
+ y = rect->ymin + v * BLI_rcti_size_y(rect);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
ui_hsv_cursor(x, y);
@@ -2179,7 +2231,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
/* ************ separator, for menus etc ***************** */
static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
{
- int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1;
+ int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1;
unsigned char col[4];
col[0] = wcol->text[0];
@@ -2198,7 +2250,7 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb;
- float rad = 0.5f * BLI_RCT_SIZE_Y(rect);
+ float rad = 0.5f * BLI_rcti_size_y(rect);
float textofs = rad * 0.75f;
if (state & UI_SELECT)
@@ -2279,12 +2331,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widget_init(&wtb);
/* determine horizontal/vertical */
- horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect));
+ horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
if (horizontal)
- rad = 0.5f * BLI_RCT_SIZE_Y(rect);
+ rad = 0.5f * BLI_rcti_size_y(rect);
else
- rad = 0.5f * BLI_RCT_SIZE_X(rect);
+ rad = 0.5f * BLI_rcti_size_x(rect);
wtb.shadedir = (horizontal) ? 1 : 0;
@@ -2296,7 +2348,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widgetbase_draw(&wtb, wcol);
/* slider */
- if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) {
+ if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) {
/* pass */
}
else {
@@ -2362,17 +2414,17 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
rect1 = *rect;
/* determine horizontal/vertical */
- horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect));
+ horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
if (horizontal) {
- fac = BLI_RCT_SIZE_X(rect) / size;
+ fac = BLI_rcti_size_x(rect) / size;
rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin));
rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin));
/* ensure minimium size */
- min = BLI_RCT_SIZE_Y(rect);
+ min = BLI_rcti_size_y(rect);
- if (BLI_RCT_SIZE_X(&rect1) < min) {
+ if (BLI_rcti_size_x(&rect1) < min) {
rect1.xmax = rect1.xmin + min;
if (rect1.xmax > rect->xmax) {
@@ -2382,14 +2434,14 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
}
else {
- fac = BLI_RCT_SIZE_Y(rect) / size;
+ fac = BLI_rcti_size_y(rect) / size;
rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin));
rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin));
/* ensure minimium size */
- min = BLI_RCT_SIZE_X(rect);
+ min = BLI_rcti_size_x(rect);
- if (BLI_RCT_SIZE_Y(&rect1) < min) {
+ if (BLI_rcti_size_y(&rect1) < min) {
rect1.ymax = rect1.ymin + min;
if (rect1.ymax > rect->ymax) {
@@ -2417,10 +2469,10 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int
rect_prog.ymax = rect_prog.ymin + 4;
rect_bar.ymax = rect_bar.ymin + 4;
- w = value * BLI_RCT_SIZE_X(&rect_prog);
+ w = value * BLI_rcti_size_x(&rect_prog);
/* ensure minimium size */
- min = BLI_RCT_SIZE_Y(&rect_prog);
+ min = BLI_rcti_size_y(&rect_prog);
w = MAX2(w, min);
rect_bar.xmax = rect_bar.xmin + w;
@@ -2440,8 +2492,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in
UI_ThemeColor(TH_TEXT_HI);
- rectlink.xmin = BLI_RCT_CENTER_X(rect);
- rectlink.ymin = BLI_RCT_CENTER_Y(rect);
+ rectlink.xmin = BLI_rcti_cent_x(rect);
+ rectlink.ymin = BLI_rcti_cent_y(rect);
rectlink.xmax = but->linkto[0];
rectlink.ymax = but->linkto[1];
@@ -2463,7 +2515,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
/* backdrop first */
/* fully rounded */
- offs = 0.5f * BLI_RCT_SIZE_Y(rect);
+ offs = 0.5f * BLI_rcti_size_y(rect);
toffs = offs * 0.75f;
round_box_edges(&wtb, roundboxalign, rect, offs);
@@ -2484,7 +2536,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
rect1 = *rect;
value = ui_get_but_val(but);
- fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin);
+ fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
/* left part of slider, always rounded */
rect1.xmax = rect1.xmin + ceil(offs + 1.0f);
@@ -2531,7 +2583,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) {
col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
@@ -2559,7 +2611,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
if (color_profile)
- linearrgb_to_srgb_v3_v3(col, col);
+ ui_block_to_display_space_v3(but->block, col);
rgba_float_to_uchar((unsigned char *)wcol->inner, col);
@@ -2617,7 +2669,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmax -= BLI_RCT_SIZE_Y(rect);
+ rect->xmax -= BLI_rcti_size_y(rect);
}
static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -2660,7 +2712,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
{
if (state & UI_ACTIVE) {
uiWidgetBase wtb;
- float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */
+ float rad = 0.5f * BLI_rcti_size_y(rect); /* 4.0f */
widget_init(&wtb);
@@ -2706,10 +2758,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widget_init(&wtb);
/* square */
- recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp);
+ recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
/* smaller */
- delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8;
+ delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
recttemp.xmin += delta;
recttemp.ymin += delta;
recttemp.xmax -= delta;
@@ -2726,7 +2778,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta;
+ rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta;
}
@@ -2788,7 +2840,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
uiWidgetBase wtb;
- float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */
+ float rad = 5.0f; /* 0.5f * BLI_rcti_size_y(rect); */
widget_init(&wtb);
@@ -3271,12 +3323,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
if (block->flag & UI_BLOCK_CLIPTOP) {
/* XXX no scaling for UI here yet */
glColor3ubv((unsigned char *)wt->wcol.text);
- UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymax - 8, 't');
+ UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymax - 8, 't');
}
if (block->flag & UI_BLOCK_CLIPBOTTOM) {
/* XXX no scaling for UI here yet */
glColor3ubv((unsigned char *)wt->wcol.text);
- UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v');
+ UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v');
}
}
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 0f1d1a24dcb..47bee92be62 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -96,11 +96,11 @@ static void view2d_masks(View2D *v2d)
/* check size if: */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
- if (BLI_RCT_SIZE_X(&v2d->tot) <= BLI_RCT_SIZE_X(&v2d->cur))
+ if (BLI_rctf_size_x(&v2d->tot) <= BLI_rcti_size_x(&v2d->cur))
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
if (v2d->scroll & V2D_SCROLL_VERTICAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
- if (BLI_RCT_SIZE_Y(&v2d->tot) <= BLI_RCT_SIZE_Y(&v2d->cur))
+ if (BLI_rctf_size_y(&v2d->tot) <= BLI_rctf_size_y(&v2d->cur))
v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
#endif
scroll = view2d_scroll_mapped(v2d->scroll);
@@ -328,8 +328,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
rctf *cur, *tot;
/* use mask as size of region that View2D resides in, as it takes into account scrollbars already */
- winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
- winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
+ winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
+ winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
/* get pointers to rcts for less typing */
cur = &v2d->cur;
@@ -347,10 +347,10 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
* - firstly, we calculate the sizes of the rects
* - curwidth and curheight are saved as reference... modify width and height values here
*/
- totwidth = BLI_RCT_SIZE_X(tot);
- totheight = BLI_RCT_SIZE_Y(tot);
- curwidth = width = BLI_RCT_SIZE_X(cur);
- curheight = height = BLI_RCT_SIZE_Y(cur);
+ totwidth = BLI_rctf_size_x(tot);
+ totheight = BLI_rctf_size_y(tot);
+ curwidth = width = BLI_rctf_size_x(cur);
+ curheight = height = BLI_rctf_size_y(cur);
/* if zoom is locked, size on the appropriate axis is reset to mask size */
if (v2d->keepzoom & V2D_LOCKZOOM_X)
@@ -499,16 +499,16 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
/* resize from centerpoint, unless otherwise specified */
if (width != curwidth) {
if (v2d->keepofs & V2D_LOCKOFS_X) {
- cur->xmax += width - BLI_RCT_SIZE_X(cur);
+ cur->xmax += width - BLI_rctf_size_x(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
if (v2d->align & V2D_ALIGN_NO_POS_X)
- cur->xmin -= width - BLI_RCT_SIZE_X(cur);
+ cur->xmin -= width - BLI_rctf_size_x(cur);
else
- cur->xmax += width - BLI_RCT_SIZE_X(cur);
+ cur->xmax += width - BLI_rctf_size_x(cur);
}
else {
- temp = BLI_RCT_CENTER_X(cur);
+ temp = BLI_rctf_cent_x(cur);
dh = width * 0.5f;
cur->xmin = temp - dh;
@@ -517,16 +517,16 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
if (height != curheight) {
if (v2d->keepofs & V2D_LOCKOFS_Y) {
- cur->ymax += height - BLI_RCT_SIZE_Y(cur);
+ cur->ymax += height - BLI_rctf_size_y(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
if (v2d->align & V2D_ALIGN_NO_POS_Y)
- cur->ymin -= height - BLI_RCT_SIZE_Y(cur);
+ cur->ymin -= height - BLI_rctf_size_y(cur);
else
- cur->ymax += height - BLI_RCT_SIZE_Y(cur);
+ cur->ymax += height - BLI_rctf_size_y(cur);
}
else {
- temp = BLI_RCT_CENTER_Y(cur);
+ temp = BLI_rctf_cent_y(cur);
dh = height * 0.5f;
cur->ymin = temp - dh;
@@ -540,8 +540,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
float temp, diff;
/* recalculate extents of cur */
- curwidth = BLI_RCT_SIZE_X(cur);
- curheight = BLI_RCT_SIZE_Y(cur);
+ curwidth = BLI_rctf_size_x(cur);
+ curheight = BLI_rctf_size_y(cur);
/* width */
if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) {
@@ -592,7 +592,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_RCT_CENTER_X(tot);
+ temp = BLI_rctf_cent_x(tot);
diff = curheight * 0.5f;
cur->xmin = temp - diff;
@@ -642,7 +642,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
*/
if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) {
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
- temp = BLI_RCT_CENTER_Y(tot);
+ temp = BLI_rctf_cent_y(tot);
diff = curheight * 0.5f;
cur->ymin = temp - diff;
@@ -791,8 +791,8 @@ void UI_view2d_curRect_reset(View2D *v2d)
float width, height;
/* assume width and height of 'cur' rect by default, should be same size as mask */
- width = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
- height = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
+ width = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
+ height = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
@@ -851,7 +851,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, int resize
if (scroll & V2D_SCROLL_VERTICAL)
height -= V2D_SCROLL_HEIGHT;
- if (ELEM3(0, v2d, width, height)) {
+ if (ELEM(0, width, height)) {
if (G.debug & G_DEBUG)
printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info
return;
@@ -958,8 +958,8 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
*curmasked = v2d->cur;
if (view2d_scroll_mapped(v2d->scroll)) {
- float dx = BLI_RCT_SIZE_X(&v2d->cur) / ((float)(BLI_RCT_SIZE_X(&v2d->mask) + 1));
- float dy = BLI_RCT_SIZE_Y(&v2d->cur) / ((float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1));
+ float dx = BLI_rctf_size_x(&v2d->cur) / ((float)(BLI_rcti_size_x(&v2d->mask) + 1));
+ float dy = BLI_rctf_size_y(&v2d->cur) / ((float)(BLI_rcti_size_y(&v2d->mask) + 1));
if (v2d->mask.xmin != 0)
curmasked->xmin -= dx * (float)v2d->mask.xmin;
@@ -985,14 +985,13 @@ void UI_view2d_view_ortho(View2D *v2d)
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
- xofs = 0.001f * BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
- yofs = 0.001f * BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask);
+ xofs = 0.001f * BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
+ yofs = 0.001f * BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
-
- curmasked.xmin -= xofs; curmasked.xmax -= xofs;
- curmasked.ymin -= yofs; curmasked.ymax -= yofs;
+
+ BLI_rctf_translate(&curmasked, -xofs, -yofs);
/* XXX ton: this flag set by outliner, for icons */
if (v2d->flag & V2D_PIXELOFS_X) {
@@ -1044,8 +1043,8 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
void UI_view2d_view_restore(const bContext *C)
{
ARegion *ar = CTX_wm_region(C);
- int width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ int width = BLI_rcti_size_x(&ar->winrct) + 1;
+ int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
glLoadIdentity();
@@ -1117,7 +1116,8 @@ static void step_to_grid(float *step, int *power, int unit)
* - winx = width of region we're drawing to, note: not used but keeping for completeness.
* - winy = height of region we're drawing into
*/
-View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int UNUSED(winx), int winy)
+View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp, int UNUSED(winx), int winy)
{
View2DGrid *grid;
@@ -1140,8 +1140,8 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
/* calculate x-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- space = BLI_RCT_SIZE_X(&v2d->cur);
- pixels = (float)BLI_RCT_SIZE_X(&v2d->mask);
+ space = BLI_rctf_size_x(&v2d->cur);
+ pixels = (float)BLI_rcti_size_x(&v2d->mask);
if (pixels != 0.0f) {
grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels);
@@ -1158,7 +1158,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
/* calculate y-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- space = BLI_RCT_SIZE_Y(&v2d->cur);
+ space = BLI_rctf_size_y(&v2d->cur);
pixels = (float)winy;
grid->dy = U.v2d_min_gridsize * space / pixels;
@@ -1206,7 +1206,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec2[1] = v2d->cur.ymax;
/* minor gridlines */
- step = (BLI_RCT_SIZE_X(&v2d->mask) + 1) / U.v2d_min_gridsize;
+ step = (BLI_rcti_size_x(&v2d->mask) + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
for (a = 0; a < step; a++) {
@@ -1240,7 +1240,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec1[0] = grid->startx;
vec2[0] = v2d->cur.xmax;
- step = (BLI_RCT_SIZE_Y(&v2d->mask) + 1) / U.v2d_min_gridsize;
+ step = (BLI_rcti_size_y(&v2d->mask) + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
for (a = 0; a <= step; a++) {
@@ -1414,7 +1414,8 @@ struct View2DScrollers {
};
/* Calculate relevant scroller properties */
-View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp)
+View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp)
{
View2DScrollers *scrollers;
rcti vert, hor;
@@ -1457,8 +1458,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* horizontal scrollers */
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
- totsize = BLI_RCT_SIZE_X(&v2d->tot);
- scrollsize = (float)BLI_RCT_SIZE_X(&hor);
+ totsize = BLI_rctf_size_x(&v2d->tot);
+ scrollsize = (float)BLI_rcti_size_x(&hor);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
@@ -1498,8 +1499,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* vertical scrollers */
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
- totsize = BLI_RCT_SIZE_Y(&v2d->tot);
- scrollsize = (float)BLI_RCT_SIZE_Y(&vert);
+ totsize = BLI_rctf_size_y(&v2d->tot);
+ scrollsize = (float)BLI_rcti_size_y(&vert);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
@@ -1547,7 +1548,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d,
xunits, xclamp, yunits, yclamp,
- BLI_RCT_SIZE_X(&hor), BLI_RCT_SIZE_Y(&vert));
+ BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert));
}
/* return scrollers */
@@ -1631,7 +1632,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) &&
- (BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE))
+ (BLI_rcti_size_x(&slider) > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1651,11 +1652,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - fac is x-coordinate to draw to
* - dfac is gap between scale markings
*/
- fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
- fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor);
+ fac = (grid->startx - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+ fac = (float)hor.xmin + fac * BLI_rcti_size_x(&hor);
- dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur);
- dfac = dfac * BLI_RCT_SIZE_X(&hor);
+ dfac = grid->dx / BLI_rctf_size_x(&v2d->cur);
+ dfac = dfac * BLI_rcti_size_x(&hor);
/* set starting value, and text color */
UI_ThemeColor(TH_TEXT);
@@ -1742,7 +1743,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) &&
- (BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE))
+ (BLI_rcti_size_y(&slider) > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1765,11 +1766,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - these involve a correction for horizontal scrollbar
* NOTE: it's assumed that that scrollbar is there if this is involved!
*/
- fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
- fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert);
+ fac = (grid->starty - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
+ fac = vert.ymin + fac * BLI_rcti_size_y(&vert);
- dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur);
- dfac = dfac * BLI_RCT_SIZE_Y(&vert);
+ dfac = grid->dy / BLI_rctf_size_y(&v2d->cur);
+ dfac = dfac * BLI_rcti_size_y(&vert);
/* set starting value, and text color */
UI_ThemeColor(TH_TEXT);
@@ -1823,7 +1824,9 @@ void UI_view2d_scrollers_free(View2DScrollers *scrollers)
* - column, row = the 2d-coordinates (in 2D-view / 'tot' rect space) the cell exists at
* - rect = coordinates of the cell (passed as single var instead of 4 separate, as it's more useful this way)
*/
-void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, rctf *rect)
+void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty,
+ int column, int row, rctf *rect)
{
/* sanity checks */
if (ELEM(NULL, v2d, rect)) {
@@ -1927,17 +1930,17 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float *
float div, ofs;
if (r_viewx) {
- div = (float)BLI_RCT_SIZE_X(&v2d->mask);
+ div = (float)BLI_rcti_size_x(&v2d->mask);
ofs = (float)v2d->mask.xmin;
- *r_viewx = v2d->cur.xmin + BLI_RCT_SIZE_X(&v2d->cur) * ((float)x - ofs) / div;
+ *r_viewx = v2d->cur.xmin + BLI_rctf_size_x(&v2d->cur) * ((float)x - ofs) / div;
}
if (r_viewy) {
- div = (float)BLI_RCT_SIZE_Y(&v2d->mask);
+ div = (float)BLI_rcti_size_y(&v2d->mask);
ofs = (float)v2d->mask.ymin;
- *r_viewy = v2d->cur.ymin + BLI_RCT_SIZE_Y(&v2d->cur) * ((float)y - ofs) / div;
+ *r_viewy = v2d->cur.ymin + BLI_rctf_size_y(&v2d->cur) * ((float)y - ofs) / div;
}
}
@@ -1956,15 +1959,15 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
*regiony = V2D_IS_CLIPPED;
/* express given coordinates as proportional values */
- x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
- y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+ y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
/* check if values are within bounds */
if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
if (regionx)
- *regionx = (int)(v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask));
+ *regionx = (int)(v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask));
if (regiony)
- *regiony = (int)(v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask));
+ *regiony = (int)(v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask));
}
}
@@ -1977,12 +1980,12 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* step 1: express given coordinates as proportional values */
- x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
- y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+ y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
/* step 2: convert proportional distances to screen coordinates */
- x = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask);
- y = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask);
+ x = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);
+ y = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask);
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
if (regionx) {
@@ -2035,8 +2038,8 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
*/
void UI_view2d_getscale(View2D *v2d, float *x, float *y)
{
- if (x) *x = BLI_RCT_SIZE_X(&v2d->mask) / BLI_RCT_SIZE_X(&v2d->cur);
- if (y) *y = BLI_RCT_SIZE_Y(&v2d->mask) / BLI_RCT_SIZE_Y(&v2d->cur);
+ if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
+ if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
}
/* Check if mouse is within scrollers
@@ -2142,7 +2145,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
const char *str = (const char *)(v2s + 1);
int xofs = 0, yofs;
- yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(&v2s->rect) - default_height));
+ yofs = ceil(0.5f * (BLI_rcti_size_y(&v2s->rect) - default_height));
if (yofs < 1) yofs = 1;
if (col_pack_prev != v2s->col.pack) {
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 99313edc289..3d3f309a8d4 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -119,10 +119,10 @@ static int view_pan_init(bContext *C, wmOperator *op)
vpd->ar = ar;
/* calculate translation factor - based on size of view */
- winx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1);
- winy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1);
- vpd->facx = (BLI_RCT_SIZE_X(&v2d->cur)) / winx;
- vpd->facy = (BLI_RCT_SIZE_Y(&v2d->cur)) / winy;
+ winx = (float)(BLI_rcti_size_x(&ar->winrct) + 1);
+ winy = (float)(BLI_rcti_size_y(&ar->winrct) + 1);
+ vpd->facx = (BLI_rctf_size_x(&v2d->cur)) / winx;
+ vpd->facy = (BLI_rctf_size_y(&v2d->cur)) / winy;
return 1;
}
@@ -471,7 +471,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
if (RNA_boolean_get(op->ptr, "page")) {
ARegion *ar = CTX_wm_region(C);
- RNA_int_set(op->ptr, "deltay", BLI_RCT_SIZE_Y(&ar->v2d.mask));
+ RNA_int_set(op->ptr, "deltay", BLI_rcti_size_y(&ar->v2d.mask));
}
/* apply movement, then we're done */
@@ -590,12 +590,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
facy = RNA_float_get(op->ptr, "zoomfacy");
if (facx >= 0.0f) {
- dx = BLI_RCT_SIZE_X(&v2d->cur) * facx;
- dy = BLI_RCT_SIZE_Y(&v2d->cur) * facy;
+ dx = BLI_rctf_size_x(&v2d->cur) * facx;
+ dy = BLI_rctf_size_y(&v2d->cur) * facy;
}
else {
- dx = (BLI_RCT_SIZE_X(&v2d->cur) / (1.0f + 2.0f * facx)) * facx;
- dy = (BLI_RCT_SIZE_Y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy;
+ dx = (BLI_rctf_size_x(&v2d->cur) / (1.0f + 2.0f * facx)) * facx;
+ dy = (BLI_rctf_size_y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy;
}
/* only resize view on an axis if change is allowed */
@@ -611,7 +611,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
+ float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dx) - (mval_faci * dx);
@@ -636,7 +636,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dy) - (mval_faci * dy);
@@ -845,7 +845,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
+ float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dx) - (mval_faci * dx);
@@ -864,7 +864,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dy) - (mval_faci * dy);
@@ -942,8 +942,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
* with magnify information that is stored in x axis
*/
fac = 0.01f * (event->x - event->prevx);
- dx = fac * BLI_RCT_SIZE_X(&v2d->cur) / 10.0f;
- dy = fac * BLI_RCT_SIZE_Y(&v2d->cur) / 10.0f;
+ dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f;
+ dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f;
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
@@ -1009,14 +1009,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
float dist;
/* x-axis transform */
- dist = BLI_RCT_SIZE_X(&v2d->mask) / 2.0f;
+ dist = BLI_rcti_size_x(&v2d->mask) / 2.0f;
dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f);
- dx *= 0.5f * BLI_RCT_SIZE_X(&v2d->cur);
+ dx *= 0.5f * BLI_rctf_size_x(&v2d->cur);
/* y-axis transform */
- dist = BLI_RCT_SIZE_Y(&v2d->mask) / 2.0f;
+ dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f);
- dy *= 0.5f * BLI_RCT_SIZE_Y(&v2d->cur);
+ dy *= 0.5f * BLI_rctf_size_y(&v2d->cur);
}
else {
/* 'continuous' or 'dolly' */
@@ -1024,11 +1024,11 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* x-axis transform */
fac = 0.01f * (event->x - vzd->lastx);
- dx = fac * BLI_RCT_SIZE_X(&v2d->cur);
+ dx = fac * BLI_rctf_size_x(&v2d->cur);
/* y-axis transform */
fac = 0.01f * (event->y - vzd->lasty);
- dy = fac * BLI_RCT_SIZE_Y(&v2d->cur);
+ dy = fac * BLI_rctf_size_y(&v2d->cur);
#if 0
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
@@ -1161,17 +1161,17 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
/* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
- size = BLI_RCT_SIZE_X(&cur_new);
- zoom = size / BLI_RCT_SIZE_X(&rect);
- center = BLI_RCT_CENTER_X(&cur_new);
+ size = BLI_rctf_size_x(&cur_new);
+ zoom = size / BLI_rctf_size_x(&rect);
+ center = BLI_rctf_cent_x(&cur_new);
cur_new.xmin = center - (size * zoom);
cur_new.xmax = center + (size * zoom);
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
- size = BLI_RCT_SIZE_Y(&cur_new);
- zoom = size / BLI_RCT_SIZE_Y(&rect);
- center = BLI_RCT_CENTER_Y(&cur_new);
+ size = BLI_rctf_size_y(&cur_new);
+ zoom = size / BLI_rctf_size_y(&rect);
+ center = BLI_rctf_cent_y(&cur_new);
cur_new.ymin = center - (size * zoom);
cur_new.ymax = center + (size * zoom);
@@ -1221,14 +1221,14 @@ struct SmoothView2DStore {
*/
static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
{
- float size_a[2] = {BLI_RCT_SIZE_X(rect_a),
- BLI_RCT_SIZE_Y(rect_a)};
- float size_b[2] = {BLI_RCT_SIZE_X(rect_b),
- BLI_RCT_SIZE_Y(rect_b)};
- float cent_a[2] = {BLI_RCT_CENTER_X(rect_a),
- BLI_RCT_CENTER_Y(rect_a)};
- float cent_b[2] = {BLI_RCT_CENTER_X(rect_b),
- BLI_RCT_CENTER_Y(rect_b)};
+ float size_a[2] = {BLI_rctf_size_x(rect_a),
+ BLI_rctf_size_y(rect_a)};
+ float size_b[2] = {BLI_rctf_size_x(rect_b),
+ BLI_rctf_size_y(rect_b)};
+ float cent_a[2] = {BLI_rctf_cent_x(rect_a),
+ BLI_rctf_cent_y(rect_a)};
+ float cent_b[2] = {BLI_rctf_cent_x(rect_b),
+ BLI_rctf_cent_y(rect_b)};
float fac_max = 0.0f;
float tfac;
@@ -1501,8 +1501,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
if (in_scroller == 'h') {
/* horizontal scroller - calculate adjustment factor first */
- mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor);
- vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size;
+ mask_size = (float)BLI_rcti_size_x(&v2d->hor);
+ vsm->fac = BLI_rctf_size_x(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
@@ -1517,8 +1517,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
else {
/* vertical scroller - calculate adjustment factor first */
- mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert);
- vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size;
+ mask_size = (float)BLI_rcti_size_y(&v2d->vert);
+ vsm->fac = BLI_rctf_size_y(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
@@ -1798,8 +1798,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
int winx, winy;
/* zoom 1.0 */
- winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
- winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
+ winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
+ winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
v2d->cur.xmax = v2d->cur.xmin + winx;
v2d->cur.ymax = v2d->cur.ymin + winy;
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 0e6b8f77528..0ec99325752 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -54,6 +54,8 @@
#include "../../collada/collada.h"
+#include "io_collada.h"
+
static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -121,32 +123,32 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
/* get editmode results */
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
- if (collada_export(
- CTX_data_scene(C),
- 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)) {
+ if (collada_export(CTX_data_scene(C),
+ 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)) {
return OPERATOR_FINISHED;
}
else {
+ BKE_report(op->reports, RPT_WARNING, "Export file not created.");
return OPERATOR_CANCELLED;
}
}
-void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
+static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
{
uiLayout *box, *row, *col, *split;
@@ -233,7 +235,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
ot->name = "Export COLLADA";
ot->description = "Save a Collada file";
ot->idname = "WM_OT_collada_export";
-
+
ot->invoke = wm_collada_export_invoke;
ot->exec = wm_collada_export_exec;
ot->poll = WM_operator_winactive;
@@ -241,7 +243,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
ot->flag |= OPTYPE_PRESET;
ot->ui = wm_collada_export_draw;
-
+
WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE,
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
@@ -296,7 +298,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
static int wm_collada_import_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
-
+
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
@@ -304,9 +306,9 @@ 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.");
-
+
return OPERATOR_FINISHED;
}
@@ -315,11 +317,11 @@ void WM_OT_collada_import(wmOperatorType *ot)
ot->name = "Import COLLADA";
ot->description = "Load a Collada file";
ot->idname = "WM_OT_collada_import";
-
+
ot->invoke = WM_operator_filesel;
ot->exec = wm_collada_import_exec;
ot->poll = WM_operator_winactive;
-
+
WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE,
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c
index d2b0ddd4e7e..f2a0532932d 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/io_ops.c
@@ -34,6 +34,8 @@
#include "WM_types.h"
#include "WM_api.h"
+#include "io_ops.h" /* own include */
+
void ED_operatortypes_io(void)
{
#ifdef WITH_COLLADA
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 7fe1ac09df6..a254a6a9278 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -64,7 +64,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
MaskLayer *masklay, *point_masklay;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
- float dist, co[2];
+ float dist = FLT_MAX, co[2];
int width, height;
float u;
float scalex, scaley;
@@ -125,7 +125,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
cur_dist = dist_to_line_segment_v2(co, a, b);
- if (point == NULL || cur_dist < dist) {
+ if (cur_dist < dist) {
if (tangent)
sub_v2_v2v2(tangent, &diff_points[2 * i + 2], &diff_points[2 * i]);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 655458bd4cb..fe6567424b6 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -520,12 +520,12 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
- /* w = BLI_RCT_SIZE_X(&v2d->tot); */
- /* h = BLI_RCT_SIZE_Y(&v2d->tot);/*/
+ /* w = BLI_rctf_size_x(&v2d->tot); */
+ /* h = BLI_rctf_size_y(&v2d->tot);/*/
- zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur));
- zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur));
+ zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / BLI_rctf_size_x(&ar->v2d.cur);
+ zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / BLI_rctf_size_y(&ar->v2d.cur);
if (do_scale_applied) {
zoomx /= width;
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index 6124947e3b9..561ad004a1d 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -48,6 +48,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
+#include "ED_mask.h" /* own include */
/* ***************************************** */
/* NOTE ABOUT THIS FILE:
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 94e10b53b29..a677f1272a3 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -533,8 +533,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
char *selar;
int a, index;
- int sx = BLI_RCT_SIZE_X(rect) + 1;
- int sy = BLI_RCT_SIZE_Y(rect) + 1;
+ int sx = BLI_rcti_size_x(rect) + 1;
+ int sy = BLI_rcti_size_y(rect) + 1;
me = BKE_mesh_from_object(ob);
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 8b032bb1a3d..fdaddec5246 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -55,9 +55,9 @@
/* ********* add primitive operators ************* */
-static void make_prim_init(bContext *C, const char *idname,
- float *dia, float mat[][4],
- int *state, const float loc[3], const float rot[3], const unsigned int layer)
+static Object *make_prim_init(bContext *C, const char *idname,
+ float *dia, float mat[][4],
+ int *state, const float loc[3], const float rot[3], const unsigned int layer)
{
Object *obedit = CTX_data_edit_object(C);
@@ -74,11 +74,12 @@ static void make_prim_init(bContext *C, const char *idname,
}
*dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
+
+ return obedit;
}
-static void make_prim_finish(bContext *C, int *state, int enter_editmode)
+static void make_prim_finish(bContext *C, Object *obedit, int *state, int enter_editmode)
{
- Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
/* Primitive has all verts selected, use vert select flush
@@ -104,9 +105,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -115,7 +114,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -148,9 +147,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) {
@@ -158,7 +155,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
}
/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -200,9 +197,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -213,7 +208,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -257,9 +252,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(
@@ -274,7 +267,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -320,9 +313,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(
@@ -334,7 +325,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -379,9 +370,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -393,7 +382,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -436,16 +425,14 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
if (!view_aligned)
rot[0] += (float)M_PI / 2.0f;
- make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) {
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -477,9 +464,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -490,7 +475,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -531,9 +516,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(
@@ -545,7 +528,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c
index 0b7d396b696..c249d764ac1 100644
--- a/source/blender/editors/mesh/editmesh_bvh.c
+++ b/source/blender/editors/mesh/editmesh_bvh.c
@@ -309,7 +309,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co
}
}
-BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist)
+BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], const float maxdist)
{
BVHTreeNearest hit;
@@ -325,7 +325,7 @@ BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist)
float dist, curdist = tree->maxdist, v[3];
int cur = 0, i;
- maxdist = tree->maxdist;
+ /* maxdist = tree->maxdist; */ /* UNUSED */
for (i = 0; i < 3; i++) {
sub_v3_v3v3(v, hit.co, ls[i]->v->co);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 7ecfb712c18..1dcbf574b44 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -29,7 +29,9 @@
* \ingroup edmesh
*/
-#define _USE_MATH_DEFINES
+#ifdef _MSC_VER
+# define _USE_MATH_DEFINES
+#endif
#include "MEM_guardedalloc.h"
@@ -222,7 +224,7 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd)
static void knife_project_v3(KnifeTool_OpData *kcd, const float co[3], float sco[3])
{
- ED_view3d_project_float_v3(kcd->ar, co, sco, kcd->projmat);
+ ED_view3d_project_float_v3_m4(kcd->ar, co, sco, kcd->projmat);
}
static void knife_pos_data_clear(KnifePosData *kpd)
@@ -1203,7 +1205,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,
}
knife_project_v3(kcd, p, sp);
- view3d_unproject(mats, view, sp[0], sp[1], 0.0f);
+ ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f);
mul_m4_v3(kcd->ob->imat, view);
if (kcd->cut_through) {
@@ -1386,7 +1388,7 @@ static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2],
mval[1] = (float)mval_i[1];
/* unproject to find view ray */
- view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f);
+ ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f);
if (kcd->is_ortho) {
negate_v3_v3(r_ray, kcd->vc.rv3d->viewinv[2]);
@@ -1753,6 +1755,9 @@ static int knife_update_active(KnifeTool_OpData *kcd)
return 1;
}
+#define SCANFILL_CUTS 0
+#if SCANFILL_CUTS
+
#define MARK 4
#define DEL 8
#define VERT_ON_EDGE 16
@@ -1761,9 +1766,6 @@ static int knife_update_active(KnifeTool_OpData *kcd)
#define BOUNDARY 128
#define FACE_NEW 256
-#define SCANFILL_CUTS 0
-#if SCANFILL_CUTS
-
typedef struct facenet_entry {
struct facenet_entry *next, *prev;
KnifeEdge *kfe;
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 60c5244ddbc..8b13cc61d3e 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -29,7 +29,9 @@
*/
#include <float.h>
-#define _USE_MATH_DEFINES
+#ifdef _MSC_VER
+# define _USE_MATH_DEFINES
+#endif
#include <math.h>
#include <string.h>
#include <ctype.h>
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 4d4a890300f..53b877f2a6e 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -61,8 +61,8 @@ static float edbm_rip_rip_edgedist(ARegion *ar, float mat[][4],
{
float vec1[3], vec2[3];
- ED_view3d_project_float_v2(ar, co1, vec1, mat);
- ED_view3d_project_float_v2(ar, co2, vec2, mat);
+ ED_view3d_project_float_v2_m4(ar, co1, vec1, mat);
+ ED_view3d_project_float_v2_m4(ar, co2, vec2, mat);
/* 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);
@@ -97,11 +97,11 @@ static float edbm_rip_edge_side_measure(BMEdge *e, BMLoop *e_l,
mid_v3_v3v3(cent, v1_other->co, v2_other->co);
mid_v3_v3v3(mid, e->v1->co, e->v2->co);
- ED_view3d_project_float_v2(ar, cent, cent, projectMat);
- ED_view3d_project_float_v2(ar, mid, mid, projectMat);
+ ED_view3d_project_float_v2_m4(ar, cent, cent, projectMat);
+ ED_view3d_project_float_v2_m4(ar, mid, mid, projectMat);
- ED_view3d_project_float_v2(ar, e->v1->co, e_v1_co, projectMat);
- ED_view3d_project_float_v2(ar, e->v2->co, e_v2_co, projectMat);
+ ED_view3d_project_float_v2_m4(ar, e->v1->co, e_v1_co, projectMat);
+ ED_view3d_project_float_v2_m4(ar, e->v2->co, e_v2_co, projectMat);
sub_v2_v2v2(vec, cent, mid);
normalize_v2(vec);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index de9b3c5ba05..f6ae661a369 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -487,7 +487,6 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int
vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]);
vec[1] = eed->v1->co[1] + labda * (eed->v2->co[1] - eed->v1->co[1]);
vec[2] = eed->v1->co[2] + labda * (eed->v2->co[2] - eed->v1->co[2]);
- mul_m4_v3(data->vc.obedit->obmat, vec);
if (ED_view3d_clipping_test(data->vc.rv3d, vec, TRUE) == 0) {
data->dist = distance;
@@ -531,7 +530,7 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, int *dist)
data.closest = NULL;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, 2);
+ mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, V3D_CLIP_TEST_REGION);
*dist = data.dist;
return data.closest;
@@ -1058,8 +1057,8 @@ 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);
- project_float_noclip(vc.ar, eed->v1->co, v1_co);
- project_float_noclip(vc.ar, eed->v2->co, v2_co);
+ ED_view3d_project_float_noclip(vc.ar, eed->v1->co, v1_co);
+ ED_view3d_project_float_noclip(vc.ar, eed->v2->co, v2_co);
#if 0
printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co),
len_squared_v2v2(mvalf, v2_co));
@@ -1087,7 +1086,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);
- project_float_noclip(vc.ar, cent, co);
+ ED_view3d_project_float_noclip(vc.ar, cent, co);
tdist = len_squared_v2v2(mvalf, co);
if (tdist < best_dist) {
/* printf("Best face: %p (%f)\n", f, tdist);*/
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c
index 86ea5bc8651..bd1d13f3528 100644
--- a/source/blender/editors/mesh/editmesh_slide.c
+++ b/source/blender/editors/mesh/editmesh_slide.c
@@ -388,10 +388,10 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2])
edge = vso->edge_frame[i];
mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co);
- project_float_noclip(vso->active_region, v1_proj, v1_proj);
+ ED_view3d_project_float_noclip(vso->active_region, v1_proj, v1_proj);
mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co);
- project_float_noclip(vso->active_region, v2_proj, v2_proj);
+ ED_view3d_project_float_noclip(vso->active_region, v2_proj, v2_proj);
dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
if (dist < min_dist) {
@@ -455,10 +455,10 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event)
/* Project points onto screen and do interpolation in 2D */
mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co);
- project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj);
+ ED_view3d_project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj);
mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co);
- project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj);
+ ED_view3d_project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj);
closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 9e83742a909..7c700cc9731 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -163,7 +163,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes
float mval[2], vec[3], no_dummy[3];
int dist_dummy;
mul_v3_m4v3(vec, obedit->obmat, eve->co);
- project_float_noclip(ar, vec, mval);
+ ED_view3d_project_float_noclip(ar, vec, mval);
if (snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) {
mul_v3_m4v3(eve->co, obedit->imat, vec);
}
@@ -761,8 +761,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
float co1[3], co2[3];
mul_v3_m4v3(co1, vc.obedit->obmat, eed->v1->co);
mul_v3_m4v3(co2, vc.obedit->obmat, eed->v2->co);
- project_float_noclip(vc.ar, co1, co1);
- project_float_noclip(vc.ar, co2, co2);
+ ED_view3d_project_float_noclip(vc.ar, co1, co1);
+ ED_view3d_project_float_noclip(vc.ar, co2, co2);
/* 2D rotate by 90d while adding.
* (x, y) = (y, -x)
@@ -2526,12 +2526,6 @@ void MESH_OT_solidify(wmOperatorType *ot)
RNA_def_property_ui_range(prop, -10, 10, 0.1, 4);
}
-#define TRAIL_POLYLINE 1 /* For future use, They don't do anything yet */
-#define TRAIL_FREEHAND 2
-#define TRAIL_MIXED 3 /* (1|2) */
-#define TRAIL_AUTO 4
-#define TRAIL_MIDPOINTS 8
-
typedef struct CutCurve {
float x;
float y;
@@ -2776,7 +2770,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
copy_v3_v3(co, bv->co);
co[3] = 1.0f;
mul_m4_v4(obedit->obmat, co);
- project_float(ar, co, scr);
+ ED_view3d_project_float(ar, co, scr);
BLI_ghash_insert(gh, bv, scr);
}
@@ -2858,9 +2852,6 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old)
{
Base *base_new;
- BMIter iter;
- BMVert *v;
- BMEdge *e;
Object *obedit = base_old->object;
BMesh *bm_new;
@@ -2886,15 +2877,10 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh
BMO_op_callf(bm_old, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES);
- /* deselect loose data - this used to get deleted */
- BM_ITER_MESH (e, &iter, bm_old, BM_EDGES_OF_MESH) {
- BM_edge_select_set(bm_old, e, FALSE);
- }
-
- /* clean up any loose verts */
- BM_ITER_MESH (v, &iter, bm_old, BM_VERTS_OF_MESH) {
- BM_vert_select_set(bm_old, v, FALSE);
- }
+ /* deselect loose data - this used to get deleted,
+ * we could de-select edges and verts only, but this turns out to be less complicated
+ * since de-selecting all skips selection flushing logic */
+ BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
BM_mesh_normals_update(bm_new, FALSE);
@@ -2908,7 +2894,10 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh
static int mesh_separate_selected(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old)
{
- /* tag -> select */
+ /* we may have tags from previous operators */
+ BM_mesh_elem_hflag_disable_all(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, FALSE);
+
+ /* sel -> tag */
BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, TRUE, BM_ELEM_SELECT);
return mesh_separate_tagged(bmain, scene, base_old, bm_old);
@@ -4721,7 +4710,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
mdiff[0] = opdata->mcenter[0] - event->mval[0];
mdiff[1] = opdata->mcenter[1] - event->mval[1];
- factor = -len_v2(mdiff) / opdata->initial_length + 1.0f;
+ factor = opdata->initial_length / -len_v2(mdiff) + 1.0f;
/* Fake shift-transform... */
if (event->shift) {
@@ -5085,9 +5074,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 + len_v2(mdiff) / opdata->initial_length - 1.0f;
+ amount = opdata->old_depth + opdata->initial_length / len_v2(mdiff) - 1.0f;
else
- amount = opdata->old_thickness - len_v2(mdiff) / opdata->initial_length + 1.0f;
+ amount = opdata->old_thickness - opdata->initial_length / len_v2(mdiff) + 1.0f;
/* Fake shift-transform... */
if (opdata->shift)
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 03e2f2691a8..b844ba0baa2 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -535,6 +535,16 @@ static void *getEditMesh(bContext *C)
typedef struct UndoMesh {
Mesh me;
int selectmode;
+
+ /** \note
+ * this isn't a prefect solution, if you edit keys and change shapes this works well (fixing [#32442]),
+ * but editing shape keys, going into object mode, removing or changing their order,
+ * then go back into editmode and undo will give issues - where the old index will be out of sync
+ * with the new object index.
+ *
+ * There are a few ways this could be made to work but for now its a known limitation with mixing
+ * object and editmode operations - Campbell */
+ int shapenr;
} UndoMesh;
/* undo simply makes copies of a bmesh */
@@ -546,13 +556,14 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata)
UndoMesh *um = MEM_callocN(sizeof(UndoMesh), "undo Mesh");
/* make sure shape keys work */
- um->me.key = obme->key ? copy_key_nolib(obme->key) : NULL;
+ um->me.key = obme->key ? BKE_key_copy_nolib(obme->key) : NULL;
/* BM_mesh_validate(em->bm); */ /* for troubleshooting */
BM_mesh_bm_to_me(em->bm, &um->me, FALSE);
um->selectmode = em->selectmode;
+ um->shapenr = em->bm->shapenr;
return um;
}
@@ -564,7 +575,7 @@ static void undoMesh_to_editbtMesh(void *umv, void *em_v, void *UNUSED(obdata))
UndoMesh *um = umv;
BMesh *bm;
- ob->shapenr = em->bm->shapenr;
+ ob->shapenr = em->bm->shapenr = um->shapenr;
EDBM_mesh_free(em);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 09d89a961e4..a52c8d47ecd 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -47,6 +47,8 @@
#include "BLI_array.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
+#include "BLI_linklist.h"
+#include "BLI_listbase.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
@@ -74,6 +76,64 @@
#include "mesh_intern.h"
+static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
+{
+ CustomData *data;
+ BMesh *bm = (me->edit_btmesh) ? me->edit_btmesh->bm : NULL;
+ int tot;
+
+ /* this */
+ switch (htype) {
+ case BM_VERT:
+ if (bm) {
+ data = &bm->vdata;
+ tot = bm->totvert;
+ }
+ else {
+ data = &me->vdata;
+ tot = me->totvert;
+ }
+ break;
+ case BM_EDGE:
+ if (bm) {
+ data = &bm->edata;
+ tot = bm->totedge;
+ }
+ else {
+ data = &me->edata;
+ tot = me->totedge;
+ }
+ break;
+ case BM_LOOP:
+ if (bm) {
+ data = &bm->ldata;
+ tot = bm->totloop;
+ }
+ else {
+ data = &me->ldata;
+ tot = me->totloop;
+ }
+ break;
+ case BM_FACE:
+ if (bm) {
+ data = &bm->pdata;
+ tot = bm->totface;
+ }
+ else {
+ data = &me->pdata;
+ tot = me->totpoly;
+ }
+ break;
+ default:
+ BLI_assert(0);
+ tot = 0;
+ data = NULL;
+ }
+
+ *r_tot = tot;
+ return data;
+}
+
#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data)
static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer)
{
@@ -85,24 +145,10 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
int i, actindex, rndindex, cloneindex, stencilindex, tot;
if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
- if (me->edit_btmesh) {
- data = &me->edit_btmesh->bm->ldata;
- tot = me->edit_btmesh->bm->totloop;
- }
- else {
- data = &me->ldata;
- tot = me->totloop;
- }
+ data = mesh_customdata_get_type(me, BM_LOOP, &tot);
}
else {
- if (me->edit_btmesh) {
- data = &me->edit_btmesh->bm->pdata;
- tot = me->edit_btmesh->bm->totface;
- }
- else {
- data = &me->pdata;
- tot = me->totpoly;
- }
+ data = mesh_customdata_get_type(me, BM_FACE, &tot);
}
index = CustomData_get_layer_index(data, type);
@@ -701,22 +747,20 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/*********************** sticky operators ************************/
+/* *** CustomData clear functions, we need an operator for each *** */
-static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
+static int mesh_customdata_clear_exec__internal(bContext *C,
+ char htype, int type)
{
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- Object *ob = ED_object_context(C);
- Mesh *me = ob->data;
+ Object *obedit = ED_object_context(C);
+ Mesh *me = obedit->data;
- /* why is this commented out? */
-#if 0
- if (me->msticky)
- return OPERATOR_CANCELLED;
-#endif
+ int tot;
+ CustomData *data = mesh_customdata_get_type(me, htype, &tot);
- RE_make_sticky(scene, v3d);
+ BLI_assert(CustomData_layertype_is_singleton(type) == TRUE);
+
+ CustomData_free_layers(data, type, tot);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
@@ -724,48 +768,79 @@ static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-void MESH_OT_sticky_add(wmOperatorType *ot)
+/* Clear Mask */
+static int mesh_customdata_clear_mask_poll(bContext *C)
+{
+ Object *ob = ED_object_context(C);
+ if (ob && ob->type == OB_MESH) {
+ Mesh *me = ob->data;
+
+ /* special case - can't run this if we're in sculpt mode */
+ if (ob->mode & OB_MODE_SCULPT) {
+ return FALSE;
+ }
+
+ if (me->id.lib == NULL) {
+ CustomData *data = GET_CD_DATA(me, vdata);
+ if (CustomData_has_layer(data, CD_PAINT_MASK)) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_PAINT_MASK);
+}
+
+void MESH_OT_customdata_clear_mask(wmOperatorType *ot)
{
+
/* identifiers */
- ot->name = "Add Sticky";
- ot->description = "Add sticky UV texture layer";
- ot->idname = "MESH_OT_sticky_add";
-
+ ot->name = "Clear Sculpt-Mask Data";
+ ot->idname = "MESH_OT_customdata_clear_mask";
+ ot->description = "Clear vertex sculpt masking data from the mesh";
+
/* api callbacks */
- ot->poll = layers_poll;
- ot->exec = mesh_sticky_add_exec;
+ ot->exec = mesh_customdata_clear_mask_exec;
+ ot->poll = mesh_customdata_clear_mask_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
+/* Clear Skin */
+static int mesh_customdata_clear_skin_poll(bContext *C)
{
Object *ob = ED_object_context(C);
- Mesh *me = ob->data;
- if (!me->msticky)
- return OPERATOR_CANCELLED;
-
- CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
- me->msticky = NULL;
-
- DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
-
- return OPERATOR_FINISHED;
+ if (ob && ob->type == OB_MESH) {
+ Mesh *me = ob->data;
+ if (me->id.lib == NULL) {
+ CustomData *data = GET_CD_DATA(me, vdata);
+ if (CustomData_has_layer(data, CD_MVERT_SKIN)) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN);
}
-void MESH_OT_sticky_remove(wmOperatorType *ot)
+void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Sticky";
- ot->description = "Remove sticky UV texture layer";
- ot->idname = "MESH_OT_sticky_remove";
-
+ ot->name = "Clear Skin Data";
+ ot->idname = "MESH_OT_customdata_clear_skin";
+ ot->description = "Clear vertex skin layer";
+
/* api callbacks */
- ot->poll = layers_poll;
- ot->exec = mesh_sticky_remove_exec;
+ ot->exec = mesh_customdata_clear_skin_exec;
+ ot->poll = mesh_customdata_clear_skin_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index aed57141c2a..b68c1836992 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -189,8 +189,10 @@ void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
-void MESH_OT_sticky_add(struct wmOperatorType *ot);
-void MESH_OT_sticky_remove(struct wmOperatorType *ot);
+/* no create_mask yet */
+void MESH_OT_customdata_clear_mask(struct wmOperatorType *ot);
+void MESH_OT_customdata_clear_skin(struct wmOperatorType *ot);
+
void MESH_OT_drop_named_image(struct wmOperatorType *ot);
/* ************* bmesh_tools.c ***********/
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 7f73851f2a8..ccf91958e08 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -136,7 +136,6 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_vertices_smooth);
WM_operatortype_append(MESH_OT_noise);
WM_operatortype_append(MESH_OT_flip_normals);
- //WM_operatortype_append(MESH_OT_knife_cut);
WM_operatortype_append(MESH_OT_rip);
WM_operatortype_append(MESH_OT_blend_from_shape);
WM_operatortype_append(MESH_OT_shape_propagate_to_all);
@@ -145,8 +144,8 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_uv_texture_remove);
WM_operatortype_append(MESH_OT_vertex_color_add);
WM_operatortype_append(MESH_OT_vertex_color_remove);
- WM_operatortype_append(MESH_OT_sticky_add);
- WM_operatortype_append(MESH_OT_sticky_remove);
+ WM_operatortype_append(MESH_OT_customdata_clear_mask);
+ WM_operatortype_append(MESH_OT_customdata_clear_skin);
WM_operatortype_append(MESH_OT_drop_named_image);
WM_operatortype_append(MESH_OT_edgering_select);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index a7467ee4c79..f2b7a2e9c22 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -104,7 +104,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
MLoop *mloop = NULL;
Key *key, *nkey = NULL;
KeyBlock *kb, *okb, *kbn;
- float imat[4][4], cmat[4][4], *fp1, *fp2, curpos;
+ float imat[4][4], cmat[4][4], *fp1, *fp2;
int a, b, totcol, totmat = 0, totedge = 0, totvert = 0, ok = 0;
int totloop = 0, totpoly = 0, vertofs, *matmap = NULL;
int i, j, index, haskey = 0, edgeofs, loopofs, polyofs;
@@ -196,7 +196,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
else if (haskey) {
/* add a new key-block and add to the mesh */
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
}
@@ -243,29 +243,29 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* if this mesh has shapekeys, check if destination mesh already has matching entries too */
if (me->key && key) {
- for (kb = me->key->block.first; kb; kb = kb->next) {
+ /* for remapping KeyBlock.relative */
+ int *index_map = MEM_mallocN(sizeof(int) * me->key->totkey, __func__);
+ KeyBlock **kb_map = MEM_mallocN(sizeof(KeyBlock *) * me->key->totkey, __func__);
+
+ for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) {
+ BLI_assert(i < me->key->totkey);
+
+ kbn = BKE_keyblock_find_name(key, kb->name);
/* if key doesn't exist in destination mesh, add it */
- if (key_get_named_keyblock(key, kb->name) == NULL) {
- /* copy this existing one over to the new shapekey block */
- kbn = MEM_dupallocN(kb);
- kbn->prev = kbn->next = NULL;
-
+ if (kbn) {
+ index_map[i] = BLI_findindex(&key->block, kbn);
+ }
+ else {
+ index_map[i] = key->totkey;
+
+ kbn = BKE_keyblock_add(key, kb->name);
+
+ BKE_keyblock_copy_settings(kbn, kb);
+
/* adjust settings to fit (allocate a new data-array) */
kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
- kbn->totelem = totvert;
- kbn->weights = NULL;
-
- okb = key->block.last;
- curpos = (okb) ? okb->pos : -0.1f;
- if (key->type == KEY_RELATIVE)
- kbn->pos = curpos + 0.1f;
- else
- kbn->pos = curpos;
-
- BLI_addtail(&key->block, kbn);
- key->totkey++;
- if (key->totkey == 1) key->refkey = kbn;
-
+ kbn->totelem = totvert;
+
/* XXX 2.5 Animato */
#if 0
/* also, copy corresponding ipo-curve to ipo-block if applicable */
@@ -275,13 +275,26 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
#endif
}
+
+ kb_map[i] = kbn;
}
+
+ /* remap relative index values */
+ for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) {
+ if (LIKELY(kb->relative < me->key->totkey)) { /* sanity check, should always be true */
+ kb_map[i]->relative = index_map[kb->relative];
+ }
+ }
+
+ MEM_freeN(index_map);
+ MEM_freeN(kb_map);
}
}
}
}
CTX_DATA_END;
-
+
+
/* setup new data for destination mesh */
memset(&vdata, 0, sizeof(vdata));
memset(&edata, 0, sizeof(edata));
@@ -356,7 +369,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
fp1 = ((float *)kb->data) + (vertofs * 3);
/* check if this mesh has such a shapekey */
- okb = key_get_named_keyblock(me->key, kb->name);
+ okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : NULL;
+
if (okb) {
/* copy this mesh's shapekey to the destination shapekey (need to transform first) */
fp2 = ((float *)(okb->data));
@@ -386,7 +400,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
fp1 = ((float *)kb->data) + (vertofs * 3);
/* check if this was one of the original shapekeys */
- okb = key_get_named_keyblock(nkey, kb->name);
+ okb = BKE_keyblock_find_name(nkey, kb->name);
if (okb) {
/* copy this mesh's shapekey to the destination shapekey */
fp2 = ((float *)(okb->data));
@@ -427,8 +441,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
if ((mmd = get_multires_modifier(scene, base->object, TRUE))) {
ED_object_iter_other(bmain, base->object, TRUE,
- ED_object_multires_update_totlevels_cb,
- &mmd->totlvl);
+ ED_object_multires_update_totlevels_cb,
+ &mmd->totlvl);
}
}
@@ -548,6 +562,12 @@ int join_mesh_exec(bContext *C, wmOperator *op)
MEM_freeN(nkey);
}
+ /* ensure newly inserted keys are time sorted */
+ if (key && (key->type != KEY_RELATIVE)) {
+ BKE_key_sort(key);
+ }
+
+
DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call
#if 0
@@ -607,12 +627,12 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
if (key == NULL) {
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
/* first key added, so it was the basis. initialize it with the existing mesh */
- kb = add_keyblock(key, NULL);
- mesh_to_key(me, kb);
+ kb = BKE_keyblock_add(key, NULL);
+ BKE_key_convert_from_mesh(me, kb);
}
/* now ready to add new keys from selected meshes */
@@ -628,7 +648,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
if (!dm) continue;
- kb = add_keyblock(key, base->object->id.name + 2);
+ kb = BKE_keyblock_add(key, base->object->id.name + 2);
DM_to_meshkey(dm, me, kb);
@@ -709,9 +729,9 @@ static void mesh_octree_add_nodes(MocNode **basetable, const float co[3], const
float fx, fy, fz;
int vx, vy, vz;
- if (!finite(co[0]) ||
- !finite(co[1]) ||
- !finite(co[2]))
+ if ((finite(co[0]) == FALSE) ||
+ (finite(co[1]) == FALSE) ||
+ (finite(co[2]) == FALSE))
{
return;
}
@@ -940,9 +960,9 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
intptr_t poinval;
/* ignore nan verts */
- if (!finite(co[0]) ||
- !finite(co[1]) ||
- !finite(co[2]))
+ if ((finite(co[0]) == FALSE) ||
+ (finite(co[1]) == FALSE) ||
+ (finite(co[2]) == FALSE))
{
return NULL;
}
@@ -1217,7 +1237,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);
- project_float_noclip(ar, co, sco);
+ ED_view3d_project_float_noclip(ar, co, sco);
len = len_squared_v2v2(mval_f, sco);
if (len < len_best) {
len_best = len;
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 50d5569c483..22ccd7bbed8 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -98,9 +98,8 @@ void load_editMball(Object *UNUSED(obedit))
}
/* Add metaelem primitive to metaball object (which is in edit mode) */
-MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname))
+MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[4][4], int type, int UNUSED(newname))
{
- Object *obedit = CTX_data_edit_object(C);
MetaBall *mball = (MetaBall *)obedit->data;
MetaElem *ml;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index d90735ca5ac..4942b9e4390 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -198,7 +198,7 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
/********************* Add Object Operator ********************/
-void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr)
+static void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr)
{
RNA_struct_idprops_unset(ptr, "rotation");
}
@@ -439,7 +439,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
((Curve *)ob->data)->flag |= CU_PATH | CU_3D;
ED_object_enter_editmode(C, 0);
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
- BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_PATH, 1));
+ 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);
@@ -574,7 +574,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
- /* elem= (MetaElem *) */ add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob);
+ /* elem= (MetaElem *) */ add_metaball_primitive(C, obedit, mat, RNA_enum_get(op->ptr, "type"), newob);
/* userdef */
if (newob && !enter_editmode) {
@@ -1826,7 +1826,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
/* check if obdata is copied */
if (didit) {
- Key *key = ob_get_key(obn);
+ Key *key = BKE_key_from_object(obn);
if (dupflag & USER_DUP_ACT) {
bActuator *act;
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index f9b73a56403..0ea2f78a415 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -69,6 +69,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "GPU_draw.h" /* GPU_free_image */
@@ -685,7 +686,7 @@ static void apply_heights_data(void *bake_data)
}
}
- ibuf->userflags = IB_RECT_INVALID;
+ ibuf->userflags = IB_RECT_INVALID | IB_DISPLAY_BUFFER_INVALID;
}
static void free_heights_data(void *bake_data)
@@ -769,6 +770,8 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
char *rrgb = (char *)ibuf->rect + pixel * 4;
rrgb[3] = 255;
}
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
/* MultiresBake callback for normals' baking
@@ -826,6 +829,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
rgb_float_to_uchar(rrgb, vec);
rrgb[3] = 255;
}
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
static void count_images(MultiresBakeRender *bkr)
@@ -895,7 +900,7 @@ static void finish_images(MultiresBakeRender *bkr)
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
- ibuf->userflags |= IB_BITMAPDIRTY;
+ ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;;
if (ibuf->rect_float)
ibuf->userflags |= IB_RECT_INVALID;
@@ -1324,11 +1329,12 @@ static int test_bake_internal(bContext *C, ReportList *reports)
static void init_bake_internal(BakeRender *bkr, bContext *C)
{
Scene *scene = CTX_data_scene(C);
+ bScreen *sc = CTX_wm_screen(C);
/* get editmode results */
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
- bkr->sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */
+ bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */
bkr->main = CTX_data_main(C);
bkr->scene = scene;
bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL;
@@ -1369,6 +1375,7 @@ static void finish_bake_internal(BakeRender *bkr)
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);
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index aa885320b37..f95a186990e 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -649,11 +649,11 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
for (base = FIRSTBASE; base; base = base->next) {
if ((base != BASACT) && (TESTBASELIB(v3d, base))) {
if (nr == 1) { /* replace */
- copy_properties(&base->object->prop, &ob->prop);
+ BKE_bproperty_copy_list(&base->object->prop, &ob->prop);
}
else {
for (prop = ob->prop.first; prop; prop = prop->next) {
- set_ob_property(base->object, prop);
+ BKE_bproperty_object_set(base->object, prop);
}
}
}
@@ -665,7 +665,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
if (prop) {
for (base = FIRSTBASE; base; base = base->next) {
if ((base != BASACT) && (TESTBASELIB(v3d, base))) {
- set_ob_property(base->object, prop);
+ BKE_bproperty_object_set(base->object, prop);
}
}
}
@@ -1585,7 +1585,7 @@ static int game_property_new(bContext *C, wmOperator *op)
char name[MAX_NAME];
int type = RNA_enum_get(op->ptr, "type");
- prop = new_property(type);
+ prop = BKE_bproperty_new(type);
BLI_addtail(&ob->prop, prop);
RNA_string_get(op->ptr, "name", name);
@@ -1593,7 +1593,7 @@ static int game_property_new(bContext *C, wmOperator *op)
BLI_strncpy(prop->name, name, sizeof(prop->name));
}
- unique_property(NULL, prop, 0); // make_unique_prop_names(prop->name);
+ BKE_bproperty_unique(NULL, prop, 0); // make_unique_prop_names(prop->name);
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
@@ -1631,7 +1631,7 @@ static int game_property_remove(bContext *C, wmOperator *op)
if (prop) {
BLI_remlink(&ob->prop, prop);
- free_property(prop);
+ BKE_bproperty_free(prop);
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
@@ -1711,7 +1711,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
{
if (ob != ob_iter)
- set_ob_property(ob_iter, prop);
+ BKE_bproperty_object_set(ob_iter, prop);
} CTX_DATA_END;
}
}
@@ -1721,12 +1721,12 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
{
if (ob != ob_iter) {
if (type == COPY_PROPERTIES_REPLACE) {
- copy_properties(&ob_iter->prop, &ob->prop);
+ BKE_bproperty_copy_list(&ob_iter->prop, &ob->prop);
}
else {
/* merge - the default when calling with no argument */
for (prop = ob->prop.first; prop; prop = prop->next) {
- set_ob_property(ob_iter, prop);
+ BKE_bproperty_object_set(ob_iter, prop);
}
}
}
@@ -1763,7 +1763,7 @@ static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
{
- free_properties(&ob_iter->prop);
+ BKE_bproperty_free_list(&ob_iter->prop);
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 7c8386d55dc..a6afe6b2d04 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -585,13 +585,11 @@ void OBJECT_OT_hook_add_newobj(wmOperatorType *ot)
static int object_hook_remove_exec(bContext *C, wmOperator *op)
{
int num = RNA_enum_get(op->ptr, "modifier");
- Object *ob = NULL;
+ Object *ob = CTX_data_edit_object(C);
HookModifierData *hmd = NULL;
- ob = CTX_data_edit_object(C);
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
-
- if (!ob || !hmd) {
+ if (!hmd) {
BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 89f9f5de311..1f7be0bf9a6 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -92,9 +92,9 @@ void make_editLatt(Object *obedit)
free_editLatt(obedit);
- actkey = ob_get_keyblock(obedit);
+ actkey = BKE_keyblock_from_object(obedit);
if (actkey)
- key_to_latt(actkey, lt);
+ BKE_key_convert_to_lattice(actkey, lt);
lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt");
lt->editlatt->latt = MEM_dupallocN(lt);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 4858fdf1c35..6fe7ad05a70 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -565,15 +565,15 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
}
if (key == NULL) {
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
/* if that was the first key block added, then it was the basis.
* Initialize it with the mesh, and add another for the modifier */
- kb = add_keyblock(key, NULL);
- mesh_to_key(me, kb);
+ kb = BKE_keyblock_add(key, NULL);
+ BKE_key_convert_from_mesh(me, kb);
}
- kb = add_keyblock(key, md->name);
+ kb = BKE_keyblock_add(key, md->name);
DM_to_meshkey(dm, me, kb);
dm->release(dm);
@@ -1692,11 +1692,9 @@ static void skin_armature_bone_create(Object *skin_ob,
v = (e->v1 == parent_v ? e->v2 : e->v1);
- bone = MEM_callocN(sizeof(EditBone),
- "skin_armature_bone_create EditBone");
+ bone = ED_armature_edit_bone_add(arm, "Bone");
bone->parent = parent_bone;
- bone->layer = 1;
bone->flag |= BONE_CONNECTED;
copy_v3_v3(bone->head, mvert[parent_v].co);
@@ -1704,8 +1702,6 @@ static void skin_armature_bone_create(Object *skin_ob,
bone->rad_head = bone->rad_tail = 0.25;
BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx);
- BLI_addtail(arm->edbo, bone);
-
/* add bDeformGroup */
if ((dg = ED_vgroup_add_name(skin_ob, bone->name))) {
ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE);
@@ -1770,16 +1766,13 @@ static Object *modifier_skin_armature_create(struct Scene *scene,
* a fake root bone (have it going off in the Y direction
* (arbitrary) */
if (emap[v].count > 1) {
- bone = MEM_callocN(sizeof(EditBone), "EditBone");
+ bone = ED_armature_edit_bone_add(arm, "Bone");
copy_v3_v3(bone->head, me->mvert[v].co);
copy_v3_v3(bone->tail, me->mvert[v].co);
- bone->layer = 1;
bone->head[1] = 1.0f;
bone->rad_head = bone->rad_tail = 0.25;
-
- BLI_addtail(arm->edbo, bone);
}
if (emap[v].count >= 1) {
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 7eb8cc01db9..ff7f33f6107 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -723,7 +723,7 @@ static short objects_share_gameprop(Object *a, Object *b)
/*make a copy of all its properties*/
for (prop = a->prop.first; prop; prop = prop->next) {
- if (get_ob_property(b, prop->name) )
+ if (BKE_bproperty_object_get(b, prop->name) )
return 1;
}
return 0;
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 40b653a62fd..cfd4945688b 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -78,7 +78,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int f
{
KeyBlock *kb;
if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) {
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
/* for absolute shape keys, new keys may not be added last */
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
@@ -95,7 +95,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
Key *key;
//IpoCurve *icu;
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key == NULL)
return 0;
@@ -115,14 +115,14 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
/* apply new basis key on original data */
switch (ob->type) {
case OB_MESH:
- key_to_mesh(key->refkey, ob->data);
+ BKE_key_convert_to_mesh(key->refkey, ob->data);
break;
case OB_CURVE:
case OB_SURF:
- key_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data));
+ BKE_key_convert_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data));
break;
case OB_LATTICE:
- key_to_latt(key->refkey, ob->data);
+ BKE_key_convert_to_lattice(key->refkey, ob->data);
break;
}
}
@@ -155,7 +155,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob)
KeyBlock *kb;
Key *key;
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key == NULL)
return 0;
@@ -323,8 +323,8 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
if (!key || !kb)
return OPERATOR_CANCELLED;
@@ -357,8 +357,8 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float cfra = 0.0f;
if (!key || !kb)
@@ -419,7 +419,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_context(C);
int type = RNA_enum_get(op->ptr, "type");
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb, *kb_other;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index b7ce32aa10a..72bbcda2b5e 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -409,7 +409,7 @@ static int key_test_depth(PEData *data, const float co[3])
if ((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0)
return 1;
- project_short(data->vc.ar, co, wco);
+ ED_view3d_project_short(data->vc.ar, co, wco);
if (wco[0] == IS_CLIPPED)
return 0;
@@ -447,7 +447,7 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float *
float dx, dy, dist;
int sco[2];
- project_int(data->vc.ar, co, sco);
+ ED_view3d_project_int(data->vc.ar, co, sco);
if (sco[0] == IS_CLIPPED)
return 0;
@@ -473,7 +473,7 @@ static int key_inside_rect(PEData *data, const float co[3])
{
int sco[2];
- project_int(data->vc.ar, co, sco);
+ ED_view3d_project_int(data->vc.ar, co, sco);
if (sco[0] == IS_CLIPPED)
return 0;
@@ -1666,7 +1666,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
LOOP_KEYS {
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- project_int(ar, co, vertco);
+ ED_view3d_project_int(ar, co, vertco);
if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
key_test_depth(&data, co))
{
@@ -1686,7 +1686,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- project_int(ar, co, vertco);
+ ED_view3d_project_int(ar, co, vertco);
if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
key_test_depth(&data, co))
{
@@ -2802,7 +2802,7 @@ static void brush_cut(PEData *data, int pa_index)
cut=0;
- project_int_noclip(ar, key->co, vertco);
+ ED_view3d_project_int_noclip(ar, key->co, vertco);
x0= (float)vertco[0];
x1= (float)vertco[1];
@@ -2820,7 +2820,7 @@ static void brush_cut(PEData *data, int pa_index)
else {
/* calculate path time closest to root that was inside the circle */
for (k=1, key++; k<=keys; k++, key++) {
- project_int_noclip(ar, key->co, vertco);
+ ED_view3d_project_int_noclip(ar, key->co, vertco);
if (key_test_depth(data, key->co) == 0) {
x0= (float)vertco[0];
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index f95b07bd71e..099d868a0ad 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -782,7 +782,7 @@ static void fluidbake_endjob(void *customdata)
}
}
-int runSimulationCallback(void *data, int status, int frame)
+static int runSimulationCallback(void *data, int status, int frame)
{
FluidBakeJob *fb = (FluidBakeJob *)data;
elbeemSimulationSettings *settings = fb->settings;
@@ -1095,7 +1095,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
return 1;
}
-void fluidsimFreeBake(Object *UNUSED(ob))
+static void UNUSED_FUNCTION(fluidsimFreeBake)(Object *UNUSED(ob))
{
/* not implemented yet */
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index b236b555850..c08ea2b6429 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -61,6 +61,7 @@
#include "ED_object.h"
#include "RE_pipeline.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -78,8 +79,8 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
{
float *rectf = NULL;
int ymin, ymax, xmin, xmax;
- int rymin, rxmin, predivide, profile_from;
- unsigned char *rectc;
+ int rymin, rxmin;
+ /* unsigned char *rectc; */ /* UNUSED */
/* if renrect argument, we only refresh scanlines */
if (renrect) {
@@ -123,8 +124,14 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
if (rr->rectf)
rectf = rr->rectf;
else {
- if (rr->rect32)
+ if (rr->rect32) {
+ /* special case, currently only happens with sequencer rendering,
+ * which updates the whole frame, so we can only mark display buffer
+ * as invalid here (sergey)
+ */
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
return;
+ }
else {
if (rr->renlay == NULL || rr->renlay->rectf == NULL) return;
rectf = rr->renlay->rectf;
@@ -136,20 +143,11 @@ 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);
-
- if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
- profile_from = IB_PROFILE_LINEAR_RGB;
- predivide = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
- }
- else {
- profile_from = IB_PROFILE_SRGB;
- predivide = 0;
- }
+ /* rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin); */ /* UNUSED */
- IMB_buffer_byte_from_float(rectc, rectf,
- 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
- xmax, ymax, ibuf->x, rr->rectx);
+ IMB_partial_display_buffer_update(ibuf, rectf, NULL, rr->rectx, rxmin, rymin,
+ &scene->view_settings, &scene->display_settings,
+ rxmin, rymin, rxmin + xmax, rymin + ymax);
}
/* ****************************** render invoking ***************** */
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 55df1caf3eb..d9618e89b68 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -63,6 +63,7 @@
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -143,22 +144,30 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
ibuf = BKE_sequencer_give_ibuf(context, CFRA, chanshown);
if (ibuf) {
+ ImBuf *linear_ibuf;
+
BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == ibuf->y));
- if (ibuf->rect_float == NULL) {
- /* internally sequencer working in sRGB space and stores both bytes and float
- * buffers in sRGB space, but if byte->float onversion doesn't happen in sequencer
- * (e.g. when adding image sequence/movie into sequencer) there'll be only
- * byte buffer and profile will still indicate sRGB->linear space conversion is needed
- * here we're ensure there'll be no conversion happen and float buffer would store
- * linear frame (sergey) */
- ibuf->profile = IB_PROFILE_NONE;
- IMB_float_from_rect(ibuf);
+ linear_ibuf = IMB_dupImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
+
+ if (linear_ibuf->rect_float == NULL) {
+ /* internally sequencer working in display space and stores both bytes and float buffers in that space.
+ * It is possible that byte->float onversion didn't happen in sequencer (e.g. when adding image sequence/movie
+ * into sequencer) there'll be only byte buffer. Create float buffer from existing byte buffer, making it linear
+ */
+
+ IMB_float_from_rect(linear_ibuf);
+ }
+ else {
+ /* ensure float buffer is in linear space, not in display space */
+ BKE_sequencer_imbuf_from_sequencer_space(scene, linear_ibuf);
}
- memcpy(rr->rectf, ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
- IMB_freeImBuf(ibuf);
+ memcpy(rr->rectf, linear_ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
+
+ IMB_freeImBuf(linear_ibuf);
}
}
else if (view_context) {
@@ -181,7 +190,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
if ((scene->r.mode & R_OSA) == 0) {
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf);
}
else {
@@ -195,7 +204,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
BLI_jitter_init(jit_ofs[0], scene->r.osa);
/* first sample buffer, also initializes 'rv3d->persmat' */
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_buffer);
/* skip the first sample */
@@ -205,7 +214,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
(jit_ofs[j][0] * 2.0f) / sizex,
(jit_ofs[j][1] * 2.0f) / sizey);
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_tmp);
add_vn_vn(accum_buffer, accum_tmp, sizex * sizey * sizeof(float));
}
@@ -221,7 +230,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
else {
/* shouldnt suddenly give errors mid-render but possible */
char err_out[256] = "unknown";
- ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, err_out);
+ ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, FALSE, err_out);
camera = scene->camera;
if (ibuf_view) {
@@ -233,27 +242,27 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
}
- /* rr->rectf is now filled with image data */
-
- if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
- BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
-
/* note on color management:
*
* OpenGL renders into sRGB colors, but render buffers are expected to be
- * linear if color management is enabled. So we convert to linear here, so
- * the conversion back to bytes using the color management flag can make it
- * sRGB again, and so that e.g. openexr saving also saves the correct linear
- * float buffer. */
+ * linear So we convert to linear here, so the conversion back to bytes can make it
+ * sRGB (or other display space) again, and so that e.g. openexr saving also saves the
+ * correct linear float buffer.
+ */
- if (oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
- int predivide = 0; /* no alpha */
+ if (!oglrender->is_sequencer) {
+ /* sequencer has got tricker ocnversion happened above */
IMB_buffer_float_from_float(rr->rectf, rr->rectf,
- 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide,
+ 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, FALSE,
oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
}
+ /* rr->rectf is now filled with image data */
+
+ if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
+ BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
+
RE_ReleaseResult(oglrender->re);
/* update byte from float buffer */
@@ -536,12 +545,28 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
if (ibuf) {
+ int needs_free = FALSE;
+
+ if (is_movie || !BKE_imtype_supports_float(scene->r.im_format.imtype)) {
+ ImBuf *colormanage_ibuf = IMB_dupImBuf(ibuf);
+
+ IMB_display_buffer_to_imbuf_rect(colormanage_ibuf, &scene->view_settings, &scene->display_settings);
+ imb_freerectfloatImBuf(colormanage_ibuf);
+
+ // IMB_freeImBuf(ibuf); /* owned by the image */
+ ibuf = colormanage_ibuf;
+ needs_free = TRUE;
+ }
+
/* color -> grayscale */
/* editing directly would alter the render view */
if (scene->r.im_format.planes == R_IMF_PLANES_BW) {
- ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
+ ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
IMB_color_to_bw(ibuf_bw);
- // IMB_freeImBuf(ibuf); /* owned by the image */
+
+ if (needs_free)
+ IMB_freeImBuf(ibuf);
+
ibuf = ibuf_bw;
}
else {
@@ -551,6 +576,13 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
ibuf_cpy->rect = ibuf->rect;
ibuf_cpy->rect_float = ibuf->rect_float;
ibuf_cpy->zbuf_float = ibuf->zbuf_float;
+
+ if (needs_free) {
+ ibuf_cpy->mall = ibuf->mall;
+ ibuf->mall = 0;
+ IMB_freeImBuf(ibuf);
+ }
+
ibuf = ibuf_cpy;
}
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 068a7aaa50a..6b6018e51d2 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -64,6 +64,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
+#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -75,11 +76,13 @@
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_object.h"
+#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_world.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -115,7 +118,8 @@ ImBuf *get_brush_icon(Brush *brush)
BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
BLI_path_abs(path, G.main->name);
- brush->icon_imbuf = IMB_loadiffname(path, flags);
+ /* use default colorspaces for brushes */
+ brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
// otherwise lets try to find it in other directories
if (!(brush->icon_imbuf)) {
@@ -123,8 +127,10 @@ ImBuf *get_brush_icon(Brush *brush)
BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
- if (path[0])
- brush->icon_imbuf = IMB_loadiffname(path, flags);
+ if (path[0]) {
+ /* use fefault color spaces */
+ brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
+ }
}
if (brush->icon_imbuf)
@@ -254,6 +260,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
sce->r.color_mgt_flag = scene->r.color_mgt_flag;
+ BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings);
+
+ BKE_color_managed_view_settings_free(&sce->view_settings);
+ 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)
@@ -263,7 +273,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
/* exception: don't color manage texture previews or icons */
if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE)
- sce->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT;
+ BKE_scene_disable_color_management(sce);
if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
sce->r.alphamode = R_ALPHAPREMUL;
@@ -475,13 +485,13 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
char name[32];
int do_gamma_correct = FALSE, do_predivide = FALSE;
int offx = 0;
- int newx = BLI_RCT_SIZE_X(rect);
- int newy = BLI_RCT_SIZE_Y(rect);
+ int newx = BLI_rcti_size_x(rect);
+ int newy = BLI_rcti_size_y(rect);
if (id && GS(id->name) != ID_TE) {
/* exception: don't color manage texture previews - show the raw values */
if (sce) {
- do_gamma_correct = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+ do_gamma_correct = TRUE;
do_predivide = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE;
}
}
@@ -514,15 +524,25 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
/* temporary conversion to byte for drawing */
float fx = rect->xmin + offx;
float fy = rect->ymin;
- int profile_from = (do_gamma_correct) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
int dither = 0;
unsigned char *rect_byte;
rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect");
- IMB_buffer_byte_from_float(rect_byte, rres.rectf,
- 4, dither, IB_PROFILE_SRGB, profile_from, do_predivide,
- rres.rectx, rres.recty, rres.rectx, rres.rectx);
+ if (do_gamma_correct) {
+ IMB_display_buffer_transform_apply(rect_byte, rres.rectf, rres.rectx, rres.recty, 4,
+ &sce->view_settings, &sce->display_settings, do_predivide);
+
+ }
+ else {
+ /* OCIO_TODO: currently seems an exception for textures (came fro mlegacish time),
+ * but is it indeed expected behavior, or textures should be
+ * color managed as well?
+ */
+ IMB_buffer_byte_from_float(rect_byte, rres.rectf,
+ 4, dither, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, do_predivide,
+ rres.rectx, rres.recty, rres.rectx, rres.rectx);
+ }
glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte);
@@ -549,8 +569,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
SpaceButs *sbuts = sa->spacedata.first;
rcti newrect;
int ok;
- int newx = BLI_RCT_SIZE_X(rect);
- int newy = BLI_RCT_SIZE_Y(rect);
+ int newx = BLI_rcti_size_x(rect);
+ int newy = BLI_rcti_size_y(rect);
newrect.xmin = rect->xmin;
newrect.xmax = rect->xmin;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 0bfe5d04e5e..d14514546f5 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -104,8 +104,8 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct)
void ED_region_pixelspace(ARegion *ar)
{
- int width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ int width = BLI_rcti_size_x(&ar->winrct) + 1;
+ int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
@@ -901,10 +901,10 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
static int rct_fits(rcti *rect, char dir, int size)
{
if (dir == 'h') {
- return BLI_RCT_SIZE_X(rect) - size;
+ return BLI_rcti_size_x(rect) - size;
}
else { /* 'v' */
- return BLI_RCT_SIZE_Y(rect) - size;
+ return BLI_rcti_size_y(rect) - size;
}
}
@@ -1010,7 +1010,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
if (alignment == RGN_ALIGN_HSPLIT) {
if (rct_fits(remainder, 'h', prefsizex) > 4) {
- ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
+ ar->winrct.xmax = BLI_rcti_cent_x(remainder);
remainder->xmin = ar->winrct.xmax + 1;
}
else {
@@ -1019,7 +1019,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
else {
if (rct_fits(remainder, 'v', prefsizey) > 4) {
- ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
+ ar->winrct.ymax = BLI_rcti_cent_y(remainder);
remainder->ymin = ar->winrct.ymax + 1;
}
else {
@@ -1051,20 +1051,20 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
if (quad) {
if (quad == 1) { /* left bottom */
- ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
- ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
+ ar->winrct.xmax = BLI_rcti_cent_x(remainder);
+ ar->winrct.ymax = BLI_rcti_cent_y(remainder);
}
else if (quad == 2) { /* left top */
- ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
- ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1;
+ ar->winrct.xmax = BLI_rcti_cent_x(remainder);
+ ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1;
}
else if (quad == 3) { /* right bottom */
- ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1;
- ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
+ ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1;
+ ar->winrct.ymax = BLI_rcti_cent_y(remainder);
}
else { /* right top */
- ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1;
- ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1;
+ ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1;
+ ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1;
BLI_rcti_init(remainder, 0, 0, 0, 0);
}
@@ -1073,8 +1073,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
/* for speedup */
- ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
/* set winrect for azones */
if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
@@ -1096,8 +1096,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
if (ar->alignment & RGN_SPLIT_PREV) {
if (ar->prev) {
remainder = remainder_prev;
- ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1;
- ar->prev->winy = BLI_RCT_SIZE_Y(&ar->prev->winrct) + 1;
+ ar->prev->winx = BLI_rcti_size_x(&ar->prev->winrct) + 1;
+ ar->prev->winy = BLI_rcti_size_y(&ar->prev->winrct) + 1;
}
}
@@ -1133,8 +1133,8 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
else sa->totrct.ymax = sa->v2->vec.y;
/* for speedup */
- sa->winx = BLI_RCT_SIZE_X(&sa->totrct) + 1;
- sa->winy = BLI_RCT_SIZE_Y(&sa->totrct) + 1;
+ sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
+ sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
}
@@ -1268,8 +1268,8 @@ void ED_region_init(bContext *C, ARegion *ar)
/* refresh can be called before window opened */
region_subwindow(CTX_wm_window(C), ar);
- ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
/* UI convention */
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
@@ -1574,7 +1574,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
newcontext = UI_view2d_tab_set(v2d, contextnr);
if (vertical) {
- w = BLI_RCT_SIZE_X(&v2d->cur);
+ w = BLI_rctf_size_x(&v2d->cur);
em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y;
}
else {
@@ -1769,7 +1769,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_RCT_SIZE_Y(&ar->v2d.tot));
+ UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_rctf_size_y(&ar->v2d.tot));
/* restore view matrix? */
UI_view2d_view_restore(C);
@@ -1798,16 +1798,16 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
/* background box */
rect = ar->winrct;
rect.xmin = 0;
- rect.ymin = BLI_RCT_SIZE_Y(&ar->winrct) - header_height;
+ rect.ymin = BLI_rcti_size_y(&ar->winrct) - header_height;
if (block) {
- rect.xmax = BLI_RCT_SIZE_X(&ar->winrct);
+ rect.xmax = BLI_rcti_size_x(&ar->winrct);
}
else {
rect.xmax = rect.xmin + BLF_width(fontid, text) + 24;
}
- rect.ymax = BLI_RCT_SIZE_Y(&ar->winrct);
+ rect.ymax = BLI_rcti_size_y(&ar->winrct);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index c93f4156eeb..24053d76672 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -669,8 +669,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
void glaDefine2DArea(rcti *screen_rect)
{
- const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1;
- const int sc_h = BLI_RCT_SIZE_Y(screen_rect) + 1;
+ const int sc_w = BLI_rcti_size_x(screen_rect) + 1;
+ const int sc_h = BLI_rcti_size_y(screen_rect) + 1;
glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
@@ -714,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
di->world_rect = *rect;
- sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
- sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
- wo_w = BLI_RCT_SIZE_X(&di->world_rect);
- wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
+ sc_w = BLI_rcti_size_x(&di->screen_rect);
+ sc_h = BLI_rcti_size_y(&di->screen_rect);
+ wo_w = BLI_rcti_size_x(&di->world_rect);
+ wo_h = BLI_rcti_size_y(&di->world_rect);
di->wo_to_sc[0] = sc_w / wo_w;
di->wo_to_sc[1] = sc_h / wo_h;
@@ -745,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
di->world_rect.ymax = di->screen_rect.ymax;
}
- sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
- sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
- wo_w = BLI_RCT_SIZE_X(&di->world_rect);
- wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
+ sc_w = BLI_rcti_size_x(&di->screen_rect);
+ sc_h = BLI_rcti_size_y(&di->screen_rect);
+ wo_w = BLI_rcti_size_x(&di->world_rect);
+ wo_h = BLI_rcti_size_y(&di->world_rect);
di->wo_to_sc[0] = sc_w / wo_w;
di->wo_to_sc[1] = sc_h / wo_h;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 11d32e11cd0..2e1723027b8 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -40,6 +40,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -704,10 +705,6 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
/* *********************** DRAWING **************************************** */
-
-#define SCR_BACK 0.55
-#define SCR_ROUND 12
-
/* draw vertical shape visualizing future joining (left as well
* right direction of future joining) */
static void draw_horizontal_join_shape(ScrArea *sa, char dir)
@@ -1506,6 +1503,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene)
CTX_data_scene_set(C, scene);
BKE_scene_set_background(bmain, scene);
+ DAG_on_visible_update(bmain, FALSE);
ED_render_engine_changed(bmain);
ED_update_for_newframe(bmain, scene, 1);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 50a210e5d7c..c64a4a37f3a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -372,6 +372,21 @@ int ED_operator_posemode_exclusive(bContext *C)
return 0;
}
+/* allows for pinned pose objects to be used in the object buttons
+ * and the the non-active pose object to be used in the 3D view */
+int ED_operator_posemode_context(bContext *C)
+{
+ Object *obpose = ED_pose_object_from_context(C);
+
+ if (obpose && !(obpose->mode & OB_MODE_EDIT)) {
+ if (BKE_object_pose_context_check(obpose)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int ED_operator_posemode(bContext *C)
{
Object *obact = CTX_data_active_object(C);
@@ -1196,9 +1211,6 @@ static void SCREEN_OT_area_move(wmOperatorType *ot)
* call exit() or cancel() and remove handler
*/
-#define SPLIT_STARTED 1
-#define SPLIT_PROGRESS 2
-
typedef struct sAreaSplitData {
int x, y; /* last used mouse position */
@@ -1635,10 +1647,10 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
int dist;
if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
- dist = BLI_RCT_SIZE_X(&sa->totrct);
+ dist = BLI_rcti_size_x(&sa->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
- dist = BLI_RCT_SIZE_Y(&sa->totrct);
+ dist = BLI_rcti_size_y(&sa->totrct);
}
/* subtractwidth of regions on opposite side
@@ -2850,35 +2862,40 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot)
}
/* ************** header tools operator ***************************** */
-
-static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
+void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- uiPopupMenu *pup;
- uiLayout *layout;
-
- pup = uiPupMenuBegin(C, "Header", ICON_NONE);
- layout = uiPupMenuLayout(pup);
-
- // XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator
+
+ /* XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator. */
if (ar->alignment == RGN_ALIGN_TOP)
- uiItemO(layout, "Flip to Bottom", ICON_NONE, "SCREEN_OT_header_flip");
+ uiItemO(layout, IFACE_("Flip to Bottom"), ICON_NONE, "SCREEN_OT_header_flip");
else
- uiItemO(layout, "Flip to Top", ICON_NONE, "SCREEN_OT_header_flip");
-
+ uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip");
+
uiItemS(layout);
-
+
/* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
if (sa->spacetype != SPACE_FILE) {
if (sa->full)
- uiItemO(layout, "Tile Area", ICON_NONE, "SCREEN_OT_screen_full_area");
+ uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
else
- uiItemO(layout, "Maximize Area", ICON_NONE, "SCREEN_OT_screen_full_area");
+ uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
}
-
+}
+
+static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
+{
+ uiPopupMenu *pup;
+ uiLayout *layout;
+
+ pup = uiPupMenuBegin(C, N_("Header"), ICON_NONE);
+ layout = uiPupMenuLayout(pup);
+
+ ED_screens_header_tools_menu_create(C, layout, NULL);
+
uiPupMenuEnd(C, pup);
-
+
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 4e71c49465f..aeae79aa9d0 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -149,8 +149,8 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
{
unsigned int *to = ibuf->rect;
unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin;
- int crop_x = BLI_RCT_SIZE_X(&crop);
- int crop_y = BLI_RCT_SIZE_Y(&crop);
+ int crop_x = BLI_rcti_size_x(&crop);
+ int crop_y = BLI_rcti_size_y(&crop);
int y;
if (crop_x > 0 && crop_y > 0) {
@@ -245,7 +245,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
- uiTemplateImageSettings(layout, &ptr);
+ uiTemplateImageSettings(layout, &ptr, FALSE);
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 8616d4e66eb..e14266c83a7 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -322,8 +322,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 */
- project_float(vc->ar, location, p1);
- project_float(vc->ar, offset, p2);
+ ED_view3d_project_float(vc->ar, location, p1);
+ ED_view3d_project_float(vc->ar, offset, p2);
/* the distance between these points is the size of the projected brush in pixels */
return len_v2v2(p1, p2);
@@ -441,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
else {
quad.xmin = 0;
quad.ymin = 0;
- quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct);
- quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct);
+ quad.xmax = BLI_rcti_size_x(&vc->ar->winrct);
+ quad.ymax = BLI_rcti_size_y(&vc->ar->winrct);
}
/* set quad color */
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index e809267d076..2970bdfb5a4 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -251,7 +251,7 @@ static void clip_planes_from_rect(bContext *C,
view3d_operator_needs_opengl(C);
view3d_set_viewcontext(C, &vc);
view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
- ED_view3d_calc_clipping(&bb, clip_planes, &mats, rect);
+ ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
mul_m4_fl(clip_planes, -1.0f);
}
@@ -388,7 +388,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
ot->modal = WM_border_select_modal;
ot->exec = hide_show_exec;
/* sculpt-only for now */
- ot->poll = sculpt_mode_poll;
+ ot->poll = sculpt_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 7c3f376df91..b8e365c4c8e 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -104,6 +104,8 @@
#include "GPU_draw.h"
#include "GPU_extensions.h"
+#include "IMB_colormanagement.h"
+
#include "paint_intern.h"
/* Defines and Structs */
@@ -139,7 +141,7 @@
#define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS)
#define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS)
-static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint);
+static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint);
typedef struct ImagePaintState {
@@ -153,7 +155,6 @@ typedef struct ImagePaintState {
Image *image;
ImBuf *canvas;
ImBuf *clonecanvas;
- short clonefreefloat;
char *warnpackedfile;
char *warnmultifile;
@@ -239,8 +240,6 @@ typedef struct ImagePaintRegion {
/* vert flags */
#define PROJ_VERT_CULL 1
-#define PI_80_DEG ((M_PI_2 / 9) * 8)
-
/* This is mainly a convenience struct used so we can keep an array of images we use
* Thir imbufs, etc, in 1 array, When using threads this array is copied for each thread
* because 'partRedrawRect' and 'touch' values would not be thread safe */
@@ -510,7 +509,7 @@ static void image_undo_restore(bContext *C, ListBase *lb)
ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */
-
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
IMB_freeImBuf(tmpibuf);
@@ -3137,7 +3136,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->is_ortho = params.is_ortho;
}
- /* same as view3d_get_object_project_mat */
+ /* same as #ED_view3d_ob_project_mat_get */
mult_m4_m4m4(vmat, viewmat, ps->ob->obmat);
mult_m4_m4m4(ps->projectMat, winmat, vmat);
}
@@ -3615,7 +3614,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps)
pr = &(projIma->partRedrawRect[i]);
if (pr->x2 != -1) { /* TODO - use 'enabled' ? */
imapaintpartial = *pr;
- imapaint_image_update(NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/
+ imapaint_image_update(NULL, NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/
redraw = 1;
}
}
@@ -3945,7 +3944,7 @@ static void *do_projectpaint_thread(void *ph_v)
last_projIma->touch = 1;
is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
- use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
+ use_color_correction = TRUE;
}
/* end copy */
@@ -4028,7 +4027,7 @@ static void *do_projectpaint_thread(void *ph_v)
last_projIma->touch = 1;
is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
- use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
+ use_color_correction = TRUE;
}
/* end copy */
@@ -4244,10 +4243,17 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
IMB_freeImBuf(tmpibuf);
}
-static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
+static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
{
- if (ibuf->rect_float)
- ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
+ if (scene) {
+ 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);
+ }
+ else {
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+ }
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
@@ -4257,7 +4263,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s
int w = imapaintpartial.x2 - imapaintpartial.x1;
int h = imapaintpartial.y2 - imapaintpartial.y1;
/* Testing with partial update in uv editor too */
- GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0); //!texpaint);
+ GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); //!texpaint);
}
}
@@ -4571,15 +4577,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
/* temporarily add float rect for cloning */
if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
- short profile = IB_PROFILE_NONE;
-
- /* Don't want to color manage, but don't disturb existing profiles */
- SWAP(short, s->clonecanvas->profile, profile);
-
IMB_float_from_rect(s->clonecanvas);
- s->clonefreefloat = 1;
-
- SWAP(short, s->clonecanvas->profile, profile);
}
else if (!s->canvas->rect_float && !s->clonecanvas->rect)
IMB_rect_from_float(s->clonecanvas);
@@ -4588,28 +4586,32 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
return 1;
}
-static void imapaint_canvas_free(ImagePaintState *s)
+static void imapaint_canvas_free(ImagePaintState *UNUSED(s))
{
- if (s->clonefreefloat)
- imb_freerectfloatImBuf(s->clonecanvas);
}
static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure)
{
ImBuf *ibuf = BKE_image_get_ibuf(image, s->sima ? &s->sima->iuser : NULL);
float pos[2];
+ int is_data;
if (!ibuf)
return 0;
+ is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
+
pos[0] = uv[0] * ibuf->x;
pos[1] = uv[1] * ibuf->y;
BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0);
- if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) {
+ /* OCIO_TODO: float buffers are now always linear, so always use color correction
+ * this should probably be changed when texture painting color space is supported
+ */
+ if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, is_data == FALSE)) {
if (update)
- imapaint_image_update(s->sima, image, ibuf, texpaint);
+ imapaint_image_update(s->scene, s->sima, image, ibuf, texpaint);
return 1;
}
else return 0;
@@ -5257,7 +5259,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
-int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
+static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -5884,7 +5886,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (w > maxsize) w = maxsize;
if (h > maxsize) h = maxsize;
- ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out);
+ ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, FALSE, err_out);
if (!ibuf) {
/* Mostly happens when OpenGL offscreen buffer was failed to create, */
/* but could be other reasons. Should be handled in the future. nazgul */
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index cc71be4938e..39a95300d5d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -602,7 +602,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
}
}
-void paint_partial_visibility_keys(wmKeyMap *keymap)
+static void paint_partial_visibility_keys(wmKeyMap *keymap)
{
wmKeyMapItem *kmi;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index b53edeadb51..7fabaf7f23d 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -254,7 +254,10 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
pressure = event_tablet_data(event, NULL);
if (pressure > FLT_EPSILON) {
- scale = (BKE_brush_size_get(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length;
+ /* 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);
+ scale = (size_clamp * stroke->brush->spacing / 50.0f) / length;
if (scale > FLT_EPSILON) {
mul_v2_fl(vec, scale);
@@ -521,8 +524,10 @@ int paint_poll(bContext *C)
{
Paint *p = paint_get_active_from_context(C);
Object *ob = CTX_data_active_object(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
return p && ob && paint_brush(p) &&
- CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
- CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
+ (sa && sa->spacetype == SPACE_VIEW3D) &&
+ (ar && ar->regiontype == RGN_TYPE_WINDOW);
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index df64e1c9d90..29a59651cf7 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -98,7 +98,7 @@ int paint_convert_bb_to_rect(rcti *rect,
vec[1] = j ? bb_min[1] : bb_max[1];
vec[2] = k ? bb_min[2] : bb_max[2];
/* convert corner to screen space */
- ED_view3d_project_float_v2(ar, vec, proj, projection_mat);
+ ED_view3d_project_float_v2_m4(ar, vec, proj, projection_mat);
/* expand 2D rectangle */
/* we could project directly to int? */
@@ -137,7 +137,7 @@ void paint_calc_redraw_planes(float planes[4][4],
rect.ymin -= 2;
rect.ymax += 2;
- ED_view3d_calc_clipping(&bb, planes, &mats, &rect);
+ ED_view3d_clipping_calc(&bb, planes, &mats, &rect);
mul_m4_fl(planes, -1.0f);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index ba440e98290..8aed92df3af 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -134,7 +134,7 @@ int vertex_paint_poll(bContext *C)
paint_brush(&CTX_data_tool_settings(C)->vpaint->paint))
{
ScrArea *sa = CTX_wm_area(C);
- if (sa->spacetype == SPACE_VIEW3D) {
+ if (sa && sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = CTX_wm_region(C);
if (ar->regiontype == RGN_TYPE_WINDOW)
return 1;
@@ -257,7 +257,7 @@ static void do_shared_vertex_tesscol(Mesh *me)
MEM_freeN(scolmain);
}
-void do_shared_vertexcol(Mesh *me, int do_tessface)
+static void do_shared_vertexcol(Mesh *me, int do_tessface)
{
const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK);
MPoly *mp;
@@ -850,7 +850,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_n
float dist_squared;
float vertco[2], delta[2];
- project_float_noclip(vc->ar, vert_nor, vertco);
+ ED_view3d_project_float_noclip(vc->ar, vert_nor, vertco);
sub_v2_v2v2(delta, mval, vertco);
dist_squared = dot_v2v2(delta, delta); /* len squared */
if (dist_squared > brush_size_pressure * brush_size_pressure) {
@@ -2227,19 +2227,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if (indexar[0]) totindex = 1;
else totindex = 0;
}
-
- if (wp->flag & VP_COLINDEX) {
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1);
-
- if (mpoly->mat_nr != ob->actcol - 1) {
- indexar[index] = 0;
- }
- }
- }
- }
-
+
if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) {
for (index = 0; index < totindex; index++) {
if (indexar[index] && indexar[index] <= me->totpoly) {
@@ -2639,52 +2627,13 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
return 1;
}
-#if 0
-static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
- const unsigned int index, const float mval[2],
- const float brush_size_pressure, const float brush_alpha_pressure,
- int UNUSED(flip))
+static void copy_lcol_to_mcol(MCol *mcol, const MLoopCol *lcol)
{
- ViewContext *vc = &vpd->vc;
- Brush *brush = paint_brush(&vp->paint);
- Mesh *me = BKE_mesh_from_object(ob);
- MFace *mface = &me->mface[index];
- unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index;
- unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index;
- float alpha;
- int i;
-
- int brush_alpha_pressure_i;
-
- if ((vp->flag & VP_COLINDEX && mface->mat_nr != ob->actcol - 1) ||
- ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL)))
- return;
-
- if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
- unsigned int fcol1 = mcol_blend(mcol[0], mcol[1], 128);
- if (mface->v4) {
- unsigned int fcol2 = mcol_blend(mcol[2], mcol[3], 128);
- vpd->paintcol = mcol_blend(fcol1, fcol2, 128);
- }
- else {
- vpd->paintcol = mcol_blend(mcol[2], fcol1, 170);
- }
- }
-
- brush_alpha_pressure_i = (int)(brush_alpha_pressure * 255.0f);
-
- for (i = 0; i < (mface->v4 ? 4 : 3); ++i) {
- alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos + 6 * (&mface->v1)[i],
- mval, brush_size_pressure, brush_alpha_pressure);
- if (alpha) {
- const int alpha_i = (int)(alpha * 255.0f);
- mcol[i] = vpaint_blend(vp, mcol[i], mcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i);
- }
- }
+ mcol->a = lcol->a;
+ mcol->r = lcol->r;
+ mcol->g = lcol->g;
+ mcol->b = lcol->b;
}
-#endif
-
-/* BMESH version of vpaint_paint_face (commented above) */
static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob,
const unsigned int index, const float mval[2],
@@ -2744,33 +2693,22 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob,
}
if (vpd->use_fast_update) {
-
-#ifdef CPYCOL
-# undef CPYCOL
-#endif
-#define CPYCOL(c, l) (c)->a = (l)->a, (c)->r = (l)->r, (c)->g = (l)->g, (c)->b = (l)->b
-
/* update vertex colors for tessellations incrementally,
* rather then regenerating the tessellation altogether */
for (e = vpd->polyfacemap[index].first; e; e = e->next) {
- mf = me->mface + e->facenr;
- mc = me->mcol + e->facenr * 4;
+ mf = &me->mface[e->facenr];
+ mc = &me->mcol[e->facenr * 4];
ml = me->mloop + mpoly->loopstart;
mlc = me->mloopcol + mpoly->loopstart;
for (j = 0; j < mpoly->totloop; j++, ml++, mlc++) {
- if (ml->v == mf->v1)
- CPYCOL(mc, mlc);
- else if (ml->v == mf->v2)
- CPYCOL(mc + 1, mlc);
- else if (ml->v == mf->v3)
- CPYCOL(mc + 2, mlc);
- else if (mf->v4 && ml->v == mf->v4)
- CPYCOL(mc + 3, 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);
}
}
-#undef CPYCOL
}
}
@@ -2804,7 +2742,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
mval[0] -= vc->ar->winrct.xmin;
mval[1] -= vc->ar->winrct.ymin;
-
+
/* which faces are involved */
if (vp->flag & VP_AREA) {
totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);
@@ -2814,19 +2752,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if (indexar[0]) totindex = 1;
else totindex = 0;
}
-
-
- if (vp->flag & VP_COLINDEX) {
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1);
-
- if (mpoly->mat_nr != ob->actcol - 1) {
- indexar[index] = 0;
- }
- }
- }
- }
if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) {
for (index = 0; index < totindex; index++) {
@@ -2835,15 +2760,13 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if ((mpoly->flag & ME_FACE_SEL) == 0)
indexar[index] = 0;
- }
+ }
}
}
swap_m4m4(vc->rv3d->persmat, mat);
-
for (index = 0; index < totindex; index++) {
-
if (indexar[index] && indexar[index] <= me->totpoly) {
vpaint_paint_poly(vp, vpd, ob, indexar[index] - 1, mval, brush_size_pressure, brush_alpha_pressure);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 210477e3e5a..05b5b90344c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -771,7 +771,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
if (ss->cache->radial_symmetry_pass)
mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point);
- ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
+ ED_view3d_project_float_v2_m4(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
/* keep coordinates relative to mouse */
@@ -2649,7 +2649,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
}
if (is_basis) {
- ofs = key_to_vertcos(ob, kb);
+ ofs = BKE_key_convert_to_vertcos(ob, kb);
/* calculate key coord offsets (from previous location) */
for (a = 0; a < me->totvert; a++) {
@@ -2662,7 +2662,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
int apply_offset = ((currkey != kb) && (ob->shapenr - 1 == currkey->relative));
if (apply_offset)
- offset_to_key(ob, currkey, ofs);
+ BKE_key_convert_from_offset(ob, currkey, ofs);
currkey = currkey->next;
}
@@ -2683,7 +2683,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
}
/* apply new coords on active key block */
- vertcos_to_key(ob, kb, vertCos);
+ BKE_key_convert_from_vertcos(ob, kb, vertCos);
}
static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush)
@@ -3074,7 +3074,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
/* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */
BKE_mesh_tessface_ensure(me);
- if (!mmd) ss->kb = ob_get_keyblock(ob);
+ if (!mmd) ss->kb = BKE_keyblock_from_object(ob);
else ss->kb = NULL;
/* needs to be called after we ensure tessface */
@@ -3109,7 +3109,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
free_sculptsession_deformMats(ss);
- ss->orig_cos = (ss->kb) ? key_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL);
+ ss->orig_cos = (ss->kb) ? BKE_key_convert_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL);
crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos);
BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
@@ -3123,7 +3123,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
/* if pbvh is deformed, key block is already applied to it */
if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) {
- float (*vertCos)[3] = key_to_vertcos(ob, ss->kb);
+ float (*vertCos)[3] = BKE_key_convert_to_vertcos(ob, ss->kb);
if (vertCos) {
/* apply shape keys coordinates to PBVH */
@@ -3139,6 +3139,11 @@ int sculpt_mode_poll(bContext *C)
return ob && ob->mode & OB_MODE_SCULPT;
}
+int sculpt_mode_poll_view3d(bContext *C)
+{
+ return (sculpt_mode_poll(C) && CTX_wm_region_view3d(C));
+}
+
int sculpt_poll(bContext *C)
{
return sculpt_mode_poll(C) && paint_poll(C);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index f4467dc22fc..5e79616b0b0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -56,6 +56,7 @@ struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct
void sculpt(struct Sculpt *sd);
int sculpt_mode_poll(struct bContext *C);
+int sculpt_mode_poll_view3d(struct bContext *C);
int sculpt_poll(struct bContext *C);
void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob, int need_pmap);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index c62dc687c73..bb2b4b8c743 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -107,8 +107,8 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) {
/* shape key has been changed before calling undo operator */
- Key *key = ob_get_key(ob);
- KeyBlock *kb = key_get_named_keyblock(key, unode->shapeName);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_find_name(key, unode->shapeName);
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
@@ -127,7 +127,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
if (ss->kb) {
float (*vertCos)[3];
- vertCos = key_to_vertcos(ob, ss->kb);
+ vertCos = BKE_key_convert_to_vertcos(ob, ss->kb);
for (i = 0; i < unode->totvert; i++) {
if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index fdce8ec04a4..0bcccd9479c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -156,8 +156,8 @@ typedef struct Temp_UvData {
-void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2],
- float alpha, float radius, float aspectRatio)
+static void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2],
+ float alpha, float radius, float aspectRatio)
{
Temp_UVData *tmp_uvdata;
float diff[2];
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 878fd20b27e..10adeb3e721 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -89,7 +89,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
* start of list offset, and the second is as a correction for the scrollers.
*/
height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2));
- if (height > BLI_RCT_SIZE_Y(&v2d->mask)) {
+ if (height > BLI_rcti_size_y(&v2d->mask)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index c95f1dba31d..7635f85a37e 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -365,13 +365,13 @@ static int actkeys_viewall(bContext *C, const short onlySel)
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
- extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* set vertical range */
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask);
+ v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 9ab79d73e76..5da348b2a84 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -309,7 +309,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
mode = ACTKEYS_BORDERSEL_FRAMERANGE;
else
mode = ACTKEYS_BORDERSEL_CHANNELS;
@@ -912,9 +912,6 @@ void ACTION_OT_select_leftright(wmOperatorType *ot)
* selection mode between replacing the selection (without) and inverting the selection (with).
*/
-/* sensitivity factor for frame-selections */
-#define FRAME_CLICK_THRESH 0.1f
-
/* ------------------- */
/* option 1) select keyframe directly under mouse */
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index 4bcd4a933ed..ebba7d92819 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -148,7 +148,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
uiBlockEndAlign(block);
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_SIZE_Y(&ar->v2d.tot));
+ UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_rctf_size_y(&ar->v2d.tot));
uiEndBlock(C, block);
uiDrawBlock(C, block);
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index e66faa88b93..969b0e25928 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -119,6 +119,8 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL);
if (clip) {
+ uiLayout *col;
+
row = uiLayoutRow(layout, FALSE);
block = uiLayoutGetBlock(row);
uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
@@ -129,6 +131,9 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings");
}
}
@@ -169,7 +174,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
scopes->track_preview_height =
(scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height;
- uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect),
+ uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect),
scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
}
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 5d890155e25..cc1b8d444bc 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -274,7 +274,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
dopesheet = &tracking->dopesheet;
height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
- if (height > BLI_RCT_SIZE_Y(&v2d->mask)) {
+ if (height > BLI_rcti_size_y(&v2d->mask)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 2353f8f8c12..b22c9a60bdc 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -42,6 +42,7 @@
#include "BKE_tracking.h"
#include "BKE_mask.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -246,14 +247,7 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
ED_region_info_draw(ar, str, block, 0.6f);
}
-static void verify_buffer_float(ImBuf *ibuf)
-{
- if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) {
- IMB_rect_from_float(ibuf);
- }
-}
-
-static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
+static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
int width, int height, float zoomx, float zoomy)
{
int x, y;
@@ -267,13 +261,16 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
glRectf(x, y, x + zoomx * width, y + zoomy * height);
}
else {
- verify_buffer_float(ibuf);
+ unsigned char *display_buffer;
+ void *cache_handle;
+
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
- if (ibuf->rect) {
+ if (display_buffer) {
int need_fallback = 1;
if (ED_space_clip_texture_buffer_supported(sc)) {
- if (ED_space_clip_load_movieclip_buffer(sc, ibuf)) {
+ if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) {
glPushMatrix();
glTranslatef(x, y, 0.0f);
glScalef(zoomx, zoomy, 1.0f);
@@ -299,12 +296,14 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
/* set zoom */
glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
/* reset zoom */
glPixelZoom(1.0f, 1.0f);
}
}
+
+ IMB_display_buffer_release(cache_handle);
}
/* draw boundary border for frame if stabilization is enabled */
@@ -958,12 +957,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony)
{
/* express given coordinates as proportional values */
- x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur);
- y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur);
+ x = -v2d->cur.xmin / BLI_rctf_size_x(&v2d->cur);
+ y = -v2d->cur.ymin / BLI_rctf_size_y(&v2d->cur);
/* convert proportional distances to screen coordinates */
- *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask);
- *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask);
+ *regionx = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);
+ *regiony = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask);
}
static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
@@ -1461,7 +1460,7 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
}
if (ibuf) {
- draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy);
+ draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy);
IMB_freeImBuf(ibuf);
}
else {
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 08ad6aac970..32f91671daf 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -149,8 +149,8 @@ void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoo
ED_space_clip_get_size(sc, &width, &height);
- *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width);
- *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height);
+ *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (BLI_rctf_size_x(&ar->v2d.cur) * width);
+ *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (BLI_rctf_size_y(&ar->v2d.cur) * height);
}
void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
@@ -277,13 +277,7 @@ int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
- /* IB_PROFILE_NONE is default but infact its linear */
- if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
- linearrgb_to_srgb_v3_v3(r_col, fp);
- }
- else {
- copy_v3_v3(r_col, fp);
- }
+ linearrgb_to_srgb_v3_v3(r_col, fp);
ret = TRUE;
}
else if (ibuf->rect) {
@@ -394,8 +388,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit)
ED_space_clip_get_aspect(sc, &aspx, &aspy);
- width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ width = BLI_rcti_size_x(&ar->winrct) + 1;
+ height = BLI_rcti_size_y(&ar->winrct) + 1;
zoomx = (float)width / w / aspx;
zoomy = (float)height / h / aspy;
@@ -583,12 +577,15 @@ typedef struct SpaceClipDrawContext {
GLuint texture; /* OGL texture ID */
short texture_allocated; /* flag if texture was allocated by glGenTextures */
struct ImBuf *texture_ibuf; /* image buffer for which texture was created */
+ const unsigned char *display_buffer; /* display buffer for which texture was created */
int image_width, image_height; /* image width and height for which texture was created */
unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */
/* fields to check if cache is still valid */
int framenr, start_frame, frame_offset;
short render_size, render_flag;
+
+ char colorspace[64];
} SpaceClipDrawContext;
int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
@@ -613,7 +610,7 @@ int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
return context->buffers_supported;
}
-int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
+int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsigned char *display_buffer)
{
SpaceClipDrawContext *context = sc->draw_context;
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -625,12 +622,22 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
* assuming displaying happens of footage frames only on which painting doesn't heppen.
* so not changed image buffer pointer means unchanged image content */
need_rebind |= context->texture_ibuf != ibuf;
+ need_rebind |= context->display_buffer != display_buffer;
need_rebind |= context->framenr != sc->user.framenr;
need_rebind |= context->render_size != sc->user.render_size;
need_rebind |= context->render_flag != sc->user.render_flag;
need_rebind |= context->start_frame != clip->start_frame;
need_rebind |= context->frame_offset != clip->frame_offset;
+ if (!need_rebind) {
+ /* OCIO_TODO: not entirely nice, but currently it seems to be easiest way
+ * to deal with changing input color space settings
+ * pointer-based check could fail due to new buffers could be
+ * be allocated on on old memory
+ */
+ need_rebind = strcmp(context->colorspace, clip->colorspace_settings.name) != 0;
+ }
+
if (need_rebind) {
int width = ibuf->x, height = ibuf->y;
int need_recreate = 0;
@@ -670,16 +677,12 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
glBindTexture(GL_TEXTURE_2D, context->texture);
}
- if (ibuf->rect_float) {
- if (ibuf->rect == NULL)
- IMB_rect_from_float(ibuf);
- }
-
- if (ibuf->rect)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ if (display_buffer)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
/* store settings */
context->texture_allocated = 1;
+ context->display_buffer = display_buffer;
context->texture_ibuf = ibuf;
context->image_width = ibuf->x;
context->image_height = ibuf->y;
@@ -688,6 +691,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
context->render_flag = sc->user.render_flag;
context->start_frame = clip->start_frame;
context->frame_offset = clip->frame_offset;
+
+ strcpy(context->colorspace, clip->colorspace_settings.name);
}
else {
/* displaying exactly the same image which was loaded t oa texture,
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 91501971d9d..7b070fde6ba 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -94,7 +94,7 @@ static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack
glVertex2f(scene_framenr, val);
}
-void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
+static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
{
static float colors[2][3] = {{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f}};
@@ -116,7 +116,7 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co
glBegin(GL_LINE_STRIP);
}
-void tracking_segment_end_cb(void *UNUSED(userdata))
+static void tracking_segment_end_cb(void *UNUSED(userdata))
{
glEnd();
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 71dcd326887..fa235bd2997 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -130,7 +130,7 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack
copy_v2_v2(data->prev_co, co);
}
-void find_nearest_tracking_segment_end_cb(void *userdata)
+static void find_nearest_tracking_segment_end_cb(void *userdata)
{
MouseSelectUserData *data = userdata;
@@ -580,11 +580,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
}
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
- extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
- extra = 0.01f * BLI_RCT_SIZE_Y(&v2d->cur);
+ extra = 0.01f * BLI_rctf_size_y(&v2d->cur);
v2d->cur.ymin -= extra;
v2d->cur.ymax += extra;
@@ -610,7 +610,7 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot)
void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar)
{
View2D *v2d = &ar->v2d;
- float extra = BLI_RCT_SIZE_X(&v2d->cur) / 2.0f;
+ float extra = BLI_rctf_size_x(&v2d->cur) / 2.0f;
/* set extents of view to start/end frames */
v2d->cur.xmin = (float)CFRA - extra;
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index aa2cadbd2d3..5c338f3e6f1 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -90,9 +90,9 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
if ((width < 4) && (height < 4))
sc->zoom = oldzoom;
- else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom)
+ else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom)
sc->zoom = oldzoom;
- else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom)
+ else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom)
sc->zoom = oldzoom;
}
@@ -726,8 +726,8 @@ static int view_all_exec(bContext *C, wmOperator *op)
h = h * aspy;
/* check if the image will fit in the image with zoom == 1 */
- width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ width = BLI_rcti_size_x(&ar->winrct) + 1;
+ height = BLI_rcti_size_y(&ar->winrct) + 1;
if (fit_view) {
const int margin = 5; /* margin from border */
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 7f43c404095..3f925df30c7 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1036,8 +1036,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar)
if (clip)
h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect;
- winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ winy = BLI_rcti_size_y(&ar->winrct) + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index a4f7e30ed7b..b7ef278275e 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -142,7 +142,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
/* always keep the bottom part of the view aligned, less annoying */
if (prev_y_min != ar->v2d.cur.ymin) {
- const float cur_y_range = BLI_RCT_SIZE_Y(&ar->v2d.cur);
+ const float cur_y_range = BLI_rctf_size_y(&ar->v2d.cur);
ar->v2d.cur.ymin = prev_y_min;
ar->v2d.cur.ymax = prev_y_min + cur_y_range;
}
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index a07a560328c..e5c6a839380 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -66,6 +66,7 @@ void FILE_OT_select_border(struct wmOperatorType *ot);
void FILE_OT_select_bookmark(struct wmOperatorType *ot);
void FILE_OT_bookmark_add(struct wmOperatorType *ot);
void FILE_OT_delete_bookmark(struct wmOperatorType *ot);
+void FILE_OT_reset_recent(wmOperatorType *ot);
void FILE_OT_hidedot(struct wmOperatorType *ot);
void FILE_OT_execute(struct wmOperatorType *ot);
void FILE_OT_cancel(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 040f276940d..fcbeb064e4d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -64,11 +64,6 @@
#include <stdio.h>
#include <ctype.h>
-/* for events */
-#define NOTACTIVEFILE 0
-#define ACTIVATE 1
-#define INACTIVATE 2
-
/* ---------- FILE SELECTION ------------ */
static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect)
{
@@ -459,7 +454,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op))
if (params->dir[0] != '\0') {
char name[FILE_MAX];
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, FS_INSERT_SAVE);
BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
}
@@ -515,6 +510,35 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot)
RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000);
}
+static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ ScrArea *sa = CTX_wm_area(C);
+ char name[FILE_MAX];
+ struct FSMenu *fsmenu = fsmenu_get();
+
+ while (fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) {
+ fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0);
+ }
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
+ fsmenu_write_file(fsmenu, name);
+ ED_area_tag_redraw(sa);
+
+ return OPERATOR_FINISHED;
+}
+
+void FILE_OT_reset_recent(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Reset Recent";
+ ot->description = "Reset Recent files";
+ ot->idname = "FILE_OT_reset_recent";
+
+ /* api callbacks */
+ ot->exec = reset_recent_exec;
+ ot->poll = ED_operator_file_active;
+
+}
+
int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
{
View2D *v2d = &ar->v2d;
@@ -770,8 +794,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
file_sfile_to_operator(op, sfile, filepath);
- if (BLI_exists(sfile->params->dir))
- fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1);
+ if (BLI_exists(sfile->params->dir)) {
+ fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE | FS_INSERT_FIRST);
+ }
BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu_get(), filepath);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 51bd660e126..a7054909aaa 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -67,14 +67,14 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v))
WM_operator_properties_free(&ptr);
}
-static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete, int reverse)
+static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete)
{
SpaceFile *sfile = CTX_wm_space_file(C);
uiBlock *block;
uiBut *but;
uiLayout *box, *col;
struct FSMenu *fsmenu = fsmenu_get();
- int i, i_iter, nentries = fsmenu_get_nentries(fsmenu, category);
+ int i, nentries = fsmenu_get_nentries(fsmenu, category);
/* reset each time */
*nr = -1;
@@ -89,13 +89,11 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
box = uiLayoutBox(pa->layout);
col = uiLayoutColumn(box, TRUE);
- for (i_iter = 0; i_iter < nentries; ++i_iter) {
+ for (i = 0; i < nentries; ++i) {
char dir[FILE_MAX];
char temp[FILE_MAX];
uiLayout *layout = uiLayoutRow(col, FALSE);
char *entry;
-
- i = reverse ? nentries - (i_iter + 1) : i_iter;
entry = fsmenu_get_entry(fsmenu, category, i);
@@ -134,7 +132,7 @@ static void file_panel_system(const bContext *C, Panel *pa)
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile)
- file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0);
+ file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0);
}
static void file_panel_bookmarks(const bContext *C, Panel *pa)
@@ -147,17 +145,22 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa)
uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add");
uiItemL(row, NULL, ICON_NONE);
- file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1, 0);
+ file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1);
}
}
static void file_panel_recent(const bContext *C, Panel *pa)
{
SpaceFile *sfile = CTX_wm_space_file(C);
+ uiLayout *row;
if (sfile) {
if (!(U.uiflag & USER_HIDE_RECENT) ) {
- file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1);
+ row = uiLayoutRow(pa->layout, FALSE);
+ uiItemO(row, IFACE_("Reset"), ICON_X, "file.reset_recent");
+ uiItemL(row, NULL, ICON_NONE);
+
+ file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0);
}
}
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 4abe41d5714..699cb9b4feb 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -389,7 +389,7 @@ void filelist_init_icons(void)
#ifdef WITH_HEADLESS
bbuf = NULL;
#else
- bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, "<splash>");
+ bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
#endif
if (bbuf) {
for (y = 0; y < SPECIAL_IMG_ROWS; y++) {
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 09231efd367..1fa89e5db9a 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -270,12 +270,12 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar)
int numfiles;
if (layout->flag & FILE_LAYOUT_HOR) {
- int width = (int)(BLI_RCT_SIZE_X(&ar->v2d.cur) - 2 * layout->tile_border_x);
+ int width = (int)(BLI_rctf_size_x(&ar->v2d.cur) - 2 * layout->tile_border_x);
numfiles = (int)((float)width / (float)layout->tile_w + 0.5f);
return numfiles * layout->rows;
}
else {
- int height = (int)(BLI_RCT_SIZE_Y(&ar->v2d.cur) - 2 * layout->tile_border_y);
+ int height = (int)(BLI_rctf_size_y(&ar->v2d.cur) - 2 * layout->tile_border_y);
numfiles = (int)((float)height / (float)layout->tile_h + 0.5f);
return numfiles * layout->columns;
}
@@ -503,7 +503,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->prv_border_y = 6;
layout->tile_w = layout->prv_w + 2 * layout->prv_border_x;
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
- layout->width = (int)(BLI_RCT_SIZE_X(&v2d->cur) - 2 * layout->tile_border_x);
+ layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
if (layout->columns > 0)
layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero
@@ -522,7 +522,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->prv_border_x = 0;
layout->prv_border_y = 0;
layout->tile_h = textheight * 3 / 2;
- layout->height = (int)(BLI_RCT_SIZE_Y(&v2d->cur) - 2 * layout->tile_border_y);
+ layout->height = (int)(BLI_rctf_size_y(&v2d->cur) - 2 * layout->tile_border_y);
layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y);
column_widths(sfile->files, layout);
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index a127e2ca2bc..66cda3082ea 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -97,84 +97,94 @@ FSMenu *fsmenu_get(void)
static FSMenuEntry *fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category)
{
- FSMenuEntry *fsms = NULL;
+ FSMenuEntry *fsm_head = NULL;
switch (category) {
case FS_CATEGORY_SYSTEM:
- fsms = fsmenu->fsmenu_system;
+ fsm_head = fsmenu->fsmenu_system;
break;
case FS_CATEGORY_BOOKMARKS:
- fsms = fsmenu->fsmenu_bookmarks;
+ fsm_head = fsmenu->fsmenu_bookmarks;
break;
case FS_CATEGORY_RECENT:
- fsms = fsmenu->fsmenu_recent;
+ fsm_head = fsmenu->fsmenu_recent;
break;
}
- return fsms;
+ return fsm_head;
}
-static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsms)
+static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsm_head)
{
switch (category) {
case FS_CATEGORY_SYSTEM:
- fsmenu->fsmenu_system = fsms;
+ fsmenu->fsmenu_system = fsm_head;
break;
case FS_CATEGORY_BOOKMARKS:
- fsmenu->fsmenu_bookmarks = fsms;
+ fsmenu->fsmenu_bookmarks = fsm_head;
break;
case FS_CATEGORY_RECENT:
- fsmenu->fsmenu_recent = fsms;
+ fsmenu->fsmenu_recent = fsm_head;
break;
}
}
int fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category)
{
- FSMenuEntry *fsme;
+ FSMenuEntry *fsm_iter;
int count = 0;
- for (fsme = fsmenu_get_category(fsmenu, category); fsme; fsme = fsme->next)
+ for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter; fsm_iter = fsm_iter->next) {
count++;
+ }
return count;
}
char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
{
- FSMenuEntry *fsme;
+ FSMenuEntry *fsm_iter;
- for (fsme = fsmenu_get_category(fsmenu, category); fsme && idx; fsme = fsme->next)
+ for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) {
idx--;
+ }
- return fsme ? fsme->path : NULL;
+ return fsm_iter ? fsm_iter->path : NULL;
}
short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
{
- FSMenuEntry *fsme;
+ FSMenuEntry *fsm_iter;
- for (fsme = fsmenu_get_category(fsmenu, category); fsme && idx; fsme = fsme->next)
+ for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) {
idx--;
+ }
- return fsme ? fsme->save : 0;
+ return fsm_iter ? fsm_iter->save : 0;
}
-void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save)
+void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, FSMenuInsert flag)
{
- FSMenuEntry *prev;
- FSMenuEntry *fsme;
- FSMenuEntry *fsms;
+ FSMenuEntry *fsm_prev;
+ FSMenuEntry *fsm_iter;
+ FSMenuEntry *fsm_head;
- fsms = fsmenu_get_category(fsmenu, category);
- prev = fsme = fsms;
+ fsm_head = fsmenu_get_category(fsmenu, category);
+ fsm_prev = fsm_head; /* this is odd and not really correct? */
- for (; fsme; prev = fsme, fsme = fsme->next) {
- if (fsme->path) {
- const int cmp_ret = BLI_path_cmp(path, fsme->path);
+ for (fsm_iter = fsm_head; fsm_iter; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) {
+ if (fsm_iter->path) {
+ const int cmp_ret = BLI_path_cmp(path, fsm_iter->path);
if (cmp_ret == 0) {
+ if (flag & FS_INSERT_FIRST) {
+ if (fsm_iter != fsm_head) {
+ fsm_prev->next = fsm_iter->next;
+ fsm_iter->next = fsm_head;
+ fsmenu_set_category(fsmenu, category, fsm_iter);
+ }
+ }
return;
}
- else if (sorted && cmp_ret < 0) {
+ else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) {
break;
}
}
@@ -182,78 +192,82 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c
/* if we're bookmarking this, file should come
* before the last separator, only automatically added
* current dir go after the last sep. */
- if (save) {
+ if (flag & FS_INSERT_SAVE) {
break;
}
}
}
- fsme = MEM_mallocN(sizeof(*fsme), "fsme");
- fsme->path = BLI_strdup(path);
- fsme->save = save;
+ fsm_iter = MEM_mallocN(sizeof(*fsm_iter), "fsme");
+ fsm_iter->path = BLI_strdup(path);
+ fsm_iter->save = (flag & FS_INSERT_SAVE) != 0;
- if (prev) {
- fsme->next = prev->next;
- prev->next = fsme;
+ if (fsm_prev) {
+ if (flag & FS_INSERT_FIRST) {
+ fsm_iter->next = fsm_head;
+ fsmenu_set_category(fsmenu, category, fsm_iter);
+ }
+ else {
+ fsm_iter->next = fsm_prev->next;
+ fsm_prev->next = fsm_iter;
+ }
}
else {
- fsme->next = fsms;
- fsmenu_set_category(fsmenu, category, fsme);
+ fsm_iter->next = fsm_head;
+ fsmenu_set_category(fsmenu, category, fsm_iter);
}
}
void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
{
- FSMenuEntry *prev = NULL, *fsme = NULL;
- FSMenuEntry *fsms = fsmenu_get_category(fsmenu, category);
+ FSMenuEntry *fsm_prev = NULL;
+ FSMenuEntry *fsm_iter;
+ FSMenuEntry *fsm_head;
+
+ fsm_head = fsmenu_get_category(fsmenu, category);
- for (fsme = fsms; fsme && idx; prev = fsme, fsme = fsme->next)
+ for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next)
idx--;
- if (fsme) {
+ if (fsm_iter) {
/* you should only be able to remove entries that were
* not added by default, like windows drives.
* also separators (where path == NULL) shouldn't be removed */
- if (fsme->save && fsme->path) {
+ if (fsm_iter->save && fsm_iter->path) {
/* remove fsme from list */
- if (prev) {
- prev->next = fsme->next;
+ if (fsm_prev) {
+ fsm_prev->next = fsm_iter->next;
}
else {
- fsms = fsme->next;
- fsmenu_set_category(fsmenu, category, fsms);
+ fsm_head = fsm_iter->next;
+ fsmenu_set_category(fsmenu, category, fsm_head);
}
/* free entry */
- MEM_freeN(fsme->path);
- MEM_freeN(fsme);
+ MEM_freeN(fsm_iter->path);
+ MEM_freeN(fsm_iter);
}
}
}
void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename)
{
- FSMenuEntry *fsme = NULL;
- int nskip = 0;
+ FSMenuEntry *fsm_iter = NULL;
+ int nwritten = 0;
FILE *fp = BLI_fopen(filename, "w");
if (!fp) return;
fprintf(fp, "[Bookmarks]\n");
- for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsme; fsme = fsme->next) {
- if (fsme->path && fsme->save) {
- fprintf(fp, "%s\n", fsme->path);
+ for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter; fsm_iter = fsm_iter->next) {
+ if (fsm_iter->path && fsm_iter->save) {
+ fprintf(fp, "%s\n", fsm_iter->path);
}
}
fprintf(fp, "[Recent]\n");
- nskip = fsmenu_get_nentries(fsmenu, FS_CATEGORY_RECENT) - FSMENU_RECENT_MAX;
- /* skip first entries if list too long */
- for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsme && (nskip > 0); fsme = fsme->next, --nskip) {
- /* pass */
- }
- for (; fsme; fsme = fsme->next) {
- if (fsme->path && fsme->save) {
- fprintf(fp, "%s\n", fsme->path);
+ for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nwritten < FSMENU_RECENT_MAX); fsm_iter = fsm_iter->next, ++nwritten) {
+ if (fsm_iter->path && fsm_iter->save) {
+ fprintf(fp, "%s\n", fsm_iter->path);
}
}
fclose(fp);
@@ -288,7 +302,7 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
if (BLI_exists(line))
#endif
{
- fsmenu_insert_entry(fsmenu, category, line, 0, 1);
+ fsmenu_insert_entry(fsmenu, category, line, FS_INSERT_SAVE);
}
}
}
@@ -315,16 +329,16 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
tmps[2] = '\\';
tmps[3] = 0;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, FS_INSERT_SORTED);
}
}
/* Adding Desktop and My Documents */
if (read_bookmarks) {
SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
#else
@@ -347,7 +361,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
FSRefMakePath(&dir, path, FILE_MAX);
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, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
}
}
@@ -357,26 +371,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, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
BLI_snprintf(line, 256, "%s/Desktop/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Documents/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Pictures/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Music/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Movies/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
#else
@@ -409,7 +423,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
continue;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
CFRelease(pathString);
CFRelease(cfURL);
@@ -436,7 +450,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
FSRefMakePath(&dir, path, FILE_MAX);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
}
/* Finally get user favorite places */
@@ -459,7 +473,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, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
CFRelease(pathString);
CFRelease(cfURL);
@@ -477,10 +491,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, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_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, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
@@ -505,10 +519,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
len = strlen(mnt->mnt_dir);
if (len && mnt->mnt_dir[len - 1] != '/') {
BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
+ }
+ else {
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, FS_INSERT_SORTED);
}
- else
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
found = 1;
}
@@ -520,7 +535,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
/* fallback */
if (!found)
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", FS_INSERT_SORTED);
}
}
#endif
@@ -530,15 +545,17 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
static void fsmenu_free_category(struct FSMenu *fsmenu, FSMenuCategory category)
{
- FSMenuEntry *fsme = fsmenu_get_category(fsmenu, category);
+ FSMenuEntry *fsm_iter = fsmenu_get_category(fsmenu, category);
- while (fsme) {
- FSMenuEntry *n = fsme->next;
+ while (fsm_iter) {
+ FSMenuEntry *fsm_next = fsm_iter->next;
- if (fsme->path) MEM_freeN(fsme->path);
- MEM_freeN(fsme);
+ if (fsm_iter->path) {
+ MEM_freeN(fsm_iter->path);
+ }
+ MEM_freeN(fsm_iter);
- fsme = n;
+ fsm_iter = fsm_next;
}
}
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index d7576d71933..30730578085 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -43,6 +43,12 @@ typedef enum FSMenuCategory {
FS_CATEGORY_RECENT
} FSMenuCategory;
+typedef enum FSMenuInsert {
+ FS_INSERT_SORTED = (1 << 0),
+ FS_INSERT_SAVE = (1 << 1),
+ FS_INSERT_FIRST = (1 << 2) /* moves the item to the front of the list when its not already there */
+} FSMenuInsert;
+
struct FSMenu;
struct FSMenu *fsmenu_get(void);
@@ -59,7 +65,7 @@ char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index
* Duplicate entries are not added.
* \param sorted Should entry be inserted in sorted order?
*/
-void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save);
+void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, const FSMenuInsert flag);
/** Return whether the entry was created by the user and can be saved and deleted */
short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 4b568b43695..7f39545258d 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -386,6 +386,7 @@ static void file_operatortypes(void)
WM_operatortype_append(FILE_OT_bookmark_toggle);
WM_operatortype_append(FILE_OT_bookmark_add);
WM_operatortype_append(FILE_OT_delete_bookmark);
+ WM_operatortype_append(FILE_OT_reset_recent);
WM_operatortype_append(FILE_OT_hidedot);
WM_operatortype_append(FILE_OT_filenum);
WM_operatortype_append(FILE_OT_directory_new);
@@ -537,7 +538,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* scrolling here is just annoying, disable it */
- ar->v2d.cur.ymax = BLI_RCT_SIZE_Y(&ar->v2d.cur);
+ ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur);
ar->v2d.cur.ymin = 0;
/* set view2d view matrix for scrolling (without scrollers) */
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index efe62eaf495..0d56b02e086 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -69,12 +69,6 @@
#include "graph_intern.h" // own include
-/* XXX */
-
-/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */
-#define UI_FLT_MAX 10000.0f
-
-
/* ******************* graph editor space & buttons ************** */
#define B_REDR 1
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index e4bda15bc7d..ef2e56afca0 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -88,7 +88,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
FCM_EnvelopeData *fed;
- const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur);
+ const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
/* draw two black lines showing the standard reference levels */
@@ -137,7 +137,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel)
{
BezTriple *bezt = fcu->bezt;
- const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur);
+ const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
/* we use bgl points not standard gl points, to workaround vertex
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index f01d64b46b8..7107a6a2369 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -229,11 +229,11 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i
&cur_new.ymin, &cur_new.ymax,
do_sel_only, include_handles);
- extra = 0.1f * BLI_RCT_SIZE_X(&cur_new);
+ extra = 0.1f * BLI_rctf_size_x(&cur_new);
cur_new.xmin -= extra;
cur_new.xmax += extra;
- extra = 0.1f * BLI_RCT_SIZE_Y(&cur_new);
+ extra = 0.1f * BLI_rctf_size_y(&cur_new);
cur_new.ymin -= extra;
cur_new.ymax += extra;
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 633f2b72cf6..e2fc1657379 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -325,7 +325,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if ((BLI_RCT_SIZE_X(&rect)) >= (BLI_RCT_SIZE_Y(&rect)))
+ if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect)))
mode = BEZT_OK_FRAMERANGE;
else
mode = BEZT_OK_VALUERANGE;
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 40f0683a852..0b904f36a8c 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -71,28 +71,6 @@
#include "image_intern.h"
-#define B_REDR 1
-#define B_IMAGECHANGED 2
-#define B_NOP 0
-#define B_TWINANIM 5
-#define B_SIMAGETILE 6
-#define B_IDNAME 10
-#define B_FACESEL_PAINT_TEST 11
-#define B_SIMA_RECORD 12
-#define B_SIMA_PLAY 13
-
-#define B_SIMANOTHING 16
-#define B_SIMABRUSHCHANGE 17
-#define B_SIMABRUSHBROWSE 18
-#define B_SIMABRUSHLOCAL 19
-#define B_SIMABRUSHDELETE 20
-#define B_KEEPDATA 21
-#define B_SIMABTEXBROWSE 22
-#define B_SIMABTEXDELETE 23
-#define B_VPCOLSLI 24
-#define B_SIMACLONEBROWSE 25
-#define B_SIMACLONEDELETE 26
-
/* proto */
static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, char *str)
@@ -169,47 +147,6 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
/* ************ panel stuff ************* */
-/* is used for both read and write... */
-
-static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt))
-{
- SpaceImage *sima = CTX_wm_space_image(C);
- ImBuf *ibuf;
- void *lock;
- int result;
-
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
- result = ibuf && ibuf->rect_float;
- ED_space_image_release_buffer(sima, lock);
-
- return result;
-}
-
-static void image_panel_curves(const bContext *C, Panel *pa)
-{
- bScreen *sc = CTX_wm_screen(C);
- SpaceImage *sima = CTX_wm_space_image(C);
- ImBuf *ibuf;
- PointerRNA simaptr;
- int levels;
- void *lock;
-
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
-
- if (ibuf) {
- if (sima->cumap == NULL)
- sima->cumap = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
-
- /* curvemap black/white levels only works for RGBA */
- levels = (ibuf->channels == 4);
-
- RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &simaptr);
- uiTemplateCurveMapping(pa->layout, &simaptr, "curve", 'c', levels, 0);
- }
-
- ED_space_image_release_buffer(sima, lock);
-}
-
#if 0
/* 0: disable preview
* otherwise refresh preview
@@ -234,6 +171,7 @@ void image_preview_event(int event)
}
if (exec && G.scene->nodetree) {
+ Scene *scene = G.scene;
/* should work when no node editor in screen..., so we execute right away */
ntreeCompositTagGenerators(G.scene->nodetree);
@@ -244,7 +182,7 @@ void image_preview_event(int event)
BIF_store_spare();
- ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1); /* 1 is do_previews */
+ ntreeCompositExecTree(scene->nodetree, &scene->r, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */
G.scene->nodetree->timecursor = NULL;
G.scene->nodetree->test_break = NULL;
@@ -268,13 +206,13 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
int mval[2];
if (G.scene->r.mode & R_BORDER) {
- winx *= BLI_RCT_SIZE_X(&G.scene->r.border);
- winy *= BLI_RCT_SIZE_Y(&G.scene->r.border);
+ winx *= BLI_rcti_size_x(&G.scene->r.border);
+ winy *= BLI_rctf_size_y(&G.scene->r.border);
}
/* while dragging we need to update the rects, otherwise it doesn't end with correct one */
- BLI_rctf_init(&dispf, 15.0f, BLI_RCT_SIZE_X(&block->rect) - 15.0f, 15.0f, (BLI_RCT_SIZE_Y(&block->rect)) - 15.0f);
+ BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f);
ui_graphics_to_window_rct(sa->win, &dispf, disprect);
/* correction for gla draw */
@@ -611,6 +549,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiLayout *row, *split, *col;
uiBlock *block;
char str[128];
+
void *lock;
if (!ptr->data)
@@ -728,7 +667,11 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiItemL(layout, str, ICON_NONE);
}
}
-
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
+ uiItemR(col, &imaptr, "view_as_render", 0, NULL, ICON_NONE);
+
if (ima->source != IMA_SRC_GENERATED) {
if (compact == 0) { /* background image view doesnt need these */
uiItemS(layout);
@@ -794,15 +737,18 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
MEM_freeN(cb);
}
-void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
+void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_management)
{
ImageFormatData *imf = imfptr->data;
ID *id = imfptr->id.data;
+ PointerRNA display_settings_ptr;
+ PropertyRNA *prop;
const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
/* some settings depend on this being a scene thats rendered */
const short is_render_out = (id && GS(id->name) == ID_SCE);
uiLayout *col, *row, *split, *sub;
+ int show_preview = FALSE;
col = uiLayoutColumn(layout, FALSE);
@@ -843,6 +789,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
}
if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) {
+ show_preview = TRUE;
uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE);
}
@@ -864,6 +811,22 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE);
#endif
}
+
+ /* color management */
+ if (color_management &&
+ (!BKE_imtype_supports_float(imf->imtype) ||
+ (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG)))
+ {
+ prop = RNA_struct_find_property(imfptr, "display_settings");
+ display_settings_ptr = RNA_property_pointer_get(imfptr, prop);
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiItemL(col, IFACE_("Color Management"), ICON_NONE);
+
+ uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE);
+
+ uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings");
+ }
}
void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
@@ -886,14 +849,6 @@ void image_buttons_register(ARegionType *art)
{
PanelType *pt;
- pt = MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
- strcpy(pt->idname, "IMAGE_PT_curves");
- strcpy(pt->label, "Curves");
- pt->draw = image_panel_curves;
- pt->poll = image_panel_poll;
- pt->flag |= PNL_DEFAULT_CLOSED;
- BLI_addtail(&art->paneltypes, pt);
-
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
strcpy(pt->idname, "IMAGE_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index e293264c021..749ba75cfa1 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -51,6 +51,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -70,34 +71,13 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "WM_api.h"
+#include "WM_types.h"
#include "RE_pipeline.h"
#include "image_intern.h"
-#define HEADER_HEIGHT 18
-
-static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
-{
- /* detect if we need to redo the curve map.
- * ibuf->rect is zero for compositor and render results after change
- * convert to 32 bits always... drawing float rects isn't supported well (atis)
- *
- * NOTE: if float buffer changes, we have to manually remove the rect
- */
-
- if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
- if (color_manage) {
- if (ima && ima->source == IMA_SRC_VIEWER)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- }
- else
- ibuf->profile = IB_PROFILE_NONE;
-
- IMB_rect_from_float(ibuf);
- }
-}
-
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
RenderResult *rr;
@@ -112,7 +92,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
}
/* used by node view too */
-void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y,
+void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
{
char str[256];
@@ -136,7 +116,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
/* noisy, high contrast make impossible to read if lower alpha is used. */
glColor4ub(0, 0, 0, 190);
- glRecti(0.0, 0.0, BLI_RCT_SIZE_X(&ar->winrct) + 1, 20);
+ glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, 20);
glDisable(GL_BLEND);
BLF_size(blf_mono_font, 11, 72);
@@ -209,6 +189,20 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
}
+
+ if (color_manage && channels == 4) {
+ float pixel[4];
+
+ if (use_default_view)
+ IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, NULL, &scene->display_settings);
+ else
+ IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, &scene->view_settings, &scene->display_settings);
+
+ BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", pixel[0], pixel[1], pixel[2]);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
}
/* color rectangle */
@@ -252,11 +246,15 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
}
if (color_manage) {
- linearrgb_to_srgb_v4(finalcol, col);
+ if (use_default_view)
+ IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings);
+ else
+ IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings);
}
else {
copy_v4_v4(finalcol, col);
}
+
glDisable(GL_BLEND);
glColor3fv(finalcol);
dx += 5;
@@ -418,10 +416,9 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
MEM_freeN(rectf);
}
-static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
+static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
{
int x, y;
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
/* set zoom */
glPixelZoom(zoomx, zoomy);
@@ -445,6 +442,9 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float);
}
else {
+ unsigned char *display_buffer;
+ void *cache_handle;
+
if (sima->flag & SI_USE_ALPHA) {
fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
@@ -452,17 +452,17 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- /* we don't draw floats buffers directly but
- * convert them, and optionally apply curves */
- image_verify_buffer_float(ima, ibuf, color_manage);
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
- if (ibuf->rect)
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ if (display_buffer)
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
#if 0
else
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float);
#endif
-
+
+ IMB_display_buffer_release(cache_handle);
+
if (sima->flag & SI_USE_ALPHA)
glDisable(GL_BLEND);
}
@@ -471,14 +471,14 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
glPixelZoom(1.0f, 1.0f);
}
-static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
+static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy)
{
unsigned int *rt, *rp, *rectmain;
short y, heigth, len;
/* the right offset in rectot */
- rt = ibuf->rect + (starty * ibuf->x + startx);
+ rt = buffer + (starty * width + startx);
len = (endx - startx);
heigth = (endy - starty);
@@ -487,7 +487,7 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty,
for (y = 0; y < heigth; y++) {
memcpy(rp, rt, len * 4);
- rt += ibuf->x;
+ rt += width;
rp += len;
}
return rectmain;
@@ -495,28 +495,34 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty,
static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
{
+ unsigned char *display_buffer;
unsigned int *rect;
int dx, dy, sx, sy, x, y;
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+ void *cache_handle;
/* verify valid values, just leave this a while */
if (ima->xrep < 1) return;
if (ima->yrep < 1) return;
-
+
+ if (ima->flag & IMA_VIEW_AS_RENDER)
+ display_buffer = IMB_display_buffer_acquire(ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
+ else
+ display_buffer = IMB_display_buffer_acquire(ibuf, NULL, &scene->display_settings, &cache_handle);
+
+ if (!display_buffer)
+ return;
+
glPixelZoom(zoomx, zoomy);
if (sima->curtile >= ima->xrep * ima->yrep)
sima->curtile = ima->xrep * ima->yrep - 1;
- /* create char buffer from float if needed */
- image_verify_buffer_float(ima, ibuf, color_manage);
-
/* retrieve part of image buffer */
dx = ibuf->x / ima->xrep;
dy = ibuf->y / ima->yrep;
sx = (sima->curtile % ima->xrep) * dx;
sy = (sima->curtile / ima->xrep) * dy;
- rect = get_part_from_ibuf(ibuf, sx, sy, sx + dx, sy + dy);
+ rect = get_part_from_buffer((unsigned int*)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy);
/* draw repeated */
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
@@ -529,10 +535,12 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
glPixelZoom(1.0f, 1.0f);
+ IMB_display_buffer_release(cache_handle);
+
MEM_freeN(rect);
}
-static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
+static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
{
const double time_current = PIL_check_seconds_timer();
@@ -549,7 +557,7 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce
if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
else
- draw_image_buffer(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
+ draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
/* only draw until running out of time */
if ((PIL_check_seconds_timer() - time_current) > 0.25)
@@ -632,22 +640,35 @@ static void draw_image_view_tool(Scene *scene)
}
#endif
-static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height)
+static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height)
{
Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
ImBuf *ibuf;
unsigned int size, alpha;
+ unsigned char *display_buffer;
unsigned char *rect, *cp;
+ void *cache_handle;
if (!brush || !brush->clone.image)
return NULL;
ibuf = BKE_image_get_ibuf(brush->clone.image, NULL);
- if (!ibuf || !ibuf->rect)
+ if (!ibuf)
return NULL;
- rect = MEM_dupallocN(ibuf->rect);
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (!display_buffer) {
+ IMB_display_buffer_release(cache_handle);
+
+ return NULL;
+ }
+
+ rect = MEM_dupallocN(display_buffer);
+
+ IMB_display_buffer_release(cache_handle);
+
if (!rect)
return NULL;
@@ -666,7 +687,7 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh
return rect;
}
-static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, float zoomy)
+static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy)
{
Brush *brush;
int x, y, w, h;
@@ -677,7 +698,7 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo
if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
/* this is not very efficient, but glDrawPixels doesn't allow
* drawing with alpha */
- clonerect = get_alpha_clone_image(scene, &w, &h);
+ clonerect = get_alpha_clone_image(C, scene, &w, &h);
if (clonerect) {
UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
@@ -698,8 +719,10 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo
/* draw main image area */
-void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
+void draw_image_main(const bContext *C, ARegion *ar)
{
+ SpaceImage *sima = CTX_wm_space_image(C);
+ Scene *scene = CTX_data_scene(C);
Image *ima;
ImBuf *ibuf;
float zoomx, zoomy;
@@ -748,15 +771,15 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
if (ibuf == NULL)
ED_region_grid_draw(ar, zoomx, zoomy);
else if (sima->flag & SI_DRAW_TILE)
- draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy);
+ draw_image_buffer_repeated(C, sima, ar, scene, ima, ibuf, zoomx, zoomy);
else if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
else
- draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
+ draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
/* paint helpers */
if (sima->mode == SI_MODE_PAINT)
- draw_image_paint_helpers(ar, scene, zoomx, zoomy);
+ draw_image_paint_helpers(C, ar, scene, zoomx, zoomy);
/* XXX integrate this code */
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 79d01491df7..92433449985 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -161,8 +161,8 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
*height = (scene->r.ysch * scene->r.size) / 100;
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
- *width *= BLI_RCT_SIZE_X(&scene->r.border);
- *height *= BLI_RCT_SIZE_Y(&scene->r.border);
+ *width *= BLI_rctf_size_x(&scene->r.border);
+ *height *= BLI_rctf_size_y(&scene->r.border);
}
}
@@ -204,8 +204,8 @@ void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float
ED_space_image_get_size(sima, &width, &height);
- *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width);
- *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height);
+ *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (float)(BLI_rctf_size_x(&ar->v2d.cur) * width);
+ *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (float)(BLI_rctf_size_y(&ar->v2d.cur) * height);
}
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index 0d3a7614f10..f86e59c41a8 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -52,7 +52,7 @@ struct ARegion *image_has_scope_region(struct ScrArea *sa);
extern const char *image_context_dir[]; /* doc access */
/* image_draw.c */
-void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
+void draw_image_main(const struct bContext *C, struct ARegion *ar);
void draw_image_grease_pencil(struct bContext *C, short onlyv2d);
void draw_image_sample_line(struct SpaceImage *sima);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 86722c5158e..16c9405e098 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -55,6 +55,7 @@
#include "BKE_report.h"
#include "BKE_screen.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -98,9 +99,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
if ((width < 4) && (height < 4))
sima->zoom = oldzoom;
- else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom)
+ else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
- else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom)
+ else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
}
@@ -191,7 +192,7 @@ int space_image_main_area_poll(bContext *C)
}
/* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */
-int space_image_main_area_not_uv_brush_poll(bContext *C)
+static int space_image_main_area_not_uv_brush_poll(bContext *C)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
@@ -581,8 +582,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
h = height * aspy;
/* check if the image will fit in the image with (zoom == 1) */
- width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ width = BLI_rcti_size_x(&ar->winrct) + 1;
+ height = BLI_rcti_size_y(&ar->winrct) + 1;
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
/* find the zoom value that will fit the image in the image space */
@@ -1168,6 +1169,10 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
}
BLI_path_abs(simopts->filepath, G.main->name);
}
+
+ /* color management */
+ BKE_color_managed_display_settings_copy(&simopts->im_format.display_settings, &scene->display_settings);
+ BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, &scene->view_settings);
}
ED_space_image_release_buffer(sima, lock);
@@ -1178,6 +1183,8 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
+ BKE_color_managed_view_settings_free(&simopts->im_format.view_settings);
+
simopts->im_format = *(ImageFormatData *)op->customdata;
}
@@ -1190,12 +1197,47 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op
static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
+ BKE_color_managed_view_settings_free(&((ImageFormatData *)op->customdata)->view_settings);
+
*(ImageFormatData *)op->customdata = simopts->im_format;
}
RNA_string_set(op->ptr, "filepath", simopts->filepath);
}
+static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, int save_as_render, void **cache_handle)
+{
+ ImageFormatData *imf = &simopts->im_format;
+ ImBuf *colormanaged_ibuf;
+ int do_colormanagement;
+
+ *cache_handle = NULL;
+ do_colormanagement = save_as_render && !BKE_imtype_supports_float(imf->imtype);
+
+ if (do_colormanagement) {
+ unsigned char *display_buffer;
+
+ display_buffer = IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle);
+
+ if (*cache_handle) {
+ colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
+ colormanaged_ibuf->rect = (unsigned int *) display_buffer;
+ }
+ else {
+ /* no cache handle means color management didn't run transformation
+ * or performed transformation to image's byte buffer which doesn't
+ * require allocating new image buffer
+ */
+ colormanaged_ibuf = ibuf;
+ }
+ }
+ else {
+ colormanaged_ibuf = ibuf;
+ }
+
+ return colormanaged_ibuf;
+}
+
/* assumes name is FILE_MAX */
/* ima->name and ibuf->name should end up the same */
static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
@@ -1205,9 +1247,12 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
+ void *cache_handle;
+ ImBuf *colormanaged_ibuf;
const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
+ const short save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render"));
short ok = FALSE;
/* old global to ensure a 2nd save goes to same dir */
@@ -1231,7 +1276,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24;
}
}
-
+
+ colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, save_as_render, &cache_handle);
+
if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
Scene *scene = CTX_data_scene(C);
RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
@@ -1245,7 +1292,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
BKE_image_release_renderresult(scene, ima);
}
else {
- if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
+ if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy))
+ {
ok = TRUE;
}
}
@@ -1284,6 +1332,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if (relative) {
BLI_path_rel(ima->name, relbase); /* only after saving */
}
+
+ IMB_colormanagment_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf);
}
}
else {
@@ -1294,6 +1344,13 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
WM_cursor_wait(0);
+
+ if (cache_handle) {
+ colormanaged_ibuf->rect = NULL;
+ IMB_freeImBuf(colormanaged_ibuf);
+
+ IMB_display_buffer_release(cache_handle);
+ }
}
ED_space_image_release_buffer(sima, lock);
@@ -1302,6 +1359,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
static void image_save_as_free(wmOperator *op)
{
if (op->customdata) {
+ ImageFormatData *im_format = (ImageFormatData *)op->customdata;
+ BKE_color_managed_view_settings_free(&im_format->view_settings);
+
MEM_freeN(op->customdata);
op->customdata = NULL;
}
@@ -1354,6 +1414,11 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
RNA_boolean_set(op->ptr, "copy", TRUE);
}
+ if (ima->source == IMA_SRC_VIEWER || (ima->flag & IMA_VIEW_AS_RENDER))
+ RNA_boolean_set(op->ptr, "save_as_render", TRUE);
+ else
+ RNA_boolean_set(op->ptr, "save_as_render", FALSE);
+
op->customdata = MEM_mallocN(sizeof(simopts.im_format), __func__);
memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format));
@@ -1389,7 +1454,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &ptr);
- uiTemplateImageSettings(layout, &ptr);
+ uiTemplateImageSettings(layout, &ptr, FALSE);
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
@@ -1417,6 +1482,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
+ RNA_def_boolean(ot->srna, "save_as_render", 0, "Save As Render", "Apply render part of display transform when saving byte image");
RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender");
WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE,
@@ -1601,8 +1667,10 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "color", color);
alpha = RNA_boolean_get(op->ptr, "alpha");
- if (!floatbuf && scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ if (!floatbuf) {
+ /* OCIO_TODO: perhaps we need to convert to display space, not just to sRGB */
linearrgb_to_srgb_v3_v3(color, color);
+ }
if (!alpha)
color[3] = 1.0f;
@@ -1938,14 +2006,18 @@ typedef struct ImageSampleInfo {
float *zfp;
int draw;
+ int color_manage;
+ int use_default_view;
} ImageSampleInfo;
-static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
+static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
{
ImageSampleInfo *info = arg_info;
if (info->draw) {
- /* no color management needed for images (color_manage=0) */
- ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+ Scene *scene = CTX_data_scene(C);
+
+ ED_image_draw_info(scene, ar, info->color_manage, info->use_default_view, info->channels,
+ info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
}
}
@@ -1975,13 +2047,7 @@ int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], floa
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
-
- if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
- linearrgb_to_srgb_v3_v3(r_col, fp);
- }
- else {
- copy_v3_v3(r_col, fp);
- }
+ linearrgb_to_srgb_v3_v3(r_col, fp);
ret = TRUE;
}
else if (ibuf->rect) {
@@ -2003,7 +2069,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
ImageSampleInfo *info = op->customdata;
float fx, fy;
-
+ Scene *scene = CTX_data_scene(C);
+ CurveMapping *curve_mapping = scene->view_settings.curve_mapping;
+
if (ibuf == NULL) {
ED_space_image_release_buffer(sima, lock);
info->draw = 0;
@@ -2016,6 +2084,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
+ Image *image = ED_space_image(sima);
CLAMP(x, 0, ibuf->x - 1);
CLAMP(y, 0, ibuf->y - 1);
@@ -2029,7 +2098,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colfp = NULL;
info->zp = NULL;
info->zfp = NULL;
-
+
+ info->use_default_view = (image->flag & IMA_VIEW_AS_RENDER) ? FALSE : TRUE;
+
if (ibuf->rect) {
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
@@ -2044,6 +2115,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
info->colfp = info->colf;
+
+ info->color_manage = FALSE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -2053,6 +2126,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = fp[2];
info->colf[3] = fp[3];
info->colfp = info->colf;
+
+ info->color_manage = TRUE;
}
if (ibuf->zbuf) {
@@ -2063,25 +2138,21 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->zf = ibuf->zbuf_float[y * ibuf->x + x];
info->zfp = &info->zf;
}
-
- if (sima->cumap && ibuf->channels == 4) {
+
+ if (curve_mapping && ibuf->channels == 4) {
/* we reuse this callback for set curves point operators */
if (RNA_struct_find_property(op->ptr, "point")) {
int point = RNA_enum_get(op->ptr, "point");
if (point == 1) {
- curvemapping_set_black_white(sima->cumap, NULL, info->colfp);
- if (ibuf->rect_float)
- curvemapping_do_ibuf(sima->cumap, ibuf);
+ curvemapping_set_black_white(curve_mapping, NULL, info->colfp);
}
else if (point == 0) {
- curvemapping_set_black_white(sima->cumap, info->colfp, NULL);
- if (ibuf->rect_float)
- curvemapping_do_ibuf(sima->cumap, ibuf);
+ curvemapping_set_black_white(curve_mapping, info->colfp, NULL);
}
}
}
-
+
// XXX node curve integration ..
#if 0
{
@@ -2211,7 +2282,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
hist->co[1][0] = x2f;
hist->co[1][1] = y2f;
- BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
+ BKE_histogram_update_sample_line(hist, ibuf, &scene->view_settings, &scene->display_settings);
/* reset y zoom */
hist->ymax = 1.0f;
@@ -2306,7 +2377,8 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
BKE_image_all_free_anim_ibufs(scene->r.cfra);
ntreeCompositTagAnimated(scene->nodetree);
- ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
+ ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra,
+ &scene->view_settings, &scene->display_settings); /* 1 is no previews */
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 91a0cba2555..abe8dfb751b 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -195,9 +195,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
static void image_free(SpaceLink *sl)
{
SpaceImage *simage = (SpaceImage *) sl;
-
- if (simage->cumap)
- curvemapping_free(simage->cumap);
+
scopes_free(&simage->scopes);
}
@@ -217,8 +215,6 @@ static SpaceLink *image_duplicate(SpaceLink *sl)
SpaceImage *simagen = MEM_dupallocN(sl);
/* clear or remove stuff from old */
- if (simagen->cumap)
- simagen->cumap = curvemapping_copy(simagen->cumap);
scopes_new(&simagen->scopes);
@@ -442,7 +438,12 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_redraw(sa);
break;
case ND_MODE:
+ if (wmn->subtype == NS_EDITMODE_MESH)
+ ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(sa);
+ break;
case ND_RENDER_RESULT:
+ case ND_RENDER_OPTIONS:
case ND_COMPO_RESULT:
if (ED_space_image_show_render(sima))
image_scopes_tag_refresh(sa);
@@ -561,8 +562,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
if (ima)
h *= ima->aspy / ima->aspx;
- winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ winy = BLI_rcti_size_y(&ar->winrct) + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
@@ -652,7 +653,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
image_main_area_set_view2d(sima, ar);
/* we draw image in pixelspace */
- draw_image_main(sima, ar, scene);
+ draw_image_main(C, ar);
/* and uvs in 0.0-1.0 space */
UI_view2d_view_ortho(v2d);
@@ -776,9 +777,9 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar)
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
if (!sima->scopes.ok) {
- BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
}
- scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
}
ED_space_image_release_buffer(sima, lock);
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 4ffa99319c4..5e5e0c87feb 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -368,7 +368,7 @@ static void stats_string(Scene *scene)
s += sprintf(s, "%s | ", versionstr);
if (scene->obedit) {
- if (ob_get_keyblock(scene->obedit))
+ if (BKE_keyblock_from_object(scene->obedit))
s += sprintf(s, "(Key) ");
if (scene->obedit->type == OB_MESH) {
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index abffb955405..abdfa0ef4dd 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot)
int i, b;
rcti rectlink;
- rectlink.xmin = (int)BLI_RCT_CENTER_X(&line->from->rect);
- rectlink.ymin = (int)BLI_RCT_CENTER_Y(&line->from->rect);
- rectlink.xmax = (int)BLI_RCT_CENTER_X(&line->to->rect);
- rectlink.ymax = (int)BLI_RCT_CENTER_Y(&line->to->rect);
+ rectlink.xmin = (int)BLI_rctf_cent_x(&line->from->rect);
+ rectlink.ymin = (int)BLI_rctf_cent_y(&line->from->rect);
+ rectlink.xmax = (int)BLI_rctf_cent_x(&line->to->rect);
+ rectlink.ymax = (int)BLI_rctf_cent_y(&line->to->rect);
if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) {
for (i=0; i<tot-1; i++)
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 6ffac1dcd34..5d7ff77e032 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -72,10 +72,7 @@
#include "logic_intern.h"
-
-#define MAX_RENDER_PASS 100
#define B_REDR 1
-#define B_IDNAME 2
#define B_ADD_SENS 2703
#define B_CHANGE_SENS 2704
@@ -91,7 +88,6 @@
#define B_SOUNDACT_BROWSE 2712
-#define B_SETSECTOR 2713
#define B_SETPROP 2714
#define B_SETACTOR 2715
#define B_SETMAINACTOR 2716
@@ -187,178 +183,6 @@ void make_unique_prop_names(bContext *C, char *str)
MEM_freeN(names);
}
-static void make_unique_prop_names_cb(bContext *C, void *strv, void *UNUSED(redraw_view3d_flagv))
-{
- char *str= strv;
-// int redraw_view3d_flag= GET_INT_FROM_POINTER(redraw_view3d_flagv);
-
- make_unique_prop_names(C, str);
-}
-
-
-static void old_sca_move_sensor(bContext *C, void *datav, void *move_up)
-{
- /* deprecated, no longer using it (moved to sca.c) */
- Scene *scene= CTX_data_scene(C);
- bSensor *sens_to_delete= datav;
- int val;
- Base *base;
- bSensor *sens, *tmp;
-
- // val= pupmenu("Move up%x1|Move down %x2");
- val = move_up ? 1:2;
-
- if (val>0) {
- /* now find out which object has this ... */
- base= FIRSTBASE;
- while (base) {
-
- sens= base->object->sensors.first;
- while (sens) {
- if (sens == sens_to_delete) break;
- sens= sens->next;
- }
-
- if (sens) {
- if ( val==1 && sens->prev) {
- for (tmp=sens->prev; tmp; tmp=tmp->prev) {
- if (tmp->flag & SENS_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->sensors, sens);
- BLI_insertlinkbefore(&base->object->sensors, tmp, sens);
- }
- }
- else if ( val==2 && sens->next) {
- for (tmp=sens->next; tmp; tmp=tmp->next) {
- if (tmp->flag & SENS_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->sensors, sens);
- BLI_insertlink(&base->object->sensors, tmp, sens);
- }
- }
- ED_undo_push(C, "Move sensor");
- break;
- }
-
- base= base->next;
- }
- }
-}
-
-static void old_sca_move_controller(bContext *C, void *datav, void *move_up)
-{
- /* deprecated, no longer using it (moved to sca.c) */
- Scene *scene= CTX_data_scene(C);
- bController *controller_to_del= datav;
- int val;
- Base *base;
- bController *cont, *tmp;
-
- //val= pupmenu("Move up%x1|Move down %x2");
- val = move_up ? 1:2;
-
- if (val>0) {
- /* now find out which object has this ... */
- base= FIRSTBASE;
- while (base) {
-
- cont= base->object->controllers.first;
- while (cont) {
- if (cont == controller_to_del) break;
- cont= cont->next;
- }
-
- if (cont) {
- if ( val==1 && cont->prev) {
- /* locate the controller that has the same state mask but is earlier in the list */
- tmp = cont->prev;
- while (tmp) {
- if (tmp->state_mask & cont->state_mask)
- break;
- tmp = tmp->prev;
- }
- if (tmp) {
- BLI_remlink(&base->object->controllers, cont);
- BLI_insertlinkbefore(&base->object->controllers, tmp, cont);
- }
- }
- else if ( val==2 && cont->next) {
- tmp = cont->next;
- while (tmp) {
- if (tmp->state_mask & cont->state_mask)
- break;
- tmp = tmp->next;
- }
- BLI_remlink(&base->object->controllers, cont);
- BLI_insertlink(&base->object->controllers, tmp, cont);
- }
- ED_undo_push(C, "Move controller");
- break;
- }
-
- base= base->next;
- }
- }
-}
-
-static void old_sca_move_actuator(bContext *C, void *datav, void *move_up)
-{
- /* deprecated, no longer using it (moved to sca.c) */
- Scene *scene= CTX_data_scene(C);
- bActuator *actuator_to_move= datav;
- int val;
- Base *base;
- bActuator *act, *tmp;
-
- //val= pupmenu("Move up%x1|Move down %x2");
- val = move_up ? 1:2;
-
- if (val>0) {
- /* now find out which object has this ... */
- base= FIRSTBASE;
- while (base) {
-
- act= base->object->actuators.first;
- while (act) {
- if (act == actuator_to_move) break;
- act= act->next;
- }
-
- if (act) {
- if ( val==1 && act->prev) {
- /* locate the first visible actuators before this one */
- for (tmp = act->prev; tmp; tmp=tmp->prev) {
- if (tmp->flag & ACT_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->actuators, act);
- BLI_insertlinkbefore(&base->object->actuators, tmp, act);
- }
- }
- else if ( val==2 && act->next) {
- for (tmp=act->next; tmp; tmp=tmp->next) {
- if (tmp->flag & ACT_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->actuators, act);
- BLI_insertlink(&base->object->actuators, tmp, act);
- }
- }
- ED_undo_push(C, "Move actuator");
- break;
- }
-
- base= base->next;
- }
- }
-}
-
static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
{
Main *bmain= CTX_data_main(C);
@@ -631,14 +455,6 @@ static const char *sensor_name(int type)
return "unknown";
}
-static const char *sensor_pup(void)
-{
- /* the number needs to match defines in DNA_sensor_types.h */
- return "Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5|"
- "Touch %x1|Collision %x6|Near %x2|Radar %x7|"
- "Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12|Armature %x14";
-}
-
static const char *controller_name(int type)
{
switch (type) {
@@ -662,11 +478,6 @@ static const char *controller_name(int type)
return "unknown";
}
-static const char *controller_pup(void)
-{
- return "Controllers %t|AND %x0|OR %x1|XOR %x6|NAND %x4|NOR %x5|XNOR %x7|Expression %x2|Python %x3";
-}
-
static const char *actuator_name(int type)
{
switch (type) {
@@ -718,36 +529,6 @@ static const char *actuator_name(int type)
return "unknown";
}
-
-
-
-static const char *actuator_pup(Object *owner)
-{
- switch (owner->type) {
- case OB_ARMATURE:
- return ("Actuators %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1"
- "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
- "|Scene %x11|Random %x13|Message %x14|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
- break;
-
- case OB_MESH:
- return ("Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1"
- "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
- "|Scene %x11|Random %x13|Message %x14|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
- break;
-
- default:
- return ("Actuators %t|Motion %x0|Constraint %x9|Ipo %x1"
- "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
- "|Scene %x11|Random %x13|Message %x14|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
- }
-}
-
-
-
static void set_sca_ob(Object *ob)
{
bController *cont;
@@ -935,151 +716,6 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
return idar;
}
-
-static int get_col_sensor(int type)
-{
- /* XXX themecolors not here */
-
- switch (type) {
- case SENS_ALWAYS: return TH_PANEL;
- case SENS_DELAY: return TH_PANEL;
- case SENS_TOUCH: return TH_PANEL;
- case SENS_COLLISION: return TH_PANEL;
- case SENS_NEAR: return TH_PANEL;
- case SENS_KEYBOARD: return TH_PANEL;
- case SENS_PROPERTY: return TH_PANEL;
- case SENS_ARMATURE: return TH_PANEL;
- case SENS_ACTUATOR: return TH_PANEL;
- case SENS_MOUSE: return TH_PANEL;
- case SENS_RADAR: return TH_PANEL;
- case SENS_RANDOM: return TH_PANEL;
- case SENS_RAY: return TH_PANEL;
- case SENS_MESSAGE: return TH_PANEL;
- case SENS_JOYSTICK: return TH_PANEL;
- default: return TH_PANEL;
- }
-}
-static void set_col_sensor(int type, int medium)
-{
- int col= get_col_sensor(type);
- UI_ThemeColorShade(col, medium?30:0);
-}
-
-
-static void verify_logicbutton_func(bContext *UNUSED(C), void *data1, void *data2)
-{
- bSensor *sens= (bSensor*)data1;
-
- if (sens->level && sens->tap) {
- if (data2 == &(sens->level))
- sens->tap= 0;
- else
- sens->level= 0;
- }
-}
-
-static void test_scriptpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->text, name, offsetof(ID, name) + 2);
-}
-
-static void test_actionpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->action, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-
-static void test_obpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->object, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_lib_extern(*idpp); /* checks lib data, sets correct flag for saving then */
-}
-
-static void test_meshpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->mesh, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-static void test_matpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->mat, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-static void test_scenepoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->scene, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-static void test_keyboard_event(struct bContext *UNUSED(C), void *arg_ks, void *UNUSED(arg))
-{
- bKeyboardSensor *ks= (bKeyboardSensor*)arg_ks;
-
- if (!ISKEYBOARD(ks->key))
- ks->key= 0;
- if (!ISKEYBOARD(ks->qual))
- ks->qual= 0;
- if (!ISKEYBOARD(ks->qual2))
- ks->qual2= 0;
-}
-
-/**
- * Draws a toggle for pulse mode, a frequency field and a toggle to invert
- * the value of this sensor. Operates on the shared data block of sensors.
- */
-static void draw_default_sensor_header(bSensor *sens,
- uiBlock *block,
- short x,
- short y,
- short w)
-{
- uiBut *but;
-
- /* Pulsing and frequency */
- uiBlockBeginAlign(block);
- uiDefIconButBitS(block, TOG, SENS_PULSE_REPEAT, 1, ICON_DOTSUP,
- (short)(x + 10 + 0.0 * (w - 20)), (short)(y - 21), (short)(0.1 * (w - 20)), 19,
- &sens->pulse, 0.0, 0.0, 0, 0,
- "Activate TRUE level triggering (pulse mode)");
-
- uiDefIconButBitS(block, TOG, SENS_NEG_PULSE_MODE, 1, ICON_DOTSDOWN,
- (short)(x + 10 + 0.1 * (w-20)), (short)(y - 21), (short)(0.1 * (w-20)), 19,
- &sens->pulse, 0.0, 0.0, 0, 0,
- "Activate FALSE level triggering (pulse mode)");
- uiDefButS(block, NUM, 1, "f:",
- (short)(x + 10 + 0.2 * (w-20)), (short)(y - 21), (short)(0.275 * (w-20)), 19,
- &sens->freq, 0.0, 10000.0, 0, 0,
- "Delay between repeated pulses (in logic tics, 0 = no delay)");
- uiBlockEndAlign(block);
-
- /* value or shift? */
- uiBlockBeginAlign(block);
- but = uiDefButS(block, TOG, 1, "Level",
- (short)(x + 10 + 0.5 * (w-20)), (short)(y - 21), (short)(0.20 * (w-20)), 19,
- &sens->level, 0.0, 0.0, 0, 0,
- "Level detector, trigger controllers of new states (only applicable upon logic state transition)");
- uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->level));
- but = uiDefButS(block, TOG, 1, "Tap",
- (short)(x + 10 + 0.702 * (w-20)), (short)(y - 21), (short)(0.12 * (w-20)), 19,
- &sens->tap, 0.0, 0.0, 0, 0,
- "Trigger controllers only for an instant, even while the sensor remains true");
- uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->tap));
- uiBlockEndAlign(block);
-
- uiDefButS(block, TOG, 1, "Inv",
- (short)(x + 10 + 0.85 * (w-20)), (short)(y - 21), (short)(0.15 * (w-20)), 19,
- &sens->invert, 0.0, 0.0, 0, 0,
- "Invert the level (output) of this sensor");
-}
-
static void get_armature_bone_constraint(Object *ob, const char *posechannel, const char *constraint_name, bConstraint **constraint)
{
/* check that bone exist in the active object */
@@ -1094,1848 +730,6 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co
}
/* didn't find any */
}
-static void check_armature_bone_constraint(Object *ob, char *posechannel, char *constraint)
-{
- /* check that bone exist in the active object */
- if (ob->type == OB_ARMATURE && ob->pose) {
- bPoseChannel *pchan;
- bPose *pose = ob->pose;
- for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
- if (!strcmp(pchan->name, posechannel)) {
- /* found it, now look for constraint channel */
- bConstraint *con;
- for (con=pchan->constraints.first; con; con=con->next) {
- if (!strcmp(con->name, constraint)) {
- /* found it, all ok */
- return;
- }
- }
- /* didn't find constraint, make empty */
- constraint[0] = 0;
- return;
- }
- }
- }
- /* didn't find any */
- posechannel[0] = 0;
- constraint[0] = 0;
-}
-
-static void check_armature_sensor(bContext *C, void *arg1_but, void *arg2_sens)
-{
- bArmatureSensor *sens = arg2_sens;
- uiBut *but = arg1_but;
- Object *ob= CTX_data_active_object(C);
-
- /* check that bone exist in the active object */
- but->retval = B_REDR;
- check_armature_bone_constraint(ob, sens->posechannel, sens->constraint);
-}
-
-static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short xco, short yco, short width)
-{
- bNearSensor *ns = NULL;
- bTouchSensor *ts = NULL;
- bKeyboardSensor *ks = NULL;
- bPropertySensor *ps = NULL;
- bArmatureSensor *arm = NULL;
- bMouseSensor *ms = NULL;
- bCollisionSensor *cs = NULL;
- bRadarSensor *rs = NULL;
- bRandomSensor *randomSensor = NULL;
- bRaySensor *raySens = NULL;
- bMessageSensor *mes = NULL;
- bJoystickSensor *joy = NULL;
- bActuatorSensor *as = NULL;
- bDelaySensor *ds = NULL;
- uiBut *but;
- short ysize;
- const char *str;
-
- /* yco is at the top of the rect, draw downwards */
-
- set_col_sensor(sens->type, 0);
-
- switch (sens->type) {
- case SENS_ALWAYS:
- {
- ysize= 24;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- yco-= ysize;
-
- break;
- }
- case SENS_TOUCH:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- ts= sens->data;
-
- // uiDefBut(block, TEX, 1, "Property:", xco, yco-22, width, 19, &ts->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property");
- uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:", (short)(xco + 10), (short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material");
- // uiDefButF(block, NUM, 1, "Margin:", xco+width/2, yco-44, width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity");
- yco-= ysize;
- break;
- }
- case SENS_COLLISION:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- cs= sens->data;
-
- /* The collision sensor will become a generic collision (i.e. it */
- /* absorb the old touch sensor). */
-
- uiDefButBitS(block, TOG, SENS_COLLISION_PULSE, B_REDR, "Pulse", (short)(xco + 10), (short)(yco - 44),
- (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0,
- "Changes to the set of colliding objects generated pulses");
-
- uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P", (short)(xco + 10 + (0.20 * (width-20))), (short)(yco - 44),
- (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0,
- "Toggle collision on material or property");
-
- if (cs->mode & SENS_COLLISION_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)),
- (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44),
- (short)(0.6*(width-20)), 19, &cs->name, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this property");
- }
-
- /* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90, yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */
-
- yco-= ysize;
- break;
- }
- case SENS_NEAR:
- {
- ysize= 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- ns= sens->data;
-
- uiDefBut(block, TEX, 1, "Property:", (short)(10+xco), (short)(yco-44), (short)(width-20), 19,
- &ns->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property");
- uiDefButF(block, NUM, 1, "Dist", (short)(10+xco), (short)(yco-68), (short)((width-22)/2), 19,
- &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance");
- uiDefButF(block, NUM, 1, "Reset", (short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19,
- &ns->resetdist, 0.0, 1000.0, 1000, 0, "Reset distance");
- yco-= ysize;
- break;
- }
- case SENS_RADAR:
- {
- ysize= 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- rs= sens->data;
-
- uiDefBut(block, TEX, 1, "Prop:",
- (short)(10+xco), (short)(yco-44), (short)(0.7 * (width-20)), 19,
- &rs->name, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this property");
-
- str = "Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5";
- uiDefButS(block, MENU, B_REDR, str,
- (short)(10+xco+0.7 * (width-20)), (short)(yco-44), (short)(0.3 * (width-22)), 19,
- &rs->axis, 2.0, 31, 0, 0,
- "Specify along which axis the radar cone is cast");
-
- uiDefButF(block, NUM, 1, "Ang:",
- (short)(10+xco), (short)(yco-68), (short)((width-20)/2), 19,
- &rs->angle, 0.0, 179.9, 10, 0,
- "Opening angle of the radar cone");
- uiDefButF(block, NUM, 1, "Dist:",
- (short)(xco+10 + (width-20)/2), (short)(yco-68), (short)((width-20)/2), 19,
- &rs->range, 0.01, 10000.0, 100, 0,
- "Depth of the radar cone");
- yco-= ysize;
- break;
- }
- case SENS_KEYBOARD:
- {
- ks= sens->data;
-
- /* 5 lines: 120 height */
- ysize= (ks->type&1) ? 96:120;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* header line */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- /* part of line 1 */
- uiDefBut(block, LABEL, 0, "Key", xco, yco-44, 40, 19, NULL, 0, 0, 0, 0, "");
- uiDefButBitS(block, TOG, 1, B_REDR, "All keys", xco+40+(width/2), yco-44, (width/2)-50, 19,
- &ks->type, 0, 0, 0, 0, "");
-
-
- if ((ks->type&1)==0) { /* is All Keys option off? */
- /* line 2: hotkey and allkeys toggle */
- but = uiDefKeyevtButS(block, 0, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code");
- uiButSetFunc(but, test_keyboard_event, ks, NULL);
-
- /* line 3: two key modifyers (qual1, qual2) */
- uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, "");
- but = uiDefKeyevtButS(block, 0, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code");
- uiButSetFunc(but, test_keyboard_event, ks, NULL);
- but = uiDefKeyevtButS(block, 0, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code");
- uiButSetFunc(but, test_keyboard_event, ks, NULL);
- }
-
- /* line 4: toggle property for string logging mode */
- uiDefBut(block, TEX, 1, "LogToggle: ",
- xco+10, yco-((ks->type&1) ? 68:92), (width-20), 19,
- ks->toggleName, 0, MAX_NAME, 0, 0,
- "Property that indicates whether to log "
- "keystrokes as a string");
-
- /* line 5: target property for string logging mode */
- uiDefBut(block, TEX, 1, "Target: ",
- xco+10, yco-((ks->type&1) ? 92:116), (width-20), 19,
- ks->targetName, 0, MAX_NAME, 0, 0,
- "Property that receives the keystrokes in case "
- "a string is logged");
-
- yco-= ysize;
- break;
- }
- case SENS_PROPERTY:
- {
- ysize= 96;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- ps= sens->data;
-
- str= "Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3";
- /* str= "Type %t|Equal %x0|Not Equal %x1"; */
- uiDefButI(block, MENU, B_REDR, str, xco+30, yco-44, width-60, 19,
- &ps->type, 0, 31, 0, 0, "Type");
-
- if (ps->type != SENS_PROP_EXPRESSION) {
- uiDefBut(block, TEX, 1, "Prop: ", xco+30, yco-68, width-60, 19,
- ps->name, 0, MAX_NAME, 0, 0, "Property name");
- }
-
- if (ps->type == SENS_PROP_INTERVAL) {
- uiDefBut(block, TEX, 1, "Min: ", xco, yco-92, width/2, 19,
- ps->value, 0, MAX_NAME, 0, 0, "check for min value");
- uiDefBut(block, TEX, 1, "Max: ", xco+width/2, yco-92, width/2, 19,
- ps->maxvalue, 0, MAX_NAME, 0, 0, "check for max value");
- }
- else if (ps->type == SENS_PROP_CHANGED) {
- /* pass */
- }
- else {
- uiDefBut(block, TEX, 1, "Value: ", xco+30, yco-92, width-60, 19,
- ps->value, 0, MAX_NAME, 0, 0, "check for value");
- }
-
- yco-= ysize;
- break;
- }
- case SENS_ARMATURE:
- {
- ysize= 70;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- arm= sens->data;
-
- if (ob->type == OB_ARMATURE) {
- uiBlockBeginAlign(block);
- but = uiDefBut(block, TEX, 1, "Bone: ",
- (xco+10), (yco-44), (width-20)/2, 19,
- arm->posechannel, 0, MAX_NAME, 0, 0,
- "Bone on which you want to check a constraint");
- uiButSetFunc(but, check_armature_sensor, but, arm);
- but = uiDefBut(block, TEX, 1, "Cons: ",
- (xco+10)+(width-20)/2, (yco-44), (width-20)/2, 19,
- arm->constraint, 0, MAX_NAME, 0, 0,
- "Name of the constraint you want to control");
- uiButSetFunc(but, check_armature_sensor, but, arm);
- uiBlockEndAlign(block);
-
- str= "Type %t|State changed %x0|Lin error below %x1|Lin error above %x2|Rot error below %x3|Rot error above %x4";
-
- uiDefButI(block, MENU, B_REDR, str, xco+10, yco-66, 0.4*(width-20), 19,
- &arm->type, 0, 31, 0, 0, "Type");
-
- if (arm->type != SENS_ARM_STATE_CHANGED) {
- uiDefButF(block, NUM, 1, "Value: ", xco+10+0.4*(width-20), yco-66, 0.6*(width-20), 19,
- &arm->value, -10000.0, 10000.0, 100, 0, "Test the error against this value");
- }
- }
- yco-= ysize;
- break;
- }
- case SENS_ACTUATOR:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- as= sens->data;
-
- uiDefBut(block, TEX, 1, "Act: ", xco+30, yco-44, width-60, 19,
- as->name, 0, MAX_NAME, 0, 0, "Actuator name, actuator active state modifications will be detected");
- yco-= ysize;
- break;
- }
- case SENS_DELAY:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- ds = sens->data;
-
- uiDefButS(block, NUM, 0, "Delay", (short)(10+xco), (short)(yco-44), (short)((width-22)*0.4+10), 19,
- &ds->delay, 0.0, 5000.0, 0, 0, "Delay in number of logic tics before the positive trigger (default 60 per second)");
- uiDefButS(block, NUM, 0, "Dur", (short)(10+xco+(width-22)*0.4+10), (short)(yco-44), (short)((width-22)*0.4-10), 19,
- &ds->duration, 0.0, 5000.0, 0, 0, "If >0, delay in number of logic tics before the negative trigger following the positive trigger");
- uiDefButBitS(block, TOG, SENS_DELAY_REPEAT, 0, "REP", (short)(xco + 10 + (width-22)*0.8), (short)(yco - 44),
- (short)(0.20 * (width-22)), 19, &ds->flag, 0.0, 0.0, 0, 0,
- "Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics");
- yco-= ysize;
- break;
- }
- case SENS_MOUSE:
- {
- ms= sens->data;
- /* Two lines: 48 pixels high. */
- ysize = 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* line 1: header */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- /* Line 2: type selection. The number are a bit mangled to get
- * proper compatibility with older .blend files. */
-
- /* Any sensor type default is 0 but the ms enum starts in 1.
- * Therefore the mouse sensor is initialized to 1 in sca.c */
- str= "Type %t|Left button %x1|Middle button %x2|"
- "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, (width*0.8f)-20, 19,
- &ms->type, 0, 31, 0, 0,
- "Specify the type of event this mouse sensor should trigger on");
-
- if (ms->type==32) {
- uiDefButBitS(block, TOG, SENS_MOUSE_FOCUS_PULSE, B_REDR, "Pulse", (short)(xco + 10) + (width*0.8f)-20, (short)(yco - 44),
- (short)(0.20 * (width-20)), 19, &ms->flag, 0.0, 0.0, 0, 0,
- "Moving the mouse over a different object generates a pulse");
- }
-
- yco-= ysize;
- break;
- }
- case SENS_RANDOM:
- {
- ysize = 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- randomSensor = sens->data;
- /* some files were wrongly written, avoid crash now */
- if (randomSensor) {
- uiDefButI(block, NUM, 1, "Seed: ", xco+10, yco-44, (width-20), 19,
- &randomSensor->seed, 0, 1000, 0, 0,
- "Initial seed of the generator. (Choose 0 for not random)");
- }
- yco-= ysize;
- break;
- }
- case SENS_RAY:
- {
- ysize = 72;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- raySens = sens->data;
-
- /* 1. property or material */
- uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P",
- xco + 10, yco - 44, 0.20 * (width-20), 19,
- &raySens->mode, 0.0, 0.0, 0, 0,
- "Toggle collision on material or property");
-
- if (raySens->mode & SENS_COLLISION_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19,
- &raySens->matname, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19,
- &raySens->propname, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this property");
- }
-
- /* X-Ray option */
- uiDefButBitS(block, TOG, SENS_RAY_XRAY, 1, "X",
- xco + 10, yco - 68, 0.10 * (width-20), 19,
- &raySens->mode, 0.0, 0.0, 0, 0,
- "Toggle X-Ray option (see through objects that don't have the property)");
- /* 2. sensing range */
- uiDefButF(block, NUM, 1, "Range", xco+10 + 0.10 * (width-20), yco-68, 0.5 * (width-20), 19,
- &raySens->range, 0.01, 10000.0, 100, 0,
- "Sense objects no farther than this distance");
-
- /* 3. axis choice */
- str = "Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5";
- uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &raySens->axisflag, 2.0, 31, 0, 0,
- "Specify along which axis the ray is cast");
-
- yco-= ysize;
- break;
- }
- case SENS_MESSAGE:
- {
- mes = sens->data;
- ysize = 2 * 24; /* total number of lines * 24 pixels/line */
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- /* line 1: header line */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- /* line 2: Subject filter */
- uiDefBut(block, TEX, 1, "Subject: ",
- (xco+10), (yco-44), (width-20), 19,
- mes->subject, 0, MAX_NAME, 0, 0,
- "Optional subject filter: only accept messages with this subject"
- ", or empty for all");
-
- yco -= ysize;
- break;
- }
- case SENS_JOYSTICK:
- {
-
- ysize = 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* line 1: header */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- joy= sens->data;
-
- uiDefButC(block, NUM, 1, "Index:", xco+10, yco-44, 0.33 * (width-20), 19,
- &joy->joyindex, 0, SENS_JOY_MAXINDEX-1, 100, 0,
- "Specify which joystick to use");
-
- str= "Type %t|Button %x0|Axis %x1|Single Axis %x3|Hat%x2";
- uiDefButC(block, MENU, B_REDR, str, xco+87, yco-44, 0.26 * (width-20), 19,
- &joy->type, 0, 31, 0, 0,
- "The type of event this joystick sensor is triggered on");
-
- if (joy->type != SENS_JOY_AXIS_SINGLE) {
- if (joy->flag & SENS_JOY_ANY_EVENT) {
- switch (joy->type) {
- case SENS_JOY_AXIS:
- str = "All Axis Events";
- break;
- case SENS_JOY_BUTTON:
- str = "All Button Events";
- break;
- default:
- str = "All Hat Events";
- break;
- }
- }
- else {
- str = "All";
- }
-
- uiDefButBitS(block, TOG, SENS_JOY_ANY_EVENT, B_REDR, str,
- xco+10 + 0.475 * (width-20), yco-68, ((joy->flag & SENS_JOY_ANY_EVENT) ? 0.525 : 0.12) * (width-20), 19,
- &joy->flag, 0, 0, 0, 0,
- "Triggered by all events on this joysticks current type (axis/button/hat)");
- }
- if (joy->type == SENS_JOY_BUTTON) {
- if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
- uiDefButI(block, NUM, 1, "Number:", xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &joy->button, 0, 18, 100, 0,
- "Specify which button to use");
- }
- }
- else if (joy->type == SENS_JOY_AXIS) {
- uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19,
- &joy->axis, 1, 8.0, 100, 0,
- "Specify which axis pair to use, 1 is useually the main direction input");
-
- uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20), yco-44, 0.4 * (width-20), 19,
- &joy->precision, 0, 32768.0, 100, 0,
- "Specify the precision of the axis");
-
- if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
- str = "Type %t|Up Axis %x1 |Down Axis %x3|Left Axis %x2|Right Axis %x0";
- uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &joy->axisf, 2.0, 31, 0, 0,
- "The direction of the axis, use 'All Events' to receive events on any direction");
- }
- }
- else if (joy->type == SENS_JOY_HAT) {
- uiDefButI(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19,
- &joy->hat, 1, 4.0, 100, 0,
- "Specify which hat to use");
-
- if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
- str = "Direction%t|Up%x1|Down%x4|Left%x8|Right%x2|%l|Up/Right%x3|Down/Left%x12|Up/Left%x9|Down/Right%x6";
- uiDefButI(block, MENU, 0, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &joy->hatf, 2.0, 31, 0, 0,
- "The direction of the hat, use 'All Events' to receive events on any direction");
- }
- }
- else { /* (joy->type == SENS_JOY_AXIS_SINGLE)*/
- uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19,
- &joy->axis_single, 1, 16.0, 100, 0,
- "Specify a single axis (verticle/horizontal/other) to detect");
-
- uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20), yco-44, 0.4 * (width-20), 19,
- &joy->precision, 0, 32768.0, 100, 0,
- "Specify the precision of the axis");
- }
- yco-= ysize;
- break;
- }
- }
-
- return yco-4;
-}
-
-
-
-static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco, short yco, short width)
-{
- bExpressionCont *ec;
- bPythonCont *pc;
- short ysize;
-
- switch (cont->type) {
- case CONT_EXPRESSION:
- ysize= 28;
-
- UI_ThemeColor(TH_PANEL);
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* uiDefBut(block, LABEL, 1, "Not yet...", xco, yco-24, 80, 19, NULL, 0, 0, 0, 0, ""); */
- ec= cont->data;
- /* uiDefBut(block, BUT, 1, "Variables", xco, yco-24, 80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */
- uiDefBut(block, TEX, 1, "Exp:", xco + 10, yco-21, width-20, 19,
- ec->str, 0, sizeof(ec->str), 0, 0,
- "Expression");
-
- yco-= ysize;
- break;
- case CONT_PYTHON:
- ysize= 28;
-
- if (cont->data==NULL) init_controller(cont);
- pc= cont->data;
-
- UI_ThemeColor(TH_PANEL);
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
-
- uiBlockBeginAlign(block);
- uiDefButI(block, MENU, B_REDR, "Execution Method%t|Script%x0|Module%x1", xco+4, yco-23, 66, 19, &pc->mode, 0, 0, 0, 0, "Python script type (textblock or module - faster)");
- if (pc->mode==0)
- uiDefIDPoinBut(block, test_scriptpoin_but, ID_TXT, 1, "", xco+70, yco-23, width-74, 19, &pc->text, "Blender textblock to run as a script");
- else {
- uiDefBut(block, TEX, 1, "", xco+70, yco-23, (width-70)-25, 19, pc->module, 0, sizeof(pc->module), 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used");
- uiDefButBitI(block, TOG, CONT_PY_DEBUG, B_REDR, "D", (xco+width)-25, yco-23, 19, 19, &pc->flag, 0, 0, 0, 0, "Continuously reload the module from disk for editing external modules without restarting");
- }
- uiBlockEndAlign(block);
-
- yco-= ysize;
- break;
-
- default:
- ysize= 4;
-
- UI_ThemeColor(TH_PANEL);
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- yco-= ysize;
- }
-
- return yco;
-}
-
-static int get_col_actuator(int type)
-{
- switch (type) {
- case ACT_ACTION: return TH_PANEL;
- case ACT_SHAPEACTION: return TH_PANEL;
- case ACT_OBJECT: return TH_PANEL;
- case ACT_IPO: return TH_PANEL;
- case ACT_PROPERTY: return TH_PANEL;
- case ACT_SOUND: return TH_PANEL;
- case ACT_CAMERA: return TH_PANEL;
- case ACT_EDIT_OBJECT: return TH_PANEL;
- case ACT_GROUP: return TH_PANEL;
- case ACT_RANDOM: return TH_PANEL;
- case ACT_SCENE: return TH_PANEL;
- case ACT_MESSAGE: return TH_PANEL;
- case ACT_GAME: return TH_PANEL;
- case ACT_VISIBILITY: return TH_PANEL;
- case ACT_CONSTRAINT: return TH_PANEL;
- case ACT_STATE: return TH_PANEL;
- case ACT_ARMATURE: return TH_PANEL;
- case ACT_STEERING: return TH_PANEL;
- default: return TH_PANEL;
- }
-}
-static void set_col_actuator(int item, int medium)
-{
- int col= get_col_actuator(item);
- UI_ThemeColorShade(col, medium?30:10);
-
-}
-
-static void change_object_actuator(bContext *UNUSED(C), void *act, void *UNUSED(arg))
-{
- bObjectActuator *oa = act;
-
- if (oa->type != oa->otype) {
- switch (oa->type) {
- case ACT_OBJECT_NORMAL:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_FORCE_LOCAL|ACT_TORQUE_LOCAL|ACT_DLOC_LOCAL|ACT_DROT_LOCAL;
- oa->type = ACT_OBJECT_NORMAL;
- break;
-
- case ACT_OBJECT_SERVO:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_LIN_VEL_LOCAL;
- oa->type = ACT_OBJECT_SERVO;
- oa->forcerot[0] = 30.0f;
- oa->forcerot[1] = 0.5f;
- oa->forcerot[2] = 0.0f;
- break;
- }
- }
-}
-
-static void change_ipo_actuator(bContext *UNUSED(C), void *arg1_but, void *arg2_ia)
-{
- bIpoActuator *ia = arg2_ia;
- uiBut *but = arg1_but;
-
- if (but->retval & ACT_IPOFORCE)
- ia->flag &= ~ACT_IPOADD;
- else if (but->retval & ACT_IPOADD)
- ia->flag &= ~ACT_IPOFORCE;
- but->retval = B_REDR;
-}
-
-static void update_object_actuator_PID(bContext *UNUSED(C), void *act, void *UNUSED(arg))
-{
- bObjectActuator *oa = act;
- oa->forcerot[0] = 60.0f*oa->forcerot[1];
-}
-
-static char *get_state_name(Object *ob, short bit)
-{
- bController *cont;
- unsigned int mask;
-
- mask = (1<<bit);
- cont = ob->controllers.first;
- while (cont) {
- if (cont->state_mask & mask) {
- return cont->name;
- }
- cont = cont->next;
- }
- return (char*)"";
-}
-
-static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask)
-{
- wmWindow *win= CTX_wm_window(C);
- int shift= win->eventstate->shift;
- unsigned int *cont_mask = arg2_mask;
- uiBut *but = arg1_but;
-
- if (*cont_mask == 0 || !(shift))
- *cont_mask = (1<<but->retval);
- but->retval = B_REDR;
-}
-
-static void check_armature_actuator(bContext *C, void *arg1_but, void *arg2_act)
-{
- bArmatureActuator *act = arg2_act;
- uiBut *but = arg1_but;
- Object *ob= CTX_data_active_object(C);
-
- /* check that bone exist in the active object */
- but->retval = B_REDR;
- check_armature_bone_constraint(ob, act->posechannel, act->constraint);
-}
-
-
-static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
-{
- bSoundActuator *sa = NULL;
- bObjectActuator *oa = NULL;
- bIpoActuator *ia = NULL;
- bPropertyActuator *pa = NULL;
- bCameraActuator *ca = NULL;
- bEditObjectActuator *eoa = NULL;
- bConstraintActuator *coa = NULL;
- bSceneActuator *sca = NULL;
- bGroupActuator *ga = NULL;
- bRandomActuator *randAct = NULL;
- bMessageActuator *ma = NULL;
- bActionActuator *aa = NULL;
- bGameActuator *gma = NULL;
- bVisibilityActuator *visAct = NULL;
- bTwoDFilterActuator *tdfa = NULL;
- bParentActuator *parAct = NULL;
- bStateActuator *staAct = NULL;
- bArmatureActuator *armAct = NULL;
-
- float *fp;
- short ysize = 0, wval;
- const char *str;
- int myline, stbit;
- uiBut *but;
-
-
- /* yco is at the top of the rect, draw downwards */
- set_col_actuator(act->type, 0);
-
- switch (act->type) {
- case ACT_OBJECT:
- {
- oa = act->data;
- wval = (width-100)/3;
- if (oa->type == ACT_OBJECT_NORMAL) {
- if (ob->gameflag & OB_DYNAMIC) {
- ysize= 175;
- }
- else {
- ysize= 72;
- }
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiBlockBeginAlign(block);
- uiDefBut(block, LABEL, 0, "Loc", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "Sets the location");
- uiDefButF(block, NUM, 0, "", xco+45, yco-45, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-45, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-45, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "Rot", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the rotation");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
-
- if (ob->gameflag & OB_DYNAMIC) {
- uiDefBut(block, LABEL, 0, "Force", xco, yco-87, 55, 19, NULL, 0, 0, 0, 0, "Sets the force");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-87, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-87, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "Torque", xco, yco-106, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
- }
-
- if (ob->gameflag & OB_DYNAMIC) {
- uiDefBut(block, LABEL, 0, "LinV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "AngV", xco, yco-148, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-148, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-148, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "Damp", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity");
- uiDefButS(block, NUM, 0, "", xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, "");
-
- uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L", xco+45+3*wval, yco-87, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-129, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_ANG_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-148, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
-
- uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "use_additive", xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV");
- }
- }
- else if (oa->type == ACT_OBJECT_SERVO) {
- ysize= 195;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefBut(block, LABEL, 0, "Ref", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "");
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+45, yco-45, wval*3, 19, &(oa->reference), "Reference object for velocity calculation, leave empty for world reference");
- uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, NULL, 0, 0, 0, 0, "Sets the target relative linear velocity, it will be achieved by automatic application of force. Null velocity is a valid target");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
- uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-68, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Velocity is defined in local coordinates");
-
- uiDefBut(block, LABEL, 0, "Limit", xco, yco-91, 45, 19, NULL, 0, 0, 0, 0, "Select if the force needs to be limited along certain axis (local or global depending on LinV Local flag)");
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_X, B_REDR, "X", xco+45, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the X axis");
- uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Y, B_REDR, "Y", xco+45+wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Y axis");
- uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Z, B_REDR, "Z", xco+45+2*wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Z axis");
- uiBlockEndAlign(block);
- uiDefBut(block, LABEL, 0, "Max", xco, yco-110, 45, 19, NULL, 0, 0, 0, 0, "Set the upper limit for force");
- uiDefBut(block, LABEL, 0, "Min", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Set the lower limit for force");
- if (oa->flag & ACT_SERVO_LIMIT_X) {
- uiDefButF(block, NUM, 0, "", xco+45, yco-110, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, "");
- }
- if (oa->flag & ACT_SERVO_LIMIT_Y) {
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-110, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, "");
- }
- if (oa->flag & ACT_SERVO_LIMIT_Z) {
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-110, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, "");
- }
- uiDefBut(block, LABEL, 0, "Servo", xco, yco-152, 45, 19, NULL, 0, 0, 0, 0, "Coefficients of the PID servo controller");
- uiDefButF(block, NUMSLI, B_REDR, "P: ", xco+45, yco-152, wval*3, 19, oa->forcerot, 0.00, 200.0, 100, 0, "Proportional coefficient, typical value is 60x Integral coefficient");
- uiDefBut(block, LABEL, 0, "Slow", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Low value of I coefficient correspond to slow response");
- but = uiDefButF(block, NUMSLI, B_REDR, " I : ", xco+45, yco-171, wval*3, 19, oa->forcerot+1, 0.0, 3.0, 1, 0, "Integral coefficient, low value (0.01) for slow response, high value (0.5) for fast response");
- uiButSetFunc(but, update_object_actuator_PID, oa, NULL);
- uiDefBut(block, LABEL, 0, "Fast", xco+45+3*wval, yco-171, 45, 19, NULL, 0, 0, 0, 0, "High value of I coefficient correspond to fast response");
- uiDefButF(block, NUMSLI, B_REDR, "D: ", xco+45, yco-190, wval*3, 19, oa->forcerot+2, -100.0, 100.0, 100, 0, "Derivate coefficient, not required, high values can cause instability");
- }
- str= "Motion Type %t|Simple motion %x0|Servo Control %x1";
- but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &oa->type, 0.0, 0.0, 0, 0, "");
- oa->otype = oa->type;
- uiButSetFunc(but, change_object_actuator, oa, NULL);
- yco-= ysize;
- break;
- }
- case ACT_ACTION:
- case ACT_SHAPEACTION:
- {
- /* DrawAct */
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- ysize = 112;
-#else
- ysize= 92;
-#endif
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- aa = act->data;
- wval = (width-60)/3;
-
- // str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7";
-#else
- str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
-#endif
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, width/3, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type");
- uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+10+ (width/3), yco-24, ((width/3)*2) - (20 + 60), 19, &aa->act, "Action name");
-
- uiDefButBitS(block, TOGN, 1, 0, "Continue", xco+((width/3)*2)+20, yco-24, 60, 19,
- &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time");
-
-
- if (aa->type == ACT_ACTION_FROM_PROP) {
- uiDefBut(block, TEX, 0, "Prop: ", xco+10, yco-44, width-20, 19, aa->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Action position");
- }
- else {
- uiDefButF(block, NUM, 0, "Sta: ", xco+10, yco-44, (width-20)/2, 19, &aa->sta, 1.0, MAXFRAMEF, 0, 0, "Start frame");
- uiDefButF(block, NUM, 0, "End: ", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &aa->end, 1.0, MAXFRAMEF, 0, 0, "End frame");
- }
-
- uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending");
- uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack");
-
- uiDefBut(block, TEX, 0, "FrameProp: ", xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property");
-
-
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- if (aa->type == ACT_ACTION_MOTION) {
- uiDefButF(block, NUM, 0, "Cycle: ", xco+30, yco-84, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action");
- }
-#endif
-
-
-
- yco-=ysize;
- break;
- }
- case ACT_IPO:
- {
- ia= act->data;
-
- ysize= 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str = "Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
-
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, (width-20)/2, 19, &ia->type, 0, 0, 0, 0, "");
-
- but = uiDefButBitS(block, TOG, ACT_IPOFORCE, ACT_IPOFORCE,
- "Force", xco+10+(width-20)/2, yco-24, (width-20)/4-10, 19,
- &ia->flag, 0, 0, 0, 0,
- "Apply Ipo as a global or local force depending on the local option (dynamic objects only)");
- uiButSetFunc(but, change_ipo_actuator, but, ia);
-
- but = uiDefButBitS(block, TOG, ACT_IPOADD, ACT_IPOADD,
- "Add", xco+3*(width-20)/4, yco-24, (width-20)/4-10, 19,
- &ia->flag, 0, 0, 0, 0,
- "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag");
- uiButSetFunc(but, change_ipo_actuator, but, ia);
-
- /* Only show the do-force-local toggle if force is requested */
- if (ia->flag & (ACT_IPOFORCE|ACT_IPOADD)) {
- uiDefButBitS(block, TOG, ACT_IPOLOCAL, 0,
- "L", xco+width-30, yco-24, 20, 19,
- &ia->flag, 0, 0, 0, 0,
- "Let the ipo acts in local coordinates, used in Force and Add mode");
- }
-
- if (ia->type==ACT_IPO_FROM_PROP) {
- uiDefBut(block, TEX, 0,
- "Prop: ", xco+10, yco-44, width-80, 19,
- ia->name, 0.0, MAX_NAME, 0, 0,
- "Use this property to define the Ipo position");
- }
- else {
- uiDefButF(block, NUM, 0,
- "Sta", xco+10, yco-44, (width-80)/2, 19,
- &ia->sta, 1.0, MAXFRAMEF, 0, 0,
- "Start frame");
- uiDefButF(block, NUM, 0,
- "End", xco+10+(width-80)/2, yco-44, (width-80)/2, 19,
- &ia->end, 1.0, MAXFRAMEF, 0, 0,
- "End frame");
- }
- uiDefButBitS(block, TOG, ACT_IPOCHILD, B_REDR,
- "Child", xco+10+(width-80), yco-44, 60, 19,
- &ia->flag, 0, 0, 0, 0,
- "Update IPO on all children Objects as well");
- uiDefBut(block, TEX, 0,
- "FrameProp: ", xco+10, yco-64, width-20, 19,
- ia->frameProp, 0.0, MAX_NAME, 0, 0,
- "Assign the action's current frame number to this property");
-
- yco-= ysize;
- break;
- }
- case ACT_PROPERTY:
- {
- ysize= 68;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- pa= act->data;
-
- str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3";
- uiDefButI(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &pa->type, 0, 31, 0, 0, "Type");
-
- uiDefBut(block, TEX, 1, "Prop: ", xco+30, yco-44, width-60, 19, pa->name, 0, MAX_NAME, 0, 0, "Property name");
-
-
- if (pa->type==ACT_PROP_TOGGLE) {
- /* no ui */
- ysize -= 22;
- }
- else if (pa->type==ACT_PROP_COPY) {
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object");
- uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, MAX_NAME, 0, 0, "Copy this property");
- }
- else {
- uiDefBut(block, TEX, 1, "Value: ", xco+30, yco-64, width-60, 19, pa->value, 0, MAX_NAME, 0, 0, "change with this value, use \"\" around strings");
- }
- yco-= ysize;
-
- break;
- }
- case ACT_SOUND:
- {
- sa = act->data;
- sa->sndnr = 0;
-
- if (sa->flag & ACT_SND_3D_SOUND)
- ysize = 180;
- else
- ysize = 92;
-
- wval = (width-20)/2;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- if (bmain->sound.first) {
- IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr));
- /* reset this value, it is for handling the event */
- sa->sndnr = 0;
- uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10, yco-22, 20, 19, &(sa->sndnr), 0, 0, 0, 0, "");
- uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+wval+10, yco-22, wval, 19,
- "Load a sound file (remember to set caching on for small sounds that are played often)");
-
- if (sa->sound) {
- char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|"
- "Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4";
- uiDefBut(block, TEX, B_IDNAME, "SO:", xco+30, yco-22, wval-20, 19,
- ((ID *)sa->sound)->name+2, 0.0, MAX_ID_NAME-2, 0, 0, "");
- uiDefButS(block, MENU, 1, dummy_str, xco+10, yco-44, width-20, 19,
- &sa->type, 0.0, 0.0, 0, 0, "");
- uiDefButF(block, NUM, 0, "Volume:", xco+10, yco-66, wval, 19, &sa->volume,
- 0.0, 1.0, 0, 0, "Sets the volume of this sound");
- uiDefButF(block, NUM, 0, "Pitch:", xco+wval+10, yco-66, wval, 19, &sa->pitch, -12.0,
- 12.0, 0, 0, "Sets the pitch of this sound");
- uiDefButS(block, TOG | UI_BUT_POIN_BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19,
- &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space");
- if (sa->flag & ACT_SND_3D_SOUND) {
- uiDefButF(block, NUM, 0, "Minimum Gain: ", xco+10, yco-110, wval, 19,
- &sa->sound3D.min_gain, 0.0, 1.0, 0.0, 0.0,
- "The minimum gain of the sound, no matter how far it is away");
- uiDefButF(block, NUM, 0, "Maximum Gain: ", xco+10, yco-132, wval, 19,
- &sa->sound3D.max_gain, 0.0, 1.0, 0.0, 0.0,
- "The maximum gain of the sound, no matter how near it is");
- uiDefButF(block, NUM, 0, "Reference Distance: ", xco+10, yco-154, wval, 19,
- &sa->sound3D.reference_distance, 0.0, FLT_MAX, 0.0, 0.0,
- "The reference distance is the distance where the sound has a gain of 1.0");
- uiDefButF(block, NUM, 0, "Maximum Distance: ", xco+10, yco-176, wval, 19,
- &sa->sound3D.max_distance, 0.0, FLT_MAX, 0.0, 0.0,
- "The maximum distance at which you can hear the sound");
- uiDefButF(block, NUM, 0, "Rolloff: ", xco+wval+10, yco-110, wval, 19,
- &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0,
- "The rolloff factor defines the influence factor on volume depending on distance");
- uiDefButF(block, NUM, 0, "Cone Outer Gain: ", xco+wval+10, yco-132, wval, 19,
- &sa->sound3D.cone_outer_gain, 0.0, 1.0, 0.0, 0.0,
- "The gain outside the outer cone. The gain in the outer cone will be "
- "interpolated between this value and the normal gain in the inner cone");
- uiDefButF(block, NUM, 0, "Cone Outer Angle: ", xco+wval+10, yco-154, wval,
- 19, &sa->sound3D.cone_outer_angle, 0.0, 360.0, 0.0, 0.0,
- "The angle of the outer cone");
- uiDefButF(block, NUM, 0, "Cone Inner Angle: ", xco+wval+10, yco-176, wval,
- 19, &sa->sound3D.cone_inner_angle, 0.0, 360.0, 0.0, 0.0,
- "The angle of the inner cone");
- }
- }
- MEM_freeN((void *)str);
- }
- else {
- uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+10, yco-22, width-20, 19, "Load a sound file");
- }
-
- yco-= ysize;
-
- break;
- }
- case ACT_CAMERA:
-
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- ca= act->data;
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object");
- uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, "");
-
- uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, "");
-
- if (ca->axis==0) ca->axis= 'x';
- uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis");
- uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis");
-
- uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, "");
-
- yco-= ysize;
-
- break;
-
- case ACT_EDIT_OBJECT:
-
- eoa= act->data;
-
- if (eoa->type==ACT_EDOB_ADD_OBJECT) {
- ysize = 92;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)");
- uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives");
-
- wval= (width-60)/3;
- uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19,
- NULL, 0, 0, 0, 0,
- "Velocity upon creation");
- uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19,
- eoa->linVelocity, -100.0, 100.0, 10, 0,
- "Velocity upon creation, x component");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19,
- eoa->linVelocity+1, -100.0, 100.0, 10, 0,
- "Velocity upon creation, y component");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19,
- eoa->linVelocity+2, -100.0, 100.0, 10, 0,
- "Velocity upon creation, z component");
- uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_LINV, 0, "L", xco+45+3*wval, yco-68, 15, 19,
- &eoa->localflag, 0.0, 0.0, 0, 0,
- "Apply the transformation locally");
-
-
- uiDefBut(block, LABEL, 0, "AngV", xco, yco-90, 45, 19,
- NULL, 0, 0, 0, 0,
- "Angular velocity upon creation");
- uiDefButF(block, NUM, 0, "", xco+45, yco-90, wval, 19,
- eoa->angVelocity, -10000.0, 10000.0, 10, 0,
- "Angular velocity upon creation, x component");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-90, wval, 19,
- eoa->angVelocity+1, -10000.0, 10000.0, 10, 0,
- "Angular velocity upon creation, y component");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-90, wval, 19,
- eoa->angVelocity+2, -10000.0, 10000.0, 10, 0,
- "Angular velocity upon creation, z component");
- uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_ANGV, 0, "L", xco+45+3*wval, yco-90, 15, 19,
- &eoa->localflag, 0.0, 0.0, 0, 0,
- "Apply the rotation locally");
-
-
- }
- else if (eoa->type==ACT_EDOB_END_OBJECT) {
- ysize= 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
- else if (eoa->type==ACT_EDOB_REPLACE_MESH) {
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_meshpoin_but, ID_ME, 1, "ME:", xco+40, yco-44, (width-80)/2, 19, &(eoa->me), "replace the existing, when left blank 'Phys' will remake the existing physics mesh");
-
- uiDefButBitS(block, TOGN, ACT_EDOB_REPLACE_MESH_NOGFX, 0, "Gfx", xco+40 + (width-80)/2, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the display mesh");
- uiDefButBitS(block, TOG, ACT_EDOB_REPLACE_MESH_PHYS, 0, "Phys", xco+40 + (width-80)/2 +(width-80)/4, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the physics mesh (triangle bounds only. compound shapes not supported)");
- }
- else if (eoa->type==ACT_EDOB_TRACK_TO) {
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object");
- uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes");
- uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking");
- }
- else if (eoa->type==ACT_EDOB_DYNAMICS) {
- ysize= 69;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Dynamic Operation %t|Restore Dynamics %x0|Suspend Dynamics %x1|Enable Rigid Body %x2|Disable Rigid Body %x3|Set Mass %x4";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-44, (width-80), 19, &(eoa->dyn_operation), 0.0, 0.0, 0, 0, "");
- if (eoa->dyn_operation==4) {
- uiDefButF(block, NUM, 0, "", xco+40, yco-63, width-80, 19,
- &eoa->mass, 0.0, 10000.0, 10, 0,
- "Mass for object");
- }
- }
- str= "Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3|Dynamics %x4";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, "");
-
- yco-= ysize;
-
- break;
-
- case ACT_CONSTRAINT:
- coa= act->data;
-
- if (coa->type == ACT_CONST_TYPE_LOC) {
- ysize= 69;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */
- /* coa->flag &= ~(63); */
- str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4";
- coa->flag &= 7;
- coa->time = 0;
- uiDefButS(block, MENU, 1, str, xco+10, yco-65, 70, 19, &coa->flag, 0.0, 0.0, 0, 0, "");
-
- uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter");
- uiDefBut(block, LABEL, 0, "Min", xco+80, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, "");
-
- if (coa->flag & ACT_CONST_LOCX) fp= coa->minloc;
- else if (coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1;
- else if (coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2;
- else if (coa->flag & ACT_CONST_ROTX) fp= coa->minrot;
- else if (coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1;
- else fp= coa->minrot+2;
-
- uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-65, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, "");
- }
- else if (coa->type == ACT_CONST_TYPE_DIST) {
- ysize= 106;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray");
-
- uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter");
- uiDefBut(block, LABEL, 0, "Range", xco+80, yco-45, (width-115)/2, 19, NULL, 0.0, 0.0, 0, 0, "Set the maximum length of ray");
- uiDefButBitS(block, TOG, ACT_CONST_DISTANCE, B_REDR, "Dist", xco+80+(width-115)/2, yco-45, (width-115)/2, 19, &coa->flag, 0.0, 0.0, 0, 0, "Force distance of object to point of impact of ray");
- uiDefButBitS(block, TOG, ACT_CONST_LOCAL, 0, "L", xco+80+(width-115), yco-45, 25, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Set ray along object's axis or global axis");
-
- if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc;
- else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1;
- else fp= coa->minloc+2;
-
- uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/2, 19, fp+3, 0.0, 2000.0, 10, 0, "Maximum length of ray");
- if (coa->flag & ACT_CONST_DISTANCE)
- uiDefButF(block, NUM, 0, "", xco+80+(width-115)/2, yco-65, (width-115)/2, 19, fp, -2000.0, 2000.0, 10, 0, "Keep this distance to target");
- uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Set object axis along (local axis) or parallel (global axis) to the normal at hit position");
- uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property");
- if (coa->flag & ACT_CONST_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detects only Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detect only Objects with this property");
- }
- uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target");
- uiDefButS(block, NUM, 0, "time", xco+50, yco-103, (width-60)/2, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited");
- uiDefButS(block, NUM, 0, "rotDamp", xco+50+(width-60)/2, yco-103, (width-60)/2, 19, &(coa->rotdamp), 0.0, 100.0, 0, 0, "Use a different damping for orientation");
- }
- else if (coa->type == ACT_CONST_TYPE_ORI) {
- ysize= 87;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Select the axis to be aligned along the reference direction");
-
- uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter");
- uiDefBut(block, LABEL, 0, "X", xco+80, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Y", xco+80+(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Z", xco+80+2*(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, "");
-
- uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/3, 19, &coa->maxrot[0], -2000.0, 2000.0, 10, 0, "X component of reference direction");
- uiDefButF(block, NUM, 0, "", xco+80+(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[1], -2000.0, 2000.0, 10, 0, "Y component of reference direction");
- uiDefButF(block, NUM, 0, "", xco+80+2*(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[2], -2000.0, 2000.0, 10, 0, "Z component of reference direction");
-
- uiDefButS(block, NUM, 0, "time", xco+10, yco-84, 70, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited");
- uiDefButF(block, NUM, 0, "min", xco+80, yco-84, (width-115)/2, 19, &(coa->minloc[0]), 0.0, 180.0, 10, 1, "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max");
- uiDefButF(block, NUM, 0, "max", xco+80+(width-115)/2, yco-84, (width-115)/2, 19, &(coa->maxloc[0]), 0.0, 180.0, 10, 1, "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max");
- }
- else if (coa->type == ACT_CONST_TYPE_FH) {
- ysize= 106;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray (in world coordinate)");
-
- if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc;
- else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1;
- else fp= coa->minloc+2;
-
- uiDefButF(block, NUM, 0, "damp", xco+10, yco-45, (width-70)/2, 19, &coa->maxrot[0], 0.0, 1.0, 1, 0, "Damping factor of the Fh spring force");
- uiDefButF(block, NUM, 0, "dist", xco+10+(width-70)/2, yco-45, (width-70)/2, 19, fp, 0.010, 2000.0, 10, 0, "Height of the Fh area");
- uiDefButBitS(block, TOG, ACT_CONST_DOROTFH, 0, "Rot Fh", xco+10+(width-70), yco-45, 50, 19, &coa->flag, 0.0, 0.0, 0, 0, "Keep object axis parallel to normal");
-
- uiDefButF(block, NUMSLI, 0, "Fh ", xco+80, yco-65, (width-115), 19, fp+3, 0.0, 1.0, 0, 0, "Spring force within the Fh area");
- uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes");
- uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property");
- if (coa->flag & ACT_CONST_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detects only Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detect only Objects with this property");
- }
- uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target");
- uiDefButS(block, NUM, 0, "time", xco+50, yco-103, 90, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited");
- uiDefButF(block, NUM, 0, "rotDamp", xco+140, yco-103, (width-150), 19, &coa->maxrot[1], 0.0, 1.0, 1, 0, "Use a different damping for rotation");
- }
- str= "Constraint Type %t|Location %x0|Distance %x1|Orientation %x2|Force field %x3";
- but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &coa->type, 0.0, 0.0, 0, 0, "");
- yco-= ysize;
- break;
-
- case ACT_SCENE:
- sca= act->data;
-
- if (sca->type==ACT_SCENE_RESTART) {
- ysize= 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
- else if (sca->type==ACT_SCENE_CAMERA) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object");
- }
- else if (sca->type==ACT_SCENE_SET) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene");
- }
- else if (sca->type==ACT_SCENE_ADD_FRONT) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene");
- }
- else if (sca->type==ACT_SCENE_ADD_BACK) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene");
- }
- else if (sca->type==ACT_SCENE_REMOVE) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene");
- }
- else if (sca->type==ACT_SCENE_SUSPEND) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene");
- }
- else if (sca->type==ACT_SCENE_RESUME) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene");
- }
-
- str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, "");
-
- yco-= ysize;
- break;
- case ACT_GAME:
- {
- gma = act->data;
- if (gma->type == ACT_GAME_LOAD) {
- //ysize = 68;
- ysize = 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44, width-20, 19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file");
- // uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64, width-20, 19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation");
- }
-#if 0
- else if (gma->type == ACT_GAME_START) {
- ysize = 68;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44, width-20, 19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this file");
- uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64, width-20, 19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation");
- }
-#endif
- else if (ELEM4(gma->type, ACT_GAME_RESTART, ACT_GAME_QUIT, ACT_GAME_SAVECFG, ACT_GAME_LOADCFG)) {
- ysize = 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
-
- //str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3";
- str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save bge.logic.globalDict %x4|Load bge.logic.globalDict %x5";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, "");
-
- yco -= ysize;
- break;
- }
- case ACT_GROUP:
- ga= act->data;
-
- ysize= 52;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5";
-
- uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, "");
- if (ga->type==ACT_GROUP_SET) {
- uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, MAX_NAME, 0, 0, "This name defines groupkey to be set");
- uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame");
- }
- else if (ga->type==ACT_GROUP_FROM_PROP) {
- uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Group position");
- }
- else {
- uiDefButI(block, NUM, 0, "State", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame");
- uiDefButI(block, NUM, 0, "End", xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame");
- }
- yco-= ysize;
- break;
-
- case ACT_VISIBILITY:
- ysize = 24;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco,
- (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- visAct = act->data;
-
- uiBlockBeginAlign(block);
- uiDefButBitI(block, TOGN, ACT_VISIBILITY_INVISIBLE, B_REDR,
- "Visible",
- xco + 10, yco - 20, (width - 20)/3, 19, &visAct->flag,
- 0.0, 0.0, 0, 0,
- "Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)");
- uiDefButBitI(block, TOG, ACT_VISIBILITY_OCCLUSION, B_REDR,
- "Occlusion",
- xco + 10 + ((width - 20)/3), yco - 20, (width - 20)/3, 19, &visAct->flag,
- 0.0, 0.0, 0, 0,
- "Set the object to occlude objects behind it. Initialized from the object type in physics button");
- uiBlockEndAlign(block);
-
- uiDefButBitI(block, TOG, ACT_VISIBILITY_RECURSIVE, 0,
- "Children",
- xco + 10 + (((width - 20)/3)*2)+10, yco - 20, ((width - 20)/3)-10, 19, &visAct->flag,
- 0.0, 0.0, 0, 0,
- "Sets all the children of this object to the same visibility/occlusion recursively");
-
- yco-= ysize;
-
- break;
-
- case ACT_STATE:
- ysize = 34;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco,
- (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- staAct = act->data;
-
- str= "Operation %t|Cpy %x0|Add %x1|Sub %x2|Inv %x3";
-
- uiDefButI(block, MENU, B_REDR, str,
- xco + 10, yco - 24, 65, 19, &staAct->type,
- 0.0, 0.0, 0, 0,
- "Select the bit operation on object state mask");
-
- for (wval=0; wval<15; wval+=5) {
- uiBlockBeginAlign(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, TOG, 1<<(stbit+wval), stbit+wval, "", (short)(xco+85+12*stbit+13*wval), yco-17, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval)));
- uiButSetFunc(but, check_state_mask, but, &(staAct->mask));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, TOG, 1<<(stbit+wval+15), stbit+wval+15, "", (short)(xco+85+12*stbit+13*wval), yco-29, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval+15)));
- uiButSetFunc(but, check_state_mask, but, &(staAct->mask));
- }
- }
- uiBlockEndAlign(block);
-
- yco-= ysize;
-
- break;
-
- case ACT_RANDOM:
- ysize = 69;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco,
- (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- randAct = act->data;
-
- /* 1. seed */
- uiDefButI(block, NUM, 1, "Seed: ", (xco+10), yco-24, 0.4 *(width-20), 19,
- &randAct->seed, 0, 1000, 0, 0,
- "Initial seed of the random generator. Use Python for more freedom. "
- " (Choose 0 for not random)");
-
- /* 2. distribution type */
- /* One pick per distribution. These numbers MUST match the #defines */
- /* in game.h !!! */
- str= "Distribution %t|Bool Constant %x0|Bool Uniform %x1"
- "|Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4"
- "|Int Poisson %x5|Float Constant %x6|Float Uniform %x7"
- "|Float Normal %x8|Float Neg. Exp. %x9";
- uiDefButI(block, MENU, B_REDR, str, (xco+10) + 0.4 * (width-20), yco-24, 0.6 * (width-20), 19,
- &randAct->distribution, 0.0, 0.0, 0, 0,
- "Choose the type of distribution");
-
- /* 3. property */
- uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19,
- &randAct->propname, 0, MAX_NAME, 0, 0,
- "Assign the random value to this property");
-
- /*4. and 5. arguments for the distribution*/
- switch (randAct->distribution) {
- case ACT_RANDOM_BOOL_CONST:
- uiDefButBitI(block, TOG, 1, 1, "Always true", (xco+10), yco-64, (width-20), 19,
- &randAct->int_arg_1, 2.0, 1, 0, 0,
- "Always false or always true");
- break;
- case ACT_RANDOM_BOOL_UNIFORM:
- uiDefBut(block, LABEL, 0, " Do a 50-50 pick", (xco+10), yco-64, (width-20), 19,
- NULL, 0, 0, 0, 0,
- "Choose between true and false, 50% chance each");
- break;
- case ACT_RANDOM_BOOL_BERNOUILLI:
- uiDefButF(block, NUM, 1, "Chance", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.0, 1.0, 0, 0,
- "Pick a number between 0 and 1. Success if you stay "
- "below this value");
- break;
- case ACT_RANDOM_INT_CONST:
- uiDefButI(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19,
- &randAct->int_arg_1, -1000, 1000, 0, 0,
- "Always return this number");
- break;
- case ACT_RANDOM_INT_UNIFORM:
- uiDefButI(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19,
- &randAct->int_arg_1, -1000, 1000, 0, 0,
- "Choose a number from a range. "
- "Lower boundary of the range");
- uiDefButI(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19,
- &randAct->int_arg_2, -1000, 1000, 0, 0,
- "Choose a number from a range. "
- "Upper boundary of the range");
- break;
- case ACT_RANDOM_INT_POISSON:
- uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.01, 100.0, 0, 0,
- "Expected mean value of the distribution");
- break;
- case ACT_RANDOM_FLOAT_CONST:
- uiDefButF(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.0, 1.0, 0, 0,
- "Always return this number");
- break;
- case ACT_RANDOM_FLOAT_UNIFORM:
- uiDefButF(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19,
- &randAct->float_arg_1, -10000.0, 10000.0, 0, 0,
- "Choose a number from a range"
- "Lower boundary of the range");
- uiDefButF(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19,
- &randAct->float_arg_2, -10000.0, 10000.0, 0, 0,
- "Choose a number from a range"
- "Upper boundary of the range");
- break;
- case ACT_RANDOM_FLOAT_NORMAL:
- uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20)/2, 19,
- &randAct->float_arg_1, -10000.0, 10000.0, 0, 0,
- "A normal distribution. Mean of the distribution");
- uiDefButF(block, NUM, 1, "SD: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19,
- &randAct->float_arg_2, 0.0, 10000.0, 0, 0,
- "A normal distribution. Standard deviation of the "
- "distribution");
- break;
- case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
- uiDefButF(block, NUM, 1, "Half-life time: ", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.001, 10000.0, 0, 0,
- "Negative exponential dropoff");
- break;
- default:
- ; /* don't know what this distro is... can be useful for testing */
- /* though :) */
- }
-
- yco-= ysize;
- break;
- case ACT_MESSAGE:
- ma = act->data;
-
- ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- myline=1;
-
- /* line 1: To */
- uiDefBut(block, TEX, 1, "To: ",
- (xco+10), (yco-(myline++*24)), (width-20), 19,
- &ma->toPropName, 0, MAX_NAME, 0, 0,
- "Optional send message to objects with this name only, or empty to broadcast");
-
- /* line 2: Message Subject */
- uiDefBut(block, TEX, 1, "Subject: ",
- (xco+10), (yco-(myline++*24)), (width-20), 19,
- &ma->subject, 0, MAX_NAME, 0, 0,
- "Optional message subject. This is what can be filtered on");
-
- /* line 3: Text/Property */
- uiDefButBitS(block, TOG, 1, B_REDR, "T/P",
- (xco+10), (yco-(myline*24)), (0.20 * (width-20)), 19,
- &ma->bodyType, 0.0, 0.0, 0, 0,
- "Toggle message type: either Text or a PropertyName");
-
- if (ma->bodyType == ACT_MESG_MESG) {
- /* line 3: Message Body */
- uiDefBut(block, TEX, 1, "Body: ",
- (xco+10+(0.20*(width-20))), (yco-(myline++*24)), (0.8*(width-20)), 19,
- &ma->body, 0, MAX_NAME, 0, 0,
- "Optional message body Text");
- }
- else {
- /* line 3: Property body (set by property) */
- uiDefBut(block, TEX, 1, "Propname: ",
- (xco+10+(0.20*(width-20))), (yco-(myline++*24)), (0.8*(width-20)), 19,
- &ma->body, 0, MAX_NAME, 0, 0,
- "The message body will be set by the Property Value");
- }
-
- yco -= ysize;
- break;
- case ACT_2DFILTER:
- tdfa = act->data;
-
- ysize = 50;
- if (tdfa->type == ACT_2DFILTER_CUSTOMFILTER) {
- ysize +=20;
- }
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- switch (tdfa->type) {
- case ACT_2DFILTER_MOTIONBLUR:
- if (!tdfa->flag) {
- uiDefButS(block, TOG, B_REDR, "D", xco+30, yco-44, 19, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Disable Motion Blur");
- uiDefButF(block, NUM, B_REDR, "Value:", xco+52, yco-44, width-82, 19, &tdfa->float_arg, 0.0, 1.0, 0.0, 0.0, "Set motion blur value");
- }
- else {
- uiDefButS(block, TOG, B_REDR, "Disabled", xco+30, yco-44, width-60, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Enable Motion Blur");
- }
- break;
- case ACT_2DFILTER_BLUR:
- case ACT_2DFILTER_SHARPEN:
- case ACT_2DFILTER_DILATION:
- case ACT_2DFILTER_EROSION:
- case ACT_2DFILTER_LAPLACIAN:
- case ACT_2DFILTER_SOBEL:
- case ACT_2DFILTER_PREWITT:
- case ACT_2DFILTER_GRAYSCALE:
- case ACT_2DFILTER_SEPIA:
- case ACT_2DFILTER_INVERT:
- case ACT_2DFILTER_NOFILTER:
- case ACT_2DFILTER_DISABLED:
- case ACT_2DFILTER_ENABLED:
- uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30, yco-44, width-60, 19, &tdfa->int_arg, 0.0, MAX_RENDER_PASS-1, 0.0, 0.0, "Set filter order");
- break;
- case ACT_2DFILTER_CUSTOMFILTER:
- uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30, yco-44, width-60, 19, &tdfa->int_arg, 0.0, MAX_RENDER_PASS-1, 0.0, 0.0, "Set filter order");
- uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30, yco-64, width-60, 19, &tdfa->text, "");
- break;
- }
-
- str= "2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
- "Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|"
- "Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|";
- uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type");
-
- yco -= ysize;
- break;
- case ACT_PARENT:
- parAct = act->data;
-
- if (parAct->type==ACT_PARENT_SET) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent");
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOGN, ACT_PARENT_COMPOUND, B_REDR,
- "Compound",
- xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag,
- 0.0, 0.0, 0, 0,
- "Add this object shape to the parent shape (only if the parent shape is already compound)");
- uiDefButBitS(block, TOGN, ACT_PARENT_GHOST, B_REDR,
- "Ghost",
- xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag,
- 0.0, 0.0, 0, 0,
- "Make this object ghost while parented (only if not compound)");
- uiBlockEndAlign(block);
- }
- else if (parAct->type==ACT_PARENT_REMOVE) {
-
- ysize= 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
-
- str= "Parent %t|Set Parent %x0|Remove Parent %x1";
- uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, parAct->type==1?(width-80):90, 19, &parAct->type, 0.0, 0.0, 0, 0, "");
-
- yco-= ysize;
- break;
- case ACT_ARMATURE:
- armAct = act->data;
-
- if (ob->type == OB_ARMATURE) {
- str= "Constraint %t|Run armature %x0|Enable %x1|Disable %x2|Set target %x3|Set weight %x4";
- uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, (width-10)*0.35, 19, &armAct->type, 0.0, 0.0, 0, 0, "");
-
- switch (armAct->type) {
- case ACT_ARM_RUN:
- ysize = 28;
- break;
- default:
- uiBlockBeginAlign(block);
- but = uiDefBut(block, TEX, 1, "Bone: ",
- (xco+5), (yco-44), (width-10)/2, 19,
- armAct->posechannel, 0, MAX_NAME, 0, 0,
- "Bone on which the constraint is defined");
- uiButSetFunc(but, check_armature_actuator, but, armAct);
- but = uiDefBut(block, TEX, 1, "Cons: ",
- (xco+5)+(width-10)/2, (yco-44), (width-10)/2, 19,
- armAct->constraint, 0, MAX_NAME, 0, 0,
- "Name of the constraint you want to control");
- uiButSetFunc(but, check_armature_actuator, but, armAct);
- uiBlockEndAlign(block);
- ysize = 48;
- switch (armAct->type) {
- case ACT_ARM_SETTARGET:
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "Target: ", xco+5, yco-64, (width-10), 19, &(armAct->target), "Set this object as the target of the constraint");
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "Secondary Target: ", xco+5, yco-84, (width-10), 19, &(armAct->subtarget), "Set this object as the secondary target of the constraint (only IK polar target at the moment)");
- ysize += 40;
- break;
- case ACT_ARM_SETWEIGHT:
- uiDefButF(block, NUM, B_REDR, "Weight:", xco+5+(width-10)*0.35, yco-24, (width-10)*0.65, 19, &armAct->weight, 0.0, 1.0, 0.0, 0.0, "Set weight of this constraint");
- break;
- }
- }
- }
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- yco-= ysize;
- break;
-
- default:
- ysize= 4;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- yco-= ysize;
- break;
- }
-
- uiBlockSetEmboss(block, UI_EMBOSS);
-
- return yco-4;
-}
static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event)
{
@@ -3084,8 +878,6 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
return block;
}
-
-
static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, void *arg2_mask)
{
unsigned int *cont_mask = arg2_mask;
@@ -3096,17 +888,6 @@ static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, voi
but->retval = B_REDR;
}
-static int first_bit(unsigned int mask)
-{
- int bit;
-
- for (bit=0; bit<32; bit++) {
- if (mask & (1<<bit))
- return bit;
- }
- return -1;
-}
-
static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont)
{
uiBlock *block;
@@ -3139,44 +920,6 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c
return block;
}
-static void do_object_state_menu(bContext *UNUSED(C), void *arg, int event)
-{
- Object *ob = arg;
-
- switch (event) {
- case 0:
- ob->state = 0x3FFFFFFF;
- break;
- case 1:
- ob->state = ob->init_state;
- if (!ob->state)
- ob->state = 1;
- break;
- case 2:
- ob->init_state = ob->state;
- break;
- }
-}
-
-static uiBlock *object_state_mask_menu(bContext *C, ARegion *ar, void *arg_obj)
-{
- uiBlock *block;
- short xco = 0;
-
- block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP);
- uiBlockSetButmFunc(block, do_object_state_menu, arg_obj);
-
- uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, BUTM, 1, "Recall init state", 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, "Store init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
-
- uiBlockSetDirection(block, UI_TOP);
- uiEndBlock(C, block);
-
- return block;
-}
-
static int is_sensor_linked(uiBlock *block, bSensor *sens)
{
bController *cont;
@@ -4458,14 +2201,13 @@ static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C)
}
}
-static void logic_buttons_new(bContext *C, ARegion *ar)
+void logic_buttons(bContext *C, ARegion *ar)
{
SpaceLogic *slogic= CTX_wm_space_logic(C);
Object *ob= CTX_data_active_object(C);
- Object *act_ob= ob;
ID **idar;
- PointerRNA logic_ptr, settings_ptr;
+ PointerRNA logic_ptr, settings_ptr, object_ptr;
uiLayout *layout, *row, *box;
uiBlock *block;
@@ -4558,8 +2300,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
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");
- if (ob == act_ob)
- uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE);
+
+ 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);
if (RNA_boolean_get(&settings_ptr, "show_state_panel")) {
@@ -4574,9 +2318,9 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
col = uiLayoutColumn(subsplit, FALSE);
row = uiLayoutRow(col, FALSE);
uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == FALSE);
- uiTemplateLayers(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0);
+ uiTemplateGameStates(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0);
row = uiLayoutRow(col, FALSE);
- uiTemplateLayers(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0);
+ uiTemplateGameStates(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0);
col = uiLayoutColumn(subsplit, FALSE);
uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
@@ -4653,8 +2397,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
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");
- if (ob == act_ob)
- uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE);
+
+ 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);
if ((ob->scaflag & OB_SHOWSENS) == 0) continue;
@@ -4721,8 +2467,10 @@ static void logic_buttons_new(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");
- if (ob == act_ob)
- uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE);
+
+ 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);
if ((ob->scaflag & OB_SHOWACT) == 0) continue;
@@ -4773,377 +2521,3 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
if (idar) MEM_freeN(idar);
}
-void logic_buttons(bContext *C, ARegion *ar)
-{
- Main *bmain= CTX_data_main(C);
- SpaceLogic *slogic= CTX_wm_space_logic(C);
- Object *ob= CTX_data_active_object(C);
- ID **idar;
- bSensor *sens;
- bController *cont;
- bActuator *act;
- uiBlock *block;
- uiBut *but;
- PointerRNA logic_ptr;
- int a, iact, stbit, offset;
- int xco, yco, width, ycoo;
- short count;
- char numstr[32];
- /* pin is a bool used for actuator and sensor drawing with states
- * pin so changing states dosnt hide the logic brick */
- char pin;
-
- if (G.debug_value == 0) {
- logic_buttons_new(C, ar);
- return;
- }
-
- if (ob==NULL) return;
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar);
- block= uiBeginBlock(C, ar, numstr, UI_EMBOSS);
- uiBlockSetHandleFunc(block, do_logic_buts, NULL);
-
- RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
-
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
- /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
- * we can determine which is actually linked/visible */
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- act= ob->actuators.first;
- while (act) {
- act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
- act = act->next;
- }
- /* same for sensors */
- sens= ob->sensors.first;
- while (sens) {
- sens->flag &= ~(SENS_VISIBLE);
- sens = sens->next;
- }
- }
-
- /* start with the controller because we need to know which one is visible */
- /* ******************************* */
- xco= 400; yco= 170; width= 300;
-
- uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, UI_UNIT_Y, "");
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_CONT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_CONT_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator");
- uiBlockEndAlign(block);
-
- for (a=0; a<count; a++) {
- unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */
-
- ob= (Object *)idar[a];
-// uiClearButLock();
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if ((ob->scavisflag & OB_VIS_CONT) == 0) {
- continue;
- }
-
- /* presume it is only objects for now */
- uiBlockBeginAlign(block);
-// if (ob->controllers.first) uiSetCurFont(block, UI_HELVB);
- uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Active Object name");
-// if (ob->controllers.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller");
- uiBlockEndAlign(block);
- yco-=20;
-
- /* mark all actuators linked to these controllers */
- /* note that some of these actuators could be from objects that are not in the display list.
- * It's ok because those actuators will not be displayed here */
- cont= ob->controllers.first;
- while (cont) {
- for (iact=0; iact<cont->totlinks; iact++) {
- act = cont->links[iact];
- if (act)
- act->flag |= ACT_LINKED;
- }
- controller_state_mask |= cont->state_mask;
- cont = cont->next;
- }
-
- if (ob->scaflag & OB_SHOWCONT) {
-
- /* first show the state */
- uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, UI_UNIT_Y, "Object state menu: store and retrieve initial state");
-
- if (!ob->state)
- ob->state = 1;
- for (offset=0; offset<15; offset+=5) {
- uiBlockBeginAlign(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- }
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, OB_ALLSTATE, B_SET_STATE_BIT, "All", (short)(xco+226), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
- uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini", (short)(xco+248), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
- uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D", (short)(xco+270), yco-10, 15, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
- uiBlockEndAlign(block);
-
- yco-=35;
-
- /* display only the controllers that match the current state */
- offset = 0;
- for (stbit=0; stbit<32; stbit++) {
- if (!(ob->state & (1<<stbit)))
- continue;
- /* add a separation between controllers of different states */
- if (offset) {
- offset = 0;
- yco -= 6;
- }
- cont= ob->controllers.first;
- while (cont) {
- if (cont->state_mask & (1<<stbit)) {
- /* this controller is visible, mark all its actuator */
- for (iact=0; iact<cont->totlinks; iact++) {
- act = cont->links[iact];
- if (act)
- act->flag |= ACT_VISIBLE;
- }
- uiDefIconButBitS(block, TOG, CONT_DEL, B_DEL_CONT, ICON_X, xco, yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Delete Controller");
- uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Controller settings");
- uiDefIconButBitS(block, TOG, CONT_PRIO, B_REDR, ICON_BOOKMARKS, (short)(xco+width-66), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Mark controller for execution before all non-marked controllers (good for startup scripts)");
-
- sprintf(numstr, "%d", first_bit(cont->state_mask)+1);
- uiDefBlockBut(block, controller_state_mask_menu, cont, numstr, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)");
-
- if (cont->flag & CONT_SHOW) {
- cont->otype= cont->type;
- uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(), (short)(xco+22), yco, 70, UI_UNIT_Y, &cont->type, 0, 0, 0, 0, "Controller type");
- but = uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, MAX_NAME, 0, 0, "Controller name");
- uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0);
-
- ycoo= yco;
- yco= draw_controllerbuttons(cont, block, xco, yco, width);
- if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- cpack(0x999999);
- glRecti(xco+22, yco, xco+width-22, yco+19);
- but = uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 70, UI_UNIT_Y, cont, 0, 0, 0, 0, "Controller type");
- //uiButSetFunc(but, old_sca_move_controller, cont, NULL);
- but = uiDefBut(block, LABEL, 0, cont->name, (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont, 0, 0, 0, 0, "Controller name");
- //uiButSetFunc(but, old_sca_move_controller, cont, NULL);
-
- uiBlockBeginAlign(block);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(110+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up");
- uiButSetFunc(but, old_sca_move_controller, cont, (void *)TRUE);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(88+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down");
- uiButSetFunc(but, old_sca_move_controller, cont, (void *)FALSE);
- uiBlockEndAlign(block);
-
- ycoo= yco;
- }
-
- but = uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK, (short)(xco-19), ycoo, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
- /* offset is >0 if at least one controller was displayed */
- offset++;
- yco-=20;
- }
- cont= cont->next;
- }
-
- }
- yco-= 6;
- }
- }
-
- /* ******************************* */
- xco= 10; yco= 170; width= 300;
-
- uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 70, UI_UNIT_Y, "");
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+80, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+80+(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+80+2*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
- uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "State", xco+80+3*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states");
- uiBlockEndAlign(block);
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
-// uiClearButLock();
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- if ((ob->scavisflag & OB_VIS_SENS) == 0) {
- continue;
- }
-
- /* presume it is only objects for now */
- uiBlockBeginAlign(block);
-// if (ob->sensors.first) uiSetCurFont(block, UI_HELVB);
- 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");
-// if (ob->sensors.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor");
- uiBlockEndAlign(block);
- yco-=20;
-
- if (ob->scaflag & OB_SHOWSENS) {
-
- sens= ob->sensors.first;
- while (sens) {
- if (!(slogic->scaflag & BUTS_SENS_STATE) ||
- (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
- (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
- (is_sensor_linked(block, sens))
- ) {
- /* should we draw the pin? - for now always draw when there is a state */
- pin = (slogic->scaflag & BUTS_SENS_STATE && (sens->flag & SENS_SHOW || sens->flag & SENS_PIN)) ? 1 : 0;
-
- sens->flag |= SENS_VISIBLE;
- uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X, xco, yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Delete Sensor");
- if (pin)
- uiDefIconButBitS(block, ICONTOG, SENS_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller");
-
- uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Sensor settings");
-
- ycoo= yco;
- if (sens->flag & SENS_SHOW) {
- uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 80, UI_UNIT_Y, &sens->type, 0, 0, 0, 0, "Sensor type");
- but = uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, MAX_NAME, 0, 0, "Sensor name");
- uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0);
-
- sens->otype= sens->type;
- yco= draw_sensorbuttons(ob, sens, block, xco, yco, width);
- if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- set_col_sensor(sens->type, 1);
- glRecti(xco + 22, yco, xco + width - 22, yco + 19);
- but = uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 80, UI_UNIT_Y, sens, 0, 0, 0, 0, "");
- //uiButSetFunc(but, old_sca_move_sensor, sens, NULL);
- but = uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, MAX_NAME, 0, 0, "");
- //uiButSetFunc(but, old_sca_move_sensor, sens, NULL);
-
- uiBlockBeginAlign(block);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(66+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up");
- uiButSetFunc(but, old_sca_move_sensor, sens, (void *)TRUE);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(44+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down");
- uiButSetFunc(but, old_sca_move_sensor, sens, (void *)FALSE);
- uiBlockEndAlign(block);
- }
-
- but = uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
-
- yco-=20;
- }
- sens= sens->next;
- }
- yco-= 6;
- }
- }
- /* ******************************* */
- xco= 800; yco= 170; width= 300;
- uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 90, UI_UNIT_Y, "");
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
- uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "State", xco+110+3*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states");
- uiBlockEndAlign(block);
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
-// uiClearButLock();
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if ((ob->scavisflag & OB_VIS_ACT) == 0) {
- continue;
- }
-
- /* presume it is only objects for now */
- uiBlockBeginAlign(block);
-// if (ob->actuators.first) uiSetCurFont(block, UI_HELVB);
- 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");
-// if (ob->actuators.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDACT, B_ADD_ACT, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator");
- uiBlockEndAlign(block);
- yco-=20;
-
- if (ob->scaflag & OB_SHOWACT) {
-
- act= ob->actuators.first;
- while (act) {
- if (!(slogic->scaflag & BUTS_ACT_STATE) ||
- !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
- (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */
- (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE))
- {
- pin = (slogic->scaflag & BUTS_ACT_STATE && (act->flag & SENS_SHOW || act->flag & SENS_PIN)) ? 1 : 0;
-
- act->flag |= ACT_VISIBLE; /* mark the actuator as visible to help implementing the up/down action */
- uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X, xco, yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Delete Actuator");
- if (pin)
- uiDefIconButBitS(block, ICONTOG, ACT_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller");
- uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display the actuator");
-
- if (act->flag & ACT_SHOW) {
- act->otype= act->type;
- uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, UI_UNIT_Y, &act->type, 0, 0, 0, 0, "Actuator type");
- but = uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, MAX_NAME, 0, 0, "Actuator name");
- uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0);
-
- ycoo= yco;
- yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width);
- if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- set_col_actuator(act->type, 1);
- glRecti((short)(xco+22), yco, (short)(xco+width-22), (short)(yco+19));
- /* but= */ uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator type");
- // uiButSetFunc(but, old_sca_move_actuator, act, NULL);
- /* but= */ uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator name");
- // uiButSetFunc(but, old_sca_move_actuator, act, NULL);
-
- uiBlockBeginAlign(block);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(66+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up");
- uiButSetFunc(but, old_sca_move_actuator, act, (void *)TRUE);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(44+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down");
- uiButSetFunc(but, old_sca_move_actuator, act, (void *)FALSE);
- uiBlockEndAlign(block);
-
- ycoo= yco;
- }
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK, (short)(xco - 19), ycoo, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
-
- yco-=20;
- }
- act= act->next;
- }
- yco-= 6;
- }
- }
-
- uiComposeLinks(block);
-
- uiEndBlock(C, block);
- uiDrawBlock(C, block);
-
- if (idar) MEM_freeN(idar);
-}
-
-
-
-
-
-
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 9b0e342505b..badc4dbb533 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -67,9 +67,6 @@
/* ******************* nla editor space & buttons ************** */
-#define B_NOP 1
-#define B_REDR 2
-
/* -------------- */
static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event)
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 775dd5445c3..950060dde5f 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -304,13 +304,13 @@ static int nlaedit_viewall(bContext *C, const short onlySel)
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
- extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* set vertical range */
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask);
+ v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
@@ -1170,7 +1170,8 @@ static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-void NLA_OT_bake(wmOperatorType *ot)
+/* why isn't this used? */
+static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bake Strips";
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 222c2414fcb..79be0d0a194 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -309,7 +309,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
mode = NLA_BORDERSEL_FRAMERANGE;
else
mode = NLA_BORDERSEL_CHANNELS;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 5ebcef1d9a7..3bba02f4fc8 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -63,14 +63,12 @@
#include "UI_resources.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "node_intern.h" /* own include */
-/* XXX interface.h */
-extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
-
/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
@@ -199,25 +197,22 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width))
{
SpaceNode *snode = CTX_wm_space_node(C);
- float slen;
- int ofs = 0;
const char *ui_name = IFACE_(name);
- int len = strlen(ui_name);
+ float slen;
+
UI_ThemeColor(TH_TEXT);
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
- while (slen > node->width && ofs < len) {
- ofs++;
- slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt;
+ while (slen > node->width && *ui_name) {
+ ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
+ slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
}
-
- if (ofs < len) {
- uiDefBut(block, LABEL, 0, ui_name + ofs,
- (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
- (short)(node->width - NODE_DY), (short)NODE_DY,
- NULL, 0, 0, 0, 0, "");
+
+ 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, "");
}
-
- (void)snode;
}
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
@@ -386,7 +381,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "",
(int)butr->xmin, (int)butr->xmin,
- (short)BLI_RCT_SIZE_X(butr), (short)BLI_RCT_SIZE_X(butr),
+ (short)BLI_rctf_size_x(butr), (short)BLI_rctf_size_x(butr),
nor, 0.0f, 1.0f, 0, 0, "");
uiButSetFunc(bt, node_normal_cb, ntree, node);
}
@@ -522,7 +517,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
rect->ymax += NODE_DY;
/* input sockets */
- dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
+ dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
gsock = ngroup->inputs.first;
sock = gnode->inputs.first;
while (gsock || sock) {
@@ -570,7 +565,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
}
/* output sockets */
- dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
+ dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
gsock = ngroup->outputs.first;
sock = gnode->outputs.first;
while (gsock || sock) {
@@ -645,13 +640,13 @@ static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), v
}
static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock,
- int in_out, float xoffset, float yoffset)
+ int in_out, float xoffset, float yoffset, short width, short height)
{
if (sock->flag & SOCK_DYNAMIC) {
bNodeTree *ngroup = (bNodeTree *)gnode->id;
uiBut *but;
but = uiDefBut(gnode->block, TEX, 0, "",
- sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY,
+ sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
sock->name, 0, sizeof(sock->name), 0, 0, "");
if (in_out == SOCK_IN)
uiButSetFunc(but, update_group_input_cb, snode, ngroup);
@@ -661,7 +656,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
else {
const char *ui_name = IFACE_(sock->name);
uiDefBut(gnode->block, LABEL, 0, ui_name,
- sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY,
+ sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
NULL, 0, 0, 0, 0, "");
}
}
@@ -669,23 +664,26 @@ 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;
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
uiBut *bt;
float offset;
int draw_value;
- float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72;
- float socket_size = NODE_SOCKSIZE * U.dpi / 72;
- float arrowbutw = 0.8f * UI_UNIT_X;
+ const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
+ const float socket_size = NODE_SOCKSIZE * dpi_fac;
+ const float arrowbutw = 0.8f * UI_UNIT_X;
+ const short co_text_w = 72 * dpi_fac;
+ const float co_margin = 6.0f * dpi_fac;
/* layout stuff for buttons on group left frame */
- float colw = 0.6f * node_group_frame;
- float col1 = 6 - node_group_frame;
- float col2 = col1 + colw + 6;
- float col3 = -arrowbutw - 6;
+ const float colw = 0.6f * node_group_frame;
+ const float col1 = co_margin - node_group_frame;
+ const float col2 = col1 + colw + co_margin;
+ const float col3 = -arrowbutw - co_margin;
/* layout stuff for buttons on group right frame */
- float cor1 = 6;
- float cor2 = cor1 + arrowbutw + 6;
- float cor3 = cor2 + arrowbutw + 6;
+ const float cor1 = co_margin;
+ const float cor2 = cor1 + arrowbutw;
+ const float cor3 = cor2 + arrowbutw + co_margin;
/* node and group socket circles */
if (sock)
@@ -715,13 +713,13 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
if (draw_value) {
/* both name and value buttons */
if (gsock) {
- draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0);
+ draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0, co_text_w, NODE_DY);
if (stype->buttonfunc)
stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "",
gsock->locx + offset, gsock->locy - NODE_DY, colw);
}
else {
- draw_group_socket_name(snode, gnode, sock, in_out, offset, 0);
+ draw_group_socket_name(snode, gnode, sock, in_out, offset, 0, co_text_w, NODE_DY);
if (stype->buttonfunc)
stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "",
sock->locx + offset, sock->locy - NODE_DY, colw);
@@ -730,9 +728,9 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
else {
/* only name, no value button */
if (gsock)
- draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS);
+ draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY);
else
- draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS);
+ draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY);
}
if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
@@ -836,7 +834,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_RCT_SIZE_X(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
+ mini((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);
@@ -892,7 +890,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
}
-void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
+static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
}
@@ -978,7 +976,7 @@ static void node_draw_frame_label(bNode *node, const float aspect)
ascender = BLF_ascender(fontid);
/* 'x' doesn't need aspect correction */
- x = BLI_RCT_CENTER_X(rct) - (0.5f * width);
+ x = BLI_rctf_cent_x(rct) - (0.5f * width);
y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
BLF_position(fontid, x, y, 0);
@@ -2023,7 +2021,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C
int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
node_composit_buts_file_output(layout, C, ptr);
- uiTemplateImageSettings(layout, &imfptr);
+ uiTemplateImageSettings(layout, &imfptr, TRUE);
uiItemS(layout);
@@ -2082,7 +2080,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C
col = uiLayoutColumn(layout, FALSE);
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE);
- uiTemplateImageSettings(col, &imfptr);
+ uiTemplateImageSettings(col, &imfptr, TRUE);
}
}
}
@@ -2387,7 +2385,7 @@ static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C),
uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
}
-void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
+static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
// node_composit_backdrop_canvas(snode, backdrop, node, x, y);
if (node->custom1 == 0) {
@@ -2407,7 +2405,7 @@ void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *nod
}
}
-void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
+static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
NodeBoxMask *boxmask = node->storage;
const float backdropWidth = backdrop->x;
@@ -2448,7 +2446,7 @@ void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *no
glEnd();
}
-void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
+static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
NodeEllipseMask *ellipsemask = node->storage;
const float backdropWidth = backdrop->x;
@@ -2608,7 +2606,7 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN
uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
if (node->custom1 == 2) {
- uiItemR(layout, ptr, "relative_frame", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE);
}
}
}
@@ -3051,7 +3049,7 @@ void ED_node_init_butfuncs(void)
/* ************** Generic drawing ************** */
-void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
+void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
{
if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
@@ -3059,7 +3057,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
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;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -3078,15 +3079,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
- if (!ibuf->rect) {
- if (color_manage)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- else
- ibuf->profile = IB_PROFILE_NONE;
- IMB_rect_from_float(ibuf);
- }
- if (ibuf->rect) {
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (display_buffer) {
if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
int ofs;
@@ -3104,7 +3100,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
/* swap bytes, so alpha is most significant one, then just draw it as luminance int */
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
- ((unsigned char *)ibuf->rect) + ofs);
+ display_buffer + ofs);
glPixelZoom(1.0f, 1.0f);
}
@@ -3114,7 +3110,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
#ifdef __BIG_ENDIAN__
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
#endif
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
#ifdef __BIG_ENDIAN__
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
@@ -3126,7 +3122,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPixelZoom(snode->zoom, snode->zoom);
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glPixelZoom(1.0f, 1.0f);
glDisable(GL_BLEND);
@@ -3134,12 +3130,14 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
else {
glPixelZoom(snode->zoom, snode->zoom);
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glPixelZoom(1.0f, 1.0f);
}
}
+ IMB_display_buffer_release(cache_handle);
+
/** @note draw selected info on backdrop */
if (snode->edittree) {
bNode *node = snode->edittree->nodes.first;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f1a91df6f53..379e9987c4c 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -62,10 +62,8 @@
#include "node_intern.h" /* own include */
#include "COM_compositor.h"
-/* width of socket columns in group display */
-#define NODE_GROUP_FRAME 120
/* XXX interface.h */
-extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
+extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select);
/* XXX update functions for node editor are a mess, needs a clear concept */
void ED_node_tree_update(SpaceNode *snode, Scene *scene)
@@ -343,7 +341,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
}
else {
- float oldh = BLI_RCT_SIZE_Y(&node->prvr);
+ float oldh = BLI_rctf_size_y(&node->prvr);
if (oldh == 0.0f)
oldh = 0.6f * node->width - NODE_DY;
dy -= NODE_DYS / 2;
@@ -584,9 +582,9 @@ void node_socket_circle_draw(bNodeTree *UNUSED(ntree), bNodeSocket *sock, float
/* not a callback */
static void node_draw_preview(bNodePreview *preview, rctf *prv)
{
- float xscale = BLI_RCT_SIZE_X(prv) / ((float)preview->xsize);
- float yscale = BLI_RCT_SIZE_Y(prv) / ((float)preview->ysize);
- float tile = BLI_RCT_SIZE_X(prv) / 10.0f;
+ float xscale = BLI_rctf_size_x(prv) / ((float)preview->xsize);
+ float yscale = BLI_rctf_size_y(prv) / ((float)preview->ysize);
+ float tile = BLI_rctf_size_x(prv) / 10.0f;
float x, y;
/* draw checkerboard backdrop to show alpha */
@@ -852,8 +850,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
{
bNodeSocket *sock;
rctf *rct = &node->totr;
- float dx, centy = BLI_RCT_CENTER_Y(rct);
- float hiddenrad = BLI_RCT_SIZE_Y(rct) / 2.0f;
+ 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;
int color_id = node_get_colorid(node);
char showname[128]; /* 128 is used below */
@@ -932,7 +930,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
uiDefBut(node->block, LABEL, 0, showname,
(int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
- (short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY,
+ (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
}
@@ -1091,8 +1089,6 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
{
View2DScrollers *scrollers;
SpaceNode *snode = CTX_wm_space_node(C);
- Scene *scene = CTX_data_scene(C);
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
bNodeLinkDrag *nldrag;
LinkData *linkdata;
@@ -1110,7 +1106,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
glEnable(GL_MAP1_VERTEX_3);
/* aspect+font, set each time */
- snode->aspect = BLI_RCT_SIZE_X(&v2d->cur) / (float)ar->winx;
+ snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx;
snode->aspect_sqrt = sqrtf(snode->aspect);
// XXX snode->curfont= uiSetCurFont_ext(snode->aspect);
@@ -1118,7 +1114,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2);
/* backdrop */
- draw_nodespace_back_pix(ar, snode, color_manage);
+ draw_nodespace_back_pix(C, ar, snode);
/* nodes */
snode_set_context(snode, CTX_data_scene(C));
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 9e04bd36a1f..64a8d96a74f 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -148,8 +148,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
{
CompoJob *cj = cjv;
bNodeTree *ntree = cj->localtree;
+ Scene *scene = cj->scene;
- if (cj->scene->use_nodes == FALSE)
+ if (scene->use_nodes == FALSE)
return;
cj->stop = stop;
@@ -165,7 +166,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
// XXX BIF_store_spare();
- ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */
+ ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */
ntree->test_break = NULL;
ntree->stats_draw = NULL;
@@ -2066,8 +2067,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
/* calculate "barycenter" for placing on mouse cursor */
zero_v2(center);
for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) {
- center[0] += BLI_RCT_CENTER_X(&node->totr);
- center[1] += BLI_RCT_CENTER_Y(&node->totr);
+ center[0] += BLI_rctf_cent_x(&node->totr);
+ center[1] += BLI_rctf_cent_y(&node->totr);
}
mul_v2_fl(center, 1.0 / num_nodes);
diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c
index e17961b6c7c..5ab698cd415 100644
--- a/source/blender/editors/space_node/node_header.c
+++ b/source/blender/editors/space_node/node_header.c
@@ -100,7 +100,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
/* once this is called from an operator, this should be removed */
if (node_new) {
char undostr[BKE_UNDO_STR_MAX];
- BLI_snprintf(undostr, sizeof(BKE_UNDO_STR_MAX), "Add Node %s", nodeLabel(node_new));
+ BLI_snprintf(undostr, sizeof(undostr), "Add Node %s", nodeLabel(node_new));
BKE_write_undo(C, undostr);
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 2bb550d1a63..36ebddc8d22 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -125,7 +125,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3);
int node_link_bezier_points(View2D * v2d, SpaceNode * snode, bNodeLink * link, float coord_array[][2], int resol);
// void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
-void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage);
+void draw_nodespace_back_pix(const struct bContext *C, ARegion *ar, SpaceNode *snode);
/* node_add.c */
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index a56d76a3ef7..f7757ce49b4 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -555,8 +555,8 @@ static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short
/* do actual selection */
for (node = snode->edittree->nodes.first; node; node = node->next) {
int screen_co[2];
- const float cent[2] = {BLI_RCT_CENTER_X(&node->totr),
- BLI_RCT_CENTER_Y(&node->totr)};
+ const float cent[2] = {BLI_rctf_cent_x(&node->totr),
+ BLI_rctf_cent_y(&node->totr)};
/* marker in screen coords */
UI_view2d_view_to_region(&ar->v2d,
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 7881014ed54..3d93a6c14a1 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -230,7 +230,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
/****************************** Node Link Menu *******************************/
-#define UI_NODE_LINK_ADD 0
+// #define UI_NODE_LINK_ADD 0
#define UI_NODE_LINK_DISCONNECT -1
#define UI_NODE_LINK_REMOVE -2
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index e89e798a6fa..ccf5c4b540f 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -72,8 +72,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
int tot = 0;
int has_frame = FALSE;
- oldwidth = BLI_RCT_SIZE_X(&ar->v2d.cur);
- oldheight = BLI_RCT_SIZE_Y(&ar->v2d.cur);
+ oldwidth = BLI_rctf_size_x(&ar->v2d.cur);
+ oldheight = BLI_rctf_size_y(&ar->v2d.cur);
BLI_rctf_init_minmax(&cur_new);
@@ -91,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
}
if (tot) {
- width = BLI_RCT_SIZE_X(&cur_new);
- height = BLI_RCT_SIZE_Y(&cur_new);
+ width = BLI_rctf_size_x(&cur_new);
+ height = BLI_rctf_size_y(&cur_new);
/* for single non-frame nodes, don't zoom in, just pan view,
* but do allow zooming out, this allows for big nodes to be zoomed out */
@@ -327,12 +327,12 @@ typedef struct ImageSampleInfo {
void *draw_handle;
int x, y;
int channels;
- int color_manage;
unsigned char col[4];
float colf[4];
int draw;
+ int color_manage;
} ImageSampleInfo;
static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -341,7 +341,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
ImageSampleInfo *info = arg_info;
if (info->draw) {
- ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+ ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels,
info->x, info->y, info->col, info->colf,
NULL, NULL /* zbuf - unused for nodes */
);
@@ -358,6 +358,13 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float
float fx, fy, bufx, bufy;
int ret = FALSE;
+ if (snode->treetype != NTREE_COMPOSIT || (snode->flag & SNODE_BACKDRAW) == 0) {
+ /* use viewer image for color sampling only if we're in compositor tree
+ * with backdrop enabled
+ */
+ return FALSE;
+ }
+
ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
@@ -381,12 +388,7 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
/* IB_PROFILE_NONE is default but infact its linear */
- if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
- linearrgb_to_srgb_v3_v3(r_col, fp);
- }
- else {
- copy_v3_v3(r_col, fp);
- }
+ linearrgb_to_srgb_v3_v3(r_col, fp);
ret = TRUE;
}
else if (ibuf->rect) {
@@ -419,10 +421,6 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
}
if (!ibuf->rect) {
- if (info->color_manage)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- else
- ibuf->profile = IB_PROFILE_NONE;
IMB_rect_from_float(ibuf);
}
@@ -457,6 +455,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[1] = (float)cp[1] / 255.0f;
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
+
+ info->color_manage = FALSE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -465,6 +465,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[1] = fp[1];
info->colf[2] = fp[2];
info->colf[3] = fp[3];
+
+ info->color_manage = TRUE;
}
ED_node_sample_set(info->colf);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 1522528a8ac..0601d7c105f 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -44,6 +44,7 @@
#include "BKE_screen.h"
#include "BKE_node.h"
+#include "ED_space_api.h"
#include "ED_render.h"
#include "ED_screen.h"
#include "ED_node.h"
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 0874ddcb279..d7e180f982b 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -579,11 +579,11 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
te = outliner_find_id(so, &so->tree, (ID *)OBACT);
if (te) {
/* make te->ys center of view */
- ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&v2d->mask) / 2);
+ ytop = (int)(te->ys + BLI_rcti_size_y(&v2d->mask) / 2);
if (ytop > 0) ytop = 0;
v2d->cur.ymax = (float)ytop;
- v2d->cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&v2d->mask));
+ v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask));
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - v2d->cur.xmin);
@@ -615,7 +615,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
- int dy = BLI_RCT_SIZE_Y(&ar->v2d.mask);
+ int dy = BLI_rcti_size_y(&ar->v2d.mask);
int up = 0;
if (RNA_boolean_get(op->ptr, "up"))
@@ -760,10 +760,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
tselem->flag |= TSE_SELECTED;
/* make te->ys center of view */
- ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2);
+ ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2);
if (ytop > 0) ytop = 0;
ar->v2d.cur.ymax = (float)ytop;
- ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&ar->v2d.mask));
+ ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask));
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - ar->v2d.cur.xmin);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 8b7cf406642..823de61d044 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -433,8 +433,11 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
if (set) {
if (!(bone->flag & BONE_HIDDEN_P)) {
- if (set == 2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag
- else ED_pose_deselectall(OBACT, 0);
+ Object *ob = OBACT;
+ if (ob) {
+ if (set == 2) ED_pose_deselectall(ob, 2); // 2 is clear active tag
+ else ED_pose_deselectall(ob, 0);
+ }
if (set == 2 && (bone->flag & BONE_SELECTED)) {
bone->flag &= ~BONE_SELECTED;
@@ -444,7 +447,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
arm->act_bone = bone;
}
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob);
}
}
else {
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 0c316450c29..f927e83cabe 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -52,6 +52,7 @@
#include "BKE_sound.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "BIF_gl.h"
@@ -68,6 +69,9 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "WM_api.h"
+#include "WM_types.h"
+
/* own include */
#include "sequencer_intern.h"
@@ -428,7 +432,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
- pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask);
+ pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
if (pixely <= 0) return; /* can happen when the view is split/resized */
@@ -721,7 +725,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
/* draw sound wave */
if (seq->type == SEQ_TYPE_SOUND_RAM) {
- drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx);
+ drawseqwave(scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx);
}
/* draw lock */
@@ -846,6 +850,50 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int
return ibuf;
}
+static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf)
+{
+ if (scopes->reference_ibuf != ibuf) {
+ if (scopes->zebra_ibuf) {
+ IMB_freeImBuf(scopes->zebra_ibuf);
+ scopes->zebra_ibuf = NULL;
+ }
+
+ if (scopes->waveform_ibuf) {
+ IMB_freeImBuf(scopes->waveform_ibuf);
+ scopes->waveform_ibuf = NULL;
+ }
+
+ if (scopes->sep_waveform_ibuf) {
+ IMB_freeImBuf(scopes->sep_waveform_ibuf);
+ scopes->sep_waveform_ibuf = NULL;
+ }
+
+ if (scopes->vector_ibuf) {
+ IMB_freeImBuf(scopes->vector_ibuf);
+ scopes->vector_ibuf = NULL;
+ }
+
+ if (scopes->histogram_ibuf) {
+ IMB_freeImBuf(scopes->histogram_ibuf);
+ scopes->histogram_ibuf = NULL;
+ }
+ }
+}
+
+static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf))
+{
+ ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
+ ImBuf *scope;
+
+ IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings);
+
+ scope = make_scope_cb(display_ibuf);
+
+ IMB_freeImBuf(display_ibuf);
+
+ return scope;
+}
+
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
{
struct Main *bmain = CTX_data_main(C);
@@ -859,6 +907,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
float col[3];
GLuint texid;
GLuint last_texid;
+ unsigned char *display_buffer;
+ void *cache_handle = NULL;
render_size = sseq->render_size;
if (render_size == 0) {
@@ -906,38 +956,64 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (ibuf->rect == NULL && ibuf->rect_float == NULL)
return;
-
- switch (sseq->mainb) {
- case SEQ_DRAW_IMG_IMBUF:
- if (sseq->zebra != 0) {
- scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra);
- }
- break;
- case SEQ_DRAW_IMG_WAVEFORM:
- if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
- scope = make_sep_waveform_view_from_ibuf(ibuf);
- }
- else {
- scope = make_waveform_view_from_ibuf(ibuf);
- }
- break;
- case SEQ_DRAW_IMG_VECTORSCOPE:
- scope = make_vectorscope_view_from_ibuf(ibuf);
- break;
- case SEQ_DRAW_IMG_HISTOGRAM:
- scope = make_histogram_view_from_ibuf(ibuf);
- break;
+
+ if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) {
+ SequencerScopes *scopes = &sseq->scopes;
+
+ sequencer_check_scopes(scopes, ibuf);
+
+ switch (sseq->mainb) {
+ case SEQ_DRAW_IMG_IMBUF:
+ if (!scopes->zebra_ibuf) {
+ ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
+
+ IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings);
+ scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
+ IMB_freeImBuf(display_ibuf);
+ }
+ scope = scopes->zebra_ibuf;
+ break;
+ case SEQ_DRAW_IMG_WAVEFORM:
+ if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
+ if (!scopes->sep_waveform_ibuf)
+ scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf);
+ scope = scopes->sep_waveform_ibuf;
+ }
+ else {
+ if (!scopes->waveform_ibuf)
+ scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf);
+ scope = scopes->waveform_ibuf;
+ }
+ break;
+ case SEQ_DRAW_IMG_VECTORSCOPE:
+ if (!scopes->vector_ibuf)
+ scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
+ scope = scopes->vector_ibuf;
+ break;
+ case SEQ_DRAW_IMG_HISTOGRAM:
+ if (!scopes->histogram_ibuf)
+ scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf);
+ scope = scopes->histogram_ibuf;
+ break;
+ }
+
+ scopes->reference_ibuf = ibuf;
}
if (scope) {
IMB_freeImBuf(ibuf);
ibuf = scope;
- }
- if (ibuf->rect_float && ibuf->rect == NULL) {
- IMB_rect_from_float(ibuf);
+ if (ibuf->rect_float && ibuf->rect == NULL) {
+ IMB_rect_from_float(ibuf);
+ }
+
+ display_buffer = (unsigned char *)ibuf->rect;
}
-
+ else {
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+ }
+
/* setting up the view - actual drawing starts here */
UI_view2d_view_ortho(v2d);
@@ -950,16 +1026,16 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glBegin(GL_QUADS);
if (draw_overlay) {
if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
rctf tot_clip;
- tot_clip.xmin = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmin);
- tot_clip.ymin = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymin);
- tot_clip.xmax = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmax);
- tot_clip.ymax = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymax);
+ tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin);
+ tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin);
+ tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
+ tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax);
@@ -1030,7 +1106,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
/* draw grease-pencil (image aligned) */
draw_gpencil_2dimage(C);
- IMB_freeImBuf(ibuf);
+ if (!scope)
+ IMB_freeImBuf(ibuf);
/* ortho at pixel level */
UI_view2d_view_restore(C);
@@ -1065,6 +1142,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
}
}
+ if (cache_handle)
+ IMB_display_buffer_release(cache_handle);
}
#if 0
@@ -1143,7 +1222,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
View2D *v2d = &ar->v2d;
Sequence *last_seq = BKE_sequencer_active_get(scene);
int sel = 0, j;
- float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
/* loop through twice, first unselected, then selected */
for (j = 0; j < 2; j++) {
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index f47eb339878..e7d964ba715 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -372,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
if (ed == NULL) return NULL;
- pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -2164,8 +2164,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
float winx = (int)(rd->size * rd->xsch) / 100;
float winy = (int)(rd->size * rd->ysch) / 100;
- float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx;
- float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy;
+ float facx = BLI_rcti_size_x(&v2d->mask) / winx;
+ float facy = BLI_rcti_size_y(&v2d->mask) / winy;
BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
@@ -2268,7 +2268,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
ymax += ymargin;
ymin -= ymargin;
- orig_height = BLI_RCT_SIZE_Y(&cur_new);
+ orig_height = BLI_rctf_size_y(&cur_new);
cur_new.xmin = xmin;
cur_new.xmax = xmax;
@@ -2277,8 +2277,8 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
cur_new.ymax = ymax;
/* only zoom out vertically */
- if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) {
- ymid = BLI_RCT_CENTER_Y(&cur_new);
+ if (orig_height > BLI_rctf_size_y(&cur_new)) {
+ ymid = BLI_rctf_cent_y(&cur_new);
cur_new.ymin = ymid - (orig_height / 2);
cur_new.ymax = ymid + (orig_height / 2);
@@ -2800,11 +2800,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op)
if (ed == NULL)
return OPERATOR_CANCELLED;
- rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot)));
- rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot)));
+ rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot));
+ rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot));
- rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot)));
- rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot)));
+ rect.xmax /= fabsf(BLI_rctf_size_x(&v2d->tot));
+ rect.ymax /= fabsf(BLI_rctf_size_y(&v2d->tot));
rect.xmin += 0.5f;
rect.xmax += 0.5f;
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index aa6bacf8836..70b288a59e6 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -43,6 +43,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "ED_sequencer.h"
#include "ED_markers.h"
#include "ED_transform.h" /* transform keymap */
@@ -77,6 +78,9 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_swap_data);
WM_operatortype_append(SEQUENCER_OT_rendersize);
+ WM_operatortype_append(SEQUENCER_OT_copy);
+ WM_operatortype_append(SEQUENCER_OT_paste);
+
WM_operatortype_append(SEQUENCER_OT_view_all);
WM_operatortype_append(SEQUENCER_OT_view_selected);
WM_operatortype_append(SEQUENCER_OT_view_all_preview);
@@ -109,10 +113,9 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
WM_operatortype_append(SEQUENCER_OT_image_strip_add);
WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
- WM_operatortype_append(SEQUENCER_OT_properties);
- WM_operatortype_append(SEQUENCER_OT_copy);
- WM_operatortype_append(SEQUENCER_OT_paste);
+ /* sequencer_buttons.c */
+ WM_operatortype_append(SEQUENCER_OT_properties);
/* sequencer_modifiers.c */
WM_operatortype_append(SEQUENCER_OT_strip_modifier_add);
@@ -131,7 +134,9 @@ void sequencer_keymap(wmKeyConfig *keyconf)
/* Common items ------------------------------------------------------------------ */
keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0);
-
+
+ WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.show_overlay");
@@ -140,9 +145,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
/* Strips Region --------------------------------------------------------------- */
keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
-
- WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
@@ -152,12 +155,12 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_enum_set(kmi->ptr, "type", SEQ_CUT_SOFT);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", SEQ_CUT_HARD);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", FALSE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", TRUE);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "unselected", FALSE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
@@ -178,7 +181,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
@@ -209,7 +212,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT);
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0);
@@ -244,7 +247,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
@@ -292,14 +295,14 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
@@ -307,33 +310,32 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame");
RNA_int_set(kmi->ptr, "value", 0);
transform_keymap_for_space(keyconf, keymap, SPACE_SEQ);
-
+
/* special markers hotkeys for anim editors: see note in definition of this function */
ED_marker_keymap_animedit_conflictfree(keymap);
-
-
+
+
/* Preview Region ----------------------------------------------------------- */
keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0);
/* would prefer to use numpad keys for job */
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
-
+
/* Setting zoom levels is not that useful, except for back to zoom level 1, removing keymap because of conflicts for now */
#if 0
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
-
+
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 1655b3ec7bc..6ed34a79510 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -449,6 +449,8 @@ static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col)
}
}
+#define HIS_STEPS 512
+
static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
{
ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
@@ -456,22 +458,38 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
unsigned int n;
unsigned char *src = (unsigned char *) ibuf->rect;
- unsigned int bins[3][256];
+ unsigned int bins[3][HIS_STEPS];
memset(bins, 0, sizeof(bins));
+ #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256)
for (y = 0; y < ibuf->y; y++) {
+ unsigned int cur_bins[3][HIS_STEPS];
+
+ memset(cur_bins, 0, sizeof(cur_bins));
+
for (x = 0; x < ibuf->x; x++) {
- bins[0][*src++]++;
- bins[1][*src++]++;
- bins[2][*src++]++;
- src++;
+ unsigned char *pixel = src + (y * ibuf->x + x) * 4;
+
+ cur_bins[0][pixel[0]]++;
+ cur_bins[1][pixel[1]]++;
+ cur_bins[2][pixel[2]]++;
+ }
+
+ #pragma omp critical
+ {
+ int i;
+ for (i = 0; i < HIS_STEPS; i++) {
+ bins[0][i] += cur_bins[0][i];
+ bins[1][i] += cur_bins[1][i];
+ bins[2][i] += cur_bins[2][i];
+ }
}
}
n = 0;
for (c = 0; c < 3; c++) {
- for (x = 0; x < 256; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
if (bins[c][x] > n) {
n = bins[c][x];
}
@@ -479,7 +497,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
}
for (c = 0; c < 3; c++) {
- for (x = 0; x < 256; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
draw_histogram_bar(rval, x * 2 + 1, ((float) bins[c][x]) / n, c);
draw_histogram_bar(rval, x * 2 + 2, ((float) bins[c][x]) / n, c);
}
@@ -490,7 +508,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
return rval;
}
-static int get_bin_float(float f)
+BLI_INLINE int get_bin_float(float f)
{
if (f < -0.25f) {
return 0;
@@ -508,16 +526,32 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
int n, c, x, y;
float *src = ibuf->rect_float;
- unsigned int bins[3][512];
+ unsigned int bins[3][HIS_STEPS];
memset(bins, 0, sizeof(bins));
+ #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256)
for (y = 0; y < ibuf->y; y++) {
+ unsigned int cur_bins[3][HIS_STEPS];
+
+ memset(cur_bins, 0, sizeof(cur_bins));
+
for (x = 0; x < ibuf->x; x++) {
- bins[0][get_bin_float(*src++)]++;
- bins[1][get_bin_float(*src++)]++;
- bins[2][get_bin_float(*src++)]++;
- src++;
+ float *pixel = src + (y * ibuf->x + x) * 4;
+
+ cur_bins[0][get_bin_float(pixel[0])]++;
+ cur_bins[1][get_bin_float(pixel[1])]++;
+ cur_bins[2][get_bin_float(pixel[2])]++;
+ }
+
+ #pragma omp critical
+ {
+ int i;
+ for (i = 0; i < HIS_STEPS; i++) {
+ bins[0][i] += cur_bins[0][i];
+ bins[1][i] += cur_bins[1][i];
+ bins[2][i] += cur_bins[2][i];
+ }
}
}
@@ -526,14 +560,14 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
n = 0;
for (c = 0; c < 3; c++) {
- for (x = 0; x < 512; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
if (bins[c][x] > n) {
n = bins[c][x];
}
}
}
for (c = 0; c < 3; c++) {
- for (x = 0; x < 512; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
draw_histogram_bar(rval, x + 1, (float) bins[c][x] / n, c);
}
}
@@ -543,6 +577,8 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
return rval;
}
+#undef HIS_STEPS
+
ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf)
{
if (ibuf->rect_float) {
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index d500bef4f02..3c3489115a4 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -49,6 +49,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "UI_view2d.h"
@@ -70,6 +71,7 @@ typedef struct ImageSampleInfo {
float *colfp;
int draw;
+int color_manage;
} ImageSampleInfo;
static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -78,8 +80,8 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
ImageSampleInfo *info = arg_info;
if (info->draw) {
- ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
- info->x, info->y, info->col, info->colf, NULL, NULL);
+ ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels,
+ info->x, info->y, info->colp, info->colfp, NULL, NULL);
}
}
@@ -131,6 +133,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
info->colfp = info->colf;
+
+ info->color_manage = FALSE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -140,6 +144,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = fp[2];
info->colf[3] = fp[3];
info->colfp = info->colf;
+
+ /* sequencer's image buffers are in non-linear space, need to make them linear */
+ BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->colf);
+
+ info->color_manage = TRUE;
}
}
else {
@@ -202,7 +211,7 @@ static int sample_cancel(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
-int sample_poll(bContext *C)
+static int sample_poll(bContext *C)
{
return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL;
}
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index f7362aab7aa..8ac50a57b10 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -57,8 +57,19 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "IMB_imbuf.h"
+
#include "sequencer_intern.h" // own include
+/**************************** common state *****************************/
+
+static void sequencer_scopes_tag_refresh(ScrArea *sa)
+{
+ SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
+
+ sseq->scopes.reference_ibuf = NULL;
+}
+
/* ******************** manage regions ********************* */
ARegion *sequencer_has_buttons_region(ScrArea *sa)
@@ -183,12 +194,27 @@ static SpaceLink *sequencer_new(const bContext *C)
}
/* not spacelink itself */
-static void sequencer_free(SpaceLink *UNUSED(sl))
+static void sequencer_free(SpaceLink *sl)
{
-// SpaceSeq *sseq= (SpaceSequencer*) sl;
-
+ SpaceSeq *sseq= (SpaceSeq *) sl;
+ SequencerScopes *scopes = &sseq->scopes;
+
// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd);
+ if (scopes->zebra_ibuf)
+ IMB_freeImBuf(scopes->zebra_ibuf);
+
+ if (scopes->waveform_ibuf)
+ IMB_freeImBuf(scopes->waveform_ibuf);
+
+ if (scopes->sep_waveform_ibuf)
+ IMB_freeImBuf(scopes->sep_waveform_ibuf);
+
+ if (scopes->vector_ibuf)
+ IMB_freeImBuf(scopes->vector_ibuf);
+
+ if (scopes->histogram_ibuf)
+ IMB_freeImBuf(scopes->histogram_ibuf);
}
@@ -290,7 +316,24 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
return (SpaceLink *)sseqn;
}
-
+static void sequencer_listener(ScrArea *sa, wmNotifier *wmn)
+{
+ /* context changes */
+ switch (wmn->category) {
+ case NC_SCENE:
+ switch (wmn->data) {
+ case ND_FRAME:
+ case ND_SEQUENCER:
+ sequencer_scopes_tag_refresh(sa);
+ break;
+ }
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_SEQUENCER)
+ sequencer_scopes_tag_refresh(sa);
+ break;
+ }
+}
/* *********************** sequencer (main) region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
@@ -610,6 +653,7 @@ void ED_spacetype_sequencer(void)
st->context = sequencer_context;
st->dropboxes = sequencer_dropboxes;
st->refresh = sequencer_refresh;
+ st->listener = sequencer_listener;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 97eb5b41db7..5111d20b8ee 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1232,7 +1232,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_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll));
+ rad = 0.4f * mini(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
UI_GetThemeColor3ubv(TH_HILITE, col);
col[3] = 48;
glColor4ubv(col);
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index b0cd6aeaab4..7dc3ec1ac60 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -59,17 +59,12 @@
#include "WM_types.h"
-
-
-
#ifdef WITH_PYTHON
// XXX #include "BPY_menus.h"
#endif
#include "text_intern.h"
-#define HEADER_PATH_MAX 260
-
/* ************************ header area region *********************** */
/************************** properties ******************************/
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 5af44f93d06..75b8e2f218d 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -602,9 +602,12 @@ static int text_run_script(bContext *C, ReportList *reports)
/* Don't report error messages while live editing */
if (!is_live) {
- if (text->curl != curl_prev || curc_prev != text->curc) {
- text_update_cursor_moved(C);
- WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+ /* text may have freed its self */
+ if (CTX_data_edit_text(C) == text) {
+ if (text->curl != curl_prev || curc_prev != text->curc) {
+ text_update_cursor_moved(C);
+ WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+ }
}
BKE_report(reports, RPT_ERROR, "Python script fail, look in the console for now...");
@@ -2409,8 +2412,8 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* jump scroll, works in v2d but needs to be added here too :S */
if (event->type == MIDDLEMOUSE) {
- tsc->old[0] = ar->winrct.xmin + BLI_RCT_CENTER_X(&st->txtbar);
- tsc->old[1] = ar->winrct.ymin + BLI_RCT_CENTER_Y(&st->txtbar);
+ tsc->old[0] = ar->winrct.xmin + BLI_rcti_cent_x(&st->txtbar);
+ tsc->old[1] = ar->winrct.ymin + BLI_rcti_cent_y(&st->txtbar);
tsc->delta[0] = 0;
tsc->delta[1] = 0;
diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c
index f980e19e9c8..966afe22e42 100644
--- a/source/blender/editors/space_text/text_python.c
+++ b/source/blender/editors/space_text/text_python.c
@@ -180,13 +180,9 @@ static void confirm_suggestion(Text *text, int skipleft)
}
// XXX
-#define L_MOUSE 0
-#define M_MOUSE 0
-#define R_MOUSE 0
#define LR_SHIFTKEY 0
#define LR_ALTKEY 0
#define LR_CTRLKEY 0
-#define LR_OSKEY 0
// XXX
static int doc_scroll = 0;
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
index 733fd27135b..9067fb6933f 100644
--- a/source/blender/editors/space_time/time_ops.c
+++ b/source/blender/editors/space_time/time_ops.c
@@ -151,7 +151,7 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
v2d->cur.xmax = (float)PEFRA;
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
- extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index da93e07748a..f05c78e8512 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -179,7 +179,7 @@ static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int i
return DM_DRAW_OPTION_SKIP;
}
-void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
+static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
{
drawMeshFaceSelect_userData data;
@@ -372,7 +372,15 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
Gtexdraw.ob = ob;
Gtexdraw.is_tex = is_tex;
- Gtexdraw.color_profile = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+
+ /* OCIO_TODO: for now assume OpenGL is always doing color management and working in sRGB space
+ * supporting for real display conversion could be nice here, but it's a bit challenging
+ * since all the shaders should be aware of such a transform
+ * perhaps this flag could be completely removed before release in separated commit and
+ * be re-implemented if real display transform would be needed
+ */
+ Gtexdraw.color_profile = TRUE;
+
memcpy(Gtexdraw.obcol, obcol, sizeof(obcol));
set_draw_settings_cached(1, NULL, NULL, Gtexdraw);
glShadeModel(GL_SMOOTH);
@@ -507,7 +515,7 @@ static void update_tface_color_layer(DerivedMesh *dm)
finalCol[i * 4 + j].r = 255;
}
}
- else if (tface && mface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
+ else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
for (j = 0; j < 4; j++) {
finalCol[i * 4 + j].b = 255;
finalCol[i * 4 + j].g = 0;
@@ -630,7 +638,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */
MLoopCol *lcol;
- bProperty *prop = get_ob_property(ob, "Text");
+ bProperty *prop = BKE_bproperty_object_get(ob, "Text");
GPUVertexAttribs gattribs;
int a, totpoly = me->totpoly;
@@ -706,7 +714,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
unsigned int j;
lcol = &mloopcol[mp->loopstart];
- for (j = 0; j <= totloop_clamp; j++, lcol++) {
+ for (j = 0; j < totloop_clamp; j++, lcol++) {
MESH_MLOOPCOL_TO_MCOL(lcol, &tmp_mcol[j]);
}
}
@@ -724,7 +732,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
/* The BM_FONT handling is in the gpu module, shared with the
* game engine, was duplicated previously */
- set_property_valstr(prop, string);
+ BKE_bproperty_set_valstr(prop, string);
characters = strlen(string);
if (!BKE_image_get_ibuf(mtpoly->tpage, NULL))
@@ -772,8 +780,8 @@ static int compareDrawOptionsEm(void *userData, int cur_index, int next_index)
return 1;
}
-void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
+static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ Object *ob, DerivedMesh *dm, const int draw_flags)
{
Mesh *me = ob->data;
@@ -824,7 +832,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
}
/* draw game engine text hack */
- if (get_ob_property(ob, "Text"))
+ if (BKE_bproperty_object_get(ob, "Text"))
draw_mesh_text(scene, ob, 0);
draw_textured_end();
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 83bc094270b..8d58530765a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -2092,7 +2092,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo
else {
float co2[2];
mul_v3_m4v3(co2, data->vc.obedit->obmat, co);
- project_short_noclip(data->vc.ar, co2, s);
+ ED_view3d_project_short_noclip(data->vc.ar, co2, s);
}
if (s[0] != IS_CLIPPED)
@@ -2169,8 +2169,8 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo
mul_v3_m4v3(v1_co, data->vc.obedit->obmat, v0co);
mul_v3_m4v3(v2_co, data->vc.obedit->obmat, v1co);
- project_short_noclip(data->vc.ar, v1_co, s[0]);
- project_short_noclip(data->vc.ar, v2_co, s[1]);
+ ED_view3d_project_short_noclip(data->vc.ar, v1_co, s[0]);
+ ED_view3d_project_short_noclip(data->vc.ar, v2_co, s[1]);
if (data->clipVerts == V3D_CLIP_TEST_REGION) {
/* make an int copy */
@@ -2225,7 +2225,7 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const flo
short s[2];
mul_v3_m4v3(cent2, data->vc.obedit->obmat, cent);
- project_short(data->vc.ar, cent2, s);
+ ED_view3d_project_short(data->vc.ar, cent2, s);
if (s[0] != IS_CLIPPED) {
data->func(data->userData, efa, s[0], s[1], index);
@@ -3335,7 +3335,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
}
- if (em) {
+
+ {
draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d);
if (me->drawflag & ME_DRAWNORMALS) {
@@ -3461,7 +3462,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
dm->drawFacesGLSL(dm, GPU_enable_material);
-// if (get_ob_property(ob, "Text"))
+// if (BKE_bproperty_object_get(ob, "Text"))
// XXX draw_mesh_text(ob, 1);
GPU_disable_material();
@@ -3649,7 +3650,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
if (obedit && ob != obedit && ob->data == obedit->data) {
- if (ob_get_key(ob) || ob_get_key(obedit)) {}
+ if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {}
else if (ob->modifiers.first || obedit->modifiers.first) {}
else drawlinked = 1;
}
@@ -6643,7 +6644,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* which wire color */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- project_short(ar, ob->obmat[3], &base->sx);
+ ED_view3d_project_short(ar, ob->obmat[3], &base->sx);
draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive);
ob_wire_col = _ob_wire_col;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index c819637fd04..c8aca5674a4 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -83,7 +83,6 @@
/* ******************* view3d space & buttons ************** */
-#define B_NOP 1
#define B_REDR 2
#define B_OBJECTPANELMEDIAN 1008
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 8a334423ab0..c0ea4173392 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -69,6 +69,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -558,7 +559,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
/* we don't want the clipping for cursor */
flag = v3d->flag;
v3d->flag = 0;
- project_int(ar, give_cursor(scene, v3d), co);
+ ED_view3d_project_int(ar, give_cursor(scene, v3d), co);
v3d->flag = flag;
mx = co[0];
@@ -900,7 +901,7 @@ static void draw_selected_name(Scene *scene, Object *ob)
/* try to display active shapekey too */
shapes[0] = '\0';
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key) {
kb = BLI_findlink(&key->block, ob->shapenr - 1);
if (kb) {
@@ -972,10 +973,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV
rect_camera = params.viewplane;
/* get camera border within viewport */
- viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
- viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
- viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
- viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
+ viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx;
+ viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx;
+ viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy;
+ viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy;
}
void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2])
@@ -983,8 +984,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R
rctf viewborder;
view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE);
- size_r[0] = BLI_RCT_SIZE_X(&viewborder);
- size_r[1] = BLI_RCT_SIZE_Y(&viewborder);
+ size_r[0] = BLI_rctf_size_x(&viewborder);
+ size_r[1] = BLI_rctf_size_y(&viewborder);
}
void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
@@ -1340,7 +1341,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
glDisable(GL_MULTISAMPLE_ARB);
region_scissor_winrct(ar, &winrct);
- glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct));
+ glScissor(winrct.xmin, winrct.ymin, BLI_rcti_size_x(&winrct), BLI_rcti_size_y(&winrct));
glClearColor(0.0, 0.0, 0.0, 0.0);
if (v3d->zbuf) {
@@ -1542,11 +1543,6 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
{
RegionView3D *rv3d = ar->regiondata;
BGpic *bgpic;
- Image *ima;
- MovieClip *clip;
- ImBuf *ibuf = NULL, *freeibuf;
- float vec[4], fac, asp, zoomx, zoomy;
- float x1, y1, x2, y2, cx, cy;
int fg_flag = do_foreground ? V3D_BGPIC_FOREGROUND : 0;
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
@@ -1559,6 +1555,13 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
(rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA)))
{
float image_aspect[2];
+ float fac, asp, zoomx, zoomy;
+ float x1, y1, x2, y2;
+
+ ImBuf *ibuf = NULL, *freeibuf;
+
+ Image *ima;
+ MovieClip *clip;
/* disable individual images */
if ((bgpic->flag & V3D_BGPIC_DISABLED))
@@ -1686,26 +1689,25 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
}
}
else {
+ float tvec[3];
float sco[2];
const float mval_f[2] = {1.0f, 0.0f};
/* calc window coord */
initgrabz(rv3d, 0.0, 0.0, 0.0);
- ED_view3d_win_to_delta(ar, mval_f, vec);
- fac = maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */
+ 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 = 1.0f / fac;
- asp = ( (float)ibuf->y) / (float)ibuf->x;
+ asp = (float)ibuf->y / (float)ibuf->x;
- zero_v3(vec);
- ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat);
- cx = sco[0];
- cy = sco[1];
+ zero_v3(tvec);
+ ED_view3d_project_float_v2_m4(ar, tvec, sco, rv3d->persmat);
- x1 = cx + fac * (bgpic->xof - bgpic->size);
- y1 = cy + asp * fac * (bgpic->yof - bgpic->size);
- x2 = cx + fac * (bgpic->xof + bgpic->size);
- y2 = cy + asp * fac * (bgpic->yof + bgpic->size);
+ x1 = sco[0] + fac * (bgpic->xof - bgpic->size);
+ y1 = sco[1] + asp * fac * (bgpic->yof - bgpic->size);
+ x2 = sco[0] + fac * (bgpic->xof + bgpic->size);
+ y2 = sco[1] + asp * fac * (bgpic->yof + bgpic->size);
}
/* complete clip? */
@@ -1771,8 +1773,9 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
glDepthMask(1);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- if (freeibuf)
+ if (freeibuf) {
IMB_freeImBuf(freeibuf);
+ }
}
}
}
@@ -2044,8 +2047,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
x = rect->xmin;
y = rect->ymin;
- w = BLI_RCT_SIZE_X(rect);
- h = BLI_RCT_SIZE_Y(rect);
+ w = BLI_rcti_size_x(rect);
+ h = BLI_rcti_size_y(rect);
if (w <= 0 || h <= 0) {
if (d->depths)
@@ -2375,7 +2378,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);
- ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE);
+ ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE, FALSE);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
v3d->drawtype = drawtype;
@@ -2514,7 +2517,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
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 do_bgpic, int colormanage_background)
{
RegionView3D *rv3d = ar->regiondata;
Base *base;
@@ -2553,10 +2556,25 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* 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) */
if (scene->world) {
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ /* NOTE: currently OpenGL is supposed to always work in sRGB space and do not
+ * apply any tonemaps since it's really tricky to support for all features (GLSL, textures, etc)
+ * but due to compatibility issues background is being affected display transform, so we can
+ * emulate behavior of disabled colro management
+ * but this function is also used for sequencer's scene strips which shouldn't be affected by
+ * tonemaps now and should be purely sRGB, that's why we've got this colormanage_background
+ * we can drop this flag in cost of some compatibility loss -- background wouldn't be
+ * color managed in 3d viewport
+ * same goes to opengl rendering, where color profile should be applied as very final step
+ */
+
+ if (colormanage_background) {
+ IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
+ &scene->display_settings);
+ }
+ else {
linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
- else
- copy_v3_v3(backcol, &scene->world->horr);
+ }
+
glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
}
else {
@@ -2661,7 +2679,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* utility func for ED_view3d_draw_offscreen */
ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
- int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256])
+ int sizex, int sizey, unsigned int flag, int draw_background,
+ int colormanage_background, char err_out[256])
{
RegionView3D *rv3d = ar->regiondata;
ImBuf *ibuf;
@@ -2686,10 +2705,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
BKE_camera_params_compute_viewplane(&params, sizex, sizey, scene->r.xasp, scene->r.yasp);
BKE_camera_params_compute_matrix(&params);
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background, colormanage_background);
}
else {
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL, draw_background);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL, draw_background, colormanage_background);
}
/* read in pixels & stamp */
@@ -2714,7 +2733,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
/* creates own 3d views, used by the sequencer */
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height,
- unsigned int flag, int drawtype, int draw_background, char err_out[256])
+ unsigned int flag, int drawtype, int draw_background,
+ int colormanage_background, char err_out[256])
{
View3D v3d = {NULL};
ARegion ar = {NULL};
@@ -2753,7 +2773,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
- return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, draw_background, err_out);
+ return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag,
+ draw_background, colormanage_background, err_out);
// seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty);
}
@@ -2860,10 +2881,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
- cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder);
- cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder);
- cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder);
- cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_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);
cliprct.xmin += ar->winrct.xmin;
cliprct.xmax += ar->winrct.xmin;
@@ -2877,7 +2898,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) {
glGetIntegerv(GL_SCISSOR_BOX, scissor);
- glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct));
+ glScissor(cliprct.xmin, cliprct.ymin, BLI_rcti_size_x(&cliprct), BLI_rcti_size_y(&cliprct));
}
else
return 0;
@@ -2936,10 +2957,9 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
/* clear background */
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
- else
- copy_v3_v3(backcol, &scene->world->horr);
+ IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
+ &scene->display_settings);
+
glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
}
else
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 7accdb0c0e4..744ce6f6209 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -375,17 +375,17 @@ typedef struct ViewOpsData {
#define TRACKBALLSIZE (1.1)
-static void calctrackballvec(rcti *rect, int mx, int my, float vec[3])
+static void calctrackballvec(const rcti *rect, int mx, int my, float vec[3])
{
float x, y, radius, d, z, t;
radius = TRACKBALLSIZE;
/* normalize x and y */
- x = BLI_RCT_CENTER_X(rect) - mx;
- x /= (float)(BLI_RCT_SIZE_X(rect) / 4);
- y = BLI_RCT_CENTER_Y(rect) - my;
- y /= (float)(BLI_RCT_SIZE_Y(rect) / 2);
+ x = BLI_rcti_cent_x(rect) - mx;
+ x /= (float)(BLI_rcti_size_x(rect) / 4);
+ y = BLI_rcti_cent_y(rect) - my;
+ y /= (float)(BLI_rcti_size_y(rect) / 2);
d = sqrt(x * x + y * y);
if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */
@@ -1637,7 +1637,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 - delta;
+ vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? delta : -delta);
CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
}
@@ -1666,8 +1666,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
int ctr[2], len1, len2;
/* method which zooms based on how far you move the mouse */
- ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct);
- ctr[1] = BLI_RCT_CENTER_Y(&vod->ar->winrct);
+ ctr[0] = BLI_rcti_cent_x(&vod->ar->winrct);
+ ctr[1] = BLI_rcti_cent_y(&vod->ar->winrct);
len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5;
len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5;
@@ -2619,10 +2619,10 @@ static int render_border_exec(bContext *C, wmOperator *op)
/* calculate range */
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
- scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb);
- scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
- scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb);
- scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
+ 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);
/* actually set border */
CLAMP(scene->r.border.xmin, 0.0f, 1.0f);
@@ -2786,8 +2786,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
}
/* work out the ratios, so that everything selected fits when we zoom */
- xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]);
- yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]);
+ xscale = (BLI_rcti_size_x(&rect) / vb[0]);
+ yscale = (BLI_rcti_size_y(&rect) / vb[1]);
new_dist *= maxf(xscale, yscale);
/* zoom in as required, or as far as we can go */
@@ -3465,7 +3465,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op)
view3d_set_viewcontext(C, &vc);
view3d_get_transformation(vc.ar, vc.rv3d, NULL, &mats); /* NULL because we don't want it in object space */
- ED_view3d_calc_clipping(rv3d->clipbb, rv3d->clip, &mats, &rect);
+ ED_view3d_clipping_calc(rv3d->clipbb, rv3d->clip, &mats, &rect);
return OPERATOR_FINISHED;
}
@@ -3529,7 +3529,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
// if (obedit && ctrl) lr_click= 1;
copy_v3_v3(oldcurs, fp);
- project_int_noclip(ar, fp, mval);
+ ED_view3d_project_int_noclip(ar, fp, mval);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
/* reset the depth based on the view offset */
@@ -3537,7 +3537,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
negate_v3_v3(fp, rv3d->ofs);
/* re initialize */
- project_int_noclip(ar, fp, mval);
+ ED_view3d_project_int_noclip(ar, fp, mval);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
(void)flip;
}
@@ -3837,10 +3837,12 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m
}
/**
- * Gets the view transformation from a camera
- * currently dosnt take camzoom into account
+ * Set the view transformation from a 4x4 matrix.
*
- * The dist is not modified for this function, if NULL its assumed zero
+ * \param mat The view 4x4 transformation matrix to assign.
+ * \param ofs The view offset, normally from RegionView3D.ofs.
+ * \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
+ * \param dist The view distance from ofs, normally from RegionView3D.dist.
*/
void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist)
{
@@ -3871,6 +3873,14 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist)
}
}
+/**
+ * Calculate the view transformation matrix from RegionView3D input.
+ * The resulting matrix is equivalent to RegionView3D.viewinv
+ * \param mat The view 4x4 transformation matrix to calculate.
+ * \param ofs The view offset, normally from RegionView3D.ofs.
+ * \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
+ * \param dist The view distance from ofs, normally from RegionView3D.dist.
+ */
void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist)
{
float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]};
@@ -3881,8 +3891,14 @@ void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], co
sub_v3_v3v3(mat[3], dvec, ofs);
}
-
-/* object -> view */
+/**
+ * Set the RegionView3D members from an objects transformation and optionally lens.
+ * \param ob The object to set the view to.
+ * \param ofs The view offset to be set, normally from RegionView3D.ofs.
+ * \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat.
+ * \param dist The view distance from ofs to be set, normally from RegionView3D.dist.
+ * \param lens The view lens angle set for cameras and lamps, normally from View3D.lens.
+ */
void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
{
ED_view3d_from_m4(ob->obmat, ofs, quat, dist);
@@ -3896,7 +3912,13 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist,
}
}
-/* view -> object */
+/**
+ * Set the object transformation from RegionView3D members.
+ * \param ob The object which has the transformation assigned.
+ * \param ofs The view offset, normally from RegionView3D.ofs.
+ * \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
+ * \param dist The view distance from ofs, normally from RegionView3D.dist.
+ */
void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist)
{
float mat[4][4];
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 855771b17a2..c743b88e889 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -346,7 +346,6 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event
/* check for flying ortho camera - which we cant support well
* we _could_ also check for an ortho camera but this is easier */
if ((fly->rv3d->persp == RV3D_CAMOB) &&
- (fly->v3d->camera != NULL) &&
(fly->rv3d->is_persp == FALSE))
{
((Camera *)fly->v3d->camera->data)->type = CAM_PERSP;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index fd43333acfe..b2ae63df662 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -84,25 +84,10 @@
* This can be cleaned when I make some new 'mode' icons.
*/
-/* view3d handler codes */
-#define VIEW3D_HANDLER_BACKGROUND 1
-#define VIEW3D_HANDLER_PROPERTIES 2
-#define VIEW3D_HANDLER_OBJECT 3
-#define VIEW3D_HANDLER_PREVIEW 4
-#define VIEW3D_HANDLER_MULTIRES 5
-#define VIEW3D_HANDLER_TRANSFORM 6
-#define VIEW3D_HANDLER_GREASEPENCIL 7
-#define VIEW3D_HANDLER_BONESKETCH 8
-
/* end XXX ************* */
static void do_view3d_header_buttons(bContext *C, void *arg, int event);
-#define B_SCENELOCK 101
-#define B_FULL 102
-#define B_HOME 103
-#define B_VIEWBUT 104
-#define B_PERSP 105
#define B_MODESELECT 108
#define B_SEL_VERT 110
#define B_SEL_EDGE 111
@@ -110,10 +95,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event);
#define B_MAN_TRANS 116
#define B_MAN_ROT 117
#define B_MAN_SCALE 118
-#define B_NDOF 119
#define B_MAN_MODE 120
-#define B_REDR 122
-#define B_NOP 123
/* XXX quickly ported across */
static void handle_view3d_lock(bContext *C)
@@ -346,10 +328,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
/* watch it: if sa->win does not exist, check that when calling direct drawing routines */
switch (event) {
- case B_REDR:
- ED_area_tag_redraw(sa);
- break;
-
case B_MODESELECT:
WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
@@ -416,9 +394,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
}
ED_area_tag_redraw(sa);
break;
- case B_NDOF:
- ED_area_tag_redraw(sa);
- break;
case B_MAN_MODE:
ED_area_tag_redraw(sa);
break;
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 5712144caf1..e409ad4e81e 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -114,7 +114,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
mval_cpy[0] = mval[0];
mval_cpy[1] = mval[1];
- project_int_noclip(vc->ar, fp, mval_cpy);
+ ED_view3d_project_int_noclip(vc->ar, fp, mval_cpy);
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
@@ -319,11 +319,6 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2)
return 1;
}
-
-#define MOVES_GESTURE 50
-#define MOVES_LASSO 500
-
-
/* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN)
* and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK
*/
@@ -339,9 +334,9 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
- project_int(vc->ar, vec, sco1);
+ ED_view3d_project_int(vc->ar, vec, sco1);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
- project_int(vc->ar, vec, sco2);
+ ED_view3d_project_int(vc->ar, vec, sco2);
if (BLI_lasso_is_edge_inside(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1], IS_CLIPPED)) {
if (select) pchan->bone->flag |= BONE_SELECTED;
@@ -376,7 +371,7 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move
for (base = vc->scene->base.first; base; base = base->next) {
if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */
- project_short(vc->ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(vc->ar, base->object->obmat[3], &base->sx);
if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) {
if (select) ED_base_object_select(base, BA_SELECT);
@@ -583,9 +578,9 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head);
- project_short(vc->ar, vec, sco1);
+ ED_view3d_project_short(vc->ar, vec, sco1);
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail);
- project_short(vc->ar, vec, sco2);
+ ED_view3d_project_short(vc->ar, vec, sco2);
didpoint = 0;
if (BLI_lasso_is_point_inside(mcords, moves, sco1[0], sco1[1], IS_CLIPPED)) {
@@ -637,7 +632,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves,
for (ml = mb->editelems->first; ml; ml = ml->next) {
mul_v3_m4v3(vec, vc->obedit->obmat, &ml->x);
- project_short(vc->ar, vec, sco);
+ ED_view3d_project_short(vc->ar, vec, sco);
if (BLI_lasso_is_point_inside(mcords, moves, sco[0], sco[1], IS_CLIPPED)) {
if (select) ml->flag |= SELECT;
@@ -646,7 +641,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves,
}
}
-int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
+static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
{
Mesh *me;
MVert *mvert;
@@ -654,8 +649,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
int a, index;
char *selar;
- int sx = BLI_RCT_SIZE_X(rect) + 1;
- int sy = BLI_RCT_SIZE_Y(rect) + 1;
+ int sx = BLI_rcti_size_x(rect) + 1;
+ int sy = BLI_rcti_size_y(rect) + 1;
me = vc->obact->data;
@@ -1065,7 +1060,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
else {
int temp, dist = 15;
- project_short(vc->ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(vc->ar, base->object->obmat[3], &base->sx);
temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]);
if (temp < dist)
@@ -1346,7 +1341,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
base = startbase;
while (base) {
if (BASE_SELECTABLE(v3d, base)) {
- project_short(ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(ar, base->object->obmat[3], &base->sx);
temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]);
if (base == BASACT) temp += 10;
@@ -2383,11 +2378,11 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f
/* project head location to screenspace */
mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_head);
- project_short(vc->ar, vec, sco1);
+ ED_view3d_project_short(vc->ar, vec, sco1);
/* project tail location to screenspace */
mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_tail);
- project_short(vc->ar, vec, sco2);
+ ED_view3d_project_short(vc->ar, vec, sco2);
/* check if the head and/or tail is in the circle
* - the call to check also does the selection already
@@ -2451,11 +2446,11 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2
/* project head location to screenspace */
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head);
- project_short(vc->ar, vec, sco1);
+ ED_view3d_project_short(vc->ar, vec, sco1);
/* project tail location to screenspace */
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail);
- project_short(vc->ar, vec, sco2);
+ ED_view3d_project_short(vc->ar, vec, sco2);
/* check if the head and/or tail is in the circle
* - the call to check also does the selection already
@@ -2561,7 +2556,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
select = select ? BA_SELECT : BA_DESELECT;
for (base = FIRSTBASE; base; base = base->next) {
if (BASE_SELECTABLE(v3d, base)) {
- project_short(ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(ar, base->object->obmat[3], &base->sx);
if (base->sx != IS_CLIPPED) {
int dx = base->sx - x;
int dy = base->sy - y;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index c25bb80bfde..ff518e6ce5b 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -520,7 +520,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
/* ********************************** */
-void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
+void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
{
float modelview[4][4];
double xs, ys, p[3];
@@ -569,7 +569,18 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co
}
}
-/* create intersection coordinates in view Z direction at mouse coordinates */
+/**
+ * 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;
@@ -604,7 +615,17 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2]
}
}
-/* create intersection ray in view Z direction at mouse coordinates */
+/**
+ * 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];
@@ -614,6 +635,13 @@ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float r
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) {
@@ -660,6 +688,13 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z)
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;
@@ -690,8 +725,14 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[
}
}
-/* always call initgrabz */
-/* only to detect delta motion */
+/**
+ * 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;
@@ -705,9 +746,19 @@ void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3])
out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy);
}
-/* doesn't rely on initgrabz */
-/* for perspective view, get the vector direction to
- * the mouse cursor as a normalized vector */
+/**
+ * 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;
@@ -754,7 +805,7 @@ void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][
/* Uses window coordinates (x,y) and depth component z to find a point in
* modelspace */
-void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, const float z)
+void ED_view3d_unproject(bglMats *mats, float out[3], const float x, const float y, const float z)
{
double ux, uy, uz;
@@ -766,44 +817,44 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y,
out[2] = uz;
}
-/* use view3d_get_object_project_mat to get projecting mat */
-void ED_view3d_project_float_v2(const ARegion *ar, const float vec[3], float adr[2], float mat[4][4])
+/* 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, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- /* adr[0]= IS_CLIPPED; */ /* always overwritten */
+ /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
mul_m4_v4(mat, vec4);
if (vec4[3] > FLT_EPSILON) {
- adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ 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 {
- adr[0] = adr[1] = 0.0f;
+ zero_v2(r_co);
}
}
-/* use view3d_get_object_project_mat to get projecting mat */
-void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float adr[3], float mat[4][4])
+/* 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;
- /* adr[0]= IS_CLIPPED; */ /* always overwritten */
+ /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
mul_m4_v4(mat, vec4);
if (vec4[3] > FLT_EPSILON) {
- adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
- adr[2] = vec4[2] / vec4[3];
+ 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(adr);
+ zero_v3(r_co);
}
}
@@ -842,24 +893,24 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
return 0;
}
-void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */
+void ED_view3d_project_short(ARegion *ar, const float co[3], short r_co[2]) /* clips */
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- adr[0] = IS_CLIPPED;
+ r_co[0] = IS_CLIPPED;
if (rv3d->rflag & RV3D_CLIPPING) {
- if (ED_view3d_clipping_test(rv3d, vec, FALSE)) {
+ if (ED_view3d_clipping_test(rv3d, co, FALSE)) {
return;
}
}
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
mul_m4_v4(rv3d->persmat, vec4);
- if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
if (fx > 0 && fx < ar->winx) {
@@ -867,44 +918,44 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
if (fy > 0.0f && fy < (float)ar->winy) {
- adr[0] = (short)floor(fx);
- adr[1] = (short)floor(fy);
+ r_co[0] = (short)floor(fx);
+ r_co[1] = (short)floor(fy);
}
}
}
}
-void project_int(ARegion *ar, const float vec[3], int adr[2])
+void ED_view3d_project_int(ARegion *ar, const float co[3], int r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- adr[0] = (int)2140000000.0f;
+ r_co[0] = (int)2140000000.0f;
mul_m4_v4(rv3d->persmat, vec4);
- if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
if (fx > -2140000000.0f && fx < 2140000000.0f) {
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
if (fy > -2140000000.0f && fy < 2140000000.0f) {
- adr[0] = (int)floor(fx);
- adr[1] = (int)floor(fy);
+ r_co[0] = (int)floor(fx);
+ r_co[1] = (int)floor(fy);
}
}
}
}
-void project_int_noclip(ARegion *ar, const float vec[3], int adr[2])
+void ED_view3d_project_int_noclip(ARegion *ar, const float co[3], int r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
mul_m4_v4(rv3d->persmat, vec4);
@@ -913,27 +964,27 @@ void project_int_noclip(ARegion *ar, const float vec[3], int adr[2])
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
- adr[0] = (int)floor(fx);
- adr[1] = (int)floor(fy);
+ r_co[0] = (int)floor(fx);
+ r_co[1] = (int)floor(fy);
}
else {
- adr[0] = ar->winx / 2;
- adr[1] = ar->winy / 2;
+ r_co[0] = ar->winx / 2;
+ r_co[1] = ar->winy / 2;
}
}
-void project_short_noclip(ARegion *ar, const float vec[3], short adr[2])
+void ED_view3d_project_short_noclip(ARegion *ar, const float co[3], short r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- adr[0] = IS_CLIPPED;
+ r_co[0] = IS_CLIPPED;
mul_m4_v4(rv3d->persmat, vec4);
- if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
if (fx > -32700 && fx < 32700) {
@@ -941,53 +992,48 @@ void project_short_noclip(ARegion *ar, const float vec[3], short adr[2])
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
if (fy > -32700.0f && fy < 32700.0f) {
- adr[0] = (short)floor(fx);
- adr[1] = (short)floor(fy);
+ r_co[0] = (short)floor(fx);
+ r_co[1] = (short)floor(fy);
}
}
}
}
-void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[3], float adr[2])
+void ED_view3d_project_float(ARegion *ar, const float co[3], float r_co[2])
{
+ RegionView3D *rv3d = ar->regiondata;
+
float vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- adr[0] = IS_CLIPPED;
+ r_co[0] = IS_CLIPPED;
- mul_m4_v4(persmat, vec4);
+ mul_m4_v4(rv3d->persmat, vec4);
if (vec4[3] > (float)BL_NEAR_CLIP) {
- adr[0] = (float)(winx / 2.0f) + (winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(winy / 2.0f) + (winy / 2.0f) * vec4[1] / vec4[3];
+ 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];
}
}
-void project_float(ARegion *ar, const float vec[3], float adr[2])
-{
- RegionView3D *rv3d = ar->regiondata;
-
- apply_project_float(rv3d->persmat, ar->winx, ar->winy, vec, adr);
-}
-
-void project_float_noclip(ARegion *ar, const float vec[3], float adr[2])
+void ED_view3d_project_float_noclip(ARegion *ar, const float co[3], float r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
mul_m4_v4(rv3d->persmat, vec4);
if (fabs(vec4[3]) > BL_NEAR_CLIP) {
- adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ 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 {
- adr[0] = ar->winx / 2.0f;
- adr[1] = ar->winy / 2.0f;
+ r_co[0] = ar->winx / 2.0f;
+ r_co[1] = ar->winy / 2.0f;
}
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index dccd0c27234..ee5d50c7aba 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -126,11 +126,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
{
float divx, divy;
- divx = BLI_RCT_SIZE_X(&v2d->mask);
- divy = BLI_RCT_SIZE_Y(&v2d->mask);
+ divx = BLI_rcti_size_x(&v2d->mask);
+ divy = BLI_rcti_size_y(&v2d->mask);
- r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx;
- r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy;
+ r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx;
+ r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy;
r_vec[2] = 0.0f;
}
@@ -139,11 +139,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
float divx, divy;
float mulx, muly;
- divx = BLI_RCT_SIZE_X(&v2d->mask);
- divy = BLI_RCT_SIZE_Y(&v2d->mask);
+ divx = BLI_rcti_size_x(&v2d->mask);
+ divy = BLI_rcti_size_y(&v2d->mask);
- mulx = BLI_RCT_SIZE_X(&v2d->cur);
- muly = BLI_RCT_SIZE_Y(&v2d->cur);
+ mulx = BLI_rctf_size_x(&v2d->cur);
+ muly = BLI_rctf_size_y(&v2d->cur);
/* difference with convertViewVec2D */
/* clamp w/h, mask only */
@@ -226,7 +226,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
if (t->spacetype == SPACE_VIEW3D) {
if (t->ar->regiontype == RGN_TYPE_WINDOW)
- project_int_noclip(t->ar, vec, adr);
+ ED_view3d_project_int_noclip(t->ar, vec, adr);
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->sa->spacedata.first;
@@ -344,7 +344,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
case SPACE_VIEW3D:
{
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- project_float_noclip(t->ar, vec, adr);
+ ED_view3d_project_float_noclip(t->ar, vec, adr);
return;
}
break;
@@ -2195,7 +2195,6 @@ static void constraintTransLim(TransInfo *t, TransData *td)
for (con = td->con; con; con = con->next) {
bConstraintTypeInfo *cti = NULL;
ListBase targets = {NULL, NULL};
- float tmat[4][4];
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
@@ -2221,8 +2220,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
/* skip... incompatable spacetype */
@@ -2237,9 +2235,8 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
/* free targets list */
@@ -2287,18 +2284,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
bConstraintOb cob;
bConstraint *con;
int do_limit = FALSE;
-
+
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data = con->data;
- float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
if ((data->flag2 & LIMIT_TRANSFORM) == 0)
continue;
@@ -2312,12 +2308,11 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
constraintob_from_transdata(&cob, td);
do_limit = TRUE;
}
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
/* do constraint */
@@ -2325,9 +2320,8 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
}
}
@@ -2382,7 +2376,6 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data = con->data;
- float tmat[4][4];
/* only use it if it's tagged for this purpose */
if ((data->flag2 & LIMIT_TRANSFORM) == 0)
@@ -2391,11 +2384,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
- /* skip... incompatable spacetype */
+ /* skip... incompatible spacetype */
continue;
}
@@ -2404,13 +2396,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
}
}
-
+
/* copy results from cob->matrix */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
@@ -2420,7 +2411,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
mat4_to_size(td->ext->size, cob.matrix);
}
}
@@ -2852,11 +2843,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) {
float obsizemat[3][3];
- // Reorient the size mat to fit the oriented object.
+ /* Reorient the size mat to fit the oriented object. */
mul_m3_m3m3(obsizemat, tmat, td->axismtx);
- //print_m3("obsizemat", obsizemat);
+ /* print_m3("obsizemat", obsizemat); */
TransMat3ToSize(obsizemat, td->axismtx, fsize);
- //print_v3("fsize", fsize);
+ /* print_v3("fsize", fsize); */
}
else {
mat3_to_size(fsize, tmat);
@@ -2864,7 +2855,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
protectedSizeBits(td->protectflag, fsize);
- if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't resize objects itself
+ if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't resize objects itself */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
*td->val = td->ival * (1 + (fsize[0] - 1) * td->factor);
@@ -4100,9 +4091,9 @@ void initMaskShrinkFatten(TransInfo *t)
int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
+ TransData *td;
float ratio;
- int i;
+ int i, initial_feather = FALSE;
char str[50];
ratio = t->values[0];
@@ -4116,13 +4107,30 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
- sprintf(str, "Shrink/Fatten: %s", c);
+ sprintf(str, "Feather Shrink/Fatten: %s", c);
}
else {
- sprintf(str, "Shrink/Fatten: %3f", ratio);
+ sprintf(str, "Feather Shrink/Fatten: %3f", ratio);
}
- for (i = 0; i < t->total; i++, td++) {
+ /* detect if no points have feather yet */
+ if (ratio > 1.0f) {
+ initial_feather = TRUE;
+
+ for (td = t->data, i = 0; i < t->total; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if (td->ival >= 0.001f)
+ initial_feather = FALSE;
+ }
+ }
+
+ /* apply shrink/fatten */
+ for (td = t->data, i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4130,7 +4138,11 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
continue;
if (td->val) {
- *td->val = td->ival * ratio;
+ if (initial_feather)
+ *td->val = td->ival + (ratio - 1.0f) * 0.01f;
+ else
+ *td->val = td->ival * ratio;
+
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
if (*td->val <= 0.0f) *td->val = 0.001f;
@@ -4774,7 +4786,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo
sv->edge_len = len_v3v3(dw_p, up_p);
mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co);
- project_float_noclip(t->ar, v_proj, v_proj);
+ ED_view3d_project_float_noclip(t->ar, v_proj, v_proj);
dist = len_squared_v2v2(mval, v_proj);
if (dist < min_dist) {
@@ -5040,19 +5052,19 @@ static int createSlideVerts(TransInfo *t)
j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v));
if (sv_array[j].down) {
- ED_view3d_project_float_v3(ar, sv_array[j].down->co, vec1, projectMat);
+ ED_view3d_project_float_v3_m4(ar, sv_array[j].down->co, vec1, projectMat);
}
else {
add_v3_v3v3(vec1, v->co, sv_array[j].downvec);
- ED_view3d_project_float_v3(ar, vec1, vec1, projectMat);
+ ED_view3d_project_float_v3_m4(ar, vec1, vec1, projectMat);
}
if (sv_array[j].up) {
- ED_view3d_project_float_v3(ar, sv_array[j].up->co, vec2, projectMat);
+ ED_view3d_project_float_v3_m4(ar, sv_array[j].up->co, vec2, projectMat);
}
else {
add_v3_v3v3(vec2, v->co, sv_array[j].upvec);
- ED_view3d_project_float_v3(ar, vec2, vec2, projectMat);
+ ED_view3d_project_float_v3_m4(ar, vec2, vec2, projectMat);
}
/* global direction */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 181f9fe6036..022e9177a4a 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1773,9 +1773,6 @@ void flushTransParticles(TransInfo *t)
/* ********************* mesh ****************** */
-/* proportional distance based on connectivity */
-#define THRESHOLDFACTOR (1.0f - 0.0001f)
-
/* I did this wrong, it should be a breadth-first search
* but instead it's a depth-first search, fudged
* to report shortest distances. I have no idea how fast
@@ -5170,7 +5167,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Depending on the lock status, draw necessary views */
// fixme... some of this stuff is not good
if (ob) {
- if (ob->pose || ob_get_key(ob))
+ if (ob->pose || BKE_key_from_object(ob))
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
else
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
@@ -5554,8 +5551,8 @@ static void createTransObject(bContext *C, TransInfo *t)
static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
{
/* hold original location */
- float locxy[2] = {BLI_RCT_CENTER_X(&node->totr),
- BLI_RCT_CENTER_Y(&node->totr)};
+ float locxy[2] = {BLI_rctf_cent_x(&node->totr),
+ BLI_rctf_cent_y(&node->totr)};
copy_v2_v2(td2d->loc, locxy);
td2d->loc[2] = 0.0f;
@@ -5722,10 +5719,9 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra
unit_m3(td->smtx);
}
-static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
+static void trackToTransData(const int framenr, TransData *td, TransData2D *td2d,
TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy)
{
- int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
tdt->flag = marker->flag;
@@ -5777,7 +5773,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
MovieClip *clip = ED_space_clip_get_clip(sc);
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
- MovieTrackingMarker *marker;
TransDataTracking *tdt;
int framenr = ED_space_clip_get_clip_frame_number(sc);
float aspx, aspy;
@@ -5788,8 +5783,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_marker_get(track, framenr);
-
t->total++; /* offset */
if (track->flag & SELECT)
@@ -5820,9 +5813,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_marker_get(track, framenr);
-
- trackToTransData(sc, td, td2d, tdt, track, aspx, aspy);
+ trackToTransData(framenr, td, td2d, tdt, track, aspx, aspy);
/* offset */
td++;
@@ -5845,12 +5836,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
td += 2;
td2d += 2;
tdt += 2;
-
- if (marker->flag & MARKER_DISABLED) {
- td += 3;
- td2d += 3;
- tdt += 3;
- };
}
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index b88ae68e00b..1d75be05534 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -315,7 +315,7 @@ void applyProject(TransInfo *t)
copy_v3_v3(iloc, td->ob->obmat[3]);
}
- project_float(t->ar, iloc, mval);
+ ED_view3d_project_float(t->ar, iloc, mval);
if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) {
// if (t->flag & (T_EDIT|T_POSE)) {
@@ -601,7 +601,7 @@ int updateSelectedSnapPoint(TransInfo *t)
int dx, dy;
int dist;
- project_int(t->ar, p->co, screen_loc);
+ ED_view3d_project_int(t->ar, p->co, screen_loc);
dx = t->mval[0] - screen_loc[0];
dy = t->mval[1] - screen_loc[1];
@@ -960,8 +960,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
if (t->spacetype == SPACE_NODE && td != NULL) {
bNode *node = td->extra;
char border = t->tsnap.snapNodeBorder;
- float width = BLI_RCT_SIZE_X(&node->totr);
- float height = BLI_RCT_SIZE_Y(&node->totr);
+ float width = BLI_rctf_size_x(&node->totr);
+ float height = BLI_rctf_size_y(&node->totr);
if (border & NODE_LEFT)
t->tsnap.snapTarget[0] -= 0.5f * width;
@@ -1164,7 +1164,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ 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) {
@@ -1232,7 +1232,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
/* 10% threshold if edge is closer but a bit further
@@ -1289,7 +1289,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ 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 <= *r_dist && new_depth < *r_depth) {
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 5008c35e46a..06da1c8bfea 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2836,7 +2836,7 @@ static int uv_lasso_select_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
}
-void UV_OT_select_lasso(wmOperatorType *ot)
+static void UV_OT_select_lasso(wmOperatorType *ot)
{
ot->name = "Lasso Select UV";
ot->description = "Select UVs using lasso selection";
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index c95b2e85248..7c06fbd2a9d 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -242,7 +242,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
key = (ParamKey)efa;
- tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+ // tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); // UNUSED
if (efa->len == 3 || efa->len == 4) {
/* for quads let parametrize split, it can make better decisions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index a342fed27e3..321dd5fe41f 100755
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -203,7 +203,8 @@ namespace StrokeShaders {
ifstream ifs(j->c_str());
if (ifs.is_open()) {
//soc image.load(j->c_str());
- image = IMB_loadiffname(j->c_str(), 0);
+ /* OCIO_TODO: support different input color space */
+ image = IMB_loadiffname(j->c_str(), 0, NULL);
break;
}
}
@@ -350,7 +351,8 @@ namespace StrokeShaders {
for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); j++) {
ifstream ifs(j->c_str());
if (ifs.is_open()) {
- image = IMB_loadiffname(j->c_str(), 0); //soc
+ /* OCIO_TODO: support different input color space */
+ image = IMB_loadiffname(j->c_str(), 0, NULL); //soc
break;
}
}
diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp
index d67f05ddb92..f2cfe6a855f 100755
--- a/source/blender/freestyle/intern/stroke/Canvas.cpp
+++ b/source/blender/freestyle/intern/stroke/Canvas.cpp
@@ -333,7 +333,8 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i
// return;
// }
// qimg = &newMap;
- ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0);;
+ /* OCIO_TODO: support different input color space */
+ ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0, NULL);
if( qimg == 0 ){
cout << "Could not load image file " << filePath << endl;
return;
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 1729ac06f5a..745ca1ef2ac 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -162,8 +162,9 @@ 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, struct MFace *mface, int *face_indices, int totface,
+ struct MVert *mvert, int *vert_indices, int totvert,
+ int (*face_vert_indices)[4], const float *vmask);
GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
unsigned int **grid_hidden, int gridsize);
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 467adbe10b8..7d829bd57bf 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);
@@ -119,7 +121,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap);
/* Image updates and free
* - these deal with images bound as opengl textures */
-void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int 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);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index c44a181841e..930573ec750 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -54,6 +54,7 @@
#include "DNA_userdef_types.h"
#include "GPU_buffers.h"
+#include "GPU_draw.h"
typedef enum {
GPU_BUFFER_VERTEX_STATE = 1,
@@ -1280,6 +1281,8 @@ typedef struct {
char pad[2];
unsigned char color[3];
+ float accum_color[3];
+ int tot_color;
} VertexBufferFormat;
struct GPU_Buffers {
@@ -1327,24 +1330,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;
}
-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])
{
float color = gpu_color_from_mask(mask);
- glColor3f(color, color, color);
+ glColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color);
}
static float gpu_color_from_mask_quad(const CCGKey *key,
@@ -1360,29 +1363,32 @@ 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])
{
float color = gpu_color_from_mask_quad(key, a, b, c, d);
- glColor3f(color, color, color);
+ glColor3f(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)
+void GPU_update_mesh_buffers(GPU_Buffers *buffers, MFace *mface, int *face_indices, int totface,
+ MVert *mvert, int *vert_indices, int totvert,
+ int (*face_vert_indices)[4], const float *vmask)
{
VertexBufferFormat *vert_data;
int i;
@@ -1404,8 +1410,40 @@ 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);
- gpu_color_from_mask_copy(vmask[vert_indices[i]],
- out->color);
+ zero_v3(out->accum_color);
+ out->tot_color = 0;
+ }
+
+#define UPDATE_VERTEX(face, vertex, index, diffuse_color) \
+ { \
+ VertexBufferFormat *out = vert_data + face_vert_indices[face][index]; \
+ add_v3_v3(out->accum_color, diffuse_color); \
+ out->tot_color++; \
+ } (void)0
+
+ for (i = 0; i < totface; ++i) {
+ MFace *f = mface + face_indices[i];
+ float diffuse_color[4];
+
+ GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+
+ 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
+
+ for (i = 0; i < totvert; ++i) {
+ VertexBufferFormat *out = vert_data + i;
+ if (out->tot_color) {
+ float diffuse_color[4];
+
+ mul_v3_v3fl(diffuse_color, out->accum_color, 1.0f / out->tot_color);
+
+ gpu_color_from_mask_copy(vmask[vert_indices[i]], diffuse_color, out->color);
+ }
}
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
@@ -1517,6 +1555,10 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
for (i = 0; i < totgrid; ++i) {
VertexBufferFormat *vd = vert_data;
CCGElem *grid = grids[grid_indices[i]];
+ const DMFlagMat *flags = &grid_flag_mats[grid_indices[i]];
+ float diffuse_color[4];
+
+ GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
for (y = 0; y < key->grid_size; y++) {
for (x = 0; x < key->grid_size; x++) {
@@ -1524,11 +1566,9 @@ 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));
- gpu_color_from_mask_copy(*CCG_elem_mask(key, elem),
- vd->color);
+ gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), diffuse_color, vd->color);
}
vd++;
}
@@ -1561,6 +1601,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
elems[1],
elems[2],
elems[3],
+ diffuse_color,
vd->color);
}
}
@@ -1769,6 +1810,9 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
{
const MVert *mvert = buffers->mvert;
int i, j;
+ float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
+
+ glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse_color);
gpu_colors_enable(VBO_DISABLED);
@@ -1784,7 +1828,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
if (smooth) {
for (j = 0; j < S; j++) {
- gpu_color_from_mask_set(buffers->vmask[fv[j]]);
+ gpu_color_from_mask_set(buffers->vmask[fv[j]], diffuse_color);
glNormal3sv(mvert[fv[j]].no);
glVertex3fv(mvert[fv[j]].co);
}
@@ -1809,7 +1853,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
fmask = (fmask + buffers->vmask[fv[3]]) * 0.25;
else
fmask /= 3.0f;
- gpu_color_from_mask_set(fmask);
+ gpu_color_from_mask_set(fmask, diffuse_color);
for (j = 0; j < S; j++)
glVertex3fv(mvert[fv[j]].co);
@@ -1825,6 +1869,9 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
{
const CCGKey *key = &buffers->gridkey;
int i, j, x, y, gridsize = buffers->gridkey.grid_size;
+ float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
+
+ glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse_color);
gpu_colors_enable(VBO_DISABLED);
@@ -1853,7 +1900,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
if (smooth) {
for (j = 0; j < 4; j++) {
- gpu_color_from_mask_set(*CCG_elem_mask(key, e[j]));
+ gpu_color_from_mask_set(*CCG_elem_mask(key, e[j]), diffuse_color);
glNormal3fv(CCG_elem_no(key, e[j]));
glVertex3fv(CCG_elem_co(key, e[j]));
}
@@ -1866,7 +1913,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
CCG_elem_co(key, e[2]),
CCG_elem_co(key, e[3]));
glNormal3fv(fno);
- 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++)
glVertex3fv(CCG_elem_co(key, e[j]));
@@ -1883,10 +1930,10 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
CCGElem *a = CCG_grid_elem(key, grid, x, y);
CCGElem *b = CCG_grid_elem(key, grid, x, y + 1);
- gpu_color_from_mask_set(*CCG_elem_mask(key, a));
+ gpu_color_from_mask_set(*CCG_elem_mask(key, a), diffuse_color);
glNormal3fv(CCG_elem_no(key, a));
glVertex3fv(CCG_elem_co(key, a));
- gpu_color_from_mask_set(*CCG_elem_mask(key, b));
+ gpu_color_from_mask_set(*CCG_elem_mask(key, b), diffuse_color);
glNormal3fv(CCG_elem_no(key, b));
glVertex3fv(CCG_elem_co(key, b));
}
@@ -1912,7 +1959,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
CCG_elem_co(key, c));
glNormal3fv(fno);
- gpu_color_from_mask_quad_set(key, a, b, c, d);
+ gpu_color_from_mask_quad_set(key, a, b, c, d, diffuse_color);
}
glVertex3fv(CCG_elem_co(key, a));
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 4314a784511..60e3c19a419 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -492,7 +492,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 && ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ if (!ncd)
do_color_management = TRUE;
if (ibuf->rect==NULL)
@@ -535,7 +535,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
if (do_color_management) {
srgb_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor");
IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float,
- ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0,
+ ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, 0,
ibuf->x, ibuf->y, ibuf->x, ibuf->x);
/* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */
IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y);
@@ -560,7 +560,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
if (do_color_management) {
frect = srgb_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(*srgb_frect)*4, "floar_buf_col_cor");
IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float,
- ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0,
+ ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, 0,
ibuf->x, ibuf->y, ibuf->x, ibuf->x);
/* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */
IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y);
@@ -709,7 +709,7 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float * frect, int
*/
int GPU_upload_dxt_texture(ImBuf *ibuf)
{
-#if WITH_DDS
+#ifdef WITH_DDS
GLint format = 0;
int blocksize, height, width, i, size, offset = 0;
@@ -878,13 +878,13 @@ void GPU_paint_set_mipmap(int mipmap)
}
}
-void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
+void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
{
ImBuf *ibuf;
ibuf = BKE_image_get_ibuf(ima, NULL);
- if (ima->repbind || (GPU_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
+ if (ima->repbind || (GPU_get_mipmap() && !GTS.gpu_mipmap) || !ima->bindcode || !ibuf ||
(!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
(w == 0) || (h == 0))
{
@@ -901,7 +901,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows);
/* if color correction is needed, we must update the part that needs updating. */
- if (ibuf->rect_float && (!U.use_16bit_textures || (ibuf->profile == IB_PROFILE_LINEAR_RGB))) {
+ 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);
@@ -911,8 +911,14 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
MEM_freeN(buffer);
- if (ima->tpageflag & IMA_MIPMAP_COMPLETE)
+ /* we have already accounted for the case where GTS.gpu_mipmap is false
+ * so we will be using GPU mipmap generation here */
+ if (GPU_get_mipmap()) {
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
+ }
+ else {
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+ }
return;
}
@@ -934,8 +940,13 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
- if (ima->tpageflag & IMA_MIPMAP_COMPLETE)
+ /* see comment above as to why we are using gpu mipmap generation here */
+ if (GPU_get_mipmap()) {
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
+ }
+ else {
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+ }
}
}
@@ -1197,7 +1208,12 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
GPUMaterial *gpumat;
GPUBlendMode alphablend;
int a;
- int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+
+ /* OCIO_TODO: assume color management is always enabled. could be nice to support real display transform here,
+ * but that's not so important and could be done later
+ */
+ int gamma = TRUE;
+
int new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
/* initialize state */
@@ -1221,7 +1237,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
* - object transparency off: for glsl we draw both in a single pass, and
* for solid we don't use transparency at all. */
GMS.use_alpha_pass = (do_alpha_after != NULL);
- GMS.is_alpha_pass = (v3d && v3d->transp);
+ GMS.is_alpha_pass = (v3d->transp != FALSE);
if (GMS.use_alpha_pass)
*do_alpha_after = FALSE;
@@ -1424,6 +1440,21 @@ void GPU_disable_material(void)
GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
}
+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_material.c b/source/blender/gpu/intern/gpu_material.c
index 61be4057843..dd92b561235 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -389,8 +389,12 @@ void gpu_material_add_node(GPUMaterial *material, GPUNode *node)
int GPU_material_do_color_management(GPUMaterial *mat)
{
- return ((mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) &&
- !((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT)));
+ /* OCIO_TODO: for now assume scene always does color management. probably could be
+ * improved in the future to support real display transform
+ * also probably we'll need to get rid ofgame engine's color management flag
+ */
+
+ return !((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT));
}
static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **lv, GPUNodeLink **dist)
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index c5722995d32..d88f954345f 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -393,7 +393,7 @@ static bool constraint_valid(bConstraint *con)
return true;
}
-int initialize_scene(Object *ob, bPoseChannel *pchan_tip)
+static int initialize_scene(Object *ob, bPoseChannel *pchan_tip)
{
bConstraint *con;
int treecount;
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index aa4454562b4..bbe70a7d73f 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -30,6 +30,7 @@ set(INC
../blenlib
../blenloader
../makesdna
+ ../makesrna
../../../intern/guardedalloc
../../../intern/memutil
)
@@ -45,6 +46,7 @@ set(SRC
intern/anim_movie.c
intern/bmp.c
intern/cache.c
+ intern/colormanagement.c
intern/divers.c
intern/filetype.c
intern/filter.c
@@ -67,16 +69,19 @@ set(SRC
intern/util.c
intern/writeimage.c
+ IMB_colormanagement.h
IMB_imbuf.h
IMB_imbuf_types.h
IMB_moviecache.h
IMB_thumbs.h
intern/IMB_allocimbuf.h
intern/IMB_anim.h
+ intern/IMB_colormanagement_intern.h
intern/IMB_filetype.h
intern/IMB_filter.h
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
@@ -94,7 +99,6 @@ set(SRC
intern/dds/PixelFormat.h
intern/dds/Stream.h
intern/dds/dds_api.h
- intern/imbuf.h
intern/openexr/openexr_api.h
intern/openexr/openexr_multi.h
@@ -180,6 +184,10 @@ if(WITH_IMAGE_HDR)
add_definitions(-DWITH_HDR)
endif()
+list(APPEND INC
+ ../../../intern/opencolorio
+)
+
if(WIN32)
list(APPEND INC
../../../intern/utfconv
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
new file mode 100644
index 00000000000..5d0ab5e57d4
--- /dev/null
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -0,0 +1,156 @@
+/*
+ * ***** 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): Xavier Thomas,
+ * Lukas Toenne,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#ifndef IMB_COLORMANAGEMENT_H
+#define IMB_COLORMANAGEMENT_H
+
+#define BCM_CONFIG_FILE "config.ocio"
+
+struct bContext;
+struct ColorManagedColorspaceSettings;
+struct ColorManagedDisplaySettings;
+struct ColorManagedViewSettings;
+struct ColormanageProcessor;
+struct EnumPropertyItem;
+struct ImBuf;
+struct Main;
+struct rcti;
+struct PartialBufferUpdateContext;
+struct wmWindow;
+struct Scene;
+
+struct ColorSpace;
+struct ColorManagedDisplay;
+
+/* ** Initialization / De-initialization ** */
+
+void IMB_colormanagement_init(void);
+void IMB_colormanagement_exit(void);
+
+/* ** Generic functions ** */
+
+void IMB_colormanagement_check_file_config(struct Main *bmain);
+
+void IMB_colormanagement_validate_settings(struct ColorManagedDisplaySettings *display_settings,
+ struct ColorManagedViewSettings *view_settings);
+
+const char *IMB_colormanagement_role_colorspace_name_get(int role);
+void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name);
+
+/* ** Color space transformation functions ** */
+void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
+ const char *from_colorspace, const char *to_colorspace, int predivide);
+void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels,
+ const char *from_colorspace, const char *to_colorspace, int predivide);
+void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace);
+
+void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace);
+void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], struct ColorSpace *colorspace);
+
+void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide);
+
+void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], struct ColorManagedDisplay *display);
+void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display);
+
+void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4], const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
+void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
+void IMB_colormanagement_imbuf_assign_float_space(struct ImBuf *ibuf, struct ColorManagedColorspaceSettings *colorspace_settings);
+
+void IMB_colormanagement_imbuf_make_display_space(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
+/* ** Public display buffers interfaces ** */
+
+unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings, void **cache_handle);
+unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle);
+
+void IMB_display_buffer_to_imbuf_rect(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
+void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height,
+ int channels, const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings, int predivide);
+
+void IMB_display_buffer_release(void *cache_handle);
+
+/* ** Display funcrions ** */
+int IMB_colormanagement_display_get_named_index(const char *name);
+const char *IMB_colormanagement_display_get_indexed_name(int index);
+const char *IMB_colormanagement_display_get_default_name(void);
+struct ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name);
+
+/* ** View funcrions ** */
+int IMB_colormanagement_view_get_named_index(const char *name);
+const char *IMB_colormanagement_view_get_indexed_name(int index);
+
+/* ** Color space functions ** */
+int IMB_colormanagement_colorspace_get_named_index(const char *name);
+const char *IMB_colormanagement_colorspace_get_indexed_name(int index);
+const char *IMB_colormanagement_view_get_default_name(const char *display_name);
+
+void IMB_colormanagment_colorspace_from_ibuf_ftype(struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf);
+
+/* ** RNA helper functions ** */
+void IMB_colormanagement_display_items_add(struct EnumPropertyItem **items, int *totitem);
+void IMB_colormanagement_view_items_add(struct EnumPropertyItem **items, int *totitem, const char *display_name);
+void IMB_colormanagement_colorspace_items_add(struct EnumPropertyItem **items, int *totitem);
+
+/* ** Tile-based buffer management ** */
+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);
+
+/* ** Pixel processor functions ** */
+struct ColormanageProcessor *IMB_colormanagement_display_processor_new(const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+struct ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace);
+void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4]);
+void IMB_colormanagement_processor_apply_v3(struct ColormanageProcessor *cm_processor, float pixel[3]);
+void IMB_colormanagement_processor_apply(struct ColormanageProcessor *cm_processor, float *buffer, int width, int height,
+ int channels, int predivide);
+void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processor);
+
+/* Roles */
+enum {
+ COLOR_ROLE_SCENE_LINEAR = 0,
+ COLOR_ROLE_COLOR_PICKING,
+ COLOR_ROLE_TEXTURE_PAINTING,
+ COLOR_ROLE_DEFAULT_SEQUENCER,
+ COLOR_ROLE_DEFAULT_BYTE,
+ COLOR_ROLE_DEFAULT_FLOAT,
+};
+
+#endif /* IMB_COLORMANAGEMENT_H */
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index d23d42ddd0c..1503b9f6f67 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -70,6 +70,8 @@
#ifndef __IMB_IMBUF_H__
#define __IMB_IMBUF_H__
+#define IM_MAX_SPACE 64
+
/**
*
* \attention defined in ???
@@ -82,6 +84,8 @@ struct ImBuf;
*/
struct anim;
+struct ColorManagedDisplay;
+
/**
*
* \attention Defined in allocimbuf.c
@@ -93,20 +97,19 @@ void IMB_exit(void);
*
* \attention Defined in readimage.c
*/
-struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size,
- int flags, const char *descr);
+struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr);
/**
*
* \attention Defined in readimage.c
*/
-struct ImBuf *IMB_testiffname(const char *filepath, int flags);
+struct ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
/**
*
* \attention Defined in readimage.c
*/
-struct ImBuf *IMB_loadiffname(const char *filepath, int flags);
+struct ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
/**
*
@@ -245,7 +248,7 @@ int IMB_anim_get_fps(struct anim * anim,
*
* \attention Defined in anim_movie.c
*/
-struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex);
+struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]);
void IMB_close_anim(struct anim *anim);
void IMB_close_anim_proxies(struct anim *anim);
@@ -372,7 +375,6 @@ void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y
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 */
-void IMB_convert_profile(struct ImBuf *ibuf, int profile);
float *IMB_float_profile_ensure(struct ImBuf *ibuf, int profile, int *alloc);
void IMB_color_to_bw(struct ImBuf *ibuf);
void IMB_saturation(struct ImBuf *ibuf, float sat);
@@ -417,7 +419,7 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, flo
*
* \attention defined in readimage.c
*/
-struct ImBuf *IMB_loadifffile(int file, int flags, const char *descr);
+struct ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const char *descr);
/**
*
@@ -478,12 +480,12 @@ void IMB_freezbuffloatImBuf(struct ImBuf *ibuf);
* \attention Defined in rectop.c
*/
void IMB_rectfill(struct ImBuf *drect, const float col[4]);
-void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2);
+void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display);
void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
/* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
- const float col[4], const int do_color_management,
+ const float col[4], struct ColorManagedDisplay *display,
int x1, int y1, int x2, int y2);
/* defined in metadata.c */
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index be93d51d7d7..f03f709f13f 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -101,7 +101,6 @@ typedef struct ImBuf {
/* parameters used by conversion between byte and float */
float dither; /* random dither value, for conversion from float -> byte rect */
- short profile; /* color space/profile preset that the byte rect buffer represents */
/* mipmapping */
struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /* MipMap levels, a series of halved images */
@@ -127,6 +126,13 @@ typedef struct ImBuf {
unsigned int encodedsize; /* Size of data written to encodedbuffer */
unsigned int encodedbuffersize; /* Size of encodedbuffer */
+ /* color management */
+ struct ColorSpace *rect_colorspace; /* color space of byte buffer */
+ struct ColorSpace *float_colorspace; /* color space of float buffer, used by sequencer only */
+ unsigned int *display_buffer_flags; /* array of per-display display buffers dirty flags */
+ struct ColormanageCache *colormanage_cache; /* cache used by color management */
+ int colormanage_flag;
+
/* information for compressed textures */
struct DDSData dds_data;
} ImBuf;
@@ -136,10 +142,11 @@ typedef struct ImBuf {
* \brief userflags: Flags used internally by blender for imagebuffers
*/
-#define IB_BITMAPFONT (1 << 0) /* this image is a font */
-#define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */
-#define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */
-#define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */
+#define IB_BITMAPFONT (1 << 0) /* this image is a font */
+#define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */
+#define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */
+#define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */
+#define IB_DISPLAY_BUFFER_INVALID (1 << 4) /* either float or byte buffer changed, need to re-calculate display buffers */
/**
* \name Imbuf Component flags
@@ -254,4 +261,8 @@ extern const char *imb_ext_image_qt[];
extern const char *imb_ext_movie[];
extern const char *imb_ext_audio[];
+enum {
+ IMB_COLORMANAGE_IS_DATA = (1 << 0)
+};
+
#endif
diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript
index a1030112f4b..976108cd84e 100644
--- a/source/blender/imbuf/SConscript
+++ b/source/blender/imbuf/SConscript
@@ -4,9 +4,9 @@ Import ('env')
sources = env.Glob('intern/*.c')
-incs = '. ../makesdna #/intern/guardedalloc #/intern/memutil ../blenlib'
+incs = '. ../makesdna ../makesrna #/intern/guardedalloc #/intern/memutil ../blenlib'
incs += ' ../avi ../blenkernel ../blenloader'
-incs += ' #/intern/ffmpeg'
+incs += ' #/intern/ffmpeg #intern/opencolorio'
incs += ' ' + env['BF_JPEG_INC']
incs += ' ' + env['BF_PNG_INC']
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index 571c54b9cb3..d5cc4929aed 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -191,6 +191,7 @@ struct anim {
struct anim *proxy_anim[IMB_PROXY_MAX_SLOT];
struct anim_index *curr_idx[IMB_TC_MAX_SLOT];
+ char colorspace[64];
};
#endif
diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
new file mode 100644
index 00000000000..059bdee00eb
--- /dev/null
+++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
@@ -0,0 +1,93 @@
+/*
+ * ***** 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): Xavier Thomas,
+ * Lukas Toenne,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#ifndef IMB_COLORMANAGEMENT_INTERN_H
+#define IMB_COLORMANAGEMENT_INTERN_H
+
+#include "DNA_listBase.h"
+
+#define BCM_CONFIG_FILE "config.ocio"
+
+struct ConstProcessorRcPtr;
+struct ImBuf;
+
+typedef struct ColorSpace {
+ struct ColorSpace *next, *prev;
+ int index;
+ char name[64];
+ char description[64];
+
+ struct ConstProcessorRcPtr *to_scene_linear;
+ struct ConstProcessorRcPtr *from_scene_linear;
+
+ int is_invertible;
+ int is_data;
+} ColorSpace;
+
+typedef struct ColorManagedDisplay {
+ struct ColorManagedDisplay *next, *prev;
+ int index;
+ char name[64];
+ ListBase views;
+
+ struct ConstProcessorRcPtr *to_scene_linear;
+ struct ConstProcessorRcPtr *from_scene_linear;
+} ColorManagedDisplay;
+
+typedef struct ColorManagedView {
+ struct ColorManagedView *next, *prev;
+ int index;
+ char name[64];
+} ColorManagedView;
+
+void colormanage_cache_free(struct ImBuf *ibuf);
+
+struct ColorManagedDisplay *colormanage_display_get_default(void);
+struct ColorManagedDisplay *colormanage_display_add(const char *name);
+struct ColorManagedDisplay *colormanage_display_get_named(const char *name);
+struct ColorManagedDisplay *colormanage_display_get_indexed(int index);
+
+const char *colormanage_view_get_default_name(const ColorManagedDisplay *display);
+struct ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *display);
+struct ColorManagedView *colormanage_view_add(const char *name);
+struct ColorManagedView *colormanage_view_get_indexed(int index);
+struct ColorManagedView *colormanage_view_get_named(const char *name);
+
+struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible, int is_data);
+struct ColorSpace *colormanage_colorspace_get_named(const char *name);
+struct ColorSpace *colormanage_colorspace_get_roled(int role);
+struct ColorSpace *colormanage_colorspace_get_indexed(int index);
+
+void colorspace_set_default_role(char *colorspace, int size, int role);
+
+void colormanage_imbuf_set_default_spaces(struct ImBuf *ibuf);
+void colormanage_imbuf_make_linear(struct ImBuf *ibuf, const char *from_colorspace);
+
+#endif /* IMB_COLORMANAGEMENT_INTERN_H */
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index 74d0a92f26b..56a03121409 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -40,12 +40,13 @@ typedef struct ImFileType {
int (*is_a)(unsigned char *buf);
int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf);
- struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags);
+ struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int (*save)(struct ImBuf *ibuf, const char *name, int flags);
void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
int flag;
int filetype;
+ int default_save_role;
} ImFileType;
extern ImFileType IMB_FILE_TYPES[];
@@ -63,57 +64,57 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty);
/* png */
int imb_is_a_png(unsigned char *buf);
-struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savepng(struct ImBuf *ibuf, const char *name, int flags);
/* targa */
int imb_is_a_targa(unsigned char *buf);
-struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags);
/* iris */
int imb_is_a_iris(unsigned char *mem);
-struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags);
/* jp2 */
int imb_is_a_jp2(unsigned char *buf);
-struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags);
/* jpeg */
int imb_is_a_jpeg(unsigned char *mem);
int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags);
-struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags);
+struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
/* bmp */
int imb_is_a_bmp(unsigned char *buf);
-struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags);
/* cocoa */
-struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
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);
+struct ImBuf *imb_loadcineon(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);
+struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_is_dpx(unsigned char *buf);
/* hdr */
int imb_is_a_hdr(unsigned char *buf);
-struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savehdr(struct ImBuf * ibuf, const char *name, int flags);
/* tiff */
void imb_inittiff(void);
int imb_is_a_tiff(unsigned char *buf);
-struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size,
int tx, int ty, unsigned int *rect);
int imb_savetiff(struct ImBuf *ibuf, const char *name, int flags);
diff --git a/source/blender/imbuf/intern/IMB_metadata.h b/source/blender/imbuf/intern/IMB_metadata.h
index 4f512e04ef8..a68d7a7813e 100644
--- a/source/blender/imbuf/intern/IMB_metadata.h
+++ b/source/blender/imbuf/intern/IMB_metadata.h
@@ -62,7 +62,7 @@ void IMB_metadata_free(struct ImBuf *img);
* \param len - length of value buffer allocated by user.
* \return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise
*/
-int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, int len);
+int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, const size_t len);
/** set user data in the ImMetaData struct, which has to be allocated with IMB_metadata_create
* before calling this function.
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 7724f444b2c..69048274104 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -41,6 +41,7 @@
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
#include "IMB_metadata.h"
+#include "IMB_colormanagement_intern.h"
#include "imbuf.h"
@@ -162,8 +163,11 @@ void IMB_freeImBuf(ImBuf *ibuf)
IMB_freezbuffloatImBuf(ibuf);
freeencodedbufferImBuf(ibuf);
IMB_metadata_free(ibuf);
- if (ibuf->dds_data.data != NULL)
+ colormanage_cache_free(ibuf);
+
+ if (ibuf->dds_data.data != NULL) {
free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
+ }
MEM_freeN(ibuf);
}
}
@@ -354,7 +358,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
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 */
-
+
if (flags & IB_rect) {
if (imb_addrectImBuf(ibuf) == FALSE) {
IMB_freeImBuf(ibuf);
@@ -382,6 +386,9 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
return NULL;
}
}
+
+ /* assign default spaces */
+ colormanage_imbuf_set_default_spaces(ibuf);
}
return (ibuf);
}
@@ -442,8 +449,11 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
/* for now don't duplicate metadata */
tbuf.metadata = NULL;
+ tbuf.display_buffer_flags = NULL;
+ tbuf.colormanage_cache = NULL;
+
*ibuf2 = tbuf;
-
+
return(ibuf2);
}
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 16dbd0823da..394f5169046 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -113,6 +113,9 @@
#endif
#endif
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
int ismovie(const char *UNUSED(filepath))
{
return 0;
@@ -263,12 +266,20 @@ void IMB_close_anim_proxies(struct anim *anim)
IMB_free_indices(anim);
}
-struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex)
+struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE])
{
struct anim *anim;
anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct");
if (anim != NULL) {
+ if (colorspace) {
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+ BLI_strncpy(anim->colorspace, colorspace, sizeof(anim->colorspace));
+ }
+ else {
+ colorspace_set_default_role(anim->colorspace, sizeof(anim->colorspace), COLOR_ROLE_DEFAULT_BYTE);
+ }
+
BLI_strncpy(anim->name, name, sizeof(anim->name));
anim->ib_flags = ib_flags;
anim->streamindex = streamindex;
@@ -404,7 +415,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
if (anim->pgf) {
lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]));
if (lpbi) {
- ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, "<avi_fetchibuf>");
+ ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
//Oh brother...
}
}
@@ -432,8 +443,8 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
MEM_freeN(tmp);
}
- ibuf->profile = IB_PROFILE_SRGB;
-
+ ibuf->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace);
+
return ibuf;
}
@@ -634,8 +645,6 @@ static void ffmpeg_postprocess(struct anim *anim)
ImBuf *ibuf = anim->last_frame;
int filter_y = 0;
- ibuf->profile = IB_PROFILE_SRGB;
-
if (!anim->pFrameComplete) {
return;
}
@@ -1090,6 +1099,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position,
IMB_freeImBuf(anim->last_frame);
anim->last_frame = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect);
+ anim->last_frame->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace);
ffmpeg_postprocess(anim);
@@ -1213,7 +1223,7 @@ static ImBuf *anim_getnew(struct anim *anim)
switch (anim->curtype) {
case ANIM_SEQUENCE:
- ibuf = IMB_loadiffname(anim->name, anim->ib_flags);
+ ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace);
if (ibuf) {
BLI_strncpy(anim->first, anim->name, sizeof(anim->first));
anim->duration = 1;
@@ -1309,7 +1319,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
pic = an_stringdec(anim->first, head, tail, &digits);
pic += position;
an_stringenc(anim->name, head, tail, digits, pic);
- ibuf = IMB_loadiffname(anim->name, IB_rect);
+ ibuf = IMB_loadiffname(anim->name, IB_rect, anim->colorspace);
if (ibuf) {
anim->curposition = position;
}
@@ -1319,7 +1329,6 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
if (ibuf) {
anim->curposition = position;
IMB_convert_rgba_to_abgr(ibuf);
- ibuf->profile = IB_PROFILE_SRGB;
}
break;
case ANIM_AVI:
@@ -1330,8 +1339,16 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
#ifdef WITH_QUICKTIME
case ANIM_QTIME:
ibuf = qtime_fetchibuf(anim, position);
- if (ibuf)
+ if (ibuf) {
+ if (ibuf->rect) {
+ /* OCIO_TODO: should happen in quicktime module, but it currently doesn't have access
+ * to color management's internals
+ */
+ ibuf->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace);
+ }
+
anim->curposition = position;
+ }
break;
#endif
#ifdef WITH_FFMPEG
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index 8fa468949e7..df12f0b703e 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -38,6 +38,9 @@
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
/* some code copied from article on microsoft.com, copied
* here for enhanced BMP support in the future
* http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0197/mfcp1/mfcp1.htm&nav=/msj/0197/newnav.htm
@@ -115,7 +118,7 @@ int imb_is_a_bmp(unsigned char *buf)
return checkbmp(buf);
}
-struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
+struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
BMPINFOHEADER bmi;
@@ -127,6 +130,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
if (checkbmp(mem) == 0) return(NULL);
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
if ((mem[0] == 'B') && (mem[1] == 'M')) {
/* skip fileheader */
mem += BMP_FILEHEADER_SIZE;
@@ -195,7 +200,6 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
if (ibuf) {
ibuf->ftype = BMP;
- ibuf->profile = IB_PROFILE_SRGB;
}
return(ibuf);
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 182e0a7e29d..7705af13b1e 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -44,6 +44,9 @@
#include "IMB_imbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
#include "BKE_global.h"
#include "MEM_guardedalloc.h"
@@ -63,7 +66,7 @@ static void cineon_conversion_parameters(LogImageByteConversionParameters *param
}
#endif
-static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags)
+static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags, char colorspace[IM_MAX_SPACE])
{
ImBuf *ibuf;
LogImageFile *image;
@@ -72,6 +75,8 @@ static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size,
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);
@@ -202,10 +207,10 @@ int imb_is_cineon(unsigned char *buf)
return cineonIsMemFileCineon(buf);
}
-ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags)
+ImBuf *imb_loadcineon(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);
+ return imb_load_dpx_cineon(mem, 1, size, flags, colorspace);
return NULL;
}
@@ -219,9 +224,9 @@ int imb_is_dpx(unsigned char *buf)
return dpxIsMemFileCineon(buf);
}
-ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags)
+ImBuf *imb_loaddpx(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);
+ return imb_load_dpx_cineon(mem, 0, size, flags, colorspace);
return NULL;
}
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
new file mode 100644
index 00000000000..11dce3087c6
--- /dev/null
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -0,0 +1,2436 @@
+/*
+ * ***** 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): Xavier Thomas,
+ * Lukas Toenne,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
+#include <string.h>
+#include <math.h>
+
+#include "DNA_color_types.h"
+#include "DNA_image_types.h"
+#include "DNA_movieclip_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "IMB_filter.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_filetype.h"
+#include "IMB_moviecache.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_math_color.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "BLI_threads.h"
+
+#include "BKE_colortools.h"
+#include "BKE_context.h"
+#include "BKE_utildefines.h"
+#include "BKE_main.h"
+
+#include "RNA_define.h"
+
+#include <ocio_capi.h>
+
+/*********************** Global declarations *************************/
+
+#define MAX_COLORSPACE_NAME 64
+#define DISPLAY_BUFFER_CHANNELS 4
+
+/* ** list of all supported color spaces, displays and views */
+static char global_role_scene_linear[MAX_COLORSPACE_NAME];
+static char global_role_color_picking[MAX_COLORSPACE_NAME];
+static char global_role_texture_painting[MAX_COLORSPACE_NAME];
+static char global_role_default_byte[MAX_COLORSPACE_NAME];
+static char global_role_default_float[MAX_COLORSPACE_NAME];
+static char global_role_default_sequencer[MAX_COLORSPACE_NAME];
+
+static ListBase global_colorspaces = {NULL};
+static ListBase global_displays = {NULL};
+static ListBase global_views = {NULL};
+
+static int global_tot_colorspace = 0;
+static int global_tot_display = 0;
+static int global_tot_view = 0;
+
+typedef struct ColormanageProcessor {
+ ConstProcessorRcPtr *processor;
+ CurveMapping *curve_mapping;
+} ColormanageProcessor;
+
+/*********************** Color managed cache *************************/
+
+/* Cache Implementation Notes
+ * ==========================
+ *
+ * All color management cache stuff is stored in two properties of
+ * image buffers:
+ *
+ * 1. display_buffer_flags
+ *
+ * This is a bit field which used to mark calculated transformations
+ * for particular image buffer. Index inside of this array means index
+ * of a color managed display. Element with given index matches view
+ * transformations applied for a given display. So if bit B of array
+ * element B is set to 1, this means display buffer with display index
+ * of A and view transform of B was ever calculated for this imbuf.
+ *
+ * In contrast with indices in global lists of displays and views this
+ * indices are 0-based, not 1-based. This is needed to save some bytes
+ * of memory.
+ *
+ * 2. colormanage_cache
+ *
+ * This is a pointer to a structure which holds all data which is
+ * needed for color management cache to work.
+ *
+ * It contains two parts:
+ * - data
+ * - moviecache
+ *
+ * Data field is used to store additional information about cached
+ * buffers which affects on whether cached buffer could be used.
+ * This data can't go to cache key because changes in this data
+ * shouldn't lead extra buffers adding to cache, it shall
+ * invalidate cached images.
+ *
+ * Currently such a data contains only exposure and gamma, but
+ * would likely extended further.
+ *
+ * data field is not null only for elements of cache, not used for
+ * original image buffers.
+ *
+ * Color management cache is using generic MovieCache implementation
+ * to make it easier to deal with memory limitation.
+ *
+ * Currently color management is using the same memory limitation
+ * pool as sequencer and clip editor are using which means color
+ * managed buffers would be removed from the cache as soon as new
+ * frames are loading for the movie clip and there's no space in
+ * cache.
+ *
+ * Every image buffer has got own movie cache instance, which
+ * means keys for color managed buffers could be really simple
+ * and look up in this cache would be fast and independent from
+ * overall amount of color managed images.
+ */
+
+/* NOTE: ColormanageCacheViewSettings and ColormanageCacheDisplaySettings are
+ * quite the same as ColorManagedViewSettings and ColorManageDisplaySettings
+ * but they holds indexes of all transformations and color spaces, not
+ * their names.
+ *
+ * This helps avoid extra colorsmace / display / view lookup without
+ * requiring to pass all variables which affects on display buffer
+ * to color management cache system and keeps calls small and nice.
+ */
+typedef struct ColormanageCacheViewSettings {
+ int flag;
+ int view;
+ float exposure;
+ float gamma;
+ CurveMapping *curve_mapping;
+} ColormanageCacheViewSettings;
+
+typedef struct ColormanageCacheDisplaySettings {
+ int display;
+} ColormanageCacheDisplaySettings;
+
+typedef struct ColormanageCacheKey {
+ int view; /* view transformation used for display buffer */
+ int display; /* display device name */
+} ColormanageCacheKey;
+
+typedef struct ColormnaageCacheData {
+ int flag; /* view flags of cached buffer */
+ float exposure; /* exposure value cached buffer is calculated with */
+ float gamma; /* gamma value cached buffer is calculated with */
+ int predivide; /* predivide flag of cached buffer */
+ CurveMapping *curve_mapping; /* curve mapping used for cached buffer */
+ int curve_mapping_timestamp; /* time stamp of curve mapping used for cached buffer */
+} ColormnaageCacheData;
+
+typedef struct ColormanageCache {
+ struct MovieCache *moviecache;
+
+ ColormnaageCacheData *data;
+} ColormanageCache;
+
+static struct MovieCache *colormanage_moviecache_get(const ImBuf *ibuf)
+{
+ if (!ibuf->colormanage_cache)
+ return NULL;
+
+ return ibuf->colormanage_cache->moviecache;
+}
+
+static ColormnaageCacheData *colormanage_cachedata_get(const ImBuf *ibuf)
+{
+ if (!ibuf->colormanage_cache)
+ return NULL;
+
+ return ibuf->colormanage_cache->data;
+}
+
+static unsigned int colormanage_hashhash(const void *key_v)
+{
+ ColormanageCacheKey *key = (ColormanageCacheKey *)key_v;
+
+ unsigned int rval = (key->display << 16) | (key->view % 0xffff);
+
+ return rval;
+}
+
+static int colormanage_hashcmp(const void *av, const void *bv)
+{
+ const ColormanageCacheKey *a = (ColormanageCacheKey *) av;
+ const ColormanageCacheKey *b = (ColormanageCacheKey *) bv;
+
+ if (a->view < b->view)
+ return -1;
+ else if (a->view > b->view)
+ return 1;
+
+ if (a->display < b->display)
+ return -1;
+ else if (a->display > b->display)
+ return 1;
+
+ return 0;
+}
+
+static struct MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf)
+{
+ if (!ibuf->colormanage_cache)
+ ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache");
+
+ if (!ibuf->colormanage_cache->moviecache) {
+ struct MovieCache *moviecache;
+
+ moviecache = IMB_moviecache_create("colormanage cache", sizeof(ColormanageCacheKey),
+ colormanage_hashhash, colormanage_hashcmp);
+
+ ibuf->colormanage_cache->moviecache = moviecache;
+ }
+
+ return ibuf->colormanage_cache->moviecache;
+}
+
+static void colormanage_cachedata_set(ImBuf *ibuf, ColormnaageCacheData *data)
+{
+ if (!ibuf->colormanage_cache)
+ ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache");
+
+ ibuf->colormanage_cache->data = data;
+}
+
+static void colormanage_view_settings_to_cache(ColormanageCacheViewSettings *cache_view_settings,
+ const ColorManagedViewSettings *view_settings)
+{
+ int view = IMB_colormanagement_view_get_named_index(view_settings->view_transform);
+
+ cache_view_settings->view = view;
+ cache_view_settings->exposure = view_settings->exposure;
+ cache_view_settings->gamma = view_settings->gamma;
+ cache_view_settings->flag = view_settings->flag;
+ cache_view_settings->curve_mapping = view_settings->curve_mapping;
+}
+
+static void colormanage_display_settings_to_cache(ColormanageCacheDisplaySettings *cache_display_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ int display = IMB_colormanagement_display_get_named_index(display_settings->display_device);
+
+ cache_display_settings->display = display;
+}
+
+static void colormanage_settings_to_key(ColormanageCacheKey *key,
+ const ColormanageCacheViewSettings *view_settings,
+ const ColormanageCacheDisplaySettings *display_settings)
+{
+ key->view = view_settings->view;
+ key->display = display_settings->display;
+}
+
+static ImBuf *colormanage_cache_get_ibuf(ImBuf *ibuf, ColormanageCacheKey *key, void **cache_handle)
+{
+ ImBuf *cache_ibuf;
+ struct MovieCache *moviecache = colormanage_moviecache_get(ibuf);
+
+ if (!moviecache) {
+ /* if there's no moviecache it means no color management was applied on given image buffer before */
+
+ return NULL;
+ }
+
+ *cache_handle = NULL;
+
+ cache_ibuf = IMB_moviecache_get(moviecache, key);
+
+ *cache_handle = cache_ibuf;
+
+ return cache_ibuf;
+}
+
+static unsigned char *colormanage_cache_get(ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings,
+ const ColormanageCacheDisplaySettings *display_settings,
+ void **cache_handle)
+{
+ ColormanageCacheKey key;
+ ImBuf *cache_ibuf;
+ int view_flag = 1 << (view_settings->view - 1);
+ int predivide = ibuf->flags & IB_cm_predivide;
+ CurveMapping *curve_mapping = view_settings->curve_mapping;
+ int curve_mapping_timestamp = curve_mapping ? curve_mapping->changed_timestamp : 0;
+
+ colormanage_settings_to_key(&key, view_settings, display_settings);
+
+ /* check whether image was marked as dirty for requested transform */
+ if ((ibuf->display_buffer_flags[display_settings->display - 1] & view_flag) == 0) {
+ return NULL;
+ }
+
+ cache_ibuf = colormanage_cache_get_ibuf(ibuf, &key, cache_handle);
+
+ if (cache_ibuf) {
+ ColormnaageCacheData *cache_data;
+
+ BLI_assert(cache_ibuf->x == ibuf->x &&
+ cache_ibuf->y == ibuf->y);
+
+ /* only buffers with different color space conversions are being stored
+ * in cache separately. buffer which were used only different exposure/gamma
+ * are re-suing the same cached buffer
+ *
+ * check here which exposure/gamma/curve was used for cached buffer and if they're
+ * different from requested buffer should be re-generated
+ */
+ cache_data = colormanage_cachedata_get(cache_ibuf);
+
+ if (cache_data->exposure != view_settings->exposure ||
+ cache_data->gamma != view_settings->gamma ||
+ cache_data->predivide != predivide ||
+ cache_data->flag != view_settings->flag ||
+ cache_data->curve_mapping != curve_mapping ||
+ cache_data->curve_mapping_timestamp != curve_mapping_timestamp)
+ {
+ *cache_handle = NULL;
+
+ IMB_freeImBuf(cache_ibuf);
+
+ return NULL;
+ }
+
+ return (unsigned char *) cache_ibuf->rect;
+ }
+
+ return NULL;
+}
+
+static void colormanage_cache_put(ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings,
+ const ColormanageCacheDisplaySettings *display_settings,
+ unsigned char *display_buffer, void **cache_handle)
+{
+ ColormanageCacheKey key;
+ ImBuf *cache_ibuf;
+ ColormnaageCacheData *cache_data;
+ int view_flag = 1 << (view_settings->view - 1);
+ int predivide = ibuf->flags & IB_cm_predivide;
+ struct MovieCache *moviecache = colormanage_moviecache_ensure(ibuf);
+ CurveMapping *curve_mapping = view_settings->curve_mapping;
+ int curve_mapping_timestamp = curve_mapping ? curve_mapping->changed_timestamp : 0;
+
+ colormanage_settings_to_key(&key, view_settings, display_settings);
+
+ /* mark display buffer as valid */
+ ibuf->display_buffer_flags[display_settings->display - 1] |= view_flag;
+
+ /* buffer itself */
+ cache_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
+ cache_ibuf->rect = (unsigned int *) display_buffer;
+
+ cache_ibuf->mall |= IB_rect;
+ cache_ibuf->flags |= IB_rect;
+
+ /* store data which is needed to check whether cached buffer could be used for color managed display settings */
+ cache_data = MEM_callocN(sizeof(ColormnaageCacheData), "color manage cache imbuf data");
+ cache_data->exposure = view_settings->exposure;
+ cache_data->gamma = view_settings->gamma;
+ cache_data->predivide = predivide;
+ cache_data->flag = view_settings->flag;
+ cache_data->curve_mapping = curve_mapping;
+ cache_data->curve_mapping_timestamp = curve_mapping_timestamp;
+
+ colormanage_cachedata_set(cache_ibuf, cache_data);
+
+ *cache_handle = cache_ibuf;
+
+ IMB_moviecache_put(moviecache, &key, cache_ibuf);
+}
+
+static void colormanage_cache_handle_release(void *cache_handle)
+{
+ ImBuf *cache_ibuf = cache_handle;
+
+ IMB_freeImBuf(cache_ibuf);
+}
+
+/*********************** Initialization / De-initialization *************************/
+
+static void colormanage_role_color_space_name_get(ConstConfigRcPtr *config, char *colorspace_name, const char *role, const char *backup_role)
+{
+ ConstColorSpaceRcPtr *ociocs;
+
+ ociocs = OCIO_configGetColorSpace(config, role);
+
+ if (!ociocs && backup_role)
+ ociocs = OCIO_configGetColorSpace(config, backup_role);
+
+ if (ociocs) {
+ const char *name = OCIO_colorSpaceGetName(ociocs);
+
+ /* assume function was called with buffer properly allocated to MAX_COLORSPACE_NAME chars */
+ BLI_strncpy(colorspace_name, name, MAX_COLORSPACE_NAME);
+ OCIO_colorSpaceRelease(ociocs);
+ }
+ else {
+ printf("Color management: Error could not find role %s role.\n", role);
+ }
+}
+
+static void colormanage_load_config(ConstConfigRcPtr *config)
+{
+ int tot_colorspace, tot_display, tot_display_view, index, viewindex, viewindex2;
+ const char *name;
+
+ /* get roles */
+ colormanage_role_color_space_name_get(config, global_role_scene_linear, OCIO_ROLE_SCENE_LINEAR, NULL);
+ colormanage_role_color_space_name_get(config, global_role_color_picking, OCIO_ROLE_COLOR_PICKING, NULL);
+ colormanage_role_color_space_name_get(config, global_role_texture_painting, OCIO_ROLE_TEXTURE_PAINT, NULL);
+ colormanage_role_color_space_name_get(config, global_role_default_sequencer, OCIO_ROLE_DEFAULT_SEQUENCER, OCIO_ROLE_SCENE_LINEAR);
+ colormanage_role_color_space_name_get(config, global_role_default_byte, OCIO_ROLE_DEFAULT_BYTE, OCIO_ROLE_TEXTURE_PAINT);
+ colormanage_role_color_space_name_get(config, global_role_default_float, OCIO_ROLE_DEFAULT_FLOAT, OCIO_ROLE_SCENE_LINEAR);
+
+ /* load colorspaces */
+ tot_colorspace = OCIO_configGetNumColorSpaces(config);
+ for (index = 0 ; index < tot_colorspace; index++) {
+ ConstColorSpaceRcPtr *ocio_colorspace;
+ const char *description;
+ int is_invertible, is_data;
+
+ name = OCIO_configGetColorSpaceNameByIndex(config, index);
+
+ ocio_colorspace = OCIO_configGetColorSpace(config, name);
+ description = OCIO_colorSpaceGetDescription(ocio_colorspace);
+ is_invertible = OCIO_colorSpaceIsInvertible(ocio_colorspace);
+ is_data = OCIO_colorSpaceIsData(ocio_colorspace);
+
+ colormanage_colorspace_add(name, description, is_invertible, is_data);
+
+ OCIO_colorSpaceRelease(ocio_colorspace);
+ }
+
+ /* load displays */
+ viewindex2 = 0;
+ tot_display = OCIO_configGetNumDisplays(config);
+
+ for (index = 0 ; index < tot_display; index++) {
+ const char *displayname;
+ ColorManagedDisplay *display;
+
+ displayname = OCIO_configGetDisplay(config, index);
+
+ display = colormanage_display_add(displayname);
+
+ /* load views */
+ tot_display_view = OCIO_configGetNumViews(config, displayname);
+ for (viewindex = 0 ; viewindex < tot_display_view; viewindex++, viewindex2++) {
+ const char *viewname;
+ ColorManagedView *view;
+ LinkData *display_view;
+
+ viewname = OCIO_configGetView(config, displayname, viewindex);
+
+ /* first check if view transform with given name was already loaded */
+ view = colormanage_view_get_named(viewname);
+
+ if (!view) {
+ view = colormanage_view_add(viewname);
+ }
+
+ display_view = BLI_genericNodeN(view);
+
+ BLI_addtail(&display->views, display_view);
+ }
+ }
+
+ global_tot_display = tot_display;
+}
+
+static void colormanage_free_config(void)
+{
+ ColorSpace *colorspace;
+ ColorManagedDisplay *display;
+
+ /* free color spaces */
+ colorspace = global_colorspaces.first;
+ while (colorspace) {
+ ColorSpace *colorspace_next = colorspace->next;
+
+ /* free precomputer processors */
+ if (colorspace->to_scene_linear)
+ OCIO_processorRelease((ConstProcessorRcPtr *) colorspace->to_scene_linear);
+
+ if (colorspace->from_scene_linear)
+ OCIO_processorRelease((ConstProcessorRcPtr *) colorspace->from_scene_linear);
+
+ /* free color space itself */
+ MEM_freeN(colorspace);
+
+ colorspace = colorspace_next;
+ }
+
+ /* free displays */
+ display = global_displays.first;
+ while (display) {
+ ColorManagedDisplay *display_next = display->next;
+
+ /* free precomputer processors */
+ if (display->to_scene_linear)
+ OCIO_processorRelease((ConstProcessorRcPtr *) display->to_scene_linear);
+
+ if (display->from_scene_linear)
+ OCIO_processorRelease((ConstProcessorRcPtr *) display->from_scene_linear);
+
+ /* free list of views */
+ BLI_freelistN(&display->views);
+
+ MEM_freeN(display);
+ display = display_next;
+ }
+
+ /* free views */
+ BLI_freelistN(&global_views);
+}
+
+void IMB_colormanagement_init(void)
+{
+ const char *ocio_env;
+ const char *configdir;
+ char configfile[FILE_MAX];
+ ConstConfigRcPtr *config = NULL;
+
+ ocio_env = getenv("OCIO");
+
+ if (ocio_env && ocio_env[0] != '\0')
+ config = OCIO_configCreateFromEnv();
+
+ if (config == NULL) {
+ configdir = BLI_get_folder(BLENDER_DATAFILES, "colormanagement");
+
+ if (configdir) {
+ BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE);
+
+ config = OCIO_configCreateFromFile(configfile);
+ }
+ }
+
+ if (config == NULL) {
+ config = OCIO_getDefaultConfig();
+ }
+
+ if (config) {
+ OCIO_setCurrentConfig(config);
+
+ colormanage_load_config(config);
+
+ OCIO_configRelease(config);
+ }
+
+ BLI_init_srgb_conversion();
+}
+
+void IMB_colormanagement_exit(void)
+{
+ colormanage_free_config();
+}
+
+/*********************** Internal functions *************************/
+
+void colormanage_cache_free(ImBuf *ibuf)
+{
+ if (ibuf->display_buffer_flags) {
+ MEM_freeN(ibuf->display_buffer_flags);
+
+ ibuf->display_buffer_flags = NULL;
+ }
+
+ if (ibuf->colormanage_cache) {
+ ColormnaageCacheData *cache_data = colormanage_cachedata_get(ibuf);
+ struct MovieCache *moviecache = colormanage_moviecache_get(ibuf);
+
+ if (cache_data) {
+ MEM_freeN(cache_data);
+ }
+
+ if (moviecache) {
+ IMB_moviecache_free(moviecache);
+ }
+
+ MEM_freeN(ibuf->colormanage_cache);
+
+ ibuf->colormanage_cache = NULL;
+ }
+}
+
+static void display_transform_get_from_ctx(const bContext *C, ColorManagedViewSettings **view_settings_r,
+ ColorManagedDisplaySettings **display_settings_r)
+{
+ Scene *scene = CTX_data_scene(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
+
+ *view_settings_r = &scene->view_settings;
+ *display_settings_r = &scene->display_settings;
+
+ if (sima) {
+ if ((sima->image->flag & IMA_VIEW_AS_RENDER) == 0)
+ *view_settings_r = NULL;
+ }
+}
+
+static ConstProcessorRcPtr *create_display_buffer_processor(const char *view_transform, const char *display,
+ float exposure, float gamma)
+{
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+ DisplayTransformRcPtr *dt;
+ ConstProcessorRcPtr *processor;
+
+ if (!config) {
+ /* there's no valid OCIO configuration, can't create processor */
+
+ return NULL;
+ }
+
+ dt = OCIO_createDisplayTransform();
+
+ /* assuming handling buffer was already converted to scene linear space */
+ OCIO_displayTransformSetInputColorSpaceName(dt, global_role_scene_linear);
+ OCIO_displayTransformSetView(dt, view_transform);
+ OCIO_displayTransformSetDisplay(dt, display);
+
+ /* fstop exposure control */
+ if (exposure != 0.0f) {
+ MatrixTransformRcPtr *mt;
+ float gain = powf(2.0f, exposure);
+ const float scale4f[] = {gain, gain, gain, gain};
+ float m44[16], offset4[4];
+
+ OCIO_matrixTransformScale(m44, offset4, scale4f);
+ mt = OCIO_createMatrixTransform();
+ OCIO_matrixTransformSetValue(mt, m44, offset4);
+ OCIO_displayTransformSetLinearCC(dt, (ConstTransformRcPtr *) mt);
+
+ OCIO_matrixTransformRelease(mt);
+ }
+
+ /* post-display gamma transform */
+ if (gamma != 1.0f) {
+ ExponentTransformRcPtr *et;
+ float exponent = 1.0f / MAX2(FLT_EPSILON, gamma);
+ const float exponent4f[] = {exponent, exponent, exponent, exponent};
+
+ et = OCIO_createExponentTransform();
+ OCIO_exponentTransformSetValue(et, exponent4f);
+ OCIO_displayTransformSetDisplayCC(dt, (ConstTransformRcPtr *) et);
+
+ OCIO_exponentTransformRelease(et);
+ }
+
+ processor = OCIO_configGetProcessor(config, (ConstTransformRcPtr *) dt);
+
+ OCIO_displayTransformRelease(dt);
+ OCIO_configRelease(config);
+
+ return processor;
+}
+
+static ConstProcessorRcPtr *create_colorspace_transform_processor(const char *from_colorspace,
+ const char *to_colorspace)
+{
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+ ConstProcessorRcPtr *processor;
+
+ if (!config) {
+ /* there's no valid OCIO configuration, can't create processor */
+
+ return NULL;
+ }
+
+ processor = OCIO_configGetProcessorWithNames(config, from_colorspace, to_colorspace);
+
+ OCIO_configRelease(config);
+
+ return processor;
+}
+
+static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *colorspace)
+{
+ if (colorspace->to_scene_linear == NULL) {
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ if (colorspace->to_scene_linear == NULL) {
+ ConstProcessorRcPtr *to_scene_linear;
+ to_scene_linear = create_colorspace_transform_processor(colorspace->name, global_role_scene_linear);
+ colorspace->to_scene_linear = (struct ConstProcessorRcPtr *) to_scene_linear;
+ }
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+ }
+
+ return (ConstProcessorRcPtr *) colorspace->to_scene_linear;
+}
+
+static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *colorspace)
+{
+ if (colorspace->from_scene_linear == NULL) {
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ if (colorspace->from_scene_linear == NULL) {
+ ConstProcessorRcPtr *from_scene_linear;
+ from_scene_linear = create_colorspace_transform_processor(global_role_scene_linear, colorspace->name);
+ colorspace->from_scene_linear = (struct ConstProcessorRcPtr *) from_scene_linear;
+ }
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+ }
+
+ return (ConstProcessorRcPtr *) colorspace->from_scene_linear;
+}
+
+static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisplay *display)
+{
+ if (display->from_scene_linear == NULL) {
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ if (display->from_scene_linear == NULL) {
+ const char *view_name = colormanage_view_get_default_name(display);
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+ ConstProcessorRcPtr *processor = NULL;
+
+ if (view_name && config) {
+ const char *view_colorspace = OCIO_configGetDisplayColorSpaceName(config, display->name, view_name);
+ processor = OCIO_configGetProcessorWithNames(config, global_role_scene_linear, view_colorspace);
+
+ OCIO_configRelease(config);
+ }
+
+ display->from_scene_linear = (struct ConstProcessorRcPtr *) processor;
+ }
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+ }
+
+ return (ConstProcessorRcPtr *) display->from_scene_linear;
+}
+
+static ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDisplay *display)
+{
+ if (display->to_scene_linear == NULL) {
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ if (display->to_scene_linear == NULL) {
+ const char *view_name = colormanage_view_get_default_name(display);
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+ ConstProcessorRcPtr *processor = NULL;
+
+ if (view_name && config) {
+ const char *view_colorspace = OCIO_configGetDisplayColorSpaceName(config, display->name, view_name);
+ processor = OCIO_configGetProcessorWithNames(config, view_colorspace, global_role_scene_linear);
+
+ OCIO_configRelease(config);
+ }
+
+ display->to_scene_linear = (struct ConstProcessorRcPtr *) processor;
+ }
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+ }
+
+ return (ConstProcessorRcPtr *) display->to_scene_linear;
+}
+
+static void init_default_view_settings(const ColorManagedDisplaySettings *display_settings,
+ ColorManagedViewSettings *view_settings)
+{
+ ColorManagedDisplay *display;
+ ColorManagedView *default_view = NULL;
+
+ display = colormanage_display_get_named(display_settings->display_device);
+
+ if (display)
+ default_view = colormanage_view_get_default(display);
+
+ if (default_view)
+ BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
+ else
+ view_settings->view_transform[0] = '\0';
+
+ view_settings->flag = 0;
+ view_settings->gamma = 1.0f;
+ view_settings->exposure = 0.0f;
+ view_settings->curve_mapping = NULL;
+}
+
+static void curve_mapping_apply_pixel(CurveMapping *curve_mapping, float *pixel, int channels)
+{
+ if (channels == 1) {
+ pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]);
+ }
+ else if (channels == 2) {
+ pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]);
+ pixel[1] = curvemap_evaluateF(curve_mapping->cm, pixel[1]);
+ }
+ else {
+ curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel);
+ }
+}
+
+void colorspace_set_default_role(char *colorspace, int size, int role)
+{
+ if (colorspace && colorspace[0] == '\0') {
+ const char *role_colorspace;
+
+ role_colorspace = IMB_colormanagement_role_colorspace_name_get(role);
+
+ BLI_strncpy(colorspace, role_colorspace, size);
+ }
+}
+
+void colormanage_imbuf_set_default_spaces(ImBuf *ibuf)
+{
+ ibuf->rect_colorspace = colormanage_colorspace_get_named(global_role_default_byte);
+}
+
+void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
+{
+ ColorSpace *colorspace = colormanage_colorspace_get_named(from_colorspace);
+
+ if (colorspace->is_data) {
+ ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
+ return;
+ }
+
+ if (ibuf->rect_float) {
+ const char *to_colorspace = global_role_scene_linear;
+ int predivide = ibuf->flags & IB_cm_predivide;
+
+ if (ibuf->rect)
+ imb_freerectImBuf(ibuf);
+
+ IMB_colormanagement_transform(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
+ from_colorspace, to_colorspace, predivide);
+ }
+}
+
+/*********************** Generic functions *************************/
+
+static void colormanage_check_display_settings(ColorManagedDisplaySettings *display_settings, const char *what,
+ const ColorManagedDisplay *default_display)
+{
+ if (display_settings->display_device[0] == '\0') {
+ BLI_strncpy(display_settings->display_device, default_display->name, sizeof(display_settings->display_device));
+ }
+ else {
+ ColorManagedDisplay *display = colormanage_display_get_named(display_settings->display_device);
+
+ if (!display) {
+ printf("Color management: display \"%s\" used by %s not found, setting to default (\"%s\").\n",
+ display_settings->display_device, what, default_display->name);
+
+ BLI_strncpy(display_settings->display_device, default_display->name,
+ sizeof(display_settings->display_device));
+ }
+ }
+}
+
+static void colormanage_check_view_settings(ColorManagedDisplaySettings *display_settings,
+ ColorManagedViewSettings *view_settings, const char *what)
+{
+ ColorManagedDisplay *display;
+ ColorManagedView *default_view = NULL;
+
+ if (view_settings->view_transform[0] == '\0') {
+ display = colormanage_display_get_named(display_settings->display_device);
+
+ if (display)
+ default_view = colormanage_view_get_default(display);
+
+ if (default_view)
+ BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
+ }
+ else {
+ ColorManagedView *view = colormanage_view_get_named(view_settings->view_transform);
+
+ if (!view) {
+ display = colormanage_display_get_named(display_settings->display_device);
+
+ if (display)
+ default_view = colormanage_view_get_default(display);
+
+ if (default_view) {
+ printf("Color management: %s view \"%s\" not found, setting default \"%s\".\n",
+ what, view_settings->view_transform, default_view->name);
+
+ BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
+ }
+ }
+ }
+
+ /* OCIO_TODO: move to do_versions() */
+ if (view_settings->exposure == 0.0f && view_settings->gamma == 0.0f) {
+ view_settings->exposure = 0.0f;
+ view_settings->gamma = 1.0f;
+ }
+}
+
+static void colormanage_check_colorspace_settings(ColorManagedColorspaceSettings *colorspace_settings, const char *what)
+{
+ if (colorspace_settings->name[0] == '\0') {
+ /* pass */
+ }
+ else {
+ ColorSpace *colorspace = colormanage_colorspace_get_named(colorspace_settings->name);
+
+ if (!colorspace) {
+ printf("Color management: %s colorspace \"%s\" not found, will use default instead.\n",
+ what, colorspace_settings->name);
+
+ BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name));
+ }
+ }
+
+ (void) what;
+}
+
+void IMB_colormanagement_check_file_config(Main *bmain)
+{
+ Scene *scene;
+ Image *image;
+ MovieClip *clip;
+
+ ColorManagedDisplay *default_display;
+
+ default_display = colormanage_display_get_default();
+
+ if (!default_display) {
+ /* happens when OCIO configuration is incorrect */
+ return;
+ }
+
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
+ ColorManagedColorspaceSettings *sequencer_colorspace_settings;
+
+ colormanage_check_display_settings(&scene->display_settings, "scene", default_display);
+ colormanage_check_view_settings(&scene->display_settings, &scene->view_settings, "scene");
+
+ sequencer_colorspace_settings = &scene->sequencer_colorspace_settings;
+
+ colormanage_check_colorspace_settings(sequencer_colorspace_settings, "sequencer");
+
+ if (sequencer_colorspace_settings->name[0] == '\0') {
+ BLI_strncpy(sequencer_colorspace_settings->name, global_role_default_sequencer, MAX_COLORSPACE_NAME);
+ }
+ }
+
+ /* ** check input color space settings ** */
+
+ for (image = bmain->image.first; image; image = image->id.next) {
+ colormanage_check_colorspace_settings(&image->colorspace_settings, "image");
+ }
+
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
+ colormanage_check_colorspace_settings(&clip->colorspace_settings, "clip");
+ }
+}
+
+void IMB_colormanagement_validate_settings(ColorManagedDisplaySettings *display_settings,
+ ColorManagedViewSettings *view_settings)
+{
+ ColorManagedDisplay *display;
+ ColorManagedView *default_view = NULL;
+ LinkData *view_link;
+
+ display = colormanage_display_get_named(display_settings->display_device);
+
+ if (display)
+ default_view = colormanage_view_get_default(display);
+
+ for (view_link = display->views.first; view_link; view_link = view_link->next) {
+ ColorManagedView *view = view_link->data;
+
+ if (!strcmp(view->name, view_settings->view_transform))
+ break;
+ }
+
+ if (view_link == NULL && default_view)
+ BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
+}
+
+const char *IMB_colormanagement_role_colorspace_name_get(int role)
+{
+ switch (role) {
+ case COLOR_ROLE_SCENE_LINEAR:
+ return global_role_scene_linear;
+ break;
+ case COLOR_ROLE_COLOR_PICKING:
+ return global_role_color_picking;
+ break;
+ case COLOR_ROLE_TEXTURE_PAINTING:
+ return global_role_texture_painting;
+ break;
+ case COLOR_ROLE_DEFAULT_SEQUENCER:
+ return global_role_default_sequencer;
+ break;
+ case COLOR_ROLE_DEFAULT_FLOAT:
+ return global_role_default_float;
+ break;
+ case COLOR_ROLE_DEFAULT_BYTE:
+ return global_role_default_byte;
+ break;
+ default:
+ printf("Unknown role was passed to %s\n", __func__);
+ BLI_assert(0);
+ }
+
+ return NULL;
+}
+
+void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
+{
+ ColorSpace *colorspace = colormanage_colorspace_get_named(name);
+ if (colorspace) {
+ ibuf->rect_colorspace = colorspace;
+
+ if (colorspace->is_data)
+ ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
+ else
+ ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
+ }
+}
+
+/*********************** Threaded display buffer transform routines *************************/
+
+typedef struct DisplayBufferThread {
+ ColormanageProcessor *cm_processor;
+
+ float *buffer;
+ unsigned char *byte_buffer;
+
+ float *display_buffer;
+ unsigned char *display_buffer_byte;
+
+ int width;
+ int start_line;
+ int tot_line;
+
+ int channels;
+ float dither;
+ int predivide;
+ int is_data;
+
+ const char *byte_colorspace;
+ const char *float_colorspace;
+} DisplayBufferThread;
+
+typedef struct DisplayBufferInitData {
+ ImBuf *ibuf;
+ ColormanageProcessor *cm_processor;
+ float *buffer;
+ unsigned char *byte_buffer;
+
+ float *display_buffer;
+ unsigned char *display_buffer_byte;
+
+ int width;
+
+ const char *byte_colorspace;
+ const char *float_colorspace;
+} DisplayBufferInitData;
+
+static void display_buffer_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
+{
+ DisplayBufferThread *handle = (DisplayBufferThread *) handle_v;
+ DisplayBufferInitData *init_data = (DisplayBufferInitData *) init_data_v;
+ ImBuf *ibuf = init_data->ibuf;
+
+ int predivide = ibuf->flags & IB_cm_predivide;
+ int channels = ibuf->channels;
+ float dither = ibuf->dither;
+ int is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
+
+ int offset = channels * start_line * ibuf->x;
+ int display_buffer_byte_offset = DISPLAY_BUFFER_CHANNELS * start_line * ibuf->x;
+
+ memset(handle, 0, sizeof(DisplayBufferThread));
+
+ handle->cm_processor = init_data->cm_processor;
+
+ if (init_data->buffer)
+ handle->buffer = init_data->buffer + offset;
+
+ if (init_data->byte_buffer)
+ handle->byte_buffer = init_data->byte_buffer + offset;
+
+ if (init_data->display_buffer)
+ handle->display_buffer = init_data->display_buffer + offset;
+
+ if (init_data->display_buffer_byte)
+ handle->display_buffer_byte = init_data->display_buffer_byte + display_buffer_byte_offset;
+
+ handle->width = ibuf->x;
+
+ handle->start_line = start_line;
+ handle->tot_line = tot_line;
+
+ handle->channels = channels;
+ handle->dither = dither;
+ handle->predivide = predivide;
+ handle->is_data = is_data;
+
+ handle->byte_colorspace = init_data->byte_colorspace;
+ handle->float_colorspace = init_data->float_colorspace;
+}
+
+static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
+{
+ float *linear_buffer = NULL;
+
+ int channels = handle->channels;
+ int width = handle->width;
+ int height = handle->tot_line;
+
+ int buffer_size = channels * width * height;
+
+ int predivide = handle->predivide;
+ int is_data = handle->is_data;
+
+ linear_buffer = MEM_callocN(buffer_size * sizeof(float), "color conversion linear buffer");
+
+ if (!handle->buffer) {
+ unsigned char *byte_buffer = handle->byte_buffer;
+
+ const char *from_colorspace = handle->byte_colorspace;
+ const char *to_colorspace = global_role_scene_linear;
+
+ float *fp;
+ unsigned char *cp;
+ int i;
+
+ /* 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++)
+ {
+ *fp = (float)(*cp) / 255.0f;
+ }
+
+ if (!is_data) {
+ /* convert float buffer to scene linear space */
+ IMB_colormanagement_transform(linear_buffer, width, height, channels,
+ from_colorspace, to_colorspace, predivide);
+ }
+ }
+ else if (handle->float_colorspace) {
+ /* currently float is non-linear only in sequencer, which is working
+ * in it's own color space even to handle float buffers.
+ * This color space is the same for byte and float images.
+ * Need to convert float buffer to linear space before applying display transform
+ */
+
+ const char *from_colorspace = handle->float_colorspace;
+ const char *to_colorspace = global_role_scene_linear;
+
+ memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float));
+
+ IMB_colormanagement_transform(linear_buffer, width, height, channels,
+ from_colorspace, to_colorspace, predivide);
+ }
+ else {
+ /* some processors would want to modify float original buffer
+ * before converting it into display byte buffer, so we need to
+ * make sure original's ImBuf buffers wouldn't be modified by
+ * using duplicated buffer here
+ *
+ * NOTE: MEM_dupallocN can't be used because buffer could be
+ * specified as an offset inside allocated buffer
+ */
+
+ memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float));
+ }
+
+ return linear_buffer;
+}
+
+static void *do_display_buffer_apply_thread(void *handle_v)
+{
+ DisplayBufferThread *handle = (DisplayBufferThread *) handle_v;
+ ColormanageProcessor *cm_processor = handle->cm_processor;
+ float *display_buffer = handle->display_buffer;
+ unsigned char *display_buffer_byte = handle->display_buffer_byte;
+ int channels = handle->channels;
+ int width = handle->width;
+ int height = handle->tot_line;
+ float dither = handle->dither;
+ int predivide = handle->predivide;
+ int is_data = handle->is_data;
+
+ if (cm_processor == NULL) {
+ if (display_buffer_byte) {
+ IMB_buffer_byte_from_byte(display_buffer_byte, handle->byte_buffer, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ FALSE, width, height, width, width);
+ }
+
+ if (display_buffer) {
+ IMB_buffer_float_from_byte(display_buffer, handle->byte_buffer, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ FALSE, width, height, width, width);
+ }
+ }
+ else {
+ float *linear_buffer = display_buffer_apply_get_linear_buffer(handle);
+
+ if (is_data) {
+ /* special case for data buffers - no color space conversions,
+ * only generate byte buffers
+ */
+ }
+ else {
+ /* apply processor */
+ IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels, predivide);
+ }
+
+ /* copy result to output buffers */
+ if (display_buffer_byte) {
+ /* do conversion */
+ IMB_buffer_byte_from_float(display_buffer_byte, linear_buffer,
+ channels, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ predivide, width, height, width, width);
+ }
+
+ if (display_buffer)
+ memcpy(display_buffer, linear_buffer, width * height * channels * sizeof(float));
+
+ MEM_freeN(linear_buffer);
+ }
+
+ return NULL;
+}
+
+static void display_buffer_apply_threaded(ImBuf *ibuf, float *buffer, unsigned char *byte_buffer, float *display_buffer,
+ unsigned char *display_buffer_byte, ColormanageProcessor *cm_processor)
+{
+ DisplayBufferInitData init_data;
+
+ init_data.ibuf = ibuf;
+ init_data.cm_processor = cm_processor;
+ init_data.buffer = buffer;
+ init_data.byte_buffer = byte_buffer;
+ init_data.display_buffer = display_buffer;
+ init_data.display_buffer_byte = display_buffer_byte;
+
+ if (ibuf->rect_colorspace != NULL) {
+ init_data.byte_colorspace = ibuf->rect_colorspace->name;
+ }
+ else {
+ /* happens for viewer images, which are not so simple to determine where to
+ * set image buffer's color spaces
+ */
+ init_data.byte_colorspace = global_role_default_byte;
+ }
+
+ if (ibuf->float_colorspace != NULL) {
+ /* sequencer stores float buffers in non-linear space */
+ init_data.float_colorspace = ibuf->float_colorspace->name;
+ }
+ else {
+ init_data.float_colorspace = NULL;
+ }
+
+ IMB_processor_apply_threaded(ibuf->y, sizeof(DisplayBufferThread), &init_data,
+ display_buffer_init_handle, do_display_buffer_apply_thread);
+}
+
+static void colormanage_display_buffer_process_ex(ImBuf *ibuf, float *display_buffer, unsigned char *display_buffer_byte,
+ const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ ColormanageProcessor *cm_processor = NULL;
+ int skip_transform = FALSE;
+
+ /* if we're going to transform byte buffer, check whether transformation would
+ * happen to the same color space as byte buffer itself is
+ * this would save byte -> float -> byte conversions making display buffer
+ * computation noticeable faster
+ */
+ if (ibuf->rect_float == NULL && ibuf->rect_colorspace) {
+ if ((view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) == 0 &&
+ view_settings->exposure == 0.0f &&
+ view_settings->gamma == 1.0f)
+ {
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+
+ if (config) {
+ const char *display = display_settings->display_device;
+ const char *view = view_settings->view_transform;
+ const char *from_colorspace = ibuf->rect_colorspace->name;
+ const char *to_colorspace = OCIO_configGetDisplayColorSpaceName(config, display, view);
+
+ if (!strcmp(from_colorspace, to_colorspace))
+ skip_transform = TRUE;
+
+ OCIO_configRelease(config);
+ }
+ }
+ }
+
+ if (skip_transform == FALSE)
+ cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+
+ display_buffer_apply_threaded(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect,
+ display_buffer, display_buffer_byte, cm_processor);
+
+ if (cm_processor)
+ IMB_colormanagement_processor_free(cm_processor);
+}
+
+static void colormanage_display_buffer_process(ImBuf *ibuf, unsigned char *display_buffer,
+ const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ colormanage_display_buffer_process_ex(ibuf, NULL, display_buffer, view_settings, display_settings);
+}
+
+/*********************** Threaded processor transform routines *************************/
+
+typedef struct ProcessorTransformThread {
+ ColormanageProcessor *cm_processor;
+ float *buffer;
+ int width;
+ int start_line;
+ int tot_line;
+ int channels;
+ int predivide;
+} ProcessorTransformThread;
+
+typedef struct ProcessorTransformInit {
+ ColormanageProcessor *cm_processor;
+ float *buffer;
+ int width;
+ int height;
+ int channels;
+ int predivide;
+} ProcessorTransformInitData;
+
+static void processor_transform_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
+{
+ ProcessorTransformThread *handle = (ProcessorTransformThread *) handle_v;
+ ProcessorTransformInitData *init_data = (ProcessorTransformInitData *) init_data_v;
+
+ int channels = init_data->channels;
+ int width = init_data->width;
+ int predivide = init_data->predivide;
+
+ int offset = channels * start_line * width;
+
+ memset(handle, 0, sizeof(ProcessorTransformThread));
+
+ handle->cm_processor = init_data->cm_processor;
+
+ handle->buffer = init_data->buffer + offset;
+
+ handle->width = width;
+
+ handle->start_line = start_line;
+ handle->tot_line = tot_line;
+
+ handle->channels = channels;
+ handle->predivide = predivide;
+}
+
+static void *do_processor_transform_thread(void *handle_v)
+{
+ ProcessorTransformThread *handle = (ProcessorTransformThread *) handle_v;
+ float *buffer = handle->buffer;
+ int channels = handle->channels;
+ int width = handle->width;
+ int height = handle->tot_line;
+ int predivide = handle->predivide;
+
+ IMB_colormanagement_processor_apply(handle->cm_processor, buffer, width, height, channels, predivide);
+
+ return NULL;
+}
+
+static void processor_transform_apply_threaded(float *buffer, int width, int height, int channels,
+ ColormanageProcessor *cm_processor, int predivide)
+{
+ ProcessorTransformInitData init_data;
+
+ init_data.cm_processor = cm_processor;
+ init_data.buffer = buffer;
+ init_data.width = width;
+ init_data.height = height;
+ init_data.channels = channels;
+ init_data.predivide = predivide;
+
+ IMB_processor_apply_threaded(height, sizeof(ProcessorTransformThread), &init_data,
+ processor_transform_init_handle, do_processor_transform_thread);
+}
+
+/*********************** Color space transformation functions *************************/
+
+/* convert the whole buffer from specified by name color space to another - internal implementation */
+static void colormanagement_transform_ex(float *buffer, int width, int height, int channels, const char *from_colorspace,
+ const char *to_colorspace, int predivide, int do_threaded)
+{
+ ColormanageProcessor *cm_processor;
+
+ if (from_colorspace[0] == '\0') {
+ return;
+ }
+
+ if (!strcmp(from_colorspace, to_colorspace)) {
+ /* if source and destination color spaces are identical, skip
+ * threading overhead and simply do nothing
+ */
+ return;
+ }
+
+ cm_processor = IMB_colormanagement_colorspace_processor_new(from_colorspace, to_colorspace);
+
+ if (do_threaded)
+ processor_transform_apply_threaded(buffer, width, height, channels, cm_processor, predivide);
+ else
+ IMB_colormanagement_processor_apply(cm_processor, buffer, width, height, channels, predivide);
+
+ IMB_colormanagement_processor_free(cm_processor);
+}
+
+/* convert the whole buffer from specified by name color space to another */
+void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
+ const char *from_colorspace, const char *to_colorspace, int predivide)
+{
+ colormanagement_transform_ex(buffer, width, height, channels, from_colorspace, to_colorspace, predivide, FALSE);
+}
+
+/* convert the whole buffer from specified by name color space to another
+ * will do threaded conversion
+ */
+void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels,
+ const char *from_colorspace, const char *to_colorspace, int predivide)
+{
+ colormanagement_transform_ex(buffer, width, height, channels, from_colorspace, to_colorspace, predivide, TRUE);
+}
+
+void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace)
+{
+ ColormanageProcessor *cm_processor;
+
+ if (from_colorspace[0] == '\0') {
+ return;
+ }
+
+ if (!strcmp(from_colorspace, to_colorspace)) {
+ /* if source and destination color spaces are identical, skip
+ * threading overhead and simply do nothing
+ */
+ return;
+ }
+
+ cm_processor = IMB_colormanagement_colorspace_processor_new(from_colorspace, to_colorspace);
+
+ IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
+
+ IMB_colormanagement_processor_free(cm_processor);
+}
+
+/* convert pixel from specified by descriptor color space to scene linear
+ * used by performance-critical areas such as renderer and baker
+ */
+void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace)
+{
+ ConstProcessorRcPtr *processor;
+
+ if (!colorspace) {
+ /* OCIO_TODO: make sure it never happens */
+
+ printf("%s: perform conversion from unknown color space\n", __func__);
+
+ return;
+ }
+
+ processor = colorspace_to_scene_linear_processor(colorspace);
+
+ if (processor)
+ OCIO_processorApplyRGB(processor, pixel);
+}
+
+/* same as above, but converts colors in opposite direction */
+void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpace *colorspace)
+{
+ ConstProcessorRcPtr *processor;
+
+ if (!colorspace) {
+ /* OCIO_TODO: make sure it never happens */
+
+ printf("%s: perform conversion from unknown color space\n", __func__);
+
+ return;
+ }
+
+ processor = colorspace_from_scene_linear_processor(colorspace);
+
+ if (processor)
+ OCIO_processorApplyRGB(processor, pixel);
+}
+
+void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide)
+{
+ ConstProcessorRcPtr *processor;
+
+ if (!colorspace) {
+ /* OCIO_TODO: make sure it never happens */
+
+ printf("%s: perform conversion from unknown color space\n", __func__);
+
+ return;
+ }
+
+ processor = colorspace_to_scene_linear_processor(colorspace);
+
+ if (processor) {
+ PackedImageDesc *img;
+
+ img = OCIO_createPackedImageDesc(buffer, width, height, channels, sizeof(float),
+ channels * sizeof(float), channels * sizeof(float) * width);
+
+ if (predivide)
+ OCIO_processorApply_predivide(processor, img);
+ else
+ OCIO_processorApply(processor, img);
+
+ OCIO_packedImageDescRelease(img);
+ }
+}
+
+/* convert pixel from scene linear to display space using default view
+ * used by performance-critical areas such as color-related widgets where we want to reduce
+ * amount of per-widget allocations
+ */
+void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
+{
+ ConstProcessorRcPtr *processor;
+
+ processor = display_from_scene_linear_processor(display);
+
+ if (processor)
+ OCIO_processorApplyRGB(processor, pixel);
+}
+
+/* same as above, but converts color in opposite direction */
+void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display)
+{
+ ConstProcessorRcPtr *processor;
+
+ processor = display_to_scene_linear_processor(display);
+
+ if (processor)
+ OCIO_processorApplyRGB(processor, pixel);
+}
+
+void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4],
+ const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ ColormanageProcessor *cm_processor;
+
+ copy_v4_v4(result, pixel);
+
+ cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+ IMB_colormanagement_processor_apply_v4(cm_processor, result);
+ IMB_colormanagement_processor_free(cm_processor);
+}
+
+void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3],
+ const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ ColormanageProcessor *cm_processor;
+
+ copy_v3_v3(result, pixel);
+
+ cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+ IMB_colormanagement_processor_apply_v3(cm_processor, result);
+ IMB_colormanagement_processor_free(cm_processor);
+}
+
+void IMB_colormanagement_imbuf_assign_float_space(ImBuf *ibuf, ColorManagedColorspaceSettings *colorspace_settings)
+{
+ ibuf->float_colorspace = colormanage_colorspace_get_named(colorspace_settings->name);
+}
+
+void IMB_colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ /* OCIO_TODO: byte buffer management is not supported here yet */
+ if (!ibuf->rect_float)
+ return;
+
+ if (global_tot_display == 0 || global_tot_view == 0) {
+ IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB,
+ ibuf->flags & IB_cm_predivide, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ }
+ else {
+ colormanage_display_buffer_process_ex(ibuf, ibuf->rect_float, NULL, view_settings, display_settings);
+ }
+}
+
+static void imbuf_verify_float(ImBuf *ibuf)
+{
+ /* multiple threads could request for display buffer at once and in case
+ * view transform is not used it'll lead to display buffer calculated
+ * several times
+ * it is harmless, but would take much more time (assuming thread lock
+ * happens faster than running float->byte conversion for average image)
+ */
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) {
+ IMB_rect_from_float(ibuf);
+
+ ibuf->userflags &= ~IB_RECT_INVALID;
+ }
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+}
+
+/*********************** Public display buffers interfaces *************************/
+
+/* acquire display buffer for given image buffer using specified view and display settings */
+unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings, void **cache_handle)
+{
+ *cache_handle = NULL;
+
+ if (!ibuf->x || !ibuf->y)
+ return NULL;
+
+ if (global_tot_display == 0 || global_tot_view == 0) {
+ /* if there's no view transform or display transforms, fallback to standard sRGB/linear conversion
+ * the same logic would be used if OCIO is disabled
+ */
+
+ imbuf_verify_float(ibuf);
+
+ return (unsigned char *) ibuf->rect;
+ }
+ else {
+ unsigned char *display_buffer;
+ int buffer_size;
+ ColormanageCacheViewSettings cache_view_settings;
+ ColormanageCacheDisplaySettings cache_display_settings;
+ ColorManagedViewSettings default_view_settings;
+ const ColorManagedViewSettings *applied_view_settings;
+
+ if (view_settings) {
+ applied_view_settings = view_settings;
+ }
+ else {
+ /* if no view settings were specified, use default display transformation
+ * this happens for images which don't want to be displayed with render settings
+ */
+
+ init_default_view_settings(display_settings, &default_view_settings);
+ applied_view_settings = &default_view_settings;
+ }
+
+ colormanage_view_settings_to_cache(&cache_view_settings, applied_view_settings);
+ colormanage_display_settings_to_cache(&cache_display_settings, display_settings);
+
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ /* ensure color management bit fields exists */
+ if (!ibuf->display_buffer_flags) {
+ 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) {
+ /* all display buffers were marked as invalid from other areas,
+ * now propagate this flag to internal color management routines
+ */
+ memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int));
+
+ ibuf->userflags &= ~IB_DISPLAY_BUFFER_INVALID;
+ }
+
+ display_buffer = colormanage_cache_get(ibuf, &cache_view_settings, &cache_display_settings, cache_handle);
+
+ if (display_buffer) {
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+ return display_buffer;
+ }
+
+ buffer_size = DISPLAY_BUFFER_CHANNELS * ibuf->x * ibuf->y * sizeof(float);
+ display_buffer = MEM_callocN(buffer_size, "imbuf display buffer");
+
+ colormanage_display_buffer_process(ibuf, display_buffer, applied_view_settings, display_settings);
+
+ colormanage_cache_put(ibuf, &cache_view_settings, &cache_display_settings, display_buffer, cache_handle);
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+
+ return display_buffer;
+ }
+}
+
+/* same as IMB_display_buffer_acquire but gets view and display settings from context */
+unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle)
+{
+ ColorManagedViewSettings *view_settings;
+ ColorManagedDisplaySettings *display_settings;
+
+ display_transform_get_from_ctx(C, &view_settings, &display_settings);
+
+ return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle);
+}
+
+/* covert float buffer to display space and store it in image buffer's byte array */
+void IMB_display_buffer_to_imbuf_rect(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ if (global_tot_display == 0 || global_tot_view == 0) {
+ imbuf_verify_float(ibuf);
+ }
+ else {
+ if (!ibuf->rect) {
+ imb_addrectImBuf(ibuf);
+ }
+
+ colormanage_display_buffer_process(ibuf, (unsigned char *) ibuf->rect, view_settings, display_settings);
+ }
+}
+
+void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height,
+ int channels, const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings, int predivide)
+{
+ if (global_tot_display == 0 || global_tot_view == 0) {
+ IMB_buffer_byte_from_float(display_buffer, linear_buffer, channels, 0.0f, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, FALSE,
+ width, height, width, width);
+ }
+ else {
+ float *buffer;
+ ColormanageProcessor *cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+
+ buffer = MEM_callocN(channels * width * height * sizeof(float), "display transform temp buffer");
+ memcpy(buffer, linear_buffer, channels * width * height * sizeof(float));
+
+ IMB_colormanagement_processor_apply(cm_processor, buffer, width, height, channels, predivide);
+
+ IMB_colormanagement_processor_free(cm_processor);
+
+ IMB_buffer_byte_from_float(display_buffer, buffer, channels, 0.0f, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ FALSE, width, height, width, width);
+
+ MEM_freeN(buffer);
+ }
+}
+
+void IMB_display_buffer_release(void *cache_handle)
+{
+ if (cache_handle) {
+ BLI_lock_thread(LOCK_COLORMANAGE);
+
+ colormanage_cache_handle_release(cache_handle);
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+ }
+}
+
+/*********************** Display functions *************************/
+
+ColorManagedDisplay *colormanage_display_get_default(void)
+{
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+ const char *display;
+
+ if (!config) {
+ /* no valid OCIO configuration, can't get default display */
+
+ return NULL;
+ }
+
+ display = OCIO_configGetDefaultDisplay(config);
+
+ OCIO_configRelease(config);
+
+ if (display[0] == '\0')
+ return NULL;
+
+ return colormanage_display_get_named(display);
+}
+
+ColorManagedDisplay *colormanage_display_add(const char *name)
+{
+ ColorManagedDisplay *display;
+ int index = 0;
+
+ if (global_displays.last) {
+ ColorManagedDisplay *last_display = global_displays.last;
+
+ index = last_display->index;
+ }
+
+ display = MEM_callocN(sizeof(ColorManagedDisplay), "ColorManagedDisplay");
+
+ display->index = index + 1;
+
+ BLI_strncpy(display->name, name, sizeof(display->name));
+
+ BLI_addtail(&global_displays, display);
+
+ return display;
+}
+
+ColorManagedDisplay *colormanage_display_get_named(const char *name)
+{
+ ColorManagedDisplay *display;
+
+ for (display = global_displays.first; display; display = display->next) {
+ if (!strcmp(display->name, name))
+ return display;
+ }
+
+ return NULL;
+}
+
+ColorManagedDisplay *colormanage_display_get_indexed(int index)
+{
+ /* display indices are 1-based */
+ return BLI_findlink(&global_displays, index - 1);
+}
+
+int IMB_colormanagement_display_get_named_index(const char *name)
+{
+ ColorManagedDisplay *display;
+
+ display = colormanage_display_get_named(name);
+
+ if (display) {
+ return display->index;
+ }
+
+ return 0;
+}
+
+const char *IMB_colormanagement_display_get_indexed_name(int index)
+{
+ ColorManagedDisplay *display;
+
+ display = colormanage_display_get_indexed(index);
+
+ if (display) {
+ return display->name;
+ }
+
+ return NULL;
+}
+
+const char *IMB_colormanagement_display_get_default_name(void)
+{
+ ColorManagedDisplay *display = colormanage_display_get_default();
+
+ return display->name;
+}
+
+/* used by performance-critical pixel processing areas, such as color widgets */
+ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name)
+{
+ return colormanage_display_get_named(name);
+}
+
+/*********************** View functions *************************/
+
+const char *colormanage_view_get_default_name(const ColorManagedDisplay *display)
+{
+ ConstConfigRcPtr *config = OCIO_getCurrentConfig();
+ const char *name;
+
+ if (!config) {
+ /* no valid OCIO configuration, can't get default view */
+
+ return NULL;
+ }
+
+ name = OCIO_configGetDefaultView(config, display->name);
+
+ OCIO_configRelease(config);
+
+ return name;
+}
+
+ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *display)
+{
+ const char *name = colormanage_view_get_default_name(display);
+
+ if (!name || name[0] == '\0')
+ return NULL;
+
+ return colormanage_view_get_named(name);
+}
+
+ColorManagedView *colormanage_view_add(const char *name)
+{
+ ColorManagedView *view;
+ int index = global_tot_view;
+
+ view = MEM_callocN(sizeof(ColorManagedView), "ColorManagedView");
+ view->index = index + 1;
+ BLI_strncpy(view->name, name, sizeof(view->name));
+
+ BLI_addtail(&global_views, view);
+
+ global_tot_view++;
+
+ return view;
+}
+
+ColorManagedView *colormanage_view_get_named(const char *name)
+{
+ ColorManagedView *view;
+
+ for (view = global_views.first; view; view = view->next) {
+ if (!strcmp(view->name, name))
+ return view;
+ }
+
+ return NULL;
+}
+
+ColorManagedView *colormanage_view_get_indexed(int index)
+{
+ /* view transform indices are 1-based */
+ return BLI_findlink(&global_views, index - 1);
+}
+
+int IMB_colormanagement_view_get_named_index(const char *name)
+{
+ ColorManagedView *view = colormanage_view_get_named(name);
+
+ if (view) {
+ return view->index;
+ }
+
+ return 0;
+}
+
+const char *IMB_colormanagement_view_get_indexed_name(int index)
+{
+ ColorManagedView *view = colormanage_view_get_indexed(index);
+
+ if (view) {
+ return view->name;
+ }
+
+ return NULL;
+}
+
+const char *IMB_colormanagement_view_get_default_name(const char *display_name)
+{
+ ColorManagedDisplay *display = colormanage_display_get_named(display_name);
+ ColorManagedView *view = NULL;
+
+ if (display)
+ view = colormanage_view_get_default(display);
+
+ if (view)
+ return view->name;
+
+ return NULL;
+}
+
+/*********************** Color space functions *************************/
+
+static void colormanage_description_strip(char *description)
+{
+ int i, n;
+
+ for (i = strlen(description) - 1; i >= 0; i--) {
+ if (ELEM(description[i], '\r', '\n')) {
+ description[i] = '\0';
+ }
+ else {
+ break;
+ }
+ }
+
+ for (i = 0, n = strlen(description); i < n; i++) {
+ if (ELEM(description[i], '\r', '\n')) {
+ description[i] = ' ';
+ }
+ }
+}
+
+ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible, int is_data)
+{
+ ColorSpace *colorspace, *prev_space;
+ int counter = 1;
+
+ colorspace = MEM_callocN(sizeof(ColorSpace), "ColorSpace");
+
+ BLI_strncpy(colorspace->name, name, sizeof(colorspace->name));
+
+ if (description) {
+ BLI_strncpy(colorspace->description, description, sizeof(colorspace->description));
+
+ colormanage_description_strip(colorspace->description);
+ }
+
+ colorspace->is_invertible = is_invertible;
+ colorspace->is_data = is_data;
+
+ for (prev_space = global_colorspaces.first; prev_space; prev_space = prev_space->next) {
+ if (BLI_strcasecmp(prev_space->name, colorspace->name) > 0)
+ break;
+
+ prev_space->index = counter++;
+ }
+
+ if (!prev_space)
+ BLI_addtail(&global_colorspaces, colorspace);
+ else
+ BLI_insertlinkbefore(&global_colorspaces, prev_space, colorspace);
+
+ colorspace->index = counter++;
+ for (; prev_space; prev_space = prev_space->next) {
+ prev_space->index = counter++;
+ }
+
+ global_tot_colorspace++;
+
+ return colorspace;
+}
+
+ColorSpace *colormanage_colorspace_get_named(const char *name)
+{
+ ColorSpace *colorspace;
+
+ for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) {
+ if (!strcmp(colorspace->name, name))
+ return colorspace;
+ }
+
+ return NULL;
+}
+
+ColorSpace *colormanage_colorspace_get_roled(int role)
+{
+ const char *role_colorspace = IMB_colormanagement_role_colorspace_name_get(role);
+
+ return colormanage_colorspace_get_named(role_colorspace);
+}
+
+ColorSpace *colormanage_colorspace_get_indexed(int index)
+{
+ /* display indices are 1-based */
+ return BLI_findlink(&global_colorspaces, index - 1);
+}
+
+int IMB_colormanagement_colorspace_get_named_index(const char *name)
+{
+ ColorSpace *colorspace;
+
+ colorspace = colormanage_colorspace_get_named(name);
+
+ if (colorspace) {
+ return colorspace->index;
+ }
+
+ return 0;
+}
+
+const char *IMB_colormanagement_colorspace_get_indexed_name(int index)
+{
+ ColorSpace *colorspace;
+
+ colorspace = colormanage_colorspace_get_indexed(index);
+
+ if (colorspace) {
+ return colorspace->name;
+ }
+
+ return "";
+}
+
+void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
+{
+ ImFileType *type;
+
+ for (type = IMB_FILE_TYPES; type->is_a; type++) {
+ if (type->save && type->ftype(type, ibuf)) {
+ const char *role_colorspace;
+
+ role_colorspace = IMB_colormanagement_role_colorspace_name_get(type->default_save_role);
+
+ BLI_strncpy(colorspace_settings->name, role_colorspace, sizeof(colorspace_settings->name));
+ }
+ }
+}
+
+/*********************** RNA helper functions *************************/
+
+void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem)
+{
+ ColorManagedDisplay *display;
+
+ for (display = global_displays.first; display; display = display->next) {
+ EnumPropertyItem item;
+
+ item.value = display->index;
+ item.name = display->name;
+ item.identifier = display->name;
+ item.icon = 0;
+ item.description = "";
+
+ RNA_enum_item_add(items, totitem, &item);
+ }
+}
+
+static void colormanagement_view_item_add(EnumPropertyItem **items, int *totitem, ColorManagedView *view)
+{
+ EnumPropertyItem item;
+
+ item.value = view->index;
+ item.name = view->name;
+ item.identifier = view->name;
+ item.icon = 0;
+ item.description = "";
+
+ RNA_enum_item_add(items, totitem, &item);
+}
+
+void IMB_colormanagement_view_items_add(EnumPropertyItem **items, int *totitem, const char *display_name)
+{
+ ColorManagedDisplay *display = colormanage_display_get_named(display_name);
+ ColorManagedView *view;
+
+ if (display) {
+ LinkData *display_view;
+
+ for (display_view = display->views.first; display_view; display_view = display_view->next) {
+ view = display_view->data;
+
+ colormanagement_view_item_add(items, totitem, view);
+ }
+ }
+}
+
+void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *totitem)
+{
+ ColorSpace *colorspace;
+
+ for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) {
+ EnumPropertyItem item;
+
+ if (!colorspace->is_invertible)
+ continue;
+
+ item.value = colorspace->index;
+ item.name = colorspace->name;
+ item.identifier = colorspace->name;
+ item.icon = 0;
+
+ if (colorspace->description)
+ item.description = colorspace->description;
+ else
+ item.description = "";
+
+ RNA_enum_item_add(items, totitem, &item);
+ }
+}
+
+/*********************** Partial display buffer update *************************/
+
+/*
+ * Partial display update is supposed to be used by such areas as
+ * compositor and renderer, This areas are calculating tiles of the
+ * images and because of performance reasons only this tiles should
+ * be color managed.
+ * This gives nice visual feedback without slowing things down.
+ *
+ * Updating happens for active display transformation only, all
+ * the rest buffers would be marked as dirty
+ */
+
+static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffer, const float *linear_buffer,
+ const unsigned char *byte_buffer, int display_stride, int linear_stride,
+ int linear_offset_x, int linear_offset_y, ColormanageProcessor *cm_processor,
+ int xmin, int ymin, int xmax, int ymax)
+{
+ int x, y;
+ int channels = ibuf->channels;
+ int predivide = ibuf->flags & IB_cm_predivide;
+ float dither = ibuf->dither;
+ ColorSpace *rect_colorspace = ibuf->rect_colorspace;
+ float *display_buffer_float = NULL;
+ int width = xmax - xmin;
+ int height = ymax - ymin;
+ int is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
+
+ if (dither != 0.0f) {
+ display_buffer_float = MEM_callocN(channels * width * height * sizeof(float), "display buffer for dither");
+ }
+
+ for (y = ymin; y < ymax; y++) {
+ for (x = xmin; x < xmax; x++) {
+ int display_index = (y * display_stride + x) * channels;
+ int linear_index = ((y - linear_offset_y) * linear_stride + (x - linear_offset_x)) * channels;
+ float pixel[4];
+
+ if (linear_buffer) {
+ copy_v4_v4(pixel, (float *) linear_buffer + linear_index);
+ }
+ else if (byte_buffer) {
+ rgba_uchar_to_float(pixel, byte_buffer + linear_index);
+
+ IMB_colormanagement_colorspace_to_scene_linear_v3(pixel, rect_colorspace);
+ }
+
+ if (!is_data) {
+ if (predivide)
+ IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
+ else
+ IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
+ }
+
+ if (display_buffer_float) {
+ int index = ((y - ymin) * width + (x - xmin)) * channels;
+
+ copy_v4_v4(display_buffer_float + index, pixel);
+ }
+ else {
+ rgba_float_to_uchar(display_buffer + display_index, pixel);
+ }
+ }
+ }
+
+ if (display_buffer_float) {
+ int display_index = (ymin * display_stride + xmin) * channels;
+
+ IMB_buffer_byte_from_float(display_buffer + display_index, display_buffer_float, channels, dither,
+ IB_PROFILE_SRGB, IB_PROFILE_SRGB, FALSE, width, height, display_stride, width);
+
+ MEM_freeN(display_buffer_float);
+ }
+}
+
+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)
+{
+ if (ibuf->rect && ibuf->rect_float) {
+ /* update byte buffer created by legacy color management */
+
+ unsigned char *rect = (unsigned char *) ibuf->rect;
+ int predivide = ibuf->flags & IB_cm_predivide;
+ int channels = ibuf->channels;
+ int width = xmax - xmin;
+ int height = ymax - ymin;
+ int rect_index = (ymin * ibuf->x + xmin) * channels;
+ int linear_index = ((ymin - offset_y) * stride + (xmin - offset_x)) * channels;
+
+ IMB_buffer_byte_from_float(rect + rect_index, linear_buffer + linear_index, channels, ibuf->dither,
+ IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide, width, height, ibuf->x, stride);
+ }
+
+ if (ibuf->display_buffer_flags) {
+ ColormanageCacheViewSettings cache_view_settings;
+ ColormanageCacheDisplaySettings cache_display_settings;
+ void *cache_handle = NULL;
+ unsigned char *display_buffer = NULL;
+ int view_flag, display_index, buffer_width;
+
+ colormanage_view_settings_to_cache(&cache_view_settings, view_settings);
+ colormanage_display_settings_to_cache(&cache_display_settings, display_settings);
+
+ view_flag = 1 << (cache_view_settings.view - 1);
+ display_index = cache_display_settings.display - 1;
+
+ BLI_lock_thread(LOCK_COLORMANAGE);
+ if ((ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) == 0)
+ display_buffer = colormanage_cache_get(ibuf, &cache_view_settings, &cache_display_settings, &cache_handle);
+
+ /* in some rare cases buffer's dimension could be changing directly from
+ * different thread
+ * this i.e. happens when image editor acquires render result
+ */
+ buffer_width = ibuf->x;
+
+ /* mark all other buffers as invalid */
+ memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int));
+ ibuf->display_buffer_flags[display_index] |= view_flag;
+
+ BLI_unlock_thread(LOCK_COLORMANAGE);
+
+ if (display_buffer) {
+ ColormanageProcessor *cm_processor;
+
+ cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+
+ partial_buffer_update_rect(ibuf, display_buffer, linear_buffer, byte_buffer, buffer_width, stride,
+ offset_x, offset_y, cm_processor, xmin, ymin, xmax, ymax);
+
+ IMB_colormanagement_processor_free(cm_processor);
+
+ IMB_display_buffer_release(cache_handle);
+ }
+ }
+}
+
+/*********************** Pixel processor functions *************************/
+
+ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ ColormanageProcessor *cm_processor;
+
+ 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;
+ }
+
+ 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);
+ }
+ }
+
+ return cm_processor;
+}
+
+ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
+{
+ ColormanageProcessor *cm_processor;
+
+ cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor");
+
+ cm_processor->processor = create_colorspace_transform_processor(from_colorspace, to_colorspace);
+
+ return cm_processor;
+}
+
+void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4])
+{
+ if (cm_processor->curve_mapping)
+ curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
+
+ if (cm_processor->processor)
+ OCIO_processorApplyRGBA(cm_processor->processor, pixel);
+}
+
+void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3])
+{
+ if (cm_processor->curve_mapping)
+ curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
+
+ if (cm_processor->processor)
+ OCIO_processorApplyRGB(cm_processor->processor, pixel);
+}
+
+void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height,
+ int channels, int predivide)
+{
+ /* apply curve mapping */
+ if (cm_processor->curve_mapping) {
+ int x, y;
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ float *pixel = buffer + channels * (y * width + x);
+
+ curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, channels);
+ }
+ }
+ }
+
+ if (cm_processor->processor && channels >= 3) {
+ PackedImageDesc *img;
+
+ /* apply OCIO processor */
+ img = OCIO_createPackedImageDesc(buffer, width, height, channels, sizeof(float),
+ channels * sizeof(float), channels * sizeof(float) * width);
+
+ if (predivide)
+ OCIO_processorApply_predivide(cm_processor->processor, img);
+ else
+ OCIO_processorApply(cm_processor->processor, img);
+
+ OCIO_packedImageDescRelease(img);
+ }
+}
+
+void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
+{
+ if (cm_processor->curve_mapping)
+ curvemapping_free(cm_processor->curve_mapping);
+ if (cm_processor->processor)
+ OCIO_processorRelease(cm_processor->processor);
+
+ MEM_freeN(cm_processor);
+}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 82f355e1bb2..d9d0cb86ee0 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -305,7 +305,7 @@ static const uint DDPF_SRGB = 0x40000000U;
};
- const char * getDxgiFormatString(DXGI_FORMAT dxgiFormat)
+ static const char * getDxgiFormatString(DXGI_FORMAT dxgiFormat)
{
#define CASE(format) case DXGI_FORMAT_##format: return #format
switch (dxgiFormat)
@@ -429,7 +429,7 @@ static const uint DDPF_SRGB = 0x40000000U;
#undef CASE
}
- const char * getD3d10ResourceDimensionString(D3D10_RESOURCE_DIMENSION resourceDimension)
+ static const char * getD3d10ResourceDimensionString(D3D10_RESOURCE_DIMENSION resourceDimension)
{
switch (resourceDimension)
{
@@ -534,7 +534,7 @@ namespace
} // namespace
-uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
+static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
{
for (int i = 0; i < s_d3dFormatCount; i++)
{
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 71313d4438f..7aacbf20bae 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -43,6 +43,9 @@ extern "C" {
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags)
{
return(0); /* todo: finish this function */
@@ -79,7 +82,7 @@ int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes
return(1);
}
-struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags)
+struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf * ibuf = 0;
DirectDrawSurface dds(mem, size); /* reads header */
@@ -92,6 +95,12 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags)
Color32 pixel;
Color32 *pixels = 0;
+ /* OCIO_TODO: never was able to save DDS, so can'ttest loading
+ * but profile used to be set to sRGB and can't see rect_float here, so
+ * default byte space should work fine
+ */
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
if (!imb_is_a_dds(mem))
return (0);
@@ -133,7 +142,6 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags)
if (ibuf == 0) return(0); /* memory allocation failed */
ibuf->ftype = DDS;
- ibuf->profile = IB_PROFILE_SRGB;
ibuf->dds_data.fourcc = dds.fourCC();
ibuf->dds_data.nummipmaps = dds.mipmapCount();
diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h
index 589257816e0..2316fefce69 100644
--- a/source/blender/imbuf/intern/dds/dds_api.h
+++ b/source/blender/imbuf/intern/dds/dds_api.h
@@ -32,9 +32,11 @@
extern "C" {
#endif
+#include "../../IMB_imbuf.h"
+
int imb_save_dds(struct ImBuf *ibuf, const char *name, int flags);
int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */
-struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
#ifdef __cplusplus
}
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 5ba08f1dd73..9ce5d0e30da 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -40,6 +40,9 @@
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
#include "MEM_guardedalloc.h"
/**************************** Interlace/Deinterlace **************************/
@@ -106,7 +109,7 @@ typedef struct DitherContext {
float f;
} DitherContext;
-DitherContext *create_dither_context(int w, float factor)
+static DitherContext *create_dither_context(int w, float factor)
{
DitherContext *di;
int i;
@@ -522,32 +525,34 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
void IMB_rect_from_float(ImBuf *ibuf)
{
int predivide = (ibuf->flags & IB_cm_predivide);
- int profile_from;
+ float *buffer;
+ const char *from_colorspace;
/* verify we have a float buffer */
if (ibuf->rect_float == NULL)
return;
/* create byte rect if it didn't exist yet */
- if (ibuf->rect == NULL)
- imb_addrectImBuf(ibuf);
-
- /* determine profiles */
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- profile_from = IB_PROFILE_LINEAR_RGB;
- }
- else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) {
- profile_from = IB_PROFILE_SRGB;
- }
- else {
- profile_from = IB_PROFILE_SRGB; /* should never happen */
- BLI_assert(0);
+ if (ibuf->rect == NULL) {
+ if (imb_addrectImBuf(ibuf) == 0)
+ return;
}
- /* do conversion */
- IMB_buffer_byte_from_float((uchar *)ibuf->rect, ibuf->rect_float,
- ibuf->channels, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ if (ibuf->float_colorspace == NULL)
+ from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+ else
+ from_colorspace = ibuf->float_colorspace->name;
+
+ buffer = MEM_dupallocN(ibuf->rect_float);
+
+ /* first make float buffer in byte space */
+ IMB_colormanagement_transform(buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, ibuf->rect_colorspace->name, predivide);
+
+ /* convert float to byte */
+ IMB_buffer_byte_from_float((unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ FALSE, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+
+ MEM_freeN(buffer);
/* ensure user flag is reset */
ibuf->userflags &= ~IB_RECT_INVALID;
@@ -559,7 +564,7 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
float *rect_float;
uchar *rect_byte;
int predivide = (ibuf->flags & IB_cm_predivide);
- int profile_from;
+ int profile_from = IB_PROFILE_LINEAR_RGB;
/* verify we have a float buffer */
if (ibuf->rect_float == NULL || buffer == NULL)
@@ -569,18 +574,6 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
if (ibuf->rect == NULL)
imb_addrectImBuf(ibuf);
- /* determine profiles */
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- profile_from = IB_PROFILE_LINEAR_RGB;
- }
- else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) {
- profile_from = IB_PROFILE_SRGB;
- }
- else {
- profile_from = IB_PROFILE_SRGB; /* should never happen */
- BLI_assert(0);
- }
-
/* do conversion */
rect_float = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
rect_byte = (uchar *)ibuf->rect + (x + y * ibuf->x) * 4;
@@ -589,6 +582,7 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
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);
@@ -600,26 +594,23 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
void IMB_float_from_rect(ImBuf *ibuf)
{
int predivide = (ibuf->flags & IB_cm_predivide);
- int profile_from;
/* verify if we byte and float buffers */
if (ibuf->rect == NULL)
return;
- if (ibuf->rect_float == NULL)
+ if (ibuf->rect_float == NULL) {
if (imb_addrectfloatImBuf(ibuf) == 0)
return;
-
- /* determine profiles */
- if (ibuf->profile == IB_PROFILE_NONE)
- profile_from = IB_PROFILE_LINEAR_RGB;
- else
- profile_from = IB_PROFILE_SRGB;
-
- /* do conversion */
- IMB_buffer_float_from_byte(ibuf->rect_float, (uchar *)ibuf->rect,
- IB_PROFILE_LINEAR_RGB, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ }
+
+ /* first, create float buffer in non-linear space */
+ IMB_buffer_float_from_byte(ibuf->rect_float, (unsigned char *) ibuf->rect, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ FALSE, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+
+ /* then make float be in linear space */
+ IMB_colormanagement_colorspace_to_scene_linear(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
+ ibuf->rect_colorspace, predivide);
}
/* no profile conversion */
@@ -635,63 +626,19 @@ void IMB_float_from_rect_simple(ImBuf *ibuf)
ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
-void IMB_convert_profile(ImBuf *ibuf, int profile)
-{
- int predivide = (ibuf->flags & IB_cm_predivide);
- int profile_from, profile_to;
-
- if (ibuf->profile == profile)
- return;
-
- /* determine profiles */
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
- profile_from = IB_PROFILE_LINEAR_RGB;
- else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE))
- profile_from = IB_PROFILE_SRGB;
- else {
- BLI_assert(0);
- profile_from = IB_PROFILE_SRGB; /* dummy, should never happen */
- }
-
- if (profile == IB_PROFILE_LINEAR_RGB)
- profile_to = IB_PROFILE_LINEAR_RGB;
- else if (ELEM(profile, IB_PROFILE_SRGB, IB_PROFILE_NONE))
- profile_to = IB_PROFILE_SRGB;
- else {
- BLI_assert(0);
- profile_to = IB_PROFILE_SRGB; /* dummy, should never happen */
- }
-
- /* do conversion */
- if (ibuf->rect_float) {
- IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float,
- 4, profile_to, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
- }
-
- if (ibuf->rect) {
- IMB_buffer_byte_from_byte((uchar *)ibuf->rect, (uchar *)ibuf->rect,
- profile_to, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
- }
-
- /* set new profile */
- ibuf->profile = profile;
-}
-
/* use when you need to get a buffer with a certain profile
* if the return */
+
+/* OCIO_TODO: used only by Cineon/DPX exporter which is still broken, so can not guarantee
+ * this function is working properly
+ */
float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc)
{
int predivide = (ibuf->flags & IB_cm_predivide);
- int profile_from, profile_to;
-
- /* determine profiles */
- if (ibuf->profile == IB_PROFILE_NONE)
- profile_from = IB_PROFILE_LINEAR_RGB;
- else
- profile_from = IB_PROFILE_SRGB;
+ int profile_from = IB_PROFILE_LINEAR_RGB;
+ int profile_to;
+ /* determine profile */
if (profile == IB_PROFILE_NONE)
profile_to = IB_PROFILE_LINEAR_RGB;
else
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index d67de3be68b..ed4db50035d 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -30,6 +30,8 @@
#include "IMB_imbuf_types.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+
#ifdef WITH_OPENEXR
#include "openexr/openexr_api.h"
#endif
@@ -66,34 +68,34 @@ void quicktime_exit(void);
#endif
ImFileType IMB_FILE_TYPES[] = {
- {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG},
- {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG},
- {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP},
- {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA},
- {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC},
+ {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE},
+ {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG, COLOR_ROLE_DEFAULT_BYTE},
+ {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP, COLOR_ROLE_DEFAULT_BYTE},
+ {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},
- {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, 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},
#endif
#ifdef WITH_TIFF
- {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF},
+ {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF, COLOR_ROLE_DEFAULT_BYTE},
#endif
#ifdef WITH_HDR
- {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR},
+ {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR, COLOR_ROLE_DEFAULT_FLOAT},
#endif
#ifdef WITH_OPENEXR
- {imb_initopenexr, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR},
+ {imb_initopenexr, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR, COLOR_ROLE_DEFAULT_FLOAT},
#endif
#ifdef WITH_OPENJPEG
- {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2},
+ {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2, COLOR_ROLE_DEFAULT_BYTE},
#endif
#ifdef WITH_DDS
- {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS},
+ {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS, COLOR_ROLE_DEFAULT_BYTE},
#endif
#ifdef WITH_QUICKTIME
- {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME},
+ {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME, COLOR_ROLE_DEFAULT_BYTE},
#endif
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0}
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0}
};
void imb_filetypes_init(void)
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index ea493e277f3..97316c48621 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1254,7 +1254,8 @@ struct anim *IMB_anim_open_proxy(
get_proxy_filename(anim, preview_size, fname, FALSE);
- anim->proxy_anim[i] = IMB_open_anim(fname, 0, 0);
+ /* proxies are generated in default color space */
+ anim->proxy_anim[i] = IMB_open_anim(fname, 0, 0, NULL);
anim->proxies_tried |= preview_size;
diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c
index 6b960a18277..7a8f8fcc752 100644
--- a/source/blender/imbuf/intern/indexer_dv.c
+++ b/source/blender/imbuf/intern/indexer_dv.c
@@ -385,7 +385,7 @@ static void indexer_dv_delete(anim_index_builder *idx)
MEM_freeN(This);
}
-void IMB_indexer_dv_new(anim_index_builder *idx)
+static void UNUSED_FUNCTION(IMB_indexer_dv_new)(anim_index_builder *idx)
{
indexer_dv_context *rv = MEM_callocN(
sizeof(indexer_dv_context), "index_dv builder context");
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 13b0fc1b55a..549a28a0453 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -42,6 +42,9 @@
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
typedef struct {
unsigned short imagic; /* stuff saved on disk . . */
unsigned short type;
@@ -80,21 +83,21 @@ typedef struct {
#define OFFSET_R 0 /* this is byte order dependent */
#define OFFSET_G 1
#define OFFSET_B 2
-#define OFFSET_A 3
+// #define OFFSET_A 3
#define CHANOFFSET(z) (3 - (z)) /* this is byte order dependent */
-#define TYPEMASK 0xff00
+// #define TYPEMASK 0xff00
#define BPPMASK 0x00ff
-#define ITYPE_VERBATIM 0x0000
+// #define ITYPE_VERBATIM 0x0000 // UNUSED
#define ITYPE_RLE 0x0100
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE)
-#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
+// #define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
#define BPP(type) ((type) & BPPMASK)
#define RLE(bpp) (ITYPE_RLE | (bpp))
-#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp))
-#define IBUFSIZE(pixels) ((pixels + (pixels >> 6)) << 2)
-#define RLE_NOP 0x00
+// #define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) // UNUSED
+// #define IBUFSIZE(pixels) ((pixels + (pixels >> 6)) << 2) // UNUSED
+// #define RLE_NOP 0x00
/* funcs */
static void readheader(FILE *inf, IMAGE *image);
@@ -247,7 +250,7 @@ int imb_is_a_iris(unsigned char *mem)
*
*/
-struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
+struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
unsigned int *base, *lptr = NULL;
float *fbase, *fptr = NULL;
@@ -265,6 +268,9 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
if (!imb_is_a_iris(mem)) return NULL;
+ /* OCIO_TODO: only tested with 1 byte per pixel, not sure how to test with other settings */
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
/*printf("new iris\n");*/
file_data = mem;
@@ -523,7 +529,6 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
}
ibuf->ftype = IMAGIC;
- ibuf->profile = IB_PROFILE_SRGB;
test_endian_zbuf(ibuf);
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 1fe9a5ab522..dd559c55402 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -36,6 +36,9 @@
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
#include "openjpeg.h"
#define JP2_FILEHEADER_SIZE 14
@@ -109,7 +112,7 @@ static void info_callback(const char *msg, void *client_data)
} \
} (void)0 \
-struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
+struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
int use_float = FALSE; /* for precision higher then 8 use float */
@@ -137,6 +140,9 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
if (!is_jp2 && !is_j2k)
return(NULL);
+ /* both 8, 12 and 16 bit JP2Ks are default to standard byte colorspace */
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
/* configure the event callbacks (not required) */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
@@ -641,136 +647,67 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
switch (prec) {
case 8: /* Convert blenders float color channels to 8, 12 or 16bit ints */
if (numcomps == 4) {
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0]));
- g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1]));
- b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2]));
- a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
- }
- PIXEL_LOOPER_END;
- }
- else {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]);
- g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]);
- b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]);
- a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
- }
- PIXEL_LOOPER_END;
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2]));
+ a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
}
+ PIXEL_LOOPER_END;
}
else {
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0]));
- g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1]));
- b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2]));
- }
- PIXEL_LOOPER_END;
- }
- else {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]);
- g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]);
- b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]);
- }
- PIXEL_LOOPER_END;
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2]));
}
+ PIXEL_LOOPER_END;
}
break;
case 12:
if (numcomps == 4) {
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0]));
- g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1]));
- b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2]));
- a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
- }
- PIXEL_LOOPER_END;
- }
- else {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]);
- g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]);
- b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]);
- a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
- }
- PIXEL_LOOPER_END;
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2]));
+ a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
}
+ PIXEL_LOOPER_END;
}
else {
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0]));
- g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1]));
- b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2]));
- }
- PIXEL_LOOPER_END;
- }
- else {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]);
- g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]);
- b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]);
- }
- PIXEL_LOOPER_END;
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2]));
}
+ PIXEL_LOOPER_END;
}
break;
case 16:
if (numcomps == 4) {
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0]));
- g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1]));
- b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2]));
- a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
- }
- PIXEL_LOOPER_END;
- }
- else {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]);
- g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]);
- b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]);
- a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
- }
- PIXEL_LOOPER_END;
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2]));
+ a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
}
+ PIXEL_LOOPER_END;
}
else {
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0]));
- g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1]));
- b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2]));
- }
- PIXEL_LOOPER_END;
- }
- else {
- PIXEL_LOOPER_BEGIN(rect_float)
- {
- r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]);
- g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]);
- b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]);
- }
- PIXEL_LOOPER_END;
+ PIXEL_LOOPER_BEGIN(rect_float)
+ {
+ r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0]));
+ g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1]));
+ b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2]));
}
+ PIXEL_LOOPER_END;
}
break;
}
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 364950b99cb..61275a8937c 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -48,9 +48,12 @@
#include "jpeglib.h"
#include "jerror.h"
-#define IS_jpg(x) (x->ftype & JPG)
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
+// #define IS_jpg(x) (x->ftype & JPG) // UNUSED
#define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD)
-#define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID)
+// #define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) // UNUSED
#define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST)
#define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX)
@@ -435,21 +438,22 @@ next_stamp_marker:
jpeg_destroy((j_common_ptr) cinfo);
if (ibuf) {
ibuf->ftype = ibuf_ftype;
- ibuf->profile = IB_PROFILE_SRGB;
}
}
return(ibuf);
}
-ImBuf *imb_load_jpeg(unsigned char *buffer, size_t size, int flags)
+ImBuf *imb_load_jpeg(unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo;
struct my_error_mgr jerr;
ImBuf *ibuf;
if (!imb_is_a_jpeg(buffer)) return NULL;
-
+
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
cinfo->err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = jpeg_error;
diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c
index 1ce2053fde5..fed55c05eea 100644
--- a/source/blender/imbuf/intern/metadata.c
+++ b/source/blender/imbuf/intern/metadata.c
@@ -63,7 +63,7 @@ void IMB_metadata_free(struct ImBuf *img)
}
}
-int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, int len)
+int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, const size_t len)
{
ImMetaData *info;
int retval = 0;
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 78a989ad48f..d5aa635f548 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -386,7 +386,7 @@ ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey)
void IMB_moviecache_free(MovieCache *cache)
{
- PRINT("%s: create '%s' free\n", __func__, cache->name);
+ PRINT("%s: cache '%s' free\n", __func__, cache->name);
BLI_ghash_free(cache->hash, moviecache_keyfree, moviecache_valfree);
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 26aab29b8dd..13078921d1c 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -64,6 +64,9 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
#include "IMB_allocimbuf.h"
#include "IMB_metadata.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
#include "openexr_multi.h"
}
@@ -379,30 +382,15 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags
else {
unsigned char *from;
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
- for (int i = ibuf->y - 1; i >= 0; i--) {
- from = (unsigned char *)ibuf->rect + channels * i * width;
+ for (int i = ibuf->y - 1; i >= 0; i--) {
+ from = (unsigned char *)ibuf->rect + channels * i * width;
- for (int j = ibuf->x; j > 0; j--) {
- to->r = (float)(from[0]) / 255.0f;
- to->g = (float)(from[1]) / 255.0f;
- to->b = (float)(from[2]) / 255.0f;
- to->a = (float)(channels >= 4) ? from[3] / 255.0f : 1.0f;
- to++; from += 4;
- }
- }
- }
- else {
- for (int i = ibuf->y - 1; i >= 0; i--) {
- from = (unsigned char *)ibuf->rect + channels * i * width;
-
- for (int j = ibuf->x; j > 0; j--) {
- to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
- to->g = srgb_to_linearrgb((float)from[1] / 255.0f);
- to->b = srgb_to_linearrgb((float)from[2] / 255.0f);
- to->a = channels >= 4 ? (float)from[3] / 255.0f : 1.0f;
- to++; from += 4;
- }
+ for (int j = ibuf->x; j > 0; j--) {
+ to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
+ to->g = srgb_to_linearrgb((float)from[1] / 255.0f);
+ to->b = srgb_to_linearrgb((float)from[2] / 255.0f);
+ to->a = channels >= 4 ? (float)from[3] / 255.0f : 1.0f;
+ to++; from += 4;
}
}
}
@@ -1129,13 +1117,15 @@ static int exr_is_multilayer(InputFile *file)
return 0;
}
-struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
+struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
InputFile *file = NULL;
if (imb_is_a_openexr(mem) == 0) return(NULL);
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
+
try
{
Mem_IStream *membuf = new Mem_IStream(mem, size);
@@ -1164,9 +1154,6 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0);
ibuf->ftype = OPENEXR;
- /* openEXR is linear as per EXR spec */
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
-
if (!(flags & IB_test)) {
if (is_multi) { /* only enters with IB_multilayer flag set */
/* constructs channels for reading, allocates memory in channels */
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h
index d12fe2fc49f..3135795fb3f 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.h
+++ b/source/blender/imbuf/intern/openexr/openexr_api.h
@@ -50,7 +50,7 @@ int imb_is_a_openexr (unsigned char *mem);
int imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags);
-struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags);
+struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags, char *colorspace);
#ifdef __cplusplus
}
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 92cd9622849..6310d8e105f 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -47,6 +47,9 @@
#include "IMB_metadata.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
typedef struct PNGReadStruct {
unsigned char *data;
unsigned int size;
@@ -302,7 +305,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
return(1);
}
-ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
+ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
png_structp png_ptr;
@@ -317,11 +320,13 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
unsigned char *from, *to;
unsigned short *from16;
float *to_float;
- float tmp[4];
int i, bytesperpixel;
if (imb_is_a_png(mem) == 0) return(NULL);
+ /* both 8 and 16 bit PNGs are default to standard byte colorspace */
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (png_ptr == NULL) {
@@ -389,10 +394,6 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
if (ibuf) {
ibuf->ftype = PNG;
- if (bit_depth == 16)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- else
- ibuf->profile = IB_PROFILE_SRGB;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) {
int unit_type;
@@ -443,37 +444,33 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
switch (bytesperpixel) {
case 4:
for (i = ibuf->x * ibuf->y; i > 0; i--) {
- tmp[0] = from16[0] / 65535.0;
- tmp[1] = from16[1] / 65535.0;
- tmp[2] = from16[2] / 65535.0;
- tmp[3] = from16[3] / 65535.0;
- srgb_to_linearrgb_v4(to_float, tmp);
+ to_float[0] = from16[0] / 65535.0;
+ to_float[1] = from16[1] / 65535.0;
+ to_float[2] = from16[2] / 65535.0;
+ to_float[3] = from16[3] / 65535.0;
to_float += 4; from16 += 4;
}
break;
case 3:
for (i = ibuf->x * ibuf->y; i > 0; i--) {
- tmp[0] = from16[0] / 65535.0;
- tmp[1] = from16[1] / 65535.0;
- tmp[2] = from16[2] / 65535.0;
- tmp[3] = 1.0;
- srgb_to_linearrgb_v4(to_float, tmp);
+ to_float[0] = from16[0] / 65535.0;
+ to_float[1] = from16[1] / 65535.0;
+ to_float[2] = from16[2] / 65535.0;
+ to_float[3] = 1.0;
to_float += 4; from16 += 3;
}
break;
case 2:
for (i = ibuf->x * ibuf->y; i > 0; i--) {
- tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0;
- tmp[3] = from16[1] / 65535.0;
- srgb_to_linearrgb_v4(to_float, tmp);
+ to_float[0] = to_float[1] = to_float[2] = from16[0] / 65535.0;
+ to_float[3] = from16[1] / 65535.0;
to_float += 4; from16 += 2;
}
break;
case 1:
for (i = ibuf->x * ibuf->y; i > 0; i--) {
- tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0;
- tmp[3] = 1.0;
- srgb_to_linearrgb_v4(to_float, tmp);
+ to_float[0] = to_float[1] = to_float[2] = from16[0] / 65535.0;
+ to_float[3] = 1.0;
to_float += 4; from16++;
}
break;
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index 4cd50484a64..5add372cd4e 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -53,6 +53,9 @@
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
/* needed constants */
#define MINELEN 8
#define MAXELEN 0x7fff
@@ -171,7 +174,7 @@ int imb_is_a_hdr(unsigned char *buf)
return 0;
}
-struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
+struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf;
RGBE *sline;
@@ -184,6 +187,8 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
char oriY[80], oriX[80];
if (imb_is_a_hdr((void *)mem)) {
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
+
/* find empty line, next line is resolution info */
for (x = 1; x < size; x++) {
if ((mem[x - 1] == '\n') && (mem[x] == '\n')) {
@@ -207,7 +212,6 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
if (ibuf == NULL) return NULL;
ibuf->ftype = RADHDR;
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
if (flags & IB_test) return ibuf;
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 4bde71588b7..a1fa05d1098 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -54,20 +54,42 @@
#include "IMB_imbuf.h"
#include "IMB_filetype.h"
-ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, const char *descr)
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
+ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
{
ImBuf *ibuf;
ImFileType *type;
+ char effective_colorspace[IM_MAX_SPACE] = "";
if (mem == NULL) {
fprintf(stderr, "%s: NULL pointer\n", __func__);
return NULL;
}
+ if (colorspace)
+ BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace));
+
for (type = IMB_FILE_TYPES; type->is_a; type++) {
if (type->load) {
- ibuf = type->load(mem, size, flags);
+ ibuf = type->load(mem, size, flags, effective_colorspace);
if (ibuf) {
+ if (colorspace) {
+ if (ibuf->rect) {
+ /* byte buffer is never internally converted to some standard space,
+ * store pointer to it's color space descriptor instead
+ */
+ ibuf->rect_colorspace = colormanage_colorspace_get_named(effective_colorspace);
+ }
+
+ BLI_strncpy(colorspace, effective_colorspace, IM_MAX_SPACE);
+ }
+
+ /* OCIO_TODO: in some cases it's faster to do threaded conversion,
+ * but how to distinguish such cases */
+ colormanage_imbuf_make_linear(ibuf, effective_colorspace);
+
if (flags & IB_premul) {
IMB_premultiply_alpha(ibuf);
ibuf->flags |= IB_premul;
@@ -83,7 +105,7 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, const c
return NULL;
}
-ImBuf *IMB_loadifffile(int file, int flags, const char *descr)
+ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
{
ImBuf *ibuf;
unsigned char *mem;
@@ -99,7 +121,7 @@ ImBuf *IMB_loadifffile(int file, int flags, const char *descr)
return NULL;
}
- ibuf = IMB_ibImageFromMemory(mem, size, flags, descr);
+ ibuf = IMB_ibImageFromMemory(mem, size, flags, colorspace, descr);
if (munmap(mem, size))
fprintf(stderr, "%s: couldn't unmap file %s\n", __func__, descr);
@@ -122,7 +144,7 @@ static void imb_cache_filename(char *filename, const char *name, int flags)
BLI_strncpy(filename, name, IB_FILENAME_SIZE);
}
-ImBuf *IMB_loadiffname(const char *filepath, int flags)
+ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
{
ImBuf *ibuf;
int file, a;
@@ -133,7 +155,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags)
file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
if (file < 0) return NULL;
- ibuf = IMB_loadifffile(file, flags, filepath_tx);
+ ibuf = IMB_loadifffile(file, flags, colorspace, filepath_tx);
if (ibuf) {
BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
@@ -148,7 +170,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags)
return ibuf;
}
-ImBuf *IMB_testiffname(const char *filepath, int flags)
+ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
{
ImBuf *ibuf;
int file;
@@ -159,7 +181,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
if (file < 0) return NULL;
- ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, filepath_tx);
+ ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, colorspace, filepath_tx);
if (ibuf) {
BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index c3e23246638..a11f16d5669 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -42,6 +42,7 @@
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"
+#include "IMB_colormanagement.h"
/* blend modes */
@@ -486,7 +487,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4])
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
- const float col[4], const int do_color_management,
+ const float col[4], struct ColorManagedDisplay *display,
int x1, int y1, int x2, int y2)
{
int i, j;
@@ -553,11 +554,12 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
float col_conv[4];
float *pixel;
- if (do_color_management) {
- srgb_to_linearrgb_v4(col_conv, col);
+ if (display) {
+ copy_v4_v4(col_conv, col);
+ IMB_colormanagement_display_to_scene_linear_v3(col_conv, display);
}
else {
- copy_v4_v4(col_conv, col);
+ srgb_to_linearrgb_v4(col_conv, col);
}
for (j = 0; j < y2 - y1; j++) {
@@ -581,12 +583,10 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
}
}
-void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
+void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display)
{
- int do_color_management;
if (!ibuf) return;
- do_color_management = (ibuf->profile == IB_PROFILE_LINEAR_RGB);
- buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, do_color_management,
+ buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, display,
x1, y1, x2, y2);
}
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 389c3c42b6d..527f334d6a4 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -1051,7 +1051,7 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
sample -= 1.0f;
}
- }
+ }
if (do_rect) {
// printf("%ld %ld\n", (uchar *)rect - ((uchar *)ibuf->rect), rect_size);
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 4df49386ce1..253680e4bea 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -46,6 +46,8 @@
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
/* this one is only def-ed once, strangely... related to GS? */
#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
@@ -546,22 +548,23 @@ partial_load:
}
-ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags)
+ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE])
{
TARGA tga;
struct ImBuf *ibuf;
int col, count, size;
unsigned int *rect, *cmap = NULL /*, mincol = 0*/, maxcol = 0;
uchar *cp = (uchar *) &col;
-
+
if (checktarga(&tga, mem) == 0) return(NULL);
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
if (flags & IB_test) ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, tga.pixsize, 0);
else ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, (tga.pixsize + 0x7) & ~0x7, IB_rect);
if (ibuf == NULL) return(NULL);
ibuf->ftype = TGA;
- ibuf->profile = IB_PROFILE_SRGB;
mem = mem + 18 + tga.numid;
cp[0] = 0xff;
@@ -682,9 +685,11 @@ ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags)
}
}
- if (tga.imgdes & 0x20) IMB_flipy(ibuf);
+ if (tga.imgdes & 0x20) {
+ IMB_flipy(ibuf);
+ }
- if (ibuf && ibuf->rect)
+ if (ibuf->rect)
IMB_convert_rgba_to_abgr(ibuf);
return(ibuf);
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 2a2aedb49ff..ff7218d649c 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -313,7 +313,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
img = IMB_loadblend_thumb(path);
}
else {
- img = IMB_loadiffname(path, IB_rect | IB_metadata);
+ img = IMB_loadiffname(path, IB_rect | IB_metadata, NULL);
}
}
@@ -326,7 +326,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
}
else if (THB_SOURCE_MOVIE == source) {
struct anim *anim = NULL;
- anim = IMB_open_anim(path, IB_rect | IB_metadata, 0);
+ anim = IMB_open_anim(path, IB_rect | IB_metadata, 0, NULL);
if (anim != NULL) {
img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (img == NULL) {
@@ -376,6 +376,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
}
img->ftype = PNG;
img->planes = 32;
+
if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) {
#ifndef WIN32
chmod(temp, S_IRUSR | S_IWUSR);
@@ -401,7 +402,7 @@ ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
return NULL;
}
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
- img = IMB_loadiffname(thumb, IB_rect | IB_metadata);
+ img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL);
}
return img;
@@ -456,10 +457,10 @@ ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
- img = IMB_loadiffname(path, IB_rect);
+ img = IMB_loadiffname(path, IB_rect, NULL);
}
else {
- img = IMB_loadiffname(thumb, IB_rect | IB_metadata);
+ img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL);
if (img) {
char mtime[40];
if (!IMB_metadata_get_field(img, "Thumb::MTime", mtime, 40)) {
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index ac5f5da8a67..932a4941a0a 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -57,6 +57,9 @@
#include "IMB_filetype.h"
#include "IMB_filter.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
#include "tiffio.h"
#ifdef WIN32
@@ -464,8 +467,6 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
_TIFFfree(sbuf);
if (success) {
- ibuf->profile = (bitspersample == 32) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
-
/* Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) */
if (bitspersample < 16)
if (ENDIAN_ORDER == B_ENDIAN)
@@ -508,7 +509,7 @@ void imb_inittiff(void)
*
* \return: A newly allocated ImBuf structure if successful, otherwise NULL.
*/
-ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags)
+ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
TIFF *image = NULL;
ImBuf *ibuf = NULL, *hbuf;
@@ -527,6 +528,9 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags)
if (imb_is_a_tiff(mem) == 0)
return NULL;
+ /* both 8 and 16 bit PNGs are default to standard byte colorspace */
+ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
+
image = imb_tiff_client_open(&memFile, mem, size);
if (image == NULL) {
@@ -786,10 +790,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
/* convert from float source */
float rgb[4];
- if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
- linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]);
- else
- copy_v3_v3(rgb, &fromf[from_i]);
+ linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]);
rgb[3] = fromf[from_i + 3];
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 6d1e3c16631..833671e3f2f 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -225,7 +225,7 @@ static int isqtime(const char *name)
static char ffmpeg_last_error[1024];
-void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg)
+static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg)
{
if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
size_t n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg);
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index 1c182e9784e..5d785e08212 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -38,8 +38,28 @@
#include "IMB_imbuf.h"
#include "IMB_filetype.h"
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+
#include "imbuf.h"
+static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf)
+{
+ ImBuf *write_ibuf = ibuf;
+
+ if (type->flag & IM_FTYPE_FLOAT) {
+ /* pass */
+ }
+ else {
+ if (ibuf->rect == NULL && ibuf->rect_float) {
+ ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE);
+ IMB_rect_from_float(ibuf);
+ }
+ }
+
+ return write_ibuf;
+}
+
short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
{
ImFileType *type;
@@ -49,11 +69,17 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
for (type = IMB_FILE_TYPES; type->is_a; type++) {
if (type->save && type->ftype(type, ibuf)) {
- if (!(type->flag & IM_FTYPE_FLOAT)) {
- if (ibuf->rect == NULL && ibuf->rect_float)
- IMB_rect_from_float(ibuf);
- }
- return type->save(ibuf, name, flags);
+ ImBuf *write_ibuf;
+ short result = FALSE;
+
+ write_ibuf = prepare_write_imbuf(type, ibuf);
+
+ result = type->save(write_ibuf, name, flags);
+
+ if (write_ibuf != ibuf)
+ IMB_freeImBuf(write_ibuf);
+
+ return result;
}
}
diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h
index 4ead26c04f3..32a0629c338 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -160,6 +160,26 @@ typedef struct Scopes {
#define SCOPES_WAVEFRM_YCC_709 3
#define SCOPES_WAVEFRM_YCC_JPEG 4
+typedef struct ColorManagedViewSettings {
+ int flag, pad;
+ char view_transform[64]; /* view transform which is being applied when displaying buffer on the screen */
+ float exposure; /* fstop exposure */
+ float gamma; /* post-display gamma transform */
+ struct CurveMapping *curve_mapping; /* pre-display RGB curves transform */
+ void *pad2;
+} ColorManagedViewSettings;
+
+typedef struct ColorManagedDisplaySettings {
+ char display_device[64];
+} ColorManagedDisplaySettings;
+
+typedef struct ColorManagedColorspaceSettings {
+ char name[64]; /* MAX_COLORSPACE_NAME */
+} ColorManagedColorspaceSettings;
+
+/* ColorManagedViewSettings->flag */
+enum {
+ COLORMANAGE_VIEW_USE_CURVES = (1 << 0)
+};
#endif
-
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 377af042922..c22de3cb7eb 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -74,7 +74,7 @@ typedef struct CustomData {
/* CustomData.type */
#define CD_MVERT 0
-#define CD_MSTICKY 1
+#define CD_MSTICKY 1 /* DEPRECATED */
#define CD_MDEFORMVERT 2
#define CD_MEDGE 3
#define CD_MFACE 4
@@ -118,7 +118,7 @@ typedef struct CustomData {
/* Bits for CustomDataMask */
#define CD_MASK_MVERT (1 << CD_MVERT)
-#define CD_MASK_MSTICKY (1 << CD_MSTICKY)
+#define CD_MASK_MSTICKY (1 << CD_MSTICKY) /* DEPRECATED */
#define CD_MASK_MDEFORMVERT (1 << CD_MDEFORMVERT)
#define CD_MASK_MEDGE (1 << CD_MEDGE)
#define CD_MASK_MFACE (1 << CD_MFACE)
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index 4a4b21017db..38058dbb699 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -33,6 +33,7 @@
#define __DNA_IMAGE_TYPES_H__
#include "DNA_ID.h"
+#include "DNA_color_types.h" /* for color management */
struct PackedFile;
struct Scene;
@@ -107,6 +108,9 @@ typedef struct Image {
/* display aspect - for UV editing images resized for faster openGL display */
float aspx, aspy;
+
+ /* color management */
+ ColorManagedColorspaceSettings colorspace_settings;
} Image;
@@ -123,6 +127,7 @@ typedef struct Image {
#define IMA_CM_PREDIVIDE 256
#define IMA_USED_FOR_RENDER 512
#define IMA_USER_FRAME_IN_RANGE 1024 /* for image user, but these flags are mixed */
+#define IMA_VIEW_AS_RENDER 2048
/* Image.tpageflag */
#define IMA_TILES 1
diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h
index 8494e663fbe..6e5861043c1 100644
--- a/source/blender/makesdna/DNA_key_types.h
+++ b/source/blender/makesdna/DNA_key_types.h
@@ -105,7 +105,7 @@ typedef struct Key {
/* Key->type: KeyBlocks are interpreted as... */
enum {
- /* Sequencial positions over time (using KeyBlock->pos and Key->ctime) */
+ /* Sequential positions over time (using KeyBlock->pos and Key->ctime) */
KEY_NORMAL = 0,
/* States to blend between (default) */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 1f185731e91..f3c527b6531 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -130,8 +130,11 @@ typedef struct Material {
/* for buttons and render*/
char rgbsel, texact, pr_type, use_nodes;
- short pr_back, pr_lamp, pr_texture, ml_flag; /* ml_flag is for disable base material */
+ short pr_lamp, pr_texture, ml_flag; /* ml_flag is for disable base material */
+ /* mapping */
+ char mapflag, pad;
+
/* shaders */
short diff_shader, spec_shader;
float roughness, refrac;
@@ -140,6 +143,8 @@ typedef struct Material {
float param[4]; /* size, smooth, size, smooth, for toonshader, 0 (fac) and 1 (fresnel) also for fresnel shader */
float rms;
float darkness;
+
+ /* runtime - OR'd from 'mtex' */
short texco, mapto;
/* ramp colors */
@@ -173,7 +178,7 @@ typedef struct Material {
short index; /* custom index for render passes */
short vcol_alpha;
- short pad[3];
+ short pad4[3];
ListBase gpumaterial; /* runtime */
} Material;
@@ -274,6 +279,9 @@ typedef struct Material {
#define MA_MODE_MASK 0x6fffffff /* all valid mode bits */
+/* mapflag */
+#define MA_MAPFLAG_UVPROJECT (1 << 0)
+
/* ray mirror fadeout */
#define MA_RAYMIR_FADETOSKY 0
#define MA_RAYMIR_FADETOMAT 1
@@ -340,7 +348,7 @@ typedef struct Material {
#define TEXCO_OBJECT 32
#define TEXCO_LAVECTOR 64
#define TEXCO_VIEW 128
-#define TEXCO_STICKY 256
+#define TEXCO_STICKY_ 256 // DEPRECATED
#define TEXCO_OSA 512
#define TEXCO_WINDOW 1024
#define NEED_UV 2048
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 5408e865ab2..1196ce20a6b 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -89,8 +89,7 @@ typedef struct Mesh {
/* array of colors for the tessellated faces, must be number of tessellated
* faces * 4 in length */
- struct MCol *mcol;
- struct MSticky *msticky;
+ struct MCol *mcol;
struct Mesh *texcomesh;
/* When the object is available, the preferred access method is: BMEdit_FromObject(ob) */
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 3c89e069ea0..f28c0328acc 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -119,7 +119,8 @@ typedef struct MLoopUV {
#define MLOOPUV_PINNED 4
/* at the moment alpha is abused for vertex painting
- * and not used for transparency, note that red and blue are swapped */
+ * and not used for transparency,
+ * note that red and blue are _not_ swapped, as they are with #MCol */
typedef struct MLoopCol {
char r, g, b, a;
} MLoopCol;
@@ -145,13 +146,9 @@ typedef struct MLoopCol {
mcol__tmp->a = mloopcol__tmp->a; \
} (void)0
-typedef struct MSticky {
- float co[2];
-} MSticky;
-
typedef struct MSelect {
int index;
- int type; /* EDITVERT/EDITEDGE/EDITFACE */
+ int type; /* ME_VSEL/ME_ESEL/ME_FSEL */
} MSelect;
/*tessellation uv face data*/
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index d8bba4a3bf5..cda51779528 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -37,6 +37,7 @@
#include "DNA_ID.h"
#include "DNA_tracking_types.h"
+#include "DNA_color_types.h" /* for color management */
struct anim;
struct AnimData;
@@ -94,6 +95,9 @@ typedef struct MovieClip {
/* from a file. affects only a way how scene frame is mapping */
/* to a file name and not touches other data associated with */
/* a clip */
+
+ /* color management */
+ ColorManagedColorspaceSettings colorspace_settings;
} MovieClip;
typedef struct MovieClipScopes {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 9b347a71140..3f8f043efad 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -41,6 +41,7 @@
extern "C" {
#endif
+#include "DNA_color_types.h" /* color management */
#include "DNA_vec_types.h"
#include "DNA_listBase.h"
#include "DNA_ID.h"
@@ -278,6 +279,9 @@ typedef struct ImageFormatData {
char pad[7];
+ /* color management */
+ ColorManagedViewSettings view_settings;
+ ColorManagedDisplaySettings display_settings;
} ImageFormatData;
@@ -834,14 +838,15 @@ typedef struct VPaint {
void *paintcursor; /* wm handle */
} VPaint;
-/* VPaint flag */
-#define VP_COLINDEX 1
-#define VP_AREA 2 /* vertex paint only */
-
-#define VP_NORMALS 8
-#define VP_SPRAY 16
-// #define VP_MIRROR_X 32 // deprecated in 2.5x use (me->editflag & ME_EDIT_MIRROR_X)
-#define VP_ONLYVGROUP 128 /* weight paint only */
+/* VPaint.flag */
+enum {
+ // VP_COLINDEX = (1 << 0), /* only paint onto active material*/ /* deprecated since before 2.49 */
+ VP_AREA = (1 << 1),
+ VP_NORMALS = (1 << 3),
+ VP_SPRAY = (1 << 4),
+ // VP_MIRROR_X = (1 << 5), /* deprecated in 2.5x use (me->editflag & ME_EDIT_MIRROR_X) */
+ VP_ONLYVGROUP = (1 << 7) /* weight paint only */
+};
/* *************************************************************** */
/* Transform Orientations */
@@ -1142,6 +1147,11 @@ typedef struct Scene {
uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */
uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */
+
+ /* Color Management */
+ ColorManagedViewSettings view_settings;
+ ColorManagedDisplaySettings display_settings;
+ ColorManagedColorspaceSettings sequencer_colorspace_settings;
} Scene;
@@ -1264,7 +1274,7 @@ typedef struct Scene {
#define R_ALPHAKEY 2
/* color_mgt_flag */
-#define R_COLOR_MANAGEMENT (1 << 0)
+#define R_COLOR_MANAGEMENT (1 << 0) /* deprecated, should only be used in versioning code only */
#define R_COLOR_MANAGEMENT_PREDIVIDE (1 << 1)
/* subimtype, flag options for imtype */
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index d094c1d6255..4d259fad246 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -275,6 +275,18 @@ typedef struct BrightContrastModifierData {
float contrast;
} BrightContrastModifierData;
+/* ***************** Scopes ****************** */
+
+typedef struct SequencerScopes {
+ struct ImBuf *reference_ibuf;
+
+ struct ImBuf *zebra_ibuf;
+ struct ImBuf *waveform_ibuf;
+ struct ImBuf *sep_waveform_ibuf;
+ struct ImBuf *vector_ibuf;
+ struct ImBuf *histogram_ibuf;
+} SequencerScopes;
+
#define MAXSEQ 32
#define SELECT 1
@@ -317,6 +329,7 @@ typedef struct BrightContrastModifierData {
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
#define SEQ_USE_EFFECT_DEFAULT_FADE (1 << 22)
+#define SEQ_USE_LINEAR_MODIFIERS (1 << 23)
// flags for whether those properties are animated or not
#define SEQ_AUDIO_VOLUME_ANIMATED (1 << 24)
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index b828247c816..6cc4541f19e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -40,6 +40,7 @@
#include "DNA_outliner_types.h" /* for TreeStoreElem */
#include "DNA_image_types.h" /* ImageUser */
#include "DNA_movieclip_types.h" /* MovieClipUser */
+#include "DNA_sequence_types.h" /* SequencerScopes */
/* Hum ... Not really nice... but needed for spacebuts. */
#include "DNA_view2d_types.h"
@@ -473,6 +474,8 @@ typedef struct SpaceSeq {
int overlay_type;
struct bGPdata *gpd; /* grease-pencil data */
+
+ struct SequencerScopes scopes; /* different scoped displayed in space */
} SpaceSeq;
@@ -685,8 +688,9 @@ typedef struct SpaceImage {
struct Image *image;
struct ImageUser iuser;
- struct CurveMapping *cumap;
-
+
+ struct CurveMapping *cumap DNA_DEPRECATED; /* was switched to scene's color management settings */
+
struct Scopes scopes; /* histogram waveform and vectorscope */
struct Histogram sample_line_hist; /* sample line histogram */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index ac7a5a748e9..fe3fd10b680 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -104,6 +104,9 @@ extern StructRNA RNA_CollectionProperty;
extern StructRNA RNA_CollisionModifier;
extern StructRNA RNA_CollisionSensor;
extern StructRNA RNA_CollisionSettings;
+extern StructRNA RNA_ColorManagedColorspaceSettings;
+extern StructRNA RNA_ColorManagedDisplaySettings;
+extern StructRNA RNA_ColorManagedViewSettings;
extern StructRNA RNA_ColorRamp;
extern StructRNA RNA_ColorRampElement;
extern StructRNA RNA_ColorSequence;
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 4a27761b8d2..2c3bc0360fc 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -259,7 +259,7 @@ StructRNA *rna_PropertyGroup_refine(PointerRNA *ptr)
return ptr->type;
}
-ID *rna_ID_copy(ID *id)
+static ID *rna_ID_copy(ID *id)
{
ID *newid;
@@ -312,7 +312,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
DAG_id_tag_update(id, flag);
}
-void rna_ID_user_clear(ID *id)
+static void rna_ID_user_clear(ID *id)
{
id->us = 0; /* don't save */
id->flag &= ~LIB_FAKEUSER;
@@ -344,7 +344,7 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig
}
}
-void rna_IDMaterials_append_id(ID *id, Material *ma)
+static void rna_IDMaterials_append_id(ID *id, Material *ma)
{
material_append_id(id, ma);
@@ -352,7 +352,7 @@ void rna_IDMaterials_append_id(ID *id, Material *ma)
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
}
-Material *rna_IDMaterials_pop_id(ID *id, int index_i, int remove_material_slot)
+static Material *rna_IDMaterials_pop_id(ID *id, int index_i, int remove_material_slot)
{
Material *ma = material_pop_id(id, index_i, remove_material_slot);
@@ -363,7 +363,7 @@ Material *rna_IDMaterials_pop_id(ID *id, int index_i, int remove_material_slot)
return ma;
}
-void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
+static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
{
Library *lib = (Library *)ptr->data;
BKE_library_filepath_set(lib, value);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 4c1c377cb9f..c88944b4584 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -233,7 +233,7 @@ static void rna_idproperty_touch(IDProperty *idprop)
}
/* return a UI local ID prop definition for this prop */
-IDProperty *rna_idproperty_ui(PropertyRNA *prop)
+static IDProperty *rna_idproperty_ui(PropertyRNA *prop)
{
IDProperty *idprop;
@@ -618,7 +618,7 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
}
/* Find the property which uses the given nested struct */
-PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna)
+static PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna)
{
PropertyRNA *prop = NULL;
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index bb714043002..12a41f213b7 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -29,6 +29,7 @@
#include "RNA_define.h"
#include "RNA_access.h"
+#include "RNA_enum_types.h"
#include "rna_internal.h"
#include "DNA_constraint_types.h"
@@ -110,7 +111,7 @@ static StructRNA *rna_Actuator_refine(struct PointerRNA *ptr)
}
}
-void rna_Actuator_name_set(PointerRNA *ptr, const char *value)
+static void rna_Actuator_name_set(PointerRNA *ptr, const char *value)
{
bActuator *act = (bActuator *)ptr->data;
@@ -530,7 +531,7 @@ static void rna_Actuator_action_action_set(PointerRNA *ptr, PointerRNA value)
#else
-void rna_def_actuator(BlenderRNA *brna)
+static void rna_def_actuator(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 69f785c32de..d50cb663b97 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -829,7 +829,7 @@ void rna_def_animdata_common(StructRNA *srna)
RNA_def_property_ui_text(prop, "Animation Data", "Animation data for this datablock");
}
-void rna_def_animdata(BlenderRNA *brna)
+static void rna_def_animdata(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index 32472c8d415..39128b48cd8 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -39,6 +39,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "rna_internal.h" /* own include */
#ifdef RNA_RUNTIME
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index be70405d165..a645930f09a 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -100,7 +100,7 @@ static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value)
}
}
-EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const char *name)
+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);
@@ -109,7 +109,7 @@ EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const
return ED_armature_edit_bone_add(arm, name);
}
-void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone)
+static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone)
{
if (arm->edbo == NULL) {
BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant remove an editbone", arm->id.name + 2);
diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c
index 29dc23b7bef..96c5350e5b7 100644
--- a/source/blender/makesrna/intern/rna_armature_api.c
+++ b/source/blender/makesrna/intern/rna_armature_api.c
@@ -36,18 +36,20 @@
#include "RNA_define.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include <stddef.h>
#include "BKE_armature.h"
-void rna_EditBone_align_roll(EditBone *ebo, float no[3])
+static void rna_EditBone_align_roll(EditBone *ebo, float no[3])
{
ebo->roll = ED_rollBoneToVector(ebo, no, FALSE);
}
-float rna_Bone_do_envelope(Bone *bone, float *vec)
+static float rna_Bone_do_envelope(Bone *bone, float *vec)
{
float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f;
return distfactor_to_bone(vec, bone->arm_head, bone->arm_tail, bone->rad_head * scale,
diff --git a/source/blender/makesrna/intern/rna_camera_api.c b/source/blender/makesrna/intern/rna_camera_api.c
index 75941fa224f..bf916806e40 100644
--- a/source/blender/makesrna/intern/rna_camera_api.c
+++ b/source/blender/makesrna/intern/rna_camera_api.c
@@ -31,6 +31,8 @@
#include "RNA_define.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include "DNA_scene_types.h"
@@ -39,8 +41,8 @@
#include "BKE_context.h"
#include "BKE_object.h"
-void rna_camera_view_frame(struct Camera *camera, struct Scene *scene,
- float vec1_r[3], float vec2_r[3], float vec3_r[3], float vec4_r[3])
+static void rna_camera_view_frame(struct Camera *camera, struct Scene *scene,
+ float vec1_r[3], float vec2_r[3], float vec3_r[3], float vec4_r[3])
{
float vec[4][3];
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index a0690047754..bf8b687139b 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -34,26 +34,32 @@
#include "DNA_color_types.h"
#include "DNA_texture_types.h"
+#include "WM_api.h"
+#include "WM_types.h"
+
#ifdef RNA_RUNTIME
#include "RNA_access.h"
+#include "DNA_image_types.h"
#include "DNA_material_types.h"
+#include "DNA_movieclip_types.h"
#include "DNA_node_types.h"
#include "MEM_guardedalloc.h"
#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
+#include "BKE_image.h"
+#include "BKE_movieclip.h"
#include "BKE_node.h"
#include "BKE_texture.h"
#include "BKE_linestyle.h"
-#include "WM_api.h"
-#include "WM_types.h"
-
#include "ED_node.h"
+#include "IMB_colormanagement.h"
+
static int rna_CurveMapping_curves_length(PointerRNA *ptr)
{
CurveMapping *cumap = (CurveMapping *)ptr->data;
@@ -367,8 +373,162 @@ static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointer
s->ok = 0;
}
+static int rna_ColorManagedDisplaySettings_display_device_get(struct PointerRNA *ptr)
+{
+ ColorManagedDisplaySettings *display = (ColorManagedDisplaySettings *) ptr->data;
+
+ return IMB_colormanagement_display_get_named_index(display->display_device);
+}
+
+static void rna_ColorManagedDisplaySettings_display_device_set(struct PointerRNA *ptr, int value)
+{
+ ColorManagedDisplaySettings *display = (ColorManagedDisplaySettings *) ptr->data;
+ const char *name = IMB_colormanagement_display_get_indexed_name(value);
+
+ if (name) {
+ BLI_strncpy(display->display_device, name, sizeof(display->display_device));
+ }
+}
+
+static EnumPropertyItem *rna_ColorManagedDisplaySettings_display_device_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
+{
+ EnumPropertyItem *items = NULL;
+ int totitem = 0;
+
+ IMB_colormanagement_display_items_add(&items, &totitem);
+ RNA_enum_item_end(&items, &totitem);
+
+ *free = TRUE;
+
+ return items;
+}
+
+static void rna_ColorManagedDisplaySettings_display_device_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ ID *id = ptr->id.data;
+
+ if (!id)
+ return;
+
+ if (GS(id->name) == ID_SCE) {
+ Scene *scene = (Scene *) id;
+
+ IMB_colormanagement_validate_settings(&scene->display_settings, &scene->view_settings);
+
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
+ }
+}
+
+static int rna_ColorManagedViewSettings_view_transform_get(PointerRNA *ptr)
+{
+ ColorManagedViewSettings *view = (ColorManagedViewSettings *) ptr->data;
+
+ return IMB_colormanagement_view_get_named_index(view->view_transform);
+}
+
+static void rna_ColorManagedViewSettings_view_transform_set(PointerRNA *ptr, int value)
+{
+ ColorManagedViewSettings *view = (ColorManagedViewSettings *) ptr->data;
+
+ const char *name = IMB_colormanagement_view_get_indexed_name(value);
+
+ if (name) {
+ BLI_strncpy(view->view_transform, name, sizeof(view->view_transform));
+ }
+}
+
+static EnumPropertyItem* rna_ColorManagedViewSettings_view_transform_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
+{
+ Scene *scene = CTX_data_scene(C);
+ EnumPropertyItem *items = NULL;
+ ColorManagedDisplaySettings *display_settings = &scene->display_settings;
+ int totitem = 0;
+
+ IMB_colormanagement_view_items_add(&items, &totitem, display_settings->display_device);
+ RNA_enum_item_end(&items, &totitem);
+
+ *free = TRUE;
+ return items;
+}
+
+static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, int value)
+{
+ ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *) ptr->data;
+
+ if (value) {
+ view_settings->flag |= COLORMANAGE_VIEW_USE_CURVES;
+
+ if (view_settings->curve_mapping == NULL) {
+ view_settings->curve_mapping = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
+ }
+ }
+ else {
+ view_settings->flag &= ~COLORMANAGE_VIEW_USE_CURVES;
+ }
+}
+
+static int rna_ColorManagedColorspaceSettings_colorspace_get(struct PointerRNA *ptr)
+{
+ ColorManagedColorspaceSettings *colorspace = (ColorManagedColorspaceSettings *) ptr->data;
+
+ return IMB_colormanagement_colorspace_get_named_index(colorspace->name);
+}
+
+static void rna_ColorManagedColorspaceSettings_colorspace_set(struct PointerRNA *ptr, int value)
+{
+ ColorManagedColorspaceSettings *colorspace = (ColorManagedColorspaceSettings *) ptr->data;
+ const char *name = IMB_colormanagement_colorspace_get_indexed_name(value);
+
+ if (name) {
+ BLI_strncpy(colorspace->name, name, sizeof(colorspace->name));
+ }
+}
+
+static EnumPropertyItem *rna_ColorManagedColorspaceSettings_colorspace_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
+{
+ EnumPropertyItem *items = NULL;
+ int totitem = 0;
+
+ IMB_colormanagement_colorspace_items_add(&items, &totitem);
+ RNA_enum_item_end(&items, &totitem);
+
+ *free = TRUE;
+
+ return items;
+}
+
+static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ ID *id = ptr->id.data;
+
+ if (GS(id->name) == ID_IM) {
+ Image *ima = (Image *) id;
+
+ BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
+ }
+ else if (GS(id->name) == ID_MC) {
+ MovieClip *clip = (MovieClip *) id;
+
+ BKE_movieclip_reload(clip);
+ WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id);
+ }
+}
+
+static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ ID *id = ptr->id.data;
+
+ if (!id)
+ return;
+
+ if (GS(id->name) == ID_SCE) {
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
+ }
+}
+
/* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */
-float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value)
+static float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value)
{
return curvemap_evaluateF(cuma, value);
}
@@ -712,6 +872,87 @@ static void rna_def_scopes(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Vectorscope Opacity", "Opacity of the points");
}
+static void rna_def_colormanage(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static EnumPropertyItem display_device_items[] = {
+ {0, "DEFAULT", 0, "Default", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem view_transform_items[] = {
+ {0, "NONE", 0, "None", "Do not perform any color transform on display, use old non-color managed technique for display"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem color_space_items[] = {
+ {0, "NONE", 0, "None", "Do not perform any color transform on load, treat colors as in scene linear space already"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* ** Display Settings ** */
+ srna = RNA_def_struct(brna, "ColorManagedDisplaySettings", NULL);
+ RNA_def_struct_ui_text(srna, "ColorManagedDisplaySettings", "Color management specific to display device");
+
+ prop= RNA_def_property(srna, "display_device", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, display_device_items);
+ RNA_def_property_enum_funcs(prop, "rna_ColorManagedDisplaySettings_display_device_get",
+ "rna_ColorManagedDisplaySettings_display_device_set",
+ "rna_ColorManagedDisplaySettings_display_device_itemf");
+ RNA_def_property_ui_text(prop, "Display Device", "Display device name");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedDisplaySettings_display_device_update");
+
+ /* ** View Settings ** */
+ srna = RNA_def_struct(brna, "ColorManagedViewSettings", NULL);
+ RNA_def_struct_ui_text(srna, "ColorManagedViewSettings", "Color management settings used for displaying images on the display");
+
+ prop= RNA_def_property(srna, "view_transform", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, view_transform_items);
+ RNA_def_property_enum_funcs(prop, "rna_ColorManagedViewSettings_view_transform_get",
+ "rna_ColorManagedViewSettings_view_transform_set",
+ "rna_ColorManagedViewSettings_view_transform_itemf");
+ RNA_def_property_ui_text(prop, "View Transform", "View used ");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+ prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "exposure");
+ RNA_def_property_range(prop, -10.0f, 10.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied before display transform");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+ prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "gamma");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0.0f, 5.0f);
+ RNA_def_property_ui_text(prop, "Gamma", "Amount of gamma modification applied after display transform");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+ prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping");
+ RNA_def_property_ui_text(prop, "Curve", "Color curve mapping applied before display transform");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+ prop = RNA_def_property(srna, "use_curve_mapping", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", COLORMANAGE_VIEW_USE_CURVES);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_ColorManagedViewSettings_use_curves_set");
+ RNA_def_property_ui_text(prop, "Use Curves", "Use RGB curved for pre-display transformation");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+ /* ** Colorspace ** */
+ srna = RNA_def_struct(brna, "ColorManagedColorspaceSettings", NULL);
+ RNA_def_struct_ui_text(srna, "ColorManagedColorspaceSettings", "Input color space settings");
+
+ prop= RNA_def_property(srna, "name", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, color_space_items);
+ RNA_def_property_enum_funcs(prop, "rna_ColorManagedColorspaceSettings_colorspace_get",
+ "rna_ColorManagedColorspaceSettings_colorspace_set",
+ "rna_ColorManagedColorspaceSettings_colorspace_itemf");
+ RNA_def_property_ui_text(prop, "Color Space", "Input color space name");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update");
+}
void RNA_def_color(BlenderRNA *brna)
{
@@ -722,6 +963,7 @@ void RNA_def_color(BlenderRNA *brna)
rna_def_color_ramp(brna);
rna_def_histogram(brna);
rna_def_scopes(brna);
+ rna_def_colormanage(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c
index 44c8a2b412b..aef1f765fe2 100644
--- a/source/blender/makesrna/intern/rna_controller.c
+++ b/source/blender/makesrna/intern/rna_controller.c
@@ -77,7 +77,7 @@ static StructRNA *rna_Controller_refine(struct PointerRNA *ptr)
}
}
-void rna_Constroller_name_set(PointerRNA *ptr, const char *value)
+static void rna_Constroller_name_set(PointerRNA *ptr, const char *value)
{
bController *cont = (bController *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_controller_api.c b/source/blender/makesrna/intern/rna_controller_api.c
index 6fe90e1721b..639d6a330a5 100644
--- a/source/blender/makesrna/intern/rna_controller_api.c
+++ b/source/blender/makesrna/intern/rna_controller_api.c
@@ -35,6 +35,8 @@
#include "WM_types.h"
#include "RNA_define.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include "BKE_sca.h"
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index b2a2bab0f4b..c47cb8ef2af 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -432,20 +432,20 @@ static void rna_Curve_offset_set(PointerRNA *ptr, float value)
}
/* name functions that ignore the first two ID characters */
-void rna_Curve_body_get(PointerRNA *ptr, char *value)
+static void rna_Curve_body_get(PointerRNA *ptr, char *value)
{
Curve *cu = (Curve *)ptr->id.data;
BLI_strncpy(value, cu->str, cu->len + 1);
}
-int rna_Curve_body_length(PointerRNA *ptr)
+static int rna_Curve_body_length(PointerRNA *ptr)
{
Curve *cu = (Curve *)ptr->id.data;
return cu->len;
}
/* TODO - check UTF & python play nice */
-void rna_Curve_body_set(PointerRNA *ptr, const char *value)
+static void rna_Curve_body_set(PointerRNA *ptr, const char *value)
{
int len = strlen(value);
Curve *cu = (Curve *)ptr->id.data;
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index a0d64723a5c..24b14fdb884 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -403,13 +403,13 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
}
}
-DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
+static DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
{
/* call the API function for this */
return driver_add_new_variable(driver);
}
-void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
+static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
{
if (BLI_findindex(&driver->variables, dvar) == -1) {
BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver");
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index eb12a02aa99..131611d3002 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -90,7 +90,7 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
}
}
-void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
+static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
{
bGPdata *gpd = ptr->id.data;
bGPDlayer *gpl = ptr->data;
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 62a06888613..fdab874cf01 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -147,7 +147,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *
}
-char *rna_ImageUser_path(PointerRNA *ptr)
+static char *rna_ImageUser_path(PointerRNA *ptr)
{
if (ptr->id.data) {
/* ImageUser *iuser= ptr->data; */
@@ -513,6 +513,11 @@ static void rna_def_image(BlenderRNA *brna)
"to avoid fringing for images with light backgrounds");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_free_update");
+ prop = RNA_def_property(srna, "view_as_render", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER);
+ RNA_def_property_ui_text(prop, "View as Render", "Apply render part of display transformation when displaying this image on the screen");
+ RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
+
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -652,6 +657,11 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL);
+ prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "colorspace_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings");
+ RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
+
RNA_api_image(srna);
}
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index fa3f8d69c47..c66c0085763 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -50,6 +50,7 @@
#include "BKE_global.h" /* grr: G.main->name */
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "GPU_draw.h"
@@ -80,16 +81,17 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image");
}
else {
- /* temp swap out the color */
- const unsigned char imb_planes_back = ibuf->planes;
- const float dither_back = ibuf->dither;
- ibuf->planes = scene->r.im_format.planes;
- ibuf->dither = scene->r.dither_intensity;
- if (!BKE_imbuf_write(ibuf, path, &scene->r.im_format)) {
+ ImBuf *write_ibuf = IMB_dupImBuf(ibuf);
+
+ IMB_display_buffer_to_imbuf_rect(write_ibuf, &scene->view_settings, &scene->display_settings);
+
+ write_ibuf->planes = scene->r.im_format.planes;
+ 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);
}
- ibuf->planes = imb_planes_back;
- ibuf->dither = dither_back;
+ IMB_freeImBuf(write_ibuf);
}
BKE_image_release_ibuf(image, lock);
@@ -118,6 +120,8 @@ static void rna_Image_save(Image *image, ReportList *reports)
if (image->source == IMA_SRC_GENERATED)
image->source = IMA_SRC_FILE;
+ IMB_colormanagment_colorspace_from_ibuf_ftype(&image->colorspace_settings, ibuf);
+
ibuf->userflags &= ~IB_BITMAPDIRTY;
}
else {
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index a4582406c10..b85688e156c 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -34,8 +34,14 @@
#define RNA_MAGIC ((int)~0)
+struct ColorBand;
struct ID;
struct IDProperty;
+struct Main;
+struct Mesh;
+struct Object;
+struct RenderEngine;
+struct ReportList;
struct SDNA;
struct Sequence;
@@ -400,6 +406,22 @@ void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct Re
int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr);
+
+/* 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);
+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_key.c b/source/blender/makesrna/intern/rna_key.c
index 5334c10c4c6..33bbaeec282 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -61,12 +61,12 @@ static Key *rna_ShapeKey_find_key(ID *id)
case ID_KE: return (Key *)id;
case ID_LT: return ((Lattice *)id)->key;
case ID_ME: return ((Mesh *)id)->key;
- case ID_OB: return ob_get_key((Object *)id);
+ case ID_OB: return BKE_key_from_object((Object *)id);
default: return NULL;
}
}
-void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
+static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
{
KeyBlock *kb = ptr->data;
char oldname[sizeof(kb->name)];
@@ -360,7 +360,7 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p
Object *ob;
for (ob = bmain->object.first; ob; ob = ob->id.next) {
- if (ob_get_key(ob) == key) {
+ if (BKE_key_from_object(ob) == key) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 2d26fec0d50..100485dd714 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -96,13 +96,13 @@
#include "ED_screen.h"
-Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name)
+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;
}
-void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera)
+static void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera)
{
if (ID_REAL_USERS(camera) <= 0)
BKE_libblock_free(&bmain->camera, camera);
@@ -113,11 +113,11 @@ void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *ca
/* XXX python now has invalid pointer? */
}
-Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name)
+static Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name)
{
return BKE_scene_add(name);
}
-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, struct Scene *scene)
{
/* don't call BKE_libblock_free(...) directly */
Scene *newscene;
@@ -137,7 +137,7 @@ void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struc
BKE_scene_unlink(bmain, scene, newscene);
}
-Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data)
+static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data)
{
Object *ob;
int type = OB_EMPTY;
@@ -191,7 +191,7 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha
return ob;
}
-void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object)
+static void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object)
{
if (ID_REAL_USERS(object) <= 0) {
BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */
@@ -203,13 +203,13 @@ void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *ob
}
}
-Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name)
+static Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name)
{
ID *id = (ID *)BKE_material_add(name);
id_us_min(id);
return (Material *)id;
}
-void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material)
+static void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material)
{
if (ID_REAL_USERS(material) <= 0)
BKE_libblock_free(&bmain->mat, material);
@@ -220,14 +220,14 @@ void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material
/* XXX python now has invalid pointer? */
}
-bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type)
+static bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type)
{
bNodeTree *tree = ntreeAddTree(name, type, NODE_GROUP);
id_us_min(&tree->id);
return tree;
}
-void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree)
+static void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree)
{
if (ID_REAL_USERS(tree) <= 0)
BKE_libblock_free(&bmain->nodetree, tree);
@@ -238,7 +238,7 @@ void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree
/* XXX python now has invalid pointer? */
}
-Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name)
+static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name)
{
Mesh *me = BKE_mesh_add(name);
id_us_min(&me->id);
@@ -255,14 +255,14 @@ void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh)
/* XXX python now has invalid pointer? */
}
-Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type)
+static Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type)
{
Lamp *lamp = BKE_lamp_add(name);
lamp->type = type;
id_us_min(&lamp->id);
return lamp;
}
-void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp)
+static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp)
{
if (ID_REAL_USERS(lamp) <= 0)
BKE_libblock_free(&bmain->lamp, lamp);
@@ -273,14 +273,14 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp)
/* XXX python now has invalid pointer? */
}
-Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer)
+static Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer)
{
float color[4] = {0.0, 0.0, 0.0, 1.0};
Image *image = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, float_buffer, 0, color);
id_us_min(&image->id);
return image;
}
-Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath)
+static Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath)
{
Image *ima;
@@ -293,7 +293,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char
return ima;
}
-void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
+static void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
{
if (ID_REAL_USERS(image) <= 0)
BKE_libblock_free(&bmain->image, image);
@@ -304,13 +304,13 @@ void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
/* XXX python now has invalid pointer? */
}
-Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name)
+static Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name)
{
Lattice *lt = BKE_lattice_add(name);
id_us_min(&lt->id);
return lt;
}
-void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt)
+static void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt)
{
if (ID_REAL_USERS(lt) <= 0)
BKE_libblock_free(&bmain->latt, lt);
@@ -319,13 +319,13 @@ void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *
lt->id.name + 2, ID_REAL_USERS(lt));
}
-Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type)
+static Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type)
{
Curve *cu = BKE_curve_add(name, type);
id_us_min(&cu->id);
return cu;
}
-void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu)
+static void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu)
{
if (ID_REAL_USERS(cu) <= 0)
BKE_libblock_free(&bmain->curve, cu);
@@ -334,13 +334,13 @@ void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu)
cu->id.name + 2, ID_REAL_USERS(cu));
}
-MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name)
+static MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name)
{
MetaBall *mb = BKE_mball_add(name);
id_us_min(&mb->id);
return mb;
}
-void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb)
+static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb)
{
if (ID_REAL_USERS(mb) <= 0)
BKE_libblock_free(&bmain->mball, mb);
@@ -349,7 +349,7 @@ void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall
mb->id.name + 2, ID_REAL_USERS(mb));
}
-VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath)
+static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath)
{
VFont *font;
@@ -363,7 +363,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat
return font;
}
-void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
+static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
{
if (ID_REAL_USERS(vfont) <= 0)
BKE_libblock_free(&bmain->vfont, vfont);
@@ -374,14 +374,14 @@ void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
/* XXX python now has invalid pointer? */
}
-Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type)
+static Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type)
{
Tex *tex = add_texture(name);
tex_set_type(tex, type);
id_us_min(&tex->id);
return tex;
}
-void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex)
+static void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex)
{
if (ID_REAL_USERS(tex) <= 0)
BKE_libblock_free(&bmain->tex, tex);
@@ -390,13 +390,13 @@ void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex)
tex->id.name + 2, ID_REAL_USERS(tex));
}
-Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name)
+static Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name)
{
Brush *brush = BKE_brush_add(name);
id_us_min(&brush->id);
return brush;
}
-void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush)
+static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush)
{
if (ID_REAL_USERS(brush) <= 0)
BKE_libblock_free(&bmain->brush, brush);
@@ -405,13 +405,13 @@ void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *bru
brush->id.name + 2, ID_REAL_USERS(brush));
}
-World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name)
+static World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name)
{
World *world = add_world(name);
id_us_min(&world->id);
return world;
}
-void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world)
+static void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world)
{
if (ID_REAL_USERS(world) <= 0)
BKE_libblock_free(&bmain->world, world);
@@ -420,24 +420,24 @@ void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *worl
world->id.name + 2, ID_REAL_USERS(world));
}
-Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name)
+static Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name)
{
return add_group(name);
}
-void rna_Main_groups_remove(Main *bmain, Group *group)
+static void rna_Main_groups_remove(Main *bmain, Group *group)
{
BKE_group_unlink(group);
BKE_libblock_free(&bmain->group, group);
/* XXX python now has invalid pointer? */
}
-Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name)
+static Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name)
{
Speaker *speaker = BKE_speaker_add(name);
id_us_min(&speaker->id);
return speaker;
}
-void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker)
+static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker)
{
if (ID_REAL_USERS(speaker) <= 0)
BKE_libblock_free(&bmain->speaker, speaker);
@@ -448,18 +448,18 @@ void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker
/* XXX python now has invalid pointer? */
}
-Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name)
+static Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name)
{
return BKE_text_add(name);
}
-void rna_Main_texts_remove(Main *bmain, Text *text)
+static void rna_Main_texts_remove(Main *bmain, Text *text)
{
BKE_text_unlink(bmain, text);
BKE_libblock_free(&bmain->text, text);
/* XXX python now has invalid pointer? */
}
-Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath)
+static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath)
{
Text *txt;
@@ -473,13 +473,13 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath
return txt;
}
-bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name)
+static bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name)
{
bArmature *arm = BKE_armature_add(name);
id_us_min(&arm->id);
return arm;
}
-void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm)
+static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm)
{
if (ID_REAL_USERS(arm) <= 0)
BKE_libblock_free(&bmain->armature, arm);
@@ -490,14 +490,14 @@ void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm)
/* XXX python now has invalid pointer? */
}
-bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name)
+static bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name)
{
bAction *act = add_empty_action(name);
id_us_min(&act->id);
act->id.flag &= ~LIB_FAKEUSER;
return act;
}
-void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act)
+static void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act)
{
if (ID_REAL_USERS(act) <= 0)
BKE_libblock_free(&bmain->action, act);
@@ -508,13 +508,13 @@ void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act)
/* XXX python now has invalid pointer? */
}
-ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name)
+static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name)
{
ParticleSettings *part = psys_new_settings(name, bmain);
id_us_min(&part->id);
return part;
}
-void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part)
+static void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part)
{
if (ID_REAL_USERS(part) <= 0)
BKE_libblock_free(&bmain->particle, part);
@@ -525,7 +525,7 @@ void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSetting
/* XXX python now has invalid pointer? */
}
-MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath)
+static MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath)
{
MovieClip *clip;
@@ -539,14 +539,14 @@ MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, con
return clip;
}
-void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip)
+static void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip)
{
BKE_movieclip_unlink(bmain, clip);
BKE_libblock_free(&bmain->movieclip, clip);
/* XXX python now has invalid pointer? */
}
-Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name)
+static Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name)
{
Mask *mask;
@@ -555,7 +555,7 @@ Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name)
return mask;
}
-void rna_Main_masks_remove(Main *bmain, Mask *mask)
+static void rna_Main_masks_remove(Main *bmain, Mask *mask)
{
BKE_mask_free(bmain, mask);
BKE_libblock_free(&bmain->mask, mask);
@@ -580,36 +580,36 @@ void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineS
}
/* tag functions, all the same */
-void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); }
-void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); }
-void rna_Main_objects_tag(Main *bmain, int value) { tag_main_lb(&bmain->object, value); }
-void rna_Main_materials_tag(Main *bmain, int value) { tag_main_lb(&bmain->mat, value); }
-void rna_Main_node_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->nodetree, value); }
-void rna_Main_meshes_tag(Main *bmain, int value) { tag_main_lb(&bmain->mesh, value); }
-void rna_Main_lamps_tag(Main *bmain, int value) { tag_main_lb(&bmain->lamp, value); }
-void rna_Main_libraries_tag(Main *bmain, int value) { tag_main_lb(&bmain->library, value); }
-void rna_Main_screens_tag(Main *bmain, int value) { tag_main_lb(&bmain->screen, value); }
-void rna_Main_window_managers_tag(Main *bmain, int value) { tag_main_lb(&bmain->wm, value); }
-void rna_Main_images_tag(Main *bmain, int value) { tag_main_lb(&bmain->image, value); }
-void rna_Main_lattices_tag(Main *bmain, int value) { tag_main_lb(&bmain->latt, value); }
-void rna_Main_curves_tag(Main *bmain, int value) { tag_main_lb(&bmain->curve, value); }
-void rna_Main_metaballs_tag(Main *bmain, int value) { tag_main_lb(&bmain->mball, value); }
-void rna_Main_fonts_tag(Main *bmain, int value) { tag_main_lb(&bmain->vfont, value); }
-void rna_Main_textures_tag(Main *bmain, int value) { tag_main_lb(&bmain->tex, value); }
-void rna_Main_brushes_tag(Main *bmain, int value) { tag_main_lb(&bmain->brush, value); }
-void rna_Main_worlds_tag(Main *bmain, int value) { tag_main_lb(&bmain->world, value); }
-void rna_Main_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->group, value); }
-void rna_Main_shape_keys_tag(Main *bmain, int value) { tag_main_lb(&bmain->key, value); }
-void rna_Main_scripts_tag(Main *bmain, int value) { tag_main_lb(&bmain->script, value); }
-void rna_Main_texts_tag(Main *bmain, int value) { tag_main_lb(&bmain->text, value); }
-void rna_Main_speakers_tag(Main *bmain, int value) { tag_main_lb(&bmain->speaker, value); }
-void rna_Main_sounds_tag(Main *bmain, int value) { tag_main_lb(&bmain->sound, value); }
-void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armature, value); }
-void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); }
-void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); }
-void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); }
-void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); }
-void rna_Main_masks_tag(Main *bmain, int value) { tag_main_lb(&bmain->mask, value); }
+static void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); }
+static void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); }
+static void rna_Main_objects_tag(Main *bmain, int value) { tag_main_lb(&bmain->object, value); }
+static void rna_Main_materials_tag(Main *bmain, int value) { tag_main_lb(&bmain->mat, value); }
+static void rna_Main_node_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->nodetree, value); }
+static void rna_Main_meshes_tag(Main *bmain, int value) { tag_main_lb(&bmain->mesh, value); }
+static void rna_Main_lamps_tag(Main *bmain, int value) { tag_main_lb(&bmain->lamp, value); }
+static void rna_Main_libraries_tag(Main *bmain, int value) { tag_main_lb(&bmain->library, value); }
+static void rna_Main_screens_tag(Main *bmain, int value) { tag_main_lb(&bmain->screen, value); }
+static void rna_Main_window_managers_tag(Main *bmain, int value) { tag_main_lb(&bmain->wm, value); }
+static void rna_Main_images_tag(Main *bmain, int value) { tag_main_lb(&bmain->image, value); }
+static void rna_Main_lattices_tag(Main *bmain, int value) { tag_main_lb(&bmain->latt, value); }
+static void rna_Main_curves_tag(Main *bmain, int value) { tag_main_lb(&bmain->curve, value); }
+static void rna_Main_metaballs_tag(Main *bmain, int value) { tag_main_lb(&bmain->mball, value); }
+static void rna_Main_fonts_tag(Main *bmain, int value) { tag_main_lb(&bmain->vfont, value); }
+static void rna_Main_textures_tag(Main *bmain, int value) { tag_main_lb(&bmain->tex, value); }
+static void rna_Main_brushes_tag(Main *bmain, int value) { tag_main_lb(&bmain->brush, value); }
+static void rna_Main_worlds_tag(Main *bmain, int value) { tag_main_lb(&bmain->world, value); }
+static void rna_Main_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->group, value); }
+static void rna_Main_shape_keys_tag(Main *bmain, int value) { tag_main_lb(&bmain->key, value); }
+static void rna_Main_scripts_tag(Main *bmain, int value) { tag_main_lb(&bmain->script, value); }
+static void rna_Main_texts_tag(Main *bmain, int value) { tag_main_lb(&bmain->text, value); }
+static void rna_Main_speakers_tag(Main *bmain, int value) { tag_main_lb(&bmain->speaker, value); }
+static void rna_Main_sounds_tag(Main *bmain, int value) { tag_main_lb(&bmain->sound, value); }
+static void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armature, value); }
+static void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); }
+static void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); }
+static void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); }
+static void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); }
+static void rna_Main_masks_tag(Main *bmain, int value) { tag_main_lb(&bmain->mask, value); }
void rna_Main_linestyle_tag(Main *bmain, int value) { tag_main_lb(&bmain->linestyle, value); }
static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); }
@@ -654,6 +654,8 @@ void RNA_api_main(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_pointer(func, "image", "Image", "", "New image");
RNA_def_function_return(func, parm);
+#else
+ (void)srna;
#endif
}
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 719baed8edb..97d9cc961ef 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -193,7 +193,7 @@ static void rna_MaskLayer_splines_begin(CollectionPropertyIterator *iter, Pointe
rna_iterator_listbase_begin(iter, &masklay->splines, NULL);
}
-void rna_MaskLayer_name_set(PointerRNA *ptr, const char *value)
+static void rna_MaskLayer_name_set(PointerRNA *ptr, const char *value)
{
Mask *mask = (Mask *)ptr->id.data;
MaskLayer *masklay = (MaskLayer *)ptr->data;
@@ -315,7 +315,7 @@ static MaskLayer *rna_Mask_layers_new(Mask *mask, const char *name)
return masklay;
}
-void rna_Mask_layers_remove(Mask *mask, ReportList *reports, MaskLayer *masklay)
+static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, MaskLayer *masklay)
{
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);
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 4523858d639..96529de074b 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -45,7 +45,6 @@ static EnumPropertyItem prop_texture_coordinates_items[] = {
{TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"},
{TEXCO_STRAND, "STRAND", 0, "Strand / Particle",
"Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"},
- {TEXCO_STICKY, "STICKY", 0, "Sticky", "Use mesh's sticky coordinates for the texture coordinates"},
{TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"},
{TEXCO_NORM, "NORMAL", 0, "Normal", "Use normal vector as texture coordinates"},
{TEXCO_REFL, "REFLECTION", 0, "Reflection", "Use reflection vector as texture coordinates"},
@@ -303,7 +302,6 @@ static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED
else if (ELEM3(ma->material_type, MA_TYPE_SURFACE, MA_TYPE_HALO, MA_TYPE_WIRE)) {
RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_UV);
RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRAND);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STICKY);
RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_WINDOW);
RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_NORM);
RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_REFL);
@@ -1939,6 +1937,12 @@ void RNA_def_material(BlenderRNA *brna)
"- for anisotropic shading effects");
RNA_def_property_update(prop, 0, "rna_Material_update");
+ prop = RNA_def_property(srna, "use_uv_project", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mapflag", MA_MAPFLAG_UVPROJECT);
+ RNA_def_property_ui_text(prop, "UV Project",
+ "Use to ensure UV interpolation is correct for camera projections (use with UV project modifier)");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
+
/* nested structs */
prop = RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index dbb46c9c291..ce86f90f018 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -149,7 +149,7 @@ void rna_Mesh_update_draw(Main *bmain, Scene *scene, PointerRNA *ptr)
}
-void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Mesh *me = ptr->data;
if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
@@ -158,7 +158,7 @@ void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
rna_Mesh_update_draw(bmain, scene, ptr);
}
-void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Mesh *me = ptr->data;
if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
@@ -1204,11 +1204,6 @@ static char *rna_MeshColor_path(PointerRNA *ptr)
return rna_LoopCustomData_data_path(ptr, "vertex_colors", CD_MLOOPCOL);
}
-static char *rna_MeshSticky_path(PointerRNA *ptr)
-{
- return BLI_sprintfN("sticky[%d]", (int)((MSticky *)ptr->data - rna_mesh(ptr)->msticky));
-}
-
static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr)
{
return BLI_sprintfN("int_layers[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
@@ -1972,21 +1967,6 @@ static void rna_def_mtexpoly(BlenderRNA *brna)
#endif
}
-static void rna_def_msticky(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MeshSticky", NULL);
- RNA_def_struct_sdna(srna, "MSticky");
- RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Sticky texture coordinate");
- RNA_def_struct_path_func(srna, "rna_MeshSticky_path");
-
- prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_ui_text(prop, "Location", "Sticky texture coordinate location");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-}
-
static void rna_def_mcol(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2624,7 +2604,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
-static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *cprop)
+static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *UNUSED(cprop))
{
StructRNA *srna;
PropertyRNA *prop;
@@ -2711,11 +2691,6 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Polygons", "Polygons of the mesh");
rna_def_mesh_polygons(brna, prop);
- prop = RNA_def_property(srna, "sticky", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "msticky", "totvert");
- RNA_def_property_struct_type(prop, "MeshSticky");
- RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates");
-
/* TODO, should this be allowed to be its self? */
prop = RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
@@ -3061,7 +3036,6 @@ void RNA_def_mesh(BlenderRNA *brna)
rna_def_mloopuv(brna);
rna_def_mtface(brna);
rna_def_mtexpoly(brna);
- rna_def_msticky(brna);
rna_def_mcol(brna);
rna_def_mloopcol(brna);
rna_def_mproperties(brna);
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index fe18e6254d0..b63390c65ed 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -41,8 +41,10 @@
#include "BKE_mesh.h"
#include "ED_mesh.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
-const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2)
+static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2)
{
const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON * 60);
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 084cda87507..eb4660c18e8 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -215,7 +215,7 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
}
}
-void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
+static void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
{
ModifierData *md = ptr->data;
char oldname[sizeof(md->name)];
@@ -2658,7 +2658,7 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
#endif
}
-static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna)
+static void rna_def_modifier_weightvg_mask(BlenderRNA *UNUSED(brna), StructRNA *srna)
{
static EnumPropertyItem weightvg_mask_tex_map_items[] = {
{MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", "Use local generated coordinates"},
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index 8b2b741b83e..c221d1175df 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -187,8 +187,7 @@ static void rna_def_moviecliUser(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Movie Clip User",
"Parameters defining how a MovieClip datablock is used by another datablock");
- prop = RNA_def_property(srna, "current_frame", PROP_INT, PROP_TIME);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "framenr");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Current Frame", "Current frame number in movie or image sequence");
@@ -299,6 +298,12 @@ static void rna_def_movieclip(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name "
"(affects only how footage is loading, does not change data associated with a clip)");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
+
+ /* color management */
+ prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "colorspace_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings");
+ RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
}
void RNA_def_movieclip(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 16753961852..6e0f9f37d17 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -360,7 +360,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report
/* Set the 'solo' setting for the given NLA-track, making sure that it is the only one
* that has this status in its AnimData block.
*/
-void rna_NlaTrack_solo_set(PointerRNA *ptr, int value)
+static void rna_NlaTrack_solo_set(PointerRNA *ptr, int value)
{
NlaTrack *data = (NlaTrack *)ptr->data;
AnimData *adt = BKE_animdata_from_id(ptr->id.data);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 55dda3fc315..6b543f9f576 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -3839,7 +3839,7 @@ static void def_cmp_trackpos(StructRNA *srna)
RNA_def_property_ui_text(prop, "Position", "Which marker position to use for output");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
- prop = RNA_def_property(srna, "relative_frame", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "frame_relative", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
RNA_def_property_ui_text(prop, "Frame", "Frame to be used for relative position");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -4036,7 +4036,7 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop)
}
/* shared between all note tree types*/
-static void rna_def_nodetree_active_api(StructRNA *srna, PropertyRNA *cprop)
+static void rna_def_nodetree_active_api(StructRNA *srna, PropertyRNA *UNUSED(cprop))
{
PropertyRNA *prop;
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index e69d313b23b..a10c153515a 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -231,7 +231,7 @@ void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
}
-void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Object *ob = ptr->id.data;
@@ -496,7 +496,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
"Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
}
-void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
+static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
{
Object *ob = (Object *)ptr->id.data;
bDeformGroup *dg = (bDeformGroup *)ptr->data;
@@ -1101,7 +1101,7 @@ static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
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;
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
*min = 0;
if (key) {
@@ -1130,7 +1130,7 @@ static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
KeyBlock *kb;
PointerRNA keyptr;
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 5bf1cc281ad..1263e7716dd 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -39,6 +39,8 @@
#include "DNA_object_types.h"
#include "DNA_modifier_types.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include "BLI_math.h"
@@ -385,7 +387,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *
}
}
-int rna_Object_is_visible(Object *ob, Scene *sce)
+static int rna_Object_is_visible(Object *ob, Scene *sce)
{
return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay);
}
@@ -428,8 +430,8 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int
#endif
/* BMESH_TODO, return polygon index, not tessface */
-void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3],
- float r_location[3], float r_normal[3], int *index)
+static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3],
+ float r_location[3], float r_normal[3], int *index)
{
BVHTreeFromMesh treeData = {NULL};
@@ -470,8 +472,8 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl
*index = -1;
}
-void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist,
- float n_location[3], float n_normal[3], int *index)
+static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist,
+ float n_location[3], float n_normal[3], int *index)
{
BVHTreeFromMesh treeData = {NULL};
@@ -510,7 +512,7 @@ void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float poi
/* ObjectBase */
-void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d)
+static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d)
{
base->lay = base->object->lay = v3d->lay;
}
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index fc3dfafe133..89638389fd2 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -502,7 +502,7 @@ static int rna_PartSettings_is_fluid_get(PointerRNA *ptr)
return part->type == PART_FLUID;
}
-void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value)
+static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value)
{
Object *ob = ptr->id.data;
ParticleSystem *part = (ParticleSystem *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 739f302fcbe..2b6fd2cb263 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -148,7 +148,7 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
}
}
-void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value)
+static void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value)
{
Object *ob = ptr->id.data;
bActionGroup *agrp = ptr->data;
@@ -257,7 +257,7 @@ static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
return ED_pose_channel_in_IK_chain(ob, pchan);
}
-StructRNA *rna_IKParam_refine(PointerRNA *ptr)
+static StructRNA *rna_IKParam_refine(PointerRNA *ptr)
{
bIKParam *param = (bIKParam *)ptr->data;
@@ -269,7 +269,7 @@ StructRNA *rna_IKParam_refine(PointerRNA *ptr)
}
}
-PointerRNA rna_Pose_ikparam_get(struct PointerRNA *ptr)
+static PointerRNA rna_Pose_ikparam_get(struct PointerRNA *ptr)
{
bPose *pose = (bPose *)ptr->data;
return rna_pointer_inherit_refine(ptr, &RNA_IKParam, pose->ikparam);
@@ -593,7 +593,7 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index)
}
/* not essential, but much faster then the default lookup function */
-int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
+static int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
{
bPose *pose = (bPose *)ptr->data;
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, key);
@@ -788,8 +788,6 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable");
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
- /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */
- RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
@@ -797,8 +795,6 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable");
RNA_def_property_float_array_default(prop, default_scale);
RNA_def_property_ui_text(prop, "Scale", "");
- /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */
- RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
@@ -806,8 +802,6 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
RNA_def_property_float_array_default(prop, default_quat);
RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
- /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */
- RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
/* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
@@ -820,15 +814,11 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
RNA_def_property_float_array_default(prop, default_axisAngle);
RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
- /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */
- RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "eul");
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable");
- /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */
- RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c
index bf9f924489b..fc3697633a4 100644
--- a/source/blender/makesrna/intern/rna_property.c
+++ b/source/blender/makesrna/intern/rna_property.c
@@ -89,7 +89,7 @@ static void rna_GameProperty_type_set(PointerRNA *ptr, int value)
if (prop->type != value) {
prop->type = value;
- init_property(prop);
+ BKE_bproperty_init(prop);
}
}
@@ -97,7 +97,7 @@ static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value)
{
bProperty *prop = (bProperty *)(ptr->data);
BLI_strncpy_utf8(prop->name, value, sizeof(prop->name));
- unique_property(NULL, prop, 1);
+ BKE_bproperty_unique(NULL, prop, 1);
}
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index bd4d3e84883..1c7f0b00caf 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -160,12 +160,13 @@ EnumPropertyItem snap_node_element_items[] = {
#define R_IMF_ENUM_TAGA_RAW {R_IMF_IMTYPE_RAWTGA, "TARGA_RAW", ICON_FILE_IMAGE, "Targa Raw", \
"Output image in uncompressed Targa format"},
-
+#if 0 /* UNUSED (so far) */
#ifdef WITH_DDS
# define R_IMF_ENUM_DDS {R_IMF_IMTYPE_DDS, "DDS", ICON_FILE_IMAGE, "DDS", "Output image in DDS format"},
#else
# define R_IMF_ENUM_DDS
#endif
+#endif
#ifdef WITH_OPENJPEG
# define R_IMF_ENUM_JPEG2K {R_IMF_IMTYPE_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", \
@@ -501,7 +502,7 @@ static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, Pointer
}
-static void rna_Scene_current_frame_set(PointerRNA *ptr, int value)
+static void rna_Scene_frame_current_set(PointerRNA *ptr, int value)
{
Scene *data = (Scene *)ptr->data;
@@ -1096,34 +1097,6 @@ static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi
DAG_id_tag_update(&scene->id, 0);
}
-static void rna_RenderSettings_color_management_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
-{
- /* reset image nodes */
- Scene *scene = (Scene *)ptr->id.data;
- bNodeTree *ntree = scene->nodetree;
- bNode *node;
-
- if (ntree && scene->use_nodes) {
- /* images are freed here, stop render and preview threads, until
- * Image is threadsafe. when we are changing this property from a
- * python script in the render thread, don't stop own thread */
- if (BLI_thread_is_main())
- WM_jobs_stop_all(bmain->wm.first);
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_IMAGE)) {
- ED_node_changed_update(&scene->id, node);
- WM_main_add_notifier(NC_NODE | NA_EDITED, node);
-
- if (node->type == CMP_NODE_IMAGE)
- BKE_image_signal((Image *)node->id, NULL, IMA_SIGNAL_FREE);
- }
- }
- }
-
- rna_Scene_glsl_update(bmain, scene, ptr);
-}
-
static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value)
{
Scene *scene = (Scene *)ptr->id.data;
@@ -3390,6 +3363,17 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "G", "Log conversion gamma");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ /* color management */
+ prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
+ RNA_def_property_ui_text(prop, "View Settings", "Color management settings applied on image before saving");
+
+ prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "display_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings");
+ RNA_def_property_ui_text(prop, "Display Settings", "Settings of device saved image would be displayed on");
}
static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
@@ -4140,11 +4124,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"editor pipeline, if sequencer strips exist");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "use_color_management", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT);
- RNA_def_property_ui_text(prop, "Color Management", "Use linear workflow - gamma corrected imaging pipeline");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_RenderSettings_color_management_update");
-
prop = RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT_PREDIVIDE);
RNA_def_property_ui_text(prop, "Color Unpremultiply",
@@ -4426,6 +4405,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_enum_items(prop, engine_items);
RNA_def_property_enum_funcs(prop, "rna_RenderSettings_engine_get", "rna_RenderSettings_engine_set",
"rna_RenderSettings_engine_itemf");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
RNA_def_property_update(prop, NC_WINDOW, "rna_RenderSettings_engine_update");
@@ -4774,7 +4754,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "r.cfra");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
- RNA_def_property_int_funcs(prop, NULL, "rna_Scene_current_frame_set", NULL);
+ RNA_def_property_int_funcs(prop, NULL, "rna_Scene_frame_current_set", NULL);
RNA_def_property_ui_text(prop, "Current Frame",
"Current Frame, to update animation data from python frame_set() instead");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_frame_update");
@@ -5027,6 +5007,22 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Active Movie Clip", "Active movie clip used for constraints and viewport drawing");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ /* color management */
+ prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
+ RNA_def_property_ui_text(prop, "View Settings", "Color management settings applied on image before saving");
+
+ prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "display_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings");
+ RNA_def_property_ui_text(prop, "Display Settings", "Settings of device saved image would be displayed on");
+
+ prop = RNA_def_property(srna, "sequencer_colorspace_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "sequencer_colorspace_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings");
+ RNA_def_property_ui_text(prop, "Sequencer Color Space Settings", "Settings of color space sequencer is working in");
+
/* Nestled Data */
rna_def_tool_settings(brna);
rna_def_unified_paint_settings(brna);
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 69b61b47d8a..cdf7ac5e68f 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -40,6 +40,8 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include "BKE_animsys.h"
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index a6d4e473df4..32e388598f5 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -140,12 +140,12 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
}
}
-void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2])
+static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2])
{
UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
}
-void rna_View2D_view_to_region(struct View2D *v2d, float x, float y, int clip, int result[2])
+static void rna_View2D_view_to_region(struct View2D *v2d, float x, float y, int clip, int result[2])
{
if (clip)
UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]);
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index 314082dfd02..6097fa2ae96 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -104,7 +104,7 @@ static StructRNA *rna_Sensor_refine(struct PointerRNA *ptr)
}
}
-void rna_Sensor_name_set(PointerRNA *ptr, const char *value)
+static void rna_Sensor_name_set(PointerRNA *ptr, const char *value)
{
bSensor *sens = (bSensor *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index e3e467a9abb..b27148e964d 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1433,6 +1433,11 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_channel_set", NULL); /* overlap test */
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
+ prop = RNA_def_property(srna, "use_linear_modifiers", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_LINEAR_MODIFIERS);
+ RNA_def_property_ui_text(prop, "Use Linear Modifiers", "Calculate modifiers in linear space instead of sequencer's space");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
+
/* blending */
prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index 549868e5ed0..c7c4b0817f6 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -37,8 +37,6 @@
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
-extern EnumPropertyItem blend_mode_items[];
-
#ifdef RNA_RUNTIME
//#include "DNA_anim_types.h"
@@ -188,7 +186,8 @@ static Sequence *rna_Sequences_new_movie(ID *id, Editing *ed, ReportList *report
Scene *scene = (Scene *)id;
Sequence *seq;
- struct anim *an = openanim(file, IB_rect, 0);
+ /* OCIO_TODO: support configurable color spaces for strips */
+ struct anim *an = openanim(file, IB_rect, 0, NULL);
if (an == NULL) {
BKE_report(reports, RPT_ERROR, "Sequences.new_movie: unable to open movie file");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index a00e8bfea2d..ff5f4988cc1 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -478,7 +478,7 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
}
/* api call */
-void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
+static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
{
bScreen *sc = (bScreen *)id;
@@ -658,20 +658,6 @@ static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const floa
}
}
-static void rna_SpaceImageEditor_curves_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- SpaceImage *sima = (SpaceImage *)ptr->data;
- ImBuf *ibuf;
- void *lock;
-
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
- if (ibuf->rect_float)
- curvemapping_do_ibuf(sima->cumap, ibuf);
- ED_space_image_release_buffer(sima, lock);
-
- WM_main_add_notifier(NC_IMAGE, sima->image);
-}
-
static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)ptr->data;
@@ -680,7 +666,7 @@ static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene
ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
- scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
WM_main_add_notifier(NC_IMAGE, sima->image);
}
ED_space_image_release_buffer(sima, lock);
@@ -863,7 +849,7 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *UNUSED(bmain), Scene *s
adt = BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */
}
else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = ob_get_key(obact);
+ Key *key = BKE_key_from_object(obact);
if (key)
adt = BKE_id_add_animdata(&key->id); /* this only adds if non-existant */
}
@@ -890,7 +876,7 @@ static void rna_SpaceDopeSheetEditor_mode_update(Main *UNUSED(bmain), Scene *sce
/* special exceptions for ShapeKey Editor mode */
if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = ob_get_key(obact);
+ Key *key = BKE_key_from_object(obact);
/* 1) update the action stored for the editor */
if (key)
@@ -1116,7 +1102,7 @@ static void rna_def_space(BlenderRNA *brna)
}
/* for all spaces that use a mask */
-void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set_func)
+static void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set_func)
{
PropertyRNA *prop;
@@ -1980,11 +1966,6 @@ static void rna_def_space_image(BlenderRNA *brna)
"Parameters defining which layer, pass and frame of the image is displayed");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
- prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "cumap");
- RNA_def_property_ui_text(prop, "Curve", "Color curve mapping to use for displaying the image");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_curves_update");
-
prop = RNA_def_property(srna, "scopes", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "scopes");
RNA_def_property_struct_type(prop, "Scopes");
diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c
index e62b3ecd804..a2880510958 100644
--- a/source/blender/makesrna/intern/rna_texture_api.c
+++ b/source/blender/makesrna/intern/rna_texture_api.c
@@ -32,6 +32,8 @@
#include "RNA_define.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include "IMB_imbuf.h"
@@ -42,8 +44,8 @@
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
-void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath,
- struct Scene *scene, float layout[12])
+static void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath,
+ struct Scene *scene, float layout[12])
{
if (scene == NULL) {
scene = CTX_data_scene(C);
@@ -52,7 +54,7 @@ void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const cha
RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout);
}
-void clear_envmap(struct EnvMap *env, bContext *C)
+static void clear_envmap(struct EnvMap *env, bContext *C)
{
Main *bmain = CTX_data_main(C);
Tex *tex;
@@ -66,7 +68,7 @@ void clear_envmap(struct EnvMap *env, bContext *C)
}
}
-void texture_evaluate(struct Tex *tex, float value[3], float color_r[4])
+static void texture_evaluate(struct Tex *tex, float value[3], float color_r[4])
{
TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
multitex_ext(tex, value, NULL, NULL, 1, &texres);
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 172a79970b5..0c62a280935 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -144,7 +144,7 @@ static void rna_tracking_active_track_set(PointerRNA *ptr, PointerRNA value)
clip->tracking.act_track = NULL;
}
-void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value)
+static void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value)
{
MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTracking *tracking = &clip->tracking;
@@ -325,7 +325,7 @@ static void rna_tracking_active_object_set(PointerRNA *ptr, PointerRNA value)
else clip->tracking.objectnr = 0;
}
-void rna_trackingObject_name_set(PointerRNA *ptr, const char *value)
+static void rna_trackingObject_name_set(PointerRNA *ptr, const char *value)
{
MovieClip *clip = (MovieClip *)ptr->id.data;
MovieTrackingObject *object = (MovieTrackingObject *)ptr->data;
@@ -447,7 +447,7 @@ static MovieTrackingObject *rna_trackingObject_new(MovieTracking *tracking, cons
return object;
}
-void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object)
+static void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object)
{
BKE_tracking_object_delete(tracking, object);
@@ -477,7 +477,7 @@ static MovieTrackingMarker *rna_trackingMarkers_insert_frame(MovieTrackingTrack
return new_marker;
}
-void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int framenr)
+static void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int framenr)
{
if (track->markersnr == 1)
return;
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index cf43bd74d72..006e1ad3903 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -36,6 +36,8 @@
#include "UI_resources.h"
+#include "rna_internal.h"
+
#ifdef RNA_RUNTIME
static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, int icon,
@@ -415,6 +417,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function_ui_description(func, "User interface for setting image format options");
parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
+ RNA_def_boolean(func, "color_management", 0, "", "Show color management settings");
func = RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip");
RNA_def_function_ui_description(func, "Item(s). User interface for selecting movie clips and their source paths");
@@ -497,6 +500,17 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "introspect", "uiLayoutIntrospect");
parm = RNA_def_string(func, "string", "", 1024 * 1024, "Descr", "DESCR");
RNA_def_function_return(func, parm);
+
+ /* color management templates */
+ func = RNA_def_function(srna, "template_colorspace_settings", "uiTemplateColorspaceSettings");
+ RNA_def_function_ui_description(func, "Item. A widget to control input color space settings.");
+ api_ui_item_rna_common(func);
+
+ func = RNA_def_function(srna, "template_colormanaged_view_settings", "uiTemplateColormanagedViewSettings");
+ RNA_def_function_ui_description(func, "Item. A widget to control color managed view settings settings.");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ api_ui_item_rna_common(func);
+ /* RNA_def_boolean(func, "show_global_settings", 0, "", "Show widgets to control global color management settings"); */
}
#endif
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 018022fdde9..eada607ed97 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2994,8 +2994,9 @@ static void rna_def_userdef_system(BlenderRNA *brna)
/* Note: As this list is in alphabetical order, and not defined order,
* here is the highest define currently in use: 33 (Hebrew). */
static EnumPropertyItem language_items[] = {
- { 0, "", 0, N_("Nearly done"), ""},
+ { 0, "", 0, N_("Nearly Done"), ""},
{ 0, "DEFAULT", 0, "Default (Default)", ""},
+ /* using the utf8 flipped form of Arabic (العربية) */
{21, "ARABIC", 0, "Arabic (ﺔﻴﺑﺮﻌﻟﺍ)", "ar_EG"},
{32, "BRAZILIANPORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"},
{ 1, "ENGLISH", 0, "English (English)", "en_US"},
@@ -3008,8 +3009,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{ 9, "SPANISH", 0, "Spanish (Español)", "es"},
{14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"},
{18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"},
- { 0, "", 0, N_("In progress"), ""},
- /* using the utf8 flipped form of Arabic (العربية) */
+ { 0, "", 0, N_("In Progress"), ""},
{22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"},
{10, "CATALAN", 0, "Catalan (Català)", "ca_AD"},
{16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"},
@@ -3018,8 +3018,9 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{ 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"},
{ 5, "GERMAN", 0, "German (Deutsch)", "de_DE"},
{23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"},
- {33, "HEBREW", 0, "Hebrew (עִבְרִית)", "he_IL"},
- {31, "HUNGARIAN", 0, "Hungarian (magyar)", "hu_HU"},
+ /* 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. */
@@ -3029,7 +3030,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{19, "POLISH", 0, "Polish (Polski)", "pl_PL"},
/* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX No po's yet. */
{17, "SERBIAN", 0, "Serbian (Српски)", "sr_RS"},
- {28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr_RS@latin"},
+ {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}
@@ -3602,7 +3603,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
"Enables automatic saving of preview images in the .blend file");
}
-void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)
+static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 61c75e306cb..d8753f4ff43 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -765,14 +765,14 @@ static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
{
wmKeyMapItem *kmi = ptr->data;
wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
- strcpy(value, ot ? ot->name : kmi->idname);
+ strcpy(value, ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
}
static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
- return strlen(ot ? ot->name : kmi->idname);
+ return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
}
static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
@@ -1136,7 +1136,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *
return dummyot.ext.srna;
}
-void **rna_Operator_instance(PointerRNA *ptr)
+static void **rna_Operator_instance(PointerRNA *ptr)
{
wmOperator *op = ptr->data;
return &op->py_instance;
@@ -1793,7 +1793,7 @@ static void rna_def_keyconfig(BlenderRNA *brna)
* fallback on the operator ID */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event");
+ RNA_def_property_ui_text(prop, "Name", "Name of operator (translated) to call on input event");
RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index ae4d5dc493e..cb4e00a042e 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -39,6 +39,8 @@
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
+#include "rna_internal.h" /* own include */
+
#ifdef RNA_RUNTIME
#include "BKE_context.h"
@@ -72,12 +74,12 @@ static int rna_event_modal_handler_add(struct bContext *C, struct wmOperator *op
}
/* XXX, need a way for python to know event types, 0x0110 is hard coded */
-wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win)
+static wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win)
{
return WM_event_add_timer(wm, win, 0x0110, time_step);
}
-void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
+static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
{
WM_event_remove_timer(wm, timer->win, timer);
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index cdb200ff180..638e91e22f1 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -88,10 +88,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-#define EDGE_MARK 1
-
#ifdef USE_BM_BEVEL_OP_AS_MOD
+#define EDGE_MARK 1
+
/* BMESH_TODO
*
* this bevel calls the operator which is missing many of the options
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 890e45f7e80..254c02b7672 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -188,11 +188,9 @@ static void deformVerts(ModifierData *md, Object *ob,
psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm);
}
- if (psys) {
- psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(md->scene, ob, psys);
- psmd->flag |= eParticleSystemFlag_psys_updated;
- }
+ 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_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 4fd2c658380..a94b4834d18 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -393,7 +393,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
mul_m4_v3(mtx_tx, vc->co);
/* length in 2d, don't sqrt because this is only for comparison */
- vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
+ vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
/* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
@@ -410,7 +410,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->v[0] = vc->v[1] = -1;
/* length in 2d, don't sqrt because this is only for comparison */
- vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
+ vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
/* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
@@ -430,7 +430,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->e[1] = med_new;
}
else {
- vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */
+ vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
}
vc = &vert_connect[med_new->v2];
@@ -445,7 +445,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
vc->e[1] = med_new;
}
else {
- vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */
+ vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */
}
}
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 3353382fa3d..8ef86362edd 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -54,7 +54,7 @@ static void deformVerts(ModifierData *md, Object *ob,
int numVerts,
ModifierApplyFlag UNUSED(flag))
{
- KeyBlock *kb = ob_get_keyblock(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float (*deformedVerts)[3];
if (kb && kb->totelem == numVerts) {
@@ -69,8 +69,8 @@ static void deformVerts(ModifierData *md, Object *ob,
static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float scale[3][3];
(void)vertexCos; /* unused */
@@ -94,7 +94,7 @@ static void deformVertsEM(ModifierData *md, Object *ob,
float (*vertexCos)[3],
int numVerts)
{
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
if (key && key->type == KEY_RELATIVE)
deformVerts(md, ob, derivedData, vertexCos, numVerts, 0);
@@ -107,8 +107,8 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
float (*defMats)[3][3],
int numVerts)
{
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float scale[3][3];
(void)vertexCos; /* unused */
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index eb5a74f0dcc..88951919272 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -157,7 +157,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0);
Projector projectors[MOD_UVPROJECT_MAXPROJECTORS];
int num_projectors = 0;
- float aspect;
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
float aspx = umd->aspectx ? umd->aspectx : 1.0f;
float aspy = umd->aspecty ? umd->aspecty : 1.0f;
@@ -165,8 +164,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
float scay = umd->scaley ? umd->scaley : 1.0f;
int free_uci = 0;
- aspect = aspx / aspy;
-
for (i = 0; i < umd->num_projectors; ++i)
if (umd->projectors[i])
projectors[num_projectors++].ob = umd->projectors[i];
@@ -199,39 +196,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
free_uci = 1;
}
else {
- float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
- int sensor_fit = BKE_camera_sensor_fit(cam->sensor_fit, aspx, aspy);
- float scale = (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale;
- float xmax, xmin, ymax, ymin;
-
- if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
- xmax = 0.5f * scale;
- ymax = xmax / aspect;
- }
- else {
- ymax = 0.5f * scale;
- xmax = ymax * aspect;
- }
+ CameraParams params;
- xmin = -xmax;
- ymin = -ymax;
+ /* setup parameters */
+ BKE_camera_params_init(&params);
+ BKE_camera_params_from_object(&params, projectors[i].ob);
- /* scale the matrix */
- xmin *= scax;
- xmax *= scax;
- ymin *= scay;
- ymax *= scay;
+ /* compute matrix, viewplane, .. */
+ BKE_camera_params_compute_viewplane(&params, 1, 1, aspx, aspy);
- if (cam->type == CAM_PERSP) {
- float perspmat[4][4];
- perspective_m4(perspmat, xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
- mult_m4_m4m4(tmpmat, perspmat, projectors[i].projmat);
- }
- else { /* if (cam->type == CAM_ORTHO) */
- float orthomat[4][4];
- orthographic_m4(orthomat, xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
- mult_m4_m4m4(tmpmat, orthomat, projectors[i].projmat);
- }
+ /* scale the view-plane */
+ params.viewplane.xmin *= scax;
+ params.viewplane.xmax *= scax;
+ params.viewplane.ymin *= scay;
+ params.viewplane.ymax *= scay;
+
+ BKE_camera_params_compute_matrix(&params);
+ mult_m4_m4m4(tmpmat, params.winmat, projectors[i].projmat);
}
}
else {
@@ -241,22 +222,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
unit_m4(offsetmat);
mul_mat3_m4_fl(offsetmat, 0.5);
offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5;
-
- if (cam) {
- if (aspx == aspy) {
- offsetmat[3][0] -= cam->shiftx;
- offsetmat[3][1] -= cam->shifty;
- }
- else if (aspx < aspy) {
- offsetmat[3][0] -= (cam->shiftx * aspy / aspx);
- offsetmat[3][1] -= cam->shifty;
- }
- else {
- offsetmat[3][0] -= cam->shiftx;
- offsetmat[3][1] -= (cam->shifty * aspx / aspy);
- }
- }
-
+
mult_m4_m4m4(projectors[i].projmat, offsetmat, tmpmat);
/* calculate worldspace projector normal (for best projector test) */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 22b1e33e2a6..25a2a61d8e3 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -185,7 +185,7 @@ static float get_ob2ob_distance(const Object *ob, const Object *obr)
/**
* Maps distances to weights, with an optional "smoothing" mapping.
*/
-void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode)
+static void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode)
{
const float range_inv = 1.0f / (max_d - min_d); /* invert since multiplication is faster */
unsigned int i = nidx;
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index e1510f9f813..c9960df1345 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include "DNA_anim_types.h"
+#include "DNA_color_types.h"
#include "DNA_scene_types.h"
#include "DNA_node_types.h"
@@ -693,7 +694,9 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr
void *COM_linker_hack = NULL;
-void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview)
+void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview,
+ const ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
{
#ifdef WITH_COMPOSITOR
#ifdef WITH_COMPOSITOR_LEGACY
@@ -704,10 +707,11 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int
else
#endif
{
- COM_execute(rd, ntree, rendering);
+ COM_execute(rd, ntree, rendering, view_settings, display_settings);
}
#else
(void)ntree, (void)rd, (void)rendering, (void)do_preview;
+ (void)view_settings, (void)display_settings;
#endif
(void)do_preview;
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index 2277c5a2836..8f01408d8c7 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -146,7 +146,7 @@ CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, in
if (disprect.xmin>= disprect.xmax) return NULL;
if (disprect.ymin>= disprect.ymax) return NULL;
- cbuf= alloc_compbuf(BLI_RCT_SIZE_X(&disprect), BLI_RCT_SIZE_Y(&disprect), type, 1);
+ cbuf= alloc_compbuf(BLI_rcti_size_x(&disprect), BLI_rcti_size_y(&disprect), type, 1);
outfp= cbuf->rect;
rectf += type*(disprect.ymin*rectx + disprect.xmin);
dx= type*cbuf->x;
@@ -606,6 +606,9 @@ static CompBuf *generate_procedural_preview(CompBuf *cbuf, int newx, int newy)
return outbuf;
}
+/* OCIO_TODO: this function is only used by legacy compositor system only, which would likely be removed soon,
+ * keep check for old color management flag for now
+ */
void generate_preview(void *data, bNode *node, CompBuf *stackbuf)
{
RenderData *rd= data;
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 96a92055ca9..9f3874560ac 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -282,6 +282,8 @@ static void cmp_node_image_update(bNodeTree *ntree, bNode *node)
cmp_node_image_verify_outputs(ntree, node);
}
+#ifdef WITH_COMPOSITOR_LEGACY
+
/* float buffer from the image with matching color management */
float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc)
{
@@ -290,40 +292,25 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc)
*alloc= FALSE;
+ /* OCIO_TODO: this is a part of legacy compositor system, don't bother with porting this code
+ * to new color management system since this code would likely be simply removed soon
+ */
if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) {
- if (ibuf->profile != IB_PROFILE_NONE) {
- rect= ibuf->rect_float;
- }
- else {
- rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image");
-
- IMB_buffer_float_from_float(rect, ibuf->rect_float,
- 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
-
- *alloc= TRUE;
- }
+ rect= ibuf->rect_float;
}
else {
- if (ibuf->profile == IB_PROFILE_NONE) {
- rect= ibuf->rect_float;
- }
- else {
- rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image");
+ rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image");
- IMB_buffer_float_from_float(rect, ibuf->rect_float,
- 4, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ IMB_buffer_float_from_float(rect, ibuf->rect_float,
+ 4, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
*alloc= TRUE;
- }
}
return rect;
}
-#ifdef WITH_COMPOSITOR_LEGACY
-
/* note: this function is used for multilayer too, to ensure uniform
* handling with BKE_image_get_ibuf() */
static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *iuser)
diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
index 2d9b9348668..656e2a72c03 100644
--- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c
+++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
@@ -267,9 +267,6 @@ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack
ibuf->rect_float = cbuf->rect;
ibuf->dither = rd->dither_intensity;
- if (rd->color_mgt_flag & R_COLOR_MANAGEMENT)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
-
/* get full path */
BLI_join_dirfile(path, FILE_MAX, nimf->base_path, sockdata->path);
BKE_makepicstring(filename, path, bmain->name, rd->cfra, format->imtype, (rd->scemode & R_EXTENSION), TRUE);
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index fdbe82efeda..59a4d6818c8 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -349,7 +349,7 @@ void node_group_edit_clear(bNode *node)
nodeGroupEditClear(inode);
}
-void node_group_link(bNodeTree *ntree, bNodeSocket *sock, int in_out)
+static void UNUSED_FUNCTION(node_group_link)(bNodeTree *ntree, bNodeSocket *sock, int in_out)
{
node_group_expose_socket(ntree, sock, in_out);
}
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index 9f9caef14e2..95104df5fed 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -67,7 +67,7 @@ ListBase node_internal_connect_default(struct bNodeTree *ntree, struct bNode *no
#endif
// this is needed for inlining behavior
-#if defined _WIN32
+#if defined _MSC_VER
# define DO_INLINE __inline
#elif defined (__sun) || defined (__sun__)
# define DO_INLINE
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 53f1aa82f60..5e58b74ac3a 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -49,8 +49,6 @@
#include <assert.h>
#include "node_texture_util.h"
-#define PREV_RES 128 /* default preview resolution */
-
static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread)
{
if (dg->node->need_exec) {
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 7d8c4ce232c..e938e6fc419 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -61,6 +61,8 @@
#include "node_util.h"
+#include "NOD_texture.h"
+
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_rand.h"
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index c16b1fb901f..fb5b94249e6 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -42,6 +42,8 @@
#include "bmesh.h"
+#include "bmesh_py_ops.h" /* own include */
+
#include "bmesh_py_types.h"
#include "bmesh_py_utils.h" /* own include */
@@ -69,7 +71,7 @@ typedef struct {
const char *opname;
} BPy_BMeshOpFunc;
-PyObject *bpy_bmesh_op_CreatePyObject(const char *opname)
+static PyObject *bpy_bmesh_op_CreatePyObject(const char *opname)
{
BPy_BMeshOpFunc *self = PyObject_New(BPy_BMeshOpFunc, &bmesh_op_Type);
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index 4b397ee1870..15aa5164c86 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -72,6 +72,7 @@ set(SRC
bpy_app_handlers.h
bpy_driver.h
bpy_intern_string.h
+ bpy_library.h
bpy_operator.h
bpy_operator_wrap.h
bpy_props.h
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 38d082346d8..360e041270f 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -37,6 +37,7 @@
#include "bpy_rna.h"
#include "bpy_app.h"
#include "bpy_props.h"
+#include "bpy_library.h"
#include "bpy_operator.h"
#include "BLI_path_util.h"
@@ -240,7 +241,6 @@ static PyObject *bpy_import_test(const char *modname)
void BPy_init_modules(void)
{
extern BPy_StructRNA *bpy_context_module;
- extern int bpy_lib_init(PyObject *);
PointerRNA ctx_ptr;
PyObject *mod;
@@ -276,7 +276,7 @@ void BPy_init_modules(void)
PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type);
/* needs to be first so bpy_types can run */
- bpy_lib_init(mod);
+ BPY_library_module(mod);
bpy_import_test("bpy_types");
PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index 2412d65aa21..fe877d161ff 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -23,10 +23,13 @@
* \ingroup pythonintern
*/
-
+#ifndef __BPY_H__
+
void BPy_init_modules(void);
extern PyObject *bpy_package_py;
/* bpy_interface_atexit.c */
void BPY_atexit_register(void);
void BPY_atexit_unregister(void);
+
+#endif /* __BPY_H__ */
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c
index 44bba4c098f..5ae2a11710a 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.c
+++ b/source/blender/python/intern/bpy_app_ffmpeg.c
@@ -26,11 +26,8 @@
#include <Python.h>
#include "BLI_utildefines.h"
-#include "BLI_callbacks.h"
-#include "RNA_types.h"
-#include "RNA_access.h"
-#include "bpy_rna.h"
+#include "bpy_app_ffmpeg.h"
#ifdef WITH_FFMPEG
#include <libavcodec/avcodec.h>
@@ -80,8 +77,10 @@ static PyObject *make_ffmpeg_info(void)
return NULL;
}
+#if 0 // UNUSED
#define SetIntItem(flag) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyLong_FromLong(flag))
+#endif
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyUnicode_FromString(str))
#define SetObjItem(obj) \
@@ -121,7 +120,7 @@ static PyObject *make_ffmpeg_info(void)
return NULL;
}
-#undef SetIntItem
+// #undef SetIntItem
#undef SetStrItem
#undef SetObjItem
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index bab5a83a6ed..4d7f2080bbc 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -37,6 +37,8 @@
#include "bpy_rna.h"
#include "bpy_app_handlers.h"
+#include "BPY_extern.h"
+
void bpy_app_generic_callback(struct Main *main, struct ID *id, void *arg);
static PyTypeObject BlenderAppCbType;
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 9cd0bdd090a..85f6163c721 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -53,6 +53,7 @@
#include "BLI_path_util.h"
#include "BLI_fileops.h"
+#include "BLI_listbase.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -383,6 +384,7 @@ typedef struct {
static int python_script_exec(bContext *C, const char *fn, struct Text *text,
struct ReportList *reports, const short do_jump)
{
+ Main *bmain_old = CTX_data_main(C);
PyObject *main_mod = NULL;
PyObject *py_dict = NULL, *py_result = NULL;
PyGILState_STATE gilstate;
@@ -461,7 +463,11 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
if (!py_result) {
if (text) {
if (do_jump) {
- python_script_error_jump_text(text);
+ /* ensure text is valid before use, the script may have freed its self */
+ Main *bmain_new = CTX_data_main(C);
+ if ((bmain_old == bmain_new) && (BLI_findindex(&bmain_new->text, text) != -1)) {
+ python_script_error_jump_text(text);
+ }
}
}
BPy_errors_to_report(reports);
@@ -680,11 +686,20 @@ void BPY_modules_load_user(bContext *C)
int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result)
{
- PyObject *pyctx = (PyObject *)CTX_py_dict_get(C);
- PyObject *item = PyDict_GetItemString(pyctx, member);
+ PyGILState_STATE gilstate;
+ int use_gil = !PYC_INTERPRETER_ACTIVE;
+
+ PyObject *pyctx;
+ PyObject *item;
PointerRNA *ptr = NULL;
int done = FALSE;
+ if (use_gil)
+ gilstate = PyGILState_Ensure();
+
+ pyctx = (PyObject *)CTX_py_dict_get(C);
+ item = PyDict_GetItemString(pyctx, member);
+
if (item == NULL) {
/* pass */
}
@@ -720,7 +735,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
}
else {
- printf("List item not a valid type\n");
+ printf("PyContext: '%s' list item not a valid type in sequece type '%s'\n",
+ member, Py_TYPE(item)->tp_name);
}
}
@@ -740,6 +756,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
}
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
return done;
}
diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c
index db97d361c73..13d8cedf907 100644
--- a/source/blender/python/intern/bpy_interface_atexit.c
+++ b/source/blender/python/intern/bpy_interface_atexit.c
@@ -32,6 +32,7 @@
#include <Python.h>
#include "bpy_util.h"
+#include "bpy.h" /* own include */
#include "WM_api.h"
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 40ec8136eb7..7571fe0f75e 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -55,6 +55,7 @@
#include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */
#include "bpy_util.h"
+#include "bpy_library.h"
#ifdef USE_RNA_DATABLOCKS
# include "bpy_rna.h"
@@ -426,7 +427,7 @@ static PyObject *bpy_lib_dir(BPy_Library *self)
}
-int bpy_lib_init(PyObject *mod_par)
+int BPY_library_module(PyObject *mod_par)
{
static PyMethodDef load_meth = {"load", (PyCFunction)bpy_lib_load,
METH_STATIC | METH_VARARGS | METH_KEYWORDS,
diff --git a/source/blender/python/intern/bpy_library.h b/source/blender/python/intern/bpy_library.h
new file mode 100644
index 00000000000..1b68007b704
--- /dev/null
+++ b/source/blender/python/intern/bpy_library.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.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/intern/bpy_library.h
+ * \ingroup pythonintern
+ */
+
+#ifndef __BPY_LIBRARY_H__
+#define __BPY_LIBRARY_H__
+
+int BPY_library_module(PyObject *);
+
+#endif /* __BPY_LIBRARY_H__ */
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4ae8e821298..8ec8c4c41ba 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -37,6 +37,8 @@
#include "RNA_types.h"
+#include "BPY_extern.h"
+
#include "bpy_rna.h"
#include "bpy_rna_anim.h"
#include "bpy_props.h"
@@ -45,7 +47,7 @@
#include "bpy_intern_string.h"
#ifdef USE_PYRNA_INVALIDATE_WEAKREF
-#include "MEM_guardedalloc.h"
+# include "MEM_guardedalloc.h"
#endif
#include "BLI_dynstr.h"
@@ -55,7 +57,7 @@
#include "BLI_utildefines.h"
#ifdef USE_PYRNA_INVALIDATE_WEAKREF
-#include "BLI_ghash.h"
+# include "BLI_ghash.h"
#endif
#include "RNA_enum_types.h"
@@ -78,7 +80,7 @@
#include "../generic/py_capi_utils.h"
#ifdef WITH_INTERNATIONAL
-#include "BLF_translation.h"
+# include "BLF_translation.h"
#endif
#define USE_PEDANTIC_WRITE
@@ -2150,10 +2152,10 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons
* -1: exception set
* 0: not found
* 1: found */
-int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key,
- const char *err_prefix, const short err_not_found,
- PointerRNA *r_ptr
- )
+static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key,
+ const char *err_prefix, const short err_not_found,
+ PointerRNA *r_ptr
+ )
{
char *keyname;
@@ -5908,7 +5910,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = {
NULL
};
-PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
+static PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
{
BPy_PropertyCollectionIterRNA *self = PyObject_New(BPy_PropertyCollectionIterRNA, &pyrna_prop_collection_iter_Type);
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 113367788b6..1fb4b116872 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -175,6 +175,10 @@ PyObject *BPY_rna_types(void);
PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr);
PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop);
+/* extern'd by other modules which don't deal closely with RNA */
+PyObject *pyrna_id_CreatePyObject(struct ID *id);
+int pyrna_id_FromPyObject(PyObject *obj, struct ID **id);
+
/* operators also need this to set args */
int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix);
PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index b7a45897668..69839514a12 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -52,9 +52,6 @@
#include "bpy_util.h"
#include "bpy_rna_anim.h"
-#define TRUE 1
-#define FALSE 0
-
/* for keyframes and drivers */
static int pyrna_struct_anim_args_parse(
PointerRNA *ptr, const char *error_prefix, const char *path,
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index 7e2da5b1818..69fe0c48a41 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -74,8 +74,7 @@ static struct PyModuleDef gpumodule = {
NULL, NULL, NULL, NULL, NULL
};
-PyMODINIT_FUNC
-PyInit_gpu(void)
+static PyObject *PyInit_gpu(void)
{
PyObject *m;
diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c
index 50d2e88f210..e0508359e13 100644
--- a/source/blender/python/intern/stubs.c
+++ b/source/blender/python/intern/stubs.c
@@ -28,12 +28,15 @@
* \ingroup pythonintern
*/
+#include "BLI_utildefines.h"
+
+#include "BPY_extern.h"
/* python, will come back */
//void BPY_script_exec(void) {}
//void BPY_python_start(void) {}
//void BPY_text_free_code(void) {}
-void BPY_pyconstraint_exec(void) {}
-void BPY_pyconstraint_target(void) {}
-int BPY_is_pyconstraint(void) { return 0;}
-void BPY_pyconstraint_update(void) {}
+void BPY_pyconstraint_exec(struct bPythonConstraint *UNUSED(con), struct bConstraintOb *UNUSED(cob), struct ListBase *UNUSED(targets)) {}
+void BPY_pyconstraint_target(struct bPythonConstraint *UNUSED(con), struct bConstraintTarget *UNUSED(ct)) {}
+int BPY_is_pyconstraint(struct Text *UNUSED(text)) { return 0;}
+void BPY_pyconstraint_update(struct Object *UNUSED(owner), struct bConstraint *UNUSED(con)) {}
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 19f9aa2dc88..818f30ec284 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -46,8 +46,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#define SWAP_FLOAT(a, b, tmp) tmp = a; a = b; b = tmp
-
/*-------------------------DOC STRINGS ---------------------------*/
PyDoc_STRVAR(M_Geometry_doc,
"The Blender geometry module"
diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m
index e30b8331fc0..75b9056de1b 100644
--- a/source/blender/quicktime/apple/qtkit_import.m
+++ b/source/blender/quicktime/apple/qtkit_import.m
@@ -291,7 +291,6 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
ibuf = nsImageToiBuf(frameImage,anim->x, anim->y);
[pool drain];
- ibuf->profile = IB_PROFILE_SRGB;
return ibuf;
}
diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c
index 5b13d77a030..e44eba2bfe0 100644
--- a/source/blender/quicktime/apple/quicktime_import.c
+++ b/source/blender/quicktime/apple/quicktime_import.c
@@ -392,8 +392,6 @@ ImBuf *qtime_fetchibuf(struct anim *anim, int position)
}
#endif
- ibuf->profile = IB_PROFILE_SRGB;
-
IMB_flipy(ibuf);
return ibuf;
}
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 1510d9adb10..395fbf8f01c 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -226,7 +226,7 @@ void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene
int RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode);
int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const char *filename, int compress);
-struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty);
+struct RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty);
extern const float default_envmap_layout[];
int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]);
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index c07ed42332f..2a9a1becc42 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -39,10 +39,11 @@
/* called by meshtools */
struct View3D;
struct Scene;
+struct LinkNode;
-void RE_make_sticky(struct Scene *scene, struct View3D *v3d);
-
-/* for radiosity module */
+void RE_make_sticky(struct Scene *scene, struct Object *camera, struct LinkNode *objects);
+
+/* for radiosity module */
struct RadView;
struct RNode;
struct Render;
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 26a1b9908b3..57fb80f11c0 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -134,7 +134,7 @@ typedef struct ShadeInput {
int har; /* hardness */
/* texture coordinates */
- float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4];
+ float lo[3], gl[3], ref[3], orn[3], winco[3], vcol[4];
float refcol[4], displace[3];
float strandco, tang[3], nmapnorm[3], nmaptang[4], stress, winspeed[4];
float duplilo[3], dupliuv[3];
@@ -150,7 +150,6 @@ typedef struct ShadeInput {
float dxno[3], dyno[3], dxview, dyview;
float dxlv[3], dylv[3];
float dxwin[3], dywin[3];
- float dxsticky[3], dysticky[3];
float dxrefract[3], dyrefract[3];
float dxstrand, dystrand;
diff --git a/source/blender/render/intern/include/render_result.h b/source/blender/render/intern/include/render_result.h
index 303d4094f8e..5d61417cbaf 100644
--- a/source/blender/render/intern/include/render_result.h
+++ b/source/blender/render/intern/include/render_result.h
@@ -47,6 +47,8 @@ struct RenderLayer;
struct RenderResult;
struct Scene;
struct rcti;
+struct ColorManagedDisplaySettings;
+struct ColorManagedViewSettings;
/* New */
@@ -55,7 +57,7 @@ struct RenderResult *render_result_new(struct Render *re,
struct RenderResult *render_result_new_full_sample(struct Render *re,
struct ListBase *lb, struct rcti *partrct, int crop, int savebuffers);
-struct RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty);
+struct RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty);
/* Merge */
@@ -90,7 +92,9 @@ void render_result_rect_from_ibuf(struct RenderResult *rr, struct RenderData *rd
void render_result_rect_fill_zero(struct RenderResult *rr);
void render_result_rect_get_pixels(struct RenderResult *rr, struct RenderData *rd,
- unsigned int *rect, int rectx, int recty);
+ unsigned int *rect, int rectx, int recty,
+ const struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
#endif /* __RENDER_RESULT_H__ */
diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h
index 584e56836fa..d116dfe7b17 100644
--- a/source/blender/render/intern/include/renderdatabase.h
+++ b/source/blender/render/intern/include/renderdatabase.h
@@ -55,7 +55,6 @@ struct RadFace;
typedef struct VertTableNode {
struct VertRen *vert;
float *rad;
- float *sticky;
float *strand;
float *tangent;
float *stress;
@@ -110,7 +109,6 @@ struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struc
struct ObjectInstanceRen *RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4], int lay);
void RE_makeRenderInstances(struct Render *re);
-float *RE_vertren_get_sticky(struct ObjectRen *obr, struct VertRen *ver, int verify);
float *RE_vertren_get_stress(struct ObjectRen *obr, struct VertRen *ver, int verify);
float *RE_vertren_get_rad(struct ObjectRen *obr, struct VertRen *ver, int verify);
float *RE_vertren_get_strand(struct ObjectRen *obr, struct VertRen *ver, int verify);
diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h
index e4ee19d8ed2..e873111e6bf 100644
--- a/source/blender/render/intern/include/zbuf.h
+++ b/source/blender/render/intern/include/zbuf.h
@@ -139,5 +139,10 @@ void zbufclipwire(struct ZSpan *zspan, int obi, int zvlnr, int ec,
void zbuf_make_winmat(Render *re, float winmat[][4]);
void zbuf_render_project(float winmat[][4], const float co[3], float ho[4]);
+/* sould not really be exposed, bad! */
+void hoco_to_zco(ZSpan *zspan, float zco[3], const float hoco[4]);
+void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float, float) );
+void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const float ho2[4]);
+
#endif
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
index ddc84408e26..3926e8b8e51 100644
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
@@ -185,7 +185,7 @@ RTBuilder *rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp)
return tmp;
}
-void rtbuild_calc_bb(RTBuilder *b)
+static void rtbuild_calc_bb(RTBuilder *b)
{
if (b->bb[0] == 1.0e30f) {
for (RTBuilder::Object **index = b->sorted_begin[0]; index != b->sorted_end[0]; index++)
diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
index 9e7075438cb..85c9d0d402f 100644
--- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
@@ -152,7 +152,8 @@ void bvh_hint_bb(Tree *tree, LCTSHint *hint, float *UNUSED(min), float *UNUSED(m
}
}
-void bfree(VBVHTree *tree)
+#if 0 /* UNUSED */
+static void bfree(VBVHTree *tree)
{
if (tot_pushup + tot_pushdown + tot_hints + tot_moves) {
if (G.debug & G_DEBUG) {
@@ -169,6 +170,7 @@ void bfree(VBVHTree *tree)
}
bvh_free(tree);
}
+#endif
/* the cast to pointer function is needed to workarround gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11407 */
template<class Tree, int STACK_SIZE>
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index e0864533fed..9bc639515c2 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -41,6 +41,7 @@
#include "BLI_rand.h"
#include "BLI_memarena.h"
#include "BLI_ghash.h"
+#include "BLI_linklist.h"
#include "BLI_edgehash.h"
#include "DNA_armature_types.h"
@@ -118,6 +119,7 @@
#include "zbuf.h"
#include "sunsky.h"
+#include "RE_render_ext.h"
/* 10 times larger than normal epsilon, test it on default nurbs sphere with ray_transp (for quad detection) */
/* or for checking vertex normal flips */
@@ -2260,14 +2262,6 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
if ((texco & TEXCO_ORCO) && (vr->orco)) {
copy_v3_v3(shi->lo, vr->orco);
}
- if (texco & TEXCO_STICKY) {
- float *sticky= RE_vertren_get_sticky(obr, vr, 0);
- if (sticky) {
- shi->sticky[0]= sticky[0];
- shi->sticky[1]= sticky[1];
- shi->sticky[2]= 0.0f;
- }
- }
if (texco & TEXCO_GLOB) {
copy_v3_v3(shi->gl, shi->co);
mul_m4_v3(re->viewinv, shi->gl);
@@ -3267,7 +3261,6 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
VlakRen *vlr; //, *vlr1;
VertRen *ver;
Material *ma;
- MSticky *ms = NULL;
DerivedMesh *dm;
CustomDataMask mask;
float xn, yn, zn, imat[3][3], mat[4][4]; //nor[3],
@@ -3352,8 +3345,6 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if (do_autosmooth && me->totvert==totvert && me->totface==dm->getNumTessFaces(dm))
use_original_normals= TRUE;
- ms = (totvert==me->totvert)?me->msticky:NULL;
-
ma= give_render_material(re, ob, 1);
@@ -3372,16 +3363,11 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
normalize_v3(ver->n);
negate_v3(ver->n);
}
-
+
if (orco) {
ver->orco= orco;
orco+=3;
}
- if (ms) {
- float *sticky= RE_vertren_get_sticky(obr, ver, 1);
- copy_v2_v2(sticky, ms->co);
- ms++;
- }
}
if (!timeoffset) {
@@ -5301,11 +5287,11 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con
/* size of 1 pixel mapped to viewplane coords */
float psize;
- psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx;
+ psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx;
/* x angle of a pixel */
pixelphix = atan(psize / re->clipsta);
- psize = BLI_RCT_SIZE_Y(&re->viewplane) / (float)re->winy;
+ psize = BLI_rctf_size_y(&re->viewplane) / (float)re->winy;
/* y angle of a pixel */
pixelphiy = atan(psize / re->clipsta);
}
@@ -5873,76 +5859,3 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay,
if (re->r.mode & R_SHADOW)
make_occ_tree(re);
}
-
-/* ------------------------------------------------------------------------- */
-/* Sticky texture coords */
-/* ------------------------------------------------------------------------- */
-
-void RE_make_sticky(Scene *scene, View3D *v3d)
-{
- Object *ob;
- Base *base;
- MVert *mvert;
- Mesh *me;
- MSticky *ms;
- Render *re;
- float ho[4], mat[4][4];
- int a;
- Object *camera= NULL;
-
- if (v3d==NULL) {
- printf("Need a 3d view to make sticky\n");
- return;
- }
-
- if (v3d) camera= V3D_CAMERA_LOCAL(v3d);
- if (camera == NULL) camera= scene->camera;
-
- if (camera==NULL) {
- printf("Need camera to make sticky\n");
- return;
- }
- if (scene->obedit) {
- printf("Unable to make sticky in Edit Mode\n");
- return;
- }
-
- re= RE_NewRender("_make sticky_");
- RE_InitState(re, NULL, &scene->r, NULL, scene->r.xsch, scene->r.ysch, NULL);
-
- /* use renderdata and camera to set viewplane */
- RE_SetCamera(re, camera);
-
- /* and set view matrix */
- normalize_m4(camera->obmat);
- invert_m4_m4(mat, camera->obmat);
- RE_SetView(re, mat);
-
- for (base= FIRSTBASE; base; base= base->next) {
- if (TESTBASELIB(v3d, base)) {
- if (base->object->type==OB_MESH) {
- ob= base->object;
-
- me= ob->data;
- mvert= me->mvert;
- if (me->msticky)
- CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
- me->msticky= CustomData_add_layer(&me->vdata, CD_MSTICKY,
- CD_CALLOC, NULL, me->totvert);
-
- BKE_object_where_is_calc(scene, ob);
- mult_m4_m4m4(mat, re->viewmat, ob->obmat);
-
- ms= me->msticky;
- for (a=0; a<me->totvert; a++, ms++, mvert++) {
- copy_v3_v3(ho, mvert->co);
- mul_m4_v3(mat, ho);
- projectverto(ho, re->winmat, ho);
- ms->co[0]= ho[0]/ho[3];
- ms->co[1]= ho[1]/ho[3];
- }
- }
- }
- }
-}
-
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index 26bd482af69..03eb21dfa23 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -472,9 +472,6 @@ static void render_envmap(Render *re, EnvMap *env)
ibuf = IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect | IB_rectfloat);
memcpy(ibuf->rect_float, rl->rectf, ibuf->channels * ibuf->x * ibuf->y * sizeof(float));
- if (re->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
-
/* envmap renders without alpha */
alpha = ibuf->rect_float + 3;
for (y = ibuf->x * ibuf->y - 1; y >= 0; y--, alpha += 4)
diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c
index 64925e16ae2..1c2613e8d18 100644
--- a/source/blender/render/intern/source/gammaCorrectionTables.c
+++ b/source/blender/render/intern/source/gammaCorrectionTables.c
@@ -38,7 +38,7 @@
/* result remain identical (ton) */
/* gamma is only used here for correcting adding colors or alpha */
-#define RE_DEFAULT_GAMMA 2.0
+// #define RE_DEFAULT_GAMMA 2.0 // UNUSED
/* This 400 is sort of based on the number of intensity levels needed for */
/* the typical dynamic range of a medium, in this case CRTs. (Foley) */
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 7f0484c8ee6..7a9df51e493 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -396,8 +396,8 @@ static float square_rctf(rctf *rf)
{
float x, y;
- x = BLI_RCT_SIZE_X(rf);
- y = BLI_RCT_SIZE_Y(rf);
+ x = BLI_rctf_size_x(rf);
+ y = BLI_rctf_size_y(rf);
return x * y;
}
@@ -405,7 +405,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2)
{
float size;
- size = BLI_RCT_SIZE_X(rf);
+ size = BLI_rctf_size_x(rf);
if (rf->xmin<x1) {
rf->xmin = x1;
@@ -417,8 +417,8 @@ static float clipx_rctf(rctf *rf, float x1, float x2)
rf->xmin = rf->xmax;
return 0.0;
}
- else if (size!=0.0f) {
- return BLI_RCT_SIZE_X(rf) / size;
+ else if (size != 0.0f) {
+ return BLI_rctf_size_x(rf) / size;
}
return 1.0;
}
@@ -427,7 +427,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
{
float size;
- size = BLI_RCT_SIZE_Y(rf);
+ size = BLI_rctf_size_y(rf);
if (rf->ymin<y1) {
rf->ymin = y1;
@@ -441,7 +441,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
return 0.0;
}
else if (size != 0.0f) {
- return BLI_RCT_SIZE_Y(rf) / size;
+ return BLI_rctf_size_y(rf) / size;
}
return 1.0;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 66f230a40f5..88c64b44b64 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -610,8 +610,8 @@ void initparts(Render *re, int do_crop)
}
else disprect.ymax = ymaxb;
- rectx = BLI_RCT_SIZE_X(&disprect);
- recty = BLI_RCT_SIZE_Y(&disprect);
+ rectx = BLI_rcti_size_x(&disprect);
+ recty = BLI_rcti_size_y(&disprect);
/* so, now can we add this part? */
if (rectx > 0 && recty > 0) {
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index 485dd005be7..c8aad21b322 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -61,7 +61,6 @@
/* ------------------------- Declarations --------------------------- */
-#define INVALID_INDEX ((int)(~0))
#define INVPI ((float)M_1_PI)
#define TOTCHILD 8
#define CACHE_STEP 3
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 720287510d0..ecd8524016d 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -68,6 +68,7 @@
#include "BLI_callbacks.h"
#include "PIL_time.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -205,9 +206,9 @@ RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name)
}
}
-RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty)
+RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty)
{
- return render_result_new_from_exr(exrhandle, rectx, recty);
+ return render_result_new_from_exr(exrhandle, colorspace, predivide, rectx, recty);
}
RenderLayer *render_get_active_layer(Render *re, RenderResult *rr)
@@ -336,7 +337,7 @@ void RE_ResultGet32(Render *re, unsigned int *rect)
RenderResult rres;
RE_AcquireResultImage(re, &rres);
- render_result_rect_get_pixels(&rres, &re->r, rect, re->rectx, re->recty);
+ render_result_rect_get_pixels(&rres, &re->r, rect, re->rectx, re->recty, &re->scene->view_settings, &re->scene->display_settings);
RE_ReleaseResultImage(re);
}
@@ -439,8 +440,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
re->winy = winy;
if (disprect) {
re->disprect = *disprect;
- re->rectx = BLI_RCT_SIZE_X(disprect);
- re->recty = BLI_RCT_SIZE_Y(disprect);
+ re->rectx = BLI_rcti_size_x(disprect);
+ re->recty = BLI_rcti_size_y(disprect);
}
else {
re->disprect.xmin = re->disprect.ymin = 0;
@@ -672,15 +673,15 @@ static void *do_part_thread(void *pa_v)
float panorama_pixel_rot(Render *re)
{
float psize, phi, xfac;
- float borderfac = (float)BLI_RCT_SIZE_X(&re->disprect) / (float)re->winx;
+ float borderfac = (float)BLI_rcti_size_x(&re->disprect) / (float)re->winx;
/* size of 1 pixel mapped to viewplane coords */
- psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx;
+ psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx;
/* angle of a pixel */
phi = atan(psize / re->clipsta);
/* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
- xfac = borderfac * BLI_RCT_SIZE_X(&re->viewplane) / (float)re->xparts;
+ xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)re->xparts;
xfac = atan(0.5f * xfac / re->clipsta);
/* and how much the same viewplane angle is wrapped */
psize = 0.5f * phi * ((float)re->partx);
@@ -713,7 +714,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane)
float phi = panorama_pixel_rot(re);
R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2;
- R.panodxv = (BLI_RCT_SIZE_X(viewplane) * R.panodxp) / (float)(re->winx);
+ R.panodxv = (BLI_rctf_size_x(viewplane) * R.panodxp) / (float)(re->winx);
/* shift viewplane */
R.viewplane.xmin = viewplane->xmin + R.panodxv;
@@ -740,8 +741,8 @@ static RenderPart *find_next_part(Render *re, int minx)
/* find center of rendered parts, image center counts for 1 too */
for (pa = re->parts.first; pa; pa = pa->next) {
if (pa->ready) {
- centx += BLI_RCT_CENTER_X(&pa->disprect);
- centy += BLI_RCT_CENTER_Y(&pa->disprect);
+ centx += BLI_rcti_cent_x(&pa->disprect);
+ centy += BLI_rcti_cent_y(&pa->disprect);
tot++;
}
}
@@ -751,8 +752,8 @@ static RenderPart *find_next_part(Render *re, int minx)
/* closest of the non-rendering parts */
for (pa = re->parts.first; pa; pa = pa->next) {
if (pa->ready == 0 && pa->nr == 0) {
- long long int distx = centx - BLI_RCT_CENTER_X(&pa->disprect);
- long long int disty = centy - BLI_RCT_CENTER_Y(&pa->disprect);
+ long long int distx = centx - BLI_rcti_cent_x(&pa->disprect);
+ long long int disty = centy - BLI_rcti_cent_y(&pa->disprect);
distx = (long long int)sqrt(distx * distx + disty * disty);
if (distx < mindist) {
if (re->r.mode & R_PANORAMA) {
@@ -1463,7 +1464,7 @@ static void free_all_freestyle_renders(Scene *scene)
static void do_merge_fullsample(Render *re, bNodeTree *ntree)
{
float *rectf, filt[3][3];
- int sample;
+ int x, y, sample;
/* interaction callbacks */
if (ntree) {
@@ -1484,7 +1485,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
for (sample = 0; sample < re->r.osa; sample++) {
Render *re1;
RenderResult rres;
- int x, y, mask;
+ int mask;
/* enable full sample print */
R.i.curfsa = sample + 1;
@@ -1513,7 +1514,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
ntreeCompositTagRender(re->scene);
ntreeCompositTagAnimated(ntree);
- ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0);
+ ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0, &re->scene->view_settings, &re->scene->display_settings);
}
/* ensure we get either composited result or the active layer */
@@ -1549,6 +1550,18 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
if (re->test_break(re->tbh))
break;
}
+
+ /* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */
+ for (y = 0; y < re->recty; y++) {
+ float *rf = rectf + 4 * y * re->rectx;
+
+ for (x = 0; x < re->rectx; x++, rf += 4) {
+ rf[0] = MAX2(rf[0], 0.0f);
+ rf[1] = MAX2(rf[1], 0.0f);
+ rf[2] = MAX2(rf[2], 0.0f);
+ CLAMP(rf[3], 0.0f, 1.0f);
+ }
+ }
/* clear interaction callbacks */
if (ntree) {
@@ -1677,7 +1690,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
if (re->r.scemode & R_FULL_SAMPLE)
do_merge_fullsample(re, ntree);
else {
- ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0);
+ ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0, &re->scene->view_settings, &re->scene->display_settings);
}
ntree->stats_draw = NULL;
@@ -1728,7 +1741,7 @@ int RE_seq_render_active(Scene *scene, RenderData *rd)
static void do_render_seq(Render *re)
{
static int recurs_depth = 0;
- struct ImBuf *ibuf;
+ struct ImBuf *ibuf, *out;
RenderResult *rr; /* don't assign re->result here as it might change during give_ibuf_seq */
int cfra = re->r.cfra;
SeqRenderData context;
@@ -1755,7 +1768,16 @@ static void do_render_seq(Render *re)
100);
}
- ibuf = BKE_sequencer_give_ibuf(context, cfra, 0);
+ out = BKE_sequencer_give_ibuf(context, cfra, 0);
+
+ if (out) {
+ ibuf = IMB_dupImBuf(out);
+ IMB_freeImBuf(out);
+ BKE_sequencer_imbuf_from_sequencer_space(re->scene, ibuf);
+ }
+ else {
+ ibuf = NULL;
+ }
recurs_depth--;
@@ -1789,6 +1811,9 @@ static void do_render_seq(Render *re)
re->progress(re->prh, (float)(cfra - re->r.sfra) / (re->r.efra - re->r.sfra));
else
re->progress(re->prh, 1.0f);
+
+ /* would mark display buffers as invalid */
+ re->display_draw(re->ddh, re->result, NULL);
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
@@ -2150,6 +2175,14 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
G.is_rendering = FALSE;
}
+static void colormanage_image_for_write(Scene *scene, ImBuf *ibuf)
+{
+ IMB_display_buffer_to_imbuf_rect(ibuf, &scene->view_settings, &scene->display_settings);
+
+ if (ibuf)
+ imb_freerectfloatImBuf(ibuf);
+}
+
void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene)
{
re->result_ok= 0;
@@ -2171,19 +2204,27 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
/* write movie or image */
if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
int do_free = FALSE;
- unsigned int *rect32 = (unsigned int *)rres.rect32;
+ ImBuf *ibuf = render_result_rect_to_ibuf(&rres, &scene->r);
+
/* note; the way it gets 32 bits rects is weak... */
- if (rres.rect32 == NULL) {
- rect32 = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect");
- RE_ResultGet32(re, rect32);
+ if (ibuf->rect == NULL) {
+ ibuf->rect = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect");
+ RE_ResultGet32(re, ibuf->rect);
do_free = TRUE;
}
- ok = mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *)rect32,
- rres.rectx, rres.recty, re->reports);
+ colormanage_image_for_write(scene, ibuf);
+
+ ok = mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *) ibuf->rect,
+ ibuf->x, ibuf->y, re->reports);
if (do_free) {
- MEM_freeN(rect32);
+ MEM_freeN(ibuf->rect);
+ ibuf->rect = NULL;
}
+
+ /* imbuf knows which rects are not part of ibuf */
+ IMB_freeImBuf(ibuf);
+
printf("Append frame %d", scene->r.cfra);
}
else {
@@ -2200,6 +2241,12 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
}
else {
ImBuf *ibuf = render_result_rect_to_ibuf(&rres, &scene->r);
+ int do_colormanagement;
+
+ do_colormanagement = !BKE_imtype_supports_float(scene->r.im_format.imtype);
+
+ if (do_colormanagement)
+ colormanage_image_for_write(scene, ibuf);
ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format);
@@ -2217,6 +2264,9 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
name[strlen(name) - 4] = 0;
BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90);
ibuf->planes = 24;
+
+ colormanage_image_for_write(scene, ibuf);
+
BKE_imbuf_write_stamp(scene, camera, ibuf, name, &imf);
printf("\nSaved: %s", name);
}
@@ -2471,7 +2521,8 @@ void RE_init_threadcount(Render *re)
* x/y offsets are only used on a partial copy when dimensions don't match */
void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char *filename, int x, int y)
{
- ImBuf *ibuf = IMB_loadiffname(filename, IB_rect);
+ /* OCIO_TODO: assume layer was saved in defaule color space */
+ ImBuf *ibuf = IMB_loadiffname(filename, IB_rect, NULL);
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
if (ibuf->x == layer->rectx && ibuf->y == layer->recty) {
@@ -2560,8 +2611,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env,
return 0;
}
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
+ IMB_display_buffer_to_imbuf_rect(ibuf, &scene->view_settings, &scene->display_settings);
/* to save, we first get absolute path */
BLI_strncpy(filepath, relpath, sizeof(filepath));
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index fb1a7885390..a226556828e 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -50,6 +50,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "intern/openexr/openexr_multi.h"
@@ -423,8 +424,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
SceneRenderLayer *srl;
int rectx, recty, nr;
- rectx = BLI_RCT_SIZE_X(partrct);
- recty = BLI_RCT_SIZE_Y(partrct);
+ rectx = BLI_rcti_size_x(partrct);
+ recty = BLI_rcti_size_y(partrct);
if (rectx <= 0 || recty <= 0)
return NULL;
@@ -571,8 +572,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
}
/* border render; calculate offset for use in compositor. compo is centralized coords */
- rr->xof = re->disprect.xmin + BLI_RCT_CENTER_X(&re->disprect) - (re->winx / 2);
- rr->yof = re->disprect.ymin + BLI_RCT_CENTER_Y(&re->disprect) - (re->winy / 2);
+ rr->xof = re->disprect.xmin + BLI_rcti_cent_x(&re->disprect) - (re->winx / 2);
+ rr->yof = re->disprect.ymin + BLI_rcti_cent_y(&re->disprect) - (re->winy / 2);
return rr;
}
@@ -629,12 +630,13 @@ static void ml_addpass_cb(void *UNUSED(base), void *lay, const char *str, float
}
/* from imbuf, if a handle was returned we convert this to render result */
-RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty)
+RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty)
{
RenderResult *rr = MEM_callocN(sizeof(RenderResult), __func__);
RenderLayer *rl;
RenderPass *rpass;
-
+ const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+
rr->rectx = rectx;
rr->recty = recty;
@@ -647,6 +649,11 @@ RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty)
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
rpass->rectx = rectx;
rpass->recty = recty;
+
+ if (rpass->channels >= 3) {
+ IMB_colormanagement_transform(rpass->rect, rpass->rectx, rpass->recty, rpass->channels,
+ colorspace, to_colorspace, predivide);
+ }
}
}
@@ -1084,16 +1091,12 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
/* float factor for random dither, imbuf takes care of it */
ibuf->dither = rd->dither_intensity;
- /* prepare to gamma correct to sRGB color space */
- if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) {
- /* sequence editor can generate 8bpc render buffers */
- if (ibuf->rect) {
- ibuf->profile = IB_PROFILE_SRGB;
- if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32))
- IMB_float_from_rect(ibuf);
- }
- else {
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
+ /* prepare to gamma correct to sRGB color space
+ * note that sequence editor can generate 8bpc render buffers
+ */
+ if (ibuf->rect) {
+ if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) {
+ IMB_float_from_rect(ibuf);
}
}
@@ -1109,22 +1112,14 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
return ibuf;
}
-void render_result_rect_from_ibuf(RenderResult *rr, RenderData *rd, ImBuf *ibuf)
+void render_result_rect_from_ibuf(RenderResult *rr, RenderData *UNUSED(rd), ImBuf *ibuf)
{
if (ibuf->rect_float) {
- /* color management: when off ensure rectf is non-lin, since thats what the internal
- * render engine delivers */
- int profile_to = (rd->color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
- int profile_from = (ibuf->profile == IB_PROFILE_LINEAR_RGB) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
- int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
-
if (!rr->rectf)
rr->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf");
- IMB_buffer_float_from_float(rr->rectf, ibuf->rect_float,
- 4, profile_to, profile_from, predivide,
- rr->rectx, rr->recty, rr->rectx, rr->rectx);
-
+ memcpy(rr->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty);
+
/* TSK! Since sequence render doesn't free the *rr render result, the old rect32
* can hang around when sequence render has rendered a 32 bits one before */
if (rr->rect32) {
@@ -1156,19 +1151,17 @@ void render_result_rect_fill_zero(RenderResult *rr)
rr->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
}
-void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty)
+void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty,
+ const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
{
if (rr->rect32) {
memcpy(rect, rr->rect32, sizeof(int) * rr->rectx * rr->recty);
}
else if (rr->rectf) {
- int profile_from = (rd->color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
- int dither = 0;
- IMB_buffer_byte_from_float((unsigned char *)rect, rr->rectf,
- 4, dither, IB_PROFILE_SRGB, profile_from, predivide,
- rr->rectx, rr->recty, rr->rectx, rr->rectx);
+ IMB_display_buffer_transform_apply((unsigned char *) rect, rr->rectf, rr->rectx, rr->recty, 4,
+ view_settings, display_settings, predivide);
}
else
/* else fill with black */
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index cbe8cc81451..982f7e7d824 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -50,6 +50,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "BKE_colortools.h"
#include "BKE_image.h"
@@ -82,6 +83,8 @@
#include "renderdatabase.h" /* needed for UV */
+#include "RE_render_ext.h"
+
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
/* only to be used here in this file, it's for speed */
@@ -95,7 +98,7 @@ static void init_render_texture(Render *re, Tex *tex)
{
/* imap test */
if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
- BKE_image_user_frame_calc(&tex->iuser, re->r.cfra, re?re->flag & R_SEC_FIELD:0);
+ BKE_image_user_frame_calc(&tex->iuser, re ? re->r.cfra : 0, re ? re->flag & R_SEC_FIELD:0);
}
else if (tex->type==TEX_ENVMAP) {
@@ -1224,8 +1227,8 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
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.r.color_mgt_flag & R_COLOR_MANAGEMENT)
- srgb_to_linearrgb_v3_v3(&texres->tr, &texres->tr);
+ if (ibuf && !(ibuf->rect_float))
+ IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace);
}
}
else {
@@ -1259,18 +1262,19 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
}
/* this is called for surface shading */
-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, float *dxt, float *dyt, TexResult *texres)
{
- Tex *tex= mtex->tex;
+ Tex *tex = mtex->tex;
if (tex->use_nodes && tex->nodetree) {
/* stupid exception here .. but we have to pass shi and mtex to
* textures nodes for 2d mapping and color management for images */
return ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, shi->osatex, shi->thread,
- tex, mtex->which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, shi, mtex);
+ tex, mtex->which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, shi, mtex);
}
- else
+ else {
return multitex(mtex->tex, texvec, dxt, dyt, shi->osatex, texres, shi->thread, mtex->which_output);
+ }
}
/* Warning, if the texres's values are not declared zero, check the return value to be sure
@@ -2149,9 +2153,6 @@ void do_material_tex(ShadeInput *shi, Render *re)
co= shi->lo; dx= shi->dxlo; dy= shi->dylo;
}
}
- else if (mtex->texco==TEXCO_STICKY) {
- co= shi->sticky; dx= shi->dxsticky; dy= shi->dysticky;
- }
else if (mtex->texco==TEXCO_OBJECT) {
Object *ob= mtex->object;
if (ob) {
@@ -2376,8 +2377,8 @@ 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) && re->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- srgb_to_linearrgb_v3_v3(tcol, tcol);
+ if (ibuf && !(ibuf->rect_float))
+ IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
}
if (mtex->mapto & MAP_COL) {
@@ -2756,11 +2757,9 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_
/* stencil maps on the texture control slider, not texture intensity value */
/* convert RGB to intensity if intensity info isn't provided */
- if (!(rgbnor & TEX_INT)) {
- if (rgbnor & TEX_RGB) {
- if (texres.talpha) texres.tin = texres.ta;
- else texres.tin = rgb_to_grayscale(&texres.tr);
- }
+ if (rgbnor & TEX_RGB) {
+ if (texres.talpha) texres.tin = texres.ta;
+ else texres.tin = rgb_to_grayscale(&texres.tr);
}
if ((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) {
@@ -2888,8 +2887,8 @@ 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) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
- srgb_to_linearrgb_v3_v3(&texres.tr, &texres.tr);
+ if (ibuf && !(ibuf->rect_float))
+ IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
}
fact= texres.tin*mtex->colfac;
@@ -3103,8 +3102,8 @@ 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) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
- srgb_to_linearrgb_v3_v3(tcol, tcol);
+ if (ibuf && !(ibuf->rect_float))
+ IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
}
if (mtex->mapto & WOMAP_HORIZ) {
@@ -3317,8 +3316,8 @@ 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) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
- srgb_to_linearrgb_v3_v3(&texres.tr, &texres.tr);
+ if (ibuf && !(ibuf->rect_float))
+ IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
}
/* lamp colors were premultiplied with this */
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index c009c7b7394..0d894073cee 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -62,6 +62,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
/* local include */
#include "rayintersection.h"
@@ -108,10 +109,10 @@ void calc_view_vector(float *view, float x, float y)
/* move x and y to real viewplane coords */
x = (x / (float)R.winx);
- view[0] = R.viewplane.xmin + x * BLI_RCT_SIZE_X(&R.viewplane);
+ view[0] = R.viewplane.xmin + x * BLI_rctf_size_x(&R.viewplane);
y = (y / (float)R.winy);
- view[1] = R.viewplane.ymin + y * BLI_RCT_SIZE_Y(&R.viewplane);
+ view[1] = R.viewplane.ymin + y * BLI_rctf_size_y(&R.viewplane);
// if (R.flag & R_SEC_FIELD) {
// if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor;
@@ -989,6 +990,30 @@ static void convert_to_key_alpha(RenderPart *pa, RenderLayer *rl)
}
}
+/* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */
+static void clamp_alpha_rgb_range(RenderPart *pa, RenderLayer *rl)
+{
+ RenderLayer *rlpp[RE_MAX_OSA];
+ int y, sample, totsample;
+
+ totsample= get_sample_layers(pa, rl, rlpp);
+
+ /* not for full sample, there we clamp after compositing */
+ if (totsample > 1)
+ return;
+
+ for (sample= 0; sample<totsample; sample++) {
+ float *rectf= rlpp[sample]->rectf;
+
+ for (y= pa->rectx*pa->recty; y>0; y--, rectf+=4) {
+ rectf[0] = MAX2(rectf[0], 0.0f);
+ rectf[1] = MAX2(rectf[1], 0.0f);
+ rectf[2] = MAX2(rectf[2], 0.0f);
+ CLAMP(rectf[3], 0.0f, 1.0f);
+ }
+ }
+}
+
/* adds only alpha values */
static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz)
{
@@ -1269,6 +1294,9 @@ void zbufshadeDA_tile(RenderPart *pa)
if (rl->passflag & SCE_PASS_VECTOR)
reset_sky_speed(pa, rl);
+
+ /* clamp alpha to 0..1 range, can go outside due to filter */
+ clamp_alpha_rgb_range(pa, rl);
/* de-premul alpha */
if (R.r.alphamode & R_ALPHAKEY)
@@ -1993,6 +2021,8 @@ typedef struct BakeShade {
float dxco[3], dyco[3];
short *do_update;
+
+ struct ColorSpace *rect_colorspace;
} BakeShade;
static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int UNUSED(isect), int x, int y, float u, float v)
@@ -2168,8 +2198,12 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
else {
unsigned char *col= (unsigned char *)(bs->rect + bs->rectx*y + x);
- if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) && (R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
- linearrgb_to_srgb_uchar3(col, shr.combined);
+ if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) {
+ float rgb[3];
+
+ copy_v3_v3(rgb, shr.combined);
+ IMB_colormanagement_scene_linear_to_colorspace_v3(rgb, bs->rect_colorspace);
+ rgb_float_to_uchar(col, rgb);
}
else {
rgb_float_to_uchar(col, shr.combined);
@@ -2503,6 +2537,7 @@ static void shade_tface(BakeShade *bs)
bs->rectx= bs->ibuf->x;
bs->recty= bs->ibuf->y;
bs->rect= bs->ibuf->rect;
+ bs->rect_colorspace= bs->ibuf->rect_colorspace;
bs->rect_float= bs->ibuf->rect_float;
bs->quad= 0;
@@ -2613,8 +2648,6 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
ima->flag&= ~IMA_USED_FOR_RENDER;
if (ibuf) {
ibuf->userdata = NULL; /* use for masking if needed */
- if (ibuf->rect_float)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
}
}
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index db045284d5b..6395a04b534 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -97,13 +97,10 @@
* the index */
/* NOTE! the hardcoded table size 256 is used still in code for going quickly over vertices/faces */
-
-#define RE_STICKY_ELEMS 2
#define RE_STRESS_ELEMS 1
#define RE_RAD_ELEMS 4
#define RE_STRAND_ELEMS 1
#define RE_TANGENT_ELEMS 3
-#define RE_STRESS_ELEMS 1
#define RE_WINSPEED_ELEMS 4
#define RE_MTFACE_ELEMS 1
#define RE_MCOL_ELEMS 4
@@ -114,21 +111,6 @@
#define RE_FACE_ELEMS 1
#define RE_NMAP_TANGENT_ELEMS 16
-float *RE_vertren_get_sticky(ObjectRen *obr, VertRen *ver, int verify)
-{
- float *sticky;
- int nr= ver->index>>8;
-
- sticky= obr->vertnodes[nr].sticky;
- if (sticky==NULL) {
- if (verify)
- sticky= obr->vertnodes[nr].sticky= MEM_mallocN(256*RE_STICKY_ELEMS*sizeof(float), "sticky table");
- else
- return NULL;
- }
- return sticky + (ver->index & 255)*RE_STICKY_ELEMS;
-}
-
float *RE_vertren_get_stress(ObjectRen *obr, VertRen *ver, int verify)
{
float *stress;
@@ -218,12 +200,7 @@ VertRen *RE_vertren_copy(ObjectRen *obr, VertRen *ver)
*v1= *ver;
v1->index= index;
-
- fp1= RE_vertren_get_sticky(obr, ver, 0);
- if (fp1) {
- fp2= RE_vertren_get_sticky(obr, v1, 1);
- memcpy(fp2, fp1, RE_STICKY_ELEMS*sizeof(float));
- }
+
fp1= RE_vertren_get_stress(obr, ver, 0);
if (fp1) {
fp2= RE_vertren_get_stress(obr, v1, 1);
@@ -740,8 +717,6 @@ void free_renderdata_vertnodes(VertTableNode *vertnodes)
if (vertnodes[a].rad)
MEM_freeN(vertnodes[a].rad);
- if (vertnodes[a].sticky)
- MEM_freeN(vertnodes[a].sticky);
if (vertnodes[a].strand)
MEM_freeN(vertnodes[a].strand);
if (vertnodes[a].tangent)
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index 2d7a64bad04..bed3fb5f754 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -72,6 +72,9 @@
# define ACOMP 3
#endif
+#define RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin)
+#define RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin)
+
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
/* only to be used here in this file, it's for speed */
@@ -1506,7 +1509,7 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level)
root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax);
/* find best splitpoint */
- if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box))
+ if (RCT_SIZE_X(&root->box) > RCT_SIZE_Y(&root->box))
i = root->index = 0;
else
i = root->index = 1;
@@ -1551,7 +1554,7 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem)
root->divider[1]/= BSPMAX_SAMPLE;
/* find best splitpoint */
- if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box))
+ if (RCT_SIZE_X(&root->box) > RCT_SIZE_Y(&root->box))
i = root->index = 0;
else
i = root->index = 1;
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index bbdcfbb5a73..35ab06cc564 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -574,10 +574,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
shi->dywin[1] = 0.0f;
}
}
-
- if (texco & TEXCO_STICKY) {
- /* not supported */
- }
}
if (shi->do_manage) {
@@ -1124,50 +1120,113 @@ void shade_input_set_shade_texco(ShadeInput *shi)
for (i = 0; (tface = RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) {
ShadeInputUV *suv = &shi->uv[i];
- float *uv1, *uv2, *uv3;
+ const float *uv1 = tface->uv[j1];
+ const float *uv2 = tface->uv[j2];
+ const float *uv3 = tface->uv[j3];
shi->totuv++;
suv->name = name;
-
- uv1 = tface->uv[j1];
- uv2 = tface->uv[j2];
- uv3 = tface->uv[j3];
- suv->uv[0] = -1.0f + 2.0f * (l * uv3[0] - u * uv1[0] - v * uv2[0]);
- suv->uv[1] = -1.0f + 2.0f * (l * uv3[1] - u * uv1[1] - v * uv2[1]);
- suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */
+ if ((shi->mat->mapflag & MA_MAPFLAG_UVPROJECT) && (shi->depth == 0)) {
+ float x = shi->xs;
+ float y = shi->ys;
+
+ float s1[2] = {-1.0f + 2.0f * uv1[0], -1.0f + 2.0f * uv1[1]};
+ float s2[2] = {-1.0f + 2.0f * uv2[0], -1.0f + 2.0f * uv2[1]};
+ float s3[2] = {-1.0f + 2.0f * uv3[0], -1.0f + 2.0f * uv3[1]};
+
+
+ float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4];
+ float Zmulx, Zmuly;
+ float hox, hoy, l, dl, u, v;
+ float s00, s01, s10, s11, detsh;
+
+ /* old globals, localized now */
+ Zmulx = ((float)R.winx) / 2.0f;
+ Zmuly = ((float)R.winy) / 2.0f;
+
+ zbuf_make_winmat(&R, winmat);
+ if (shi->obi->flag & R_TRANSFORMED)
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
+ else
+ copy_m4_m4(obwinmat, winmat);
+
+ zbuf_render_project(obwinmat, v1->co, ho1);
+ zbuf_render_project(obwinmat, v2->co, ho2);
+ zbuf_render_project(obwinmat, v3->co, ho3);
+
+ s00 = ho3[0] / ho3[3] - ho1[0] / ho1[3];
+ s01 = ho3[1] / ho3[3] - ho1[1] / ho1[3];
+ s10 = ho3[0] / ho3[3] - ho2[0] / ho2[3];
+ s11 = ho3[1] / ho3[3] - ho2[1] / ho2[3];
+
+ detsh = s00 * s11 - s10 * s01;
+ detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f;
+ s00 *= detsh; s01 *= detsh;
+ s10 *= detsh; s11 *= detsh;
+
+ /* recalc u and v again */
+ hox = x / Zmulx - 1.0f;
+ hoy = y / Zmuly - 1.0f;
+ u = (hox - ho3[0] / ho3[3]) * s11 - (hoy - ho3[1] / ho3[3]) * s10;
+ v = (hoy - ho3[1] / ho3[3]) * s00 - (hox - ho3[0] / ho3[3]) * s01;
+ l = 1.0f + u + v;
+
+ suv->uv[0] = l * s3[0] - u * s1[0] - v * s2[0];
+ suv->uv[1] = l * s3[1] - u * s1[1] - v * s2[1];
+ suv->uv[2] = 0.0f;
- if (shi->osatex) {
- float duv[2];
-
- dl = shi->dx_u + shi->dx_v;
- duv[0] = shi->dx_u;
- duv[1] = shi->dx_v;
+ if (shi->osatex) {
+ float dxuv[2], dyuv[2];
+ dxuv[0] = s11 / Zmulx;
+ dxuv[1] = -s01 / Zmulx;
+ dyuv[0] = -s10 / Zmuly;
+ dyuv[1] = s00 / Zmuly;
+
+ dl = dxuv[0] + dxuv[1];
+ suv->dxuv[0] = dl * s3[0] - dxuv[0] * s1[0] - dxuv[1] * s2[0];
+ suv->dxuv[1] = dl * s3[1] - dxuv[0] * s1[1] - dxuv[1] * s2[1];
+ dl = dyuv[0] + dyuv[1];
+ suv->dyuv[0] = dl * s3[0] - dyuv[0] * s1[0] - dyuv[1] * s2[0];
+ suv->dyuv[1] = dl * s3[1] - dyuv[0] * s1[1] - dyuv[1] * s2[1];
+ }
+ }
+ else {
- suv->dxuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]);
- suv->dxuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]);
+ suv->uv[0] = -1.0f + 2.0f * (l * uv3[0] - u * uv1[0] - v * uv2[0]);
+ suv->uv[1] = -1.0f + 2.0f * (l * uv3[1] - u * uv1[1] - v * uv2[1]);
+ suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */
- dl = shi->dy_u + shi->dy_v;
- duv[0] = shi->dy_u;
- duv[1] = shi->dy_v;
+ if (shi->osatex) {
+ float duv[2];
- suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]);
- suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]);
- }
+ dl = shi->dx_u + shi->dx_v;
+ duv[0] = shi->dx_u;
+ duv[1] = shi->dx_v;
- if ((mode & MA_FACETEXTURE) && i == obr->actmtface) {
- if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) {
- shi->vcol[0] = 1.0f;
- shi->vcol[1] = 1.0f;
- shi->vcol[2] = 1.0f;
- shi->vcol[3] = 1.0f;
+ suv->dxuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]);
+ suv->dxuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]);
+
+ dl = shi->dy_u + shi->dy_v;
+ duv[0] = shi->dy_u;
+ duv[1] = shi->dy_v;
+
+ suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]);
+ suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]);
}
- if (tface->tpage) {
- render_realtime_texture(shi, tface->tpage);
+
+ if ((mode & MA_FACETEXTURE) && i == obr->actmtface) {
+ if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) {
+ shi->vcol[0] = 1.0f;
+ shi->vcol[1] = 1.0f;
+ shi->vcol[2] = 1.0f;
+ shi->vcol[3] = 1.0f;
+ }
+ if (tface->tpage) {
+ render_realtime_texture(shi, tface->tpage);
+ }
}
}
-
-
}
shi->dupliuv[0] = -1.0f + 2.0f * obi->dupliuv[0];
@@ -1236,70 +1295,6 @@ void shade_input_set_shade_texco(ShadeInput *shi)
shi->dywin[0] = shi->dywin[2] = 0.0f;
}
}
-
- if (texco & TEXCO_STICKY) {
- float *s1, *s2, *s3;
-
- s1 = RE_vertren_get_sticky(obr, v1, 0);
- s2 = RE_vertren_get_sticky(obr, v2, 0);
- s3 = RE_vertren_get_sticky(obr, v3, 0);
-
- if (s1 && s2 && s3) {
- float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4];
- float Zmulx, Zmuly;
- float hox, hoy, l, dl, u, v;
- float s00, s01, s10, s11, detsh;
-
- /* old globals, localized now */
- Zmulx = ((float)R.winx) / 2.0f; Zmuly = ((float)R.winy) / 2.0f;
-
- zbuf_make_winmat(&R, winmat);
- if (shi->obi->flag & R_TRANSFORMED)
- mult_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- zbuf_render_project(obwinmat, v1->co, ho1);
- zbuf_render_project(obwinmat, v2->co, ho2);
- zbuf_render_project(obwinmat, v3->co, ho3);
-
- s00 = ho3[0] / ho3[3] - ho1[0] / ho1[3];
- s01 = ho3[1] / ho3[3] - ho1[1] / ho1[3];
- s10 = ho3[0] / ho3[3] - ho2[0] / ho2[3];
- s11 = ho3[1] / ho3[3] - ho2[1] / ho2[3];
-
- detsh = s00 * s11 - s10 * s01;
- detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f;
- s00 *= detsh; s01 *= detsh;
- s10 *= detsh; s11 *= detsh;
-
- /* recalc u and v again */
- hox = x / Zmulx - 1.0f;
- hoy = y / Zmuly - 1.0f;
- u = (hox - ho3[0] / ho3[3]) * s11 - (hoy - ho3[1] / ho3[3]) * s10;
- v = (hoy - ho3[1] / ho3[3]) * s00 - (hox - ho3[0] / ho3[3]) * s01;
- l = 1.0f + u + v;
-
- shi->sticky[0] = l * s3[0] - u * s1[0] - v * s2[0];
- shi->sticky[1] = l * s3[1] - u * s1[1] - v * s2[1];
- shi->sticky[2] = 0.0f;
-
- if (shi->osatex) {
- float dxuv[2], dyuv[2];
- dxuv[0] = s11 / Zmulx;
- dxuv[1] = -s01 / Zmulx;
- dyuv[0] = -s10 / Zmuly;
- dyuv[1] = s00 / Zmuly;
-
- dl = dxuv[0] + dxuv[1];
- shi->dxsticky[0] = dl * s3[0] - dxuv[0] * s1[0] - dxuv[1] * s2[0];
- shi->dxsticky[1] = dl * s3[1] - dxuv[0] * s1[1] - dxuv[1] * s2[1];
- dl = dyuv[0] + dyuv[1];
- shi->dysticky[0] = dl * s3[0] - dyuv[0] * s1[0] - dyuv[1] * s2[0];
- shi->dysticky[1] = dl * s3[1] - dyuv[0] * s1[1] - dyuv[1] * s2[1];
- }
- }
- }
}
/* else {
* Note! For raytracing winco is not set,
@@ -1325,7 +1320,14 @@ void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, in
shi->sample = sample;
shi->thread = pa->thread;
shi->do_preview = (R.r.scemode & R_MATNODE_PREVIEW) != 0;
- shi->do_manage = (R.r.color_mgt_flag & R_COLOR_MANAGEMENT);
+
+ /* OCIO_TODO: for now assume color management is always enabled and vertes colors are in sRGB space
+ * probably would be nice to have this things configurable, but for now it should work
+ * also probably this flag could be removed (in separated commit) before the release
+ * since it's not actually meaningful anymore
+ */
+ shi->do_manage = TRUE;
+
shi->lay = rl->lay;
shi->layflag = rl->layflag;
shi->passflag = rl->passflag;
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index 51be519d5b8..dc3225b7f09 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -61,11 +61,6 @@
#include "strand.h"
#include "zbuf.h"
-/* to be removed */
-void hoco_to_zco(ZSpan *zspan, float *zco, float *hoco);
-void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float, float) );
-void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2);
-
/* *************** */
static float strand_eval_width(Material *ma, float strandco)
diff --git a/source/blender/render/intern/source/texture_ocean.c b/source/blender/render/intern/source/texture_ocean.c
index 8c9df496dd6..b2bc635cba7 100644
--- a/source/blender/render/intern/source/texture_ocean.c
+++ b/source/blender/render/intern/source/texture_ocean.c
@@ -42,6 +42,8 @@
#include "texture.h"
+#include "texture_ocean.h" /* own include */
+
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index de9572bf57b..bf6962d0087 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -3476,7 +3476,7 @@ void zbuffer_abuf_shadow(Render *re, LampRen *lar, float winmat[][4], APixstr *A
/* speed pointer NULL = sky, we clear */
/* else if either alpha is full or no solid was filled in: copy speed */
/* else fill in minimum speed */
-void add_transp_speed(RenderLayer *rl, int offset, float *speed, float alpha, intptr_t *rdrect)
+static void add_transp_speed(RenderLayer *rl, int offset, float speed[4], float alpha, intptr_t *rdrect)
{
RenderPass *rpass;
@@ -3525,7 +3525,7 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob)
/* ONLY OSA! merge all shaderesult samples to one */
/* target should have been cleared */
-void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
+static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
{
RenderPass *rpass;
float weight= 1.0f/((float)R.osa);
@@ -3627,7 +3627,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
}
-void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alpha)
+static void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alpha)
{
RenderPass *rpass;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index ff7c8cd2ea7..9570638fb25 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -71,8 +71,18 @@ void WM_init_state_normal_set(void);
void WM_init (struct bContext *C, int argc, const char **argv);
void WM_exit_ext (struct bContext *C, const short do_python);
-void WM_exit (struct bContext *C);
-void WM_main (struct bContext *C);
+
+void WM_exit (struct bContext *C)
+#if defined(__GNUC__) || defined(__clang__)
+__attribute__((noreturn))
+#endif
+;
+
+void WM_main (struct bContext *C)
+#if defined(__GNUC__) || defined(__clang__)
+__attribute__((noreturn))
+#endif
+;
int WM_init_game (struct bContext *C);
void WM_init_splash (struct bContext *C);
@@ -104,8 +114,8 @@ void WM_cursor_set (struct wmWindow *win, int curs);
void WM_cursor_modal (struct wmWindow *win, int curs);
void WM_cursor_restore (struct wmWindow *win);
void WM_cursor_wait (int val);
-void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int *bounds);
-void WM_cursor_grab_disable(struct wmWindow *win);
+void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int bounds[4]);
+void WM_cursor_grab_disable(struct wmWindow *win, int mouse_ungrab_xy[2]);
void WM_cursor_time (struct wmWindow *win, int nr);
void *WM_paint_cursor_activate(struct wmWindowManager *wm,
@@ -361,6 +371,8 @@ void WM_progress_clear(struct wmWindow *win);
/* Draw (for screenshot) */
void WM_redraw_windows(struct bContext *C);
+void WM_main_playanim(int argc, const char **argv);
+
/* debugging only, convenience function to write on crash */
int write_crash_blend(void);
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 6fc6a57ade1..7853b40c98a 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -179,7 +179,10 @@ void WM_cursor_wait(int val)
}
}
-void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int *bounds)
+/**
+ * \param bounds can be NULL
+ */
+void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int bounds[4])
{
/* Only grab cursor when not running debug.
* It helps not to get a stuck WM when hitting a breakpoint
@@ -193,20 +196,20 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int *bounds)
const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin);
/* Note: There is no tabletdata on Windows if no tablet device is connected. */
if (!tabletdata)
- GHOST_SetCursorGrab(win->ghostwin, mode, bounds);
+ GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL);
else if (tabletdata->Active == GHOST_kTabletModeNone)
- GHOST_SetCursorGrab(win->ghostwin, mode, bounds);
+ GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL);
win->grabcursor = mode;
}
}
}
-void WM_cursor_grab_disable(wmWindow *win)
+void WM_cursor_grab_disable(wmWindow *win, int mouse_ungrab_xy[2])
{
if ((G.debug & G_DEBUG) == 0) {
if (win && win->ghostwin) {
- GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL);
+ GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, mouse_ungrab_xy);
win->grabcursor = GHOST_kGrabDisable;
}
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 17f17baba0e..c05d9532f74 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1202,7 +1202,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
CTX_wm_region_set(C, region);
}
- WM_cursor_grab_disable(CTX_wm_window(C));
+ WM_cursor_grab_disable(CTX_wm_window(C), NULL);
WM_operator_free(handler->op);
}
else if (handler->ui_remove) {
@@ -1432,7 +1432,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
/* remove modal handler, operator itself should have been canceled and freed */
if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
- WM_cursor_grab_disable(CTX_wm_window(C));
+ WM_cursor_grab_disable(CTX_wm_window(C), NULL);
BLI_remlink(handlers, handler);
wm_event_free_handler(handler);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index dca28c63557..594804d10f6 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -708,11 +708,11 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt)
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
- IB_rect, OB_SOLID, FALSE, err_out);
+ IB_rect, OB_SOLID, FALSE, FALSE, err_out);
}
else {
ibuf = ED_view3d_draw_offscreen_imbuf(scene, v3d, ar, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
- IB_rect, FALSE, err_out);
+ IB_rect, FALSE, FALSE, err_out);
}
if (ibuf) {
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 2928ba024e5..b3ffb80243a 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -130,8 +130,8 @@ int wm_gesture_evaluate(wmGesture *gesture)
{
if (gesture->type == WM_GESTURE_TWEAK) {
rcti *rect = gesture->customdata;
- int dx = BLI_RCT_SIZE_X(rect);
- int dy = BLI_RCT_SIZE_Y(rect);
+ int dx = BLI_rcti_size_x(rect);
+ int dy = BLI_rcti_size_y(rect);
if (ABS(dx) + ABS(dy) > U.tweak_threshold) {
int theta = (int)floor(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI + 0.5f);
int val = EVT_GESTURE_W;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 8c2272e4707..534bfdc369e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -32,8 +32,8 @@
#include <stdio.h>
#include <string.h>
-#if WIN32
-#include <Windows.h>
+#ifdef WIN32
+# include <Windows.h>
#endif
#include "MEM_guardedalloc.h"
@@ -67,7 +67,6 @@
#include "BKE_tracking.h" /* free tracking clipboard */
#include "BLI_listbase.h"
-#include "BLI_math_color.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -115,6 +114,8 @@
#include "BKE_sound.h"
#include "COM_compositor.h"
+#include "IMB_colormanagement.h"
+
static void wm_init_reports(bContext *C)
{
BKE_reports_init(CTX_wm_reports(C), RPT_STORE);
@@ -143,15 +144,18 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_spacetypes_init(); /* editors/space_api/spacetype.c */
+ /* initialize color management stuff
+ * do this before ED_file_init because that function would load images,
+ * so at least default byte color space should be already known
+ */
+ IMB_colormanagement_init();
+
ED_file_init(); /* for fsmenu */
ED_node_init_butfuncs();
BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
BLF_lang_init();
- /* initialize color stuff */
- BLI_init_srgb_conversion();
-
/* get the default database, plus a wm */
WM_homefile_read(C, NULL, G.factory_startup);
@@ -338,9 +342,8 @@ static void free_openrecent(void)
extern void free_anim_copybuf(void);
extern void free_anim_drivers_copybuf(void);
extern void free_fmodifiers_copybuf(void);
-extern void free_posebuf(void);
-#if WIN32
+#ifdef WIN32
/* Read console events until there is a key event. Also returns on any error. */
static void wait_for_console_key(void)
{
@@ -371,6 +374,8 @@ void WM_exit_ext(bContext *C, const short do_python)
sound_exit();
+ IMB_colormanagement_exit();
+
/* first wrap up running stuff, we assume only the active WM is running */
/* modal handlers are on window level freed, others too? */
/* note; same code copied in wm_files.c */
@@ -421,7 +426,7 @@ void WM_exit_ext(bContext *C, const short do_python)
free_anim_copybuf();
free_anim_drivers_copybuf();
free_fmodifiers_copybuf();
- free_posebuf();
+ ED_clipboard_posebuf_free();
BKE_node_clipboard_clear();
BLF_exit();
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index eb6da146a73..bcddc984ed3 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -867,7 +867,6 @@ 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);
-
if (sa && found == NULL)
found = wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
@@ -901,7 +900,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(
found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
}
}
-
+
return found;
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 0259146a9d3..313fc0a819e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1296,7 +1296,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
extern int datatoc_splash_png_size;
ImBuf *ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png,
- datatoc_splash_png_size, IB_rect, "<splash screen>");
+ datatoc_splash_png_size, IB_rect, NULL, "<splash screen>");
#else
ImBuf *ibuf = NULL;
#endif
@@ -1693,7 +1693,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
/* **************** link/append *************** */
-int wm_link_append_poll(bContext *C)
+static int wm_link_append_poll(bContext *C)
{
if (WM_operator_winactive(C)) {
/* linking changes active object which is pretty useful in general,
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index e3867c0a32a..35cc1545c40 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -72,6 +72,8 @@
#include "wm_event_types.h"
+#include "WM_api.h" /* only for WM_main_playanim */
+
typedef struct PlayState {
/* playback state */
@@ -142,7 +144,7 @@ static struct WindowStateGlobal {
eWS_Qual qual;
} g_WS = {NULL};
-void playanim_window_get_size(int *width_r, int *height_r)
+static void playanim_window_get_size(int *width_r, int *height_r)
{
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(g_WS.ghost_window);
*width_r = GHOST_GetWidthRectangle(bounds);
@@ -279,7 +281,8 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
struct anim *anim;
if (IMB_isanim(first)) {
- anim = IMB_open_anim(first, IB_rect, 0);
+ /* OCIO_TODO: support different input color space */
+ anim = IMB_open_anim(first, IB_rect, 0, NULL);
if (anim) {
int pic;
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
@@ -378,12 +381,13 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
pupdate_time();
if (ptottime > 1.0) {
+ /* OCIO_TODO: support different input color space */
if (picture->mem) {
ibuf = IMB_ibImageFromMemory((unsigned char *)picture->mem, picture->size,
- picture->IB_flags, picture->name);
+ picture->IB_flags, NULL, picture->name);
}
else {
- ibuf = IMB_loadiffname(picture->name, picture->IB_flags);
+ ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL);
}
if (ibuf) {
playanim_toscreen(picture, ibuf, fontid);
@@ -689,7 +693,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
return 1;
}
-void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey, int start_maximized)
+static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey, int start_maximized)
{
GHOST_TWindowState inital_state;
GHOST_TUns32 scr_w, scr_h;
@@ -709,18 +713,10 @@ void playanim_window_open(const char *title, int posx, int posy, int sizex, int
inital_state,
GHOST_kDrawingContextTypeOpenGL,
FALSE /* no stereo */, FALSE);
-
- //if (ghostwin) {
- //if (win) {
- // GHOST_SetWindowUserData(ghostwin, win);
- //} else {
- // GHOST_DisposeWindow(g_WS.ghost_system, ghostwin);
- //}
- //}
}
-void playanim(int argc, const char **argv)
+void WM_main_playanim(int argc, const char **argv)
{
struct ImBuf *ibuf = NULL;
char filepath[FILE_MAX];
@@ -824,7 +820,8 @@ void playanim(int argc, const char **argv)
}
if (IMB_isanim(filepath)) {
- anim = IMB_open_anim(filepath, IB_rect, 0);
+ /* OCIO_TODO: support different input color spaces */
+ anim = IMB_open_anim(filepath, IB_rect, 0, NULL);
if (anim) {
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
IMB_close_anim(anim);
@@ -836,7 +833,8 @@ void playanim(int argc, const char **argv)
}
if (ibuf == NULL) {
- ibuf = IMB_loadiffname(filepath, IB_rect);
+ /* OCIO_TODO: support different input color space */
+ ibuf = IMB_loadiffname(filepath, IB_rect, NULL);
}
if (ibuf == NULL) {
@@ -948,11 +946,13 @@ void playanim(int argc, const char **argv)
ibuf = IMB_anim_absolute(ps.picture->anim, ps.picture->frame, IMB_TC_NONE, IMB_PROXY_NONE);
}
else if (ps.picture->mem) {
+ /* use correct colorspace here */
ibuf = IMB_ibImageFromMemory((unsigned char *) ps.picture->mem, ps.picture->size,
- ps.picture->IB_flags, ps.picture->name);
+ ps.picture->IB_flags, NULL, ps.picture->name);
}
else {
- ibuf = IMB_loadiffname(ps.picture->name, ps.picture->IB_flags);
+ /* use correct colorspace here */
+ ibuf = IMB_loadiffname(ps.picture->name, ps.picture->IB_flags, NULL);
}
if (ibuf) {
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index adf54af240b..4078a88b2fd 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -116,8 +116,8 @@ void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y)
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
- *x = BLI_RCT_SIZE_X(&swin->winrct) + 1;
- *y = BLI_RCT_SIZE_Y(&swin->winrct) + 1;
+ *x = BLI_rcti_size_x(&swin->winrct) + 1;
+ *y = BLI_rcti_size_y(&swin->winrct) + 1;
}
}
@@ -256,13 +256,13 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
win->curswin = _curswin;
_curwindow = win;
- width = BLI_RCT_SIZE_X(&_curswin->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&_curswin->winrct) + 1;
+ width = BLI_rcti_size_x(&_curswin->winrct) + 1;
+ height = BLI_rcti_size_y(&_curswin->winrct) + 1;
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
if (srct) {
- width = BLI_RCT_SIZE_X(srct) + 1;
- height = BLI_RCT_SIZE_Y(srct) + 1;
+ width = BLI_rcti_size_x(srct) + 1;
+ height = BLI_rcti_size_y(srct) + 1;
glScissor(srct->xmin, srct->ymin, width, height);
}
else
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 59c8235faf0..18072d805fc 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -458,8 +458,8 @@ wmWindow *WM_window_open(bContext *C, rcti *rect)
win->posx = rect->xmin;
win->posy = rect->ymin;
- win->sizex = BLI_RCT_SIZE_X(rect);
- win->sizey = BLI_RCT_SIZE_Y(rect);
+ win->sizex = BLI_rcti_size_x(rect);
+ win->sizey = BLI_rcti_size_y(rect);
win->drawmethod = -1;
win->drawdata = NULL;
@@ -494,8 +494,8 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
win->posy = position->ymin;
}
- win->sizex = BLI_RCT_SIZE_X(position);
- win->sizey = BLI_RCT_SIZE_Y(position);
+ win->sizex = BLI_rcti_size_x(position);
+ win->sizey = BLI_rcti_size_y(position);
if (win->ghostwin) {
wm_window_set_size(win, win->sizex, win->sizey);