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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-01-26 16:12:20 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-01-26 16:12:20 +0400
commit789273986906e8661bc98fc26b6b1e643c04584c (patch)
tree21f2c2ced7ae564bc9f09537685e17f91f74e628
parentde8612ec6235044701aa8cb2e7d28cce95b95f86 (diff)
parentdb57cbac20bb513ba688c5cfb2655d8753a89aab (diff)
Merging r43501 through r43720 form trunk into soc-2011-tomato
-rw-r--r--build_files/cmake/cmake_static_check_cppcheck.py3
-rw-r--r--build_files/scons/tools/Blender.py2
-rw-r--r--doc/python_api/examples/bge.constraints.py2
-rw-r--r--doc/python_api/examples/bge.texture.1.py4
-rw-r--r--doc/python_api/examples/bge.texture.py2
-rw-r--r--doc/python_api/rst/bge.constraints.rst5
-rw-r--r--doc/python_api/rst/bge.render.rst8
-rw-r--r--doc/python_api/rst/bge.texture.rst10
-rw-r--r--doc/python_api/rst/bge.types.rst28
-rw-r--r--extern/libmv/third_party/glog/src/config.h10
-rw-r--r--extern/libmv/third_party/glog/src/config_linux.h4
-rw-r--r--intern/boolop/SConscript1
-rw-r--r--intern/boolop/intern/BOP_CarveInterface.cpp231
-rw-r--r--intern/cycles/app/cycles_xml.cpp3
-rw-r--r--intern/cycles/blender/addon/properties.py415
-rw-r--r--intern/cycles/blender/addon/ui.py86
-rw-r--r--intern/cycles/blender/blender_object.cpp37
-rw-r--r--intern/cycles/blender/blender_session.cpp113
-rw-r--r--intern/cycles/blender/blender_shader.cpp8
-rw-r--r--intern/cycles/blender/blender_sync.h1
-rw-r--r--intern/cycles/device/device_cpu.cpp12
-rw-r--r--intern/cycles/kernel/CMakeLists.txt3
-rw-r--r--intern/cycles/kernel/kernel.cl6
-rw-r--r--intern/cycles/kernel/kernel.cpp6
-rw-r--r--intern/cycles/kernel/kernel.cu6
-rw-r--r--intern/cycles/kernel/kernel.h12
-rw-r--r--intern/cycles/kernel/kernel_accumulate.h283
-rw-r--r--intern/cycles/kernel/kernel_compat_cpu.h1
-rw-r--r--intern/cycles/kernel/kernel_compat_cuda.h1
-rw-r--r--intern/cycles/kernel/kernel_differential.h4
-rw-r--r--intern/cycles/kernel/kernel_displace.h4
-rw-r--r--intern/cycles/kernel/kernel_emission.h105
-rw-r--r--intern/cycles/kernel/kernel_film.h13
-rw-r--r--intern/cycles/kernel/kernel_light.h133
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h34
-rw-r--r--intern/cycles/kernel/kernel_object.h10
-rw-r--r--intern/cycles/kernel/kernel_optimized.cpp6
-rw-r--r--intern/cycles/kernel/kernel_passes.h146
-rw-r--r--intern/cycles/kernel/kernel_path.h118
-rw-r--r--intern/cycles/kernel/kernel_random.h44
-rw-r--r--intern/cycles/kernel/kernel_shader.h110
-rw-r--r--intern/cycles/kernel/kernel_textures.h2
-rw-r--r--intern/cycles/kernel/kernel_types.h111
-rw-r--r--intern/cycles/kernel/osl/nodes/CMakeLists.txt1
-rw-r--r--intern/cycles/kernel/osl/nodes/node_brightness.osl50
-rw-r--r--intern/cycles/kernel/svm/svm.h4
-rw-r--r--intern/cycles/kernel/svm/svm_brightness.h57
-rw-r--r--intern/cycles/kernel/svm/svm_image.h5
-rw-r--r--intern/cycles/kernel/svm/svm_types.h28
-rw-r--r--intern/cycles/render/buffers.cpp120
-rw-r--r--intern/cycles/render/buffers.h46
-rw-r--r--intern/cycles/render/film.cpp179
-rw-r--r--intern/cycles/render/film.h15
-rw-r--r--intern/cycles/render/light.cpp189
-rw-r--r--intern/cycles/render/light.h3
-rw-r--r--intern/cycles/render/mesh_displace.cpp9
-rw-r--r--intern/cycles/render/nodes.cpp32
-rw-r--r--intern/cycles/render/nodes.h5
-rw-r--r--intern/cycles/render/object.cpp4
-rw-r--r--intern/cycles/render/object.h1
-rw-r--r--intern/cycles/render/scene.h2
-rw-r--r--intern/cycles/render/shader.cpp5
-rw-r--r--intern/cycles/render/shader.h1
-rw-r--r--intern/ffmpeg/ffmpeg_compat.h1
-rw-r--r--intern/ghost/GHOST_ISystem.h9
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp106
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.h11
-rw-r--r--intern/ghost/intern/GHOST_System.cpp13
-rw-r--r--intern/ghost/intern/GHOST_System.h9
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp3
-rw-r--r--release/scripts/presets/keyconfig/maya.py3
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py11
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_cloth.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_fluid.py5
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py4
-rw-r--r--release/scripts/startup/bl_ui/space_image.py8
-rw-r--r--release/scripts/startup/bl_ui/space_logic.py2
-rw-r--r--release/scripts/startup/bl_ui/space_node.py5
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py10
-rw-r--r--source/blender/avi/intern/endian.c4
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h14
-rw-r--r--source/blender/blenkernel/BKE_armature.h2
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_global.h2
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_main.h2
-rw-r--r--source/blender/blenkernel/BKE_modifier.h10
-rw-r--r--source/blender/blenkernel/BKE_node.h48
-rw-r--r--source/blender/blenkernel/BKE_tracking.h1
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h6
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c240
-rw-r--r--source/blender/blenkernel/intern/armature.c18
-rw-r--r--source/blender/blenkernel/intern/brush.c31
-rw-r--r--source/blender/blenkernel/intern/cloth.c1
-rw-r--r--source/blender/blenkernel/intern/constraint.c20
-rw-r--r--source/blender/blenkernel/intern/curve.c5
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c177
-rw-r--r--source/blender/blenkernel/intern/image.c4
-rw-r--r--source/blender/blenkernel/intern/image_gen.c15
-rw-r--r--source/blender/blenkernel/intern/implicit.c3
-rw-r--r--source/blender/blenkernel/intern/key.c2
-rw-r--r--source/blender/blenkernel/intern/mesh.c8
-rw-r--r--source/blender/blenkernel/intern/modifier.c42
-rw-r--r--source/blender/blenkernel/intern/movieclip.c2
-rw-r--r--source/blender/blenkernel/intern/nla.c38
-rw-r--r--source/blender/blenkernel/intern/node.c49
-rw-r--r--source/blender/blenkernel/intern/particle_system.c3
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenkernel/intern/sequencer.c4
-rw-r--r--source/blender/blenkernel/intern/smoke.c14
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c45
-rw-r--r--source/blender/blenkernel/intern/text.c38
-rw-r--r--source/blender/blenkernel/intern/tracking.c17
-rw-r--r--source/blender/blenlib/BLI_array.h4
-rw-r--r--source/blender/blenlib/BLI_math_color.h9
-rw-r--r--source/blender/blenlib/BLI_math_geom.h5
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c2
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c9
-rw-r--r--source/blender/blenlib/intern/boxpack2d.c2
-rw-r--r--source/blender/blenlib/intern/math_color.c37
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c16
-rw-r--r--source/blender/blenlib/intern/math_geom.c58
-rw-r--r--source/blender/blenlib/intern/math_rotation.c2
-rw-r--r--source/blender/blenlib/intern/math_vector.c14
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c23
-rw-r--r--source/blender/blenlib/intern/noise.c4
-rw-r--r--source/blender/blenloader/BLO_readfile.h2
-rw-r--r--source/blender/blenloader/intern/readfile.c33
-rw-r--r--source/blender/blenloader/intern/writefile.c5
-rw-r--r--source/blender/blenpluginapi/iff.h2
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c2
-rw-r--r--source/blender/editors/armature/editarmature.c18
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c2
-rw-r--r--source/blender/editors/armature/poselib.c10
-rw-r--r--source/blender/editors/armature/reeb.c2
-rw-r--r--source/blender/editors/curve/editcurve.c4
-rw-r--r--source/blender/editors/curve/editfont.c4
-rw-r--r--source/blender/editors/include/ED_image.h4
-rw-r--r--source/blender/editors/include/ED_mesh.h4
-rw-r--r--source/blender/editors/include/ED_object.h24
-rw-r--r--source/blender/editors/include/UI_interface.h7
-rw-r--r--source/blender/editors/include/UI_interface_icons.h2
-rw-r--r--source/blender/editors/include/UI_resources.h73
-rw-r--r--source/blender/editors/interface/interface.c167
-rw-r--r--source/blender/editors/interface/interface_draw.c42
-rw-r--r--source/blender/editors/interface/interface_handlers.c39
-rw-r--r--source/blender/editors/interface/interface_icons.c4
-rw-r--r--source/blender/editors/interface/interface_intern.h4
-rw-r--r--source/blender/editors/interface/interface_layout.c221
-rw-r--r--source/blender/editors/interface/interface_panel.c3
-rw-r--r--source/blender/editors/interface/interface_regions.c14
-rw-r--r--source/blender/editors/interface/interface_templates.c12
-rw-r--r--source/blender/editors/interface/interface_widgets.c2
-rw-r--r--source/blender/editors/interface/resources.c27
-rw-r--r--source/blender/editors/interface/view2d.c7
-rw-r--r--source/blender/editors/mesh/mesh_data.c82
-rw-r--r--source/blender/editors/mesh/mesh_ops.c1
-rw-r--r--source/blender/editors/object/object_add.c17
-rw-r--r--source/blender/editors/object/object_bake.c25
-rw-r--r--source/blender/editors/object/object_modifier.c2
-rw-r--r--source/blender/editors/object/object_relations.c119
-rw-r--r--source/blender/editors/object/object_vgroup.c4
-rw-r--r--source/blender/editors/physics/physics_fluid.c72
-rw-r--r--source/blender/editors/render/render_shading.c2
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt1
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c607
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c560
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c76
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c30
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c33
-rw-r--r--source/blender/editors/sound/sound_ops.c6
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c1
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c4
-rw-r--r--source/blender/editors/space_clip/clip_draw.c4
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c24
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c122
-rw-r--r--source/blender/editors/space_clip/clip_intern.h4
-rw-r--r--source/blender/editors/space_clip/clip_ops.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c21
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c15
-rw-r--r--source/blender/editors/space_file/filelist.c9
-rw-r--r--source/blender/editors/space_file/filesel.c19
-rw-r--r--source/blender/editors/space_graph/graph_edit.c5
-rw-r--r--source/blender/editors/space_image/image_draw.c40
-rw-r--r--source/blender/editors/space_image/image_ops.c14
-rw-r--r--source/blender/editors/space_info/info_ops.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c9
-rw-r--r--source/blender/editors/space_node/node_edit.c4
-rw-r--r--source/blender/editors/space_node/node_templates.c11
-rw-r--r--source/blender/editors/space_node/space_node.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c12
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c275
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h8
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c75
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c86
-rw-r--r--source/blender/editors/space_script/script_edit.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c2
-rw-r--r--source/blender/editors/space_text/text_ops.c30
-rw-r--r--source/blender/editors/space_time/space_time.c4
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c49
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c11
-rw-r--r--source/blender/editors/space_view3d/drawobject.c94
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c7
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c47
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c266
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c54
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h5
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c95
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c13
-rw-r--r--source/blender/editors/util/ed_util.c34
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c311
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c15
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h2
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h6
-rw-r--r--source/blender/imbuf/intern/IMB_indexer.h2
-rw-r--r--source/blender/imbuf/intern/divers.c55
-rw-r--r--source/blender/makesdna/DNA_ID.h4
-rw-r--r--source/blender/makesdna/DNA_brush_types.h2
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h3
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h2
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h5
-rw-r--r--source/blender/makesdna/DNA_fileglobal_types.h2
-rw-r--r--source/blender/makesdna/DNA_image_types.h3
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h2
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h4
-rw-r--r--source/blender/makesdna/DNA_node_types.h12
-rw-r--r--source/blender/makesdna/DNA_object_fluidsim.h8
-rw-r--r--source/blender/makesdna/DNA_object_force.h4
-rw-r--r--source/blender/makesdna/DNA_scene_types.h51
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h18
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h3
-rw-r--r--source/blender/makesdna/DNA_sound_types.h2
-rw-r--r--source/blender/makesdna/DNA_space_types.h28
-rw-r--r--source/blender/makesdna/DNA_texture_types.h4
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h29
-rw-r--r--source/blender/makesdna/DNA_vfont_types.h2
-rw-r--r--source/blender/makesrna/intern/SConscript4
-rw-r--r--source/blender/makesrna/intern/rna_access.c11
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c8
-rw-r--r--source/blender/makesrna/intern/rna_controller.c19
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c5
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c19
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c62
-rw-r--r--source/blender/makesrna/intern/rna_render.c9
-rw-r--r--source/blender/makesrna/intern/rna_scene.c68
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c1
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c4
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c21
-rw-r--r--source/blender/makesrna/intern/rna_space.c11
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c11
-rw-r--r--source/blender/modifiers/intern/MOD_boolean_util.c9
-rw-r--r--source/blender/modifiers/intern/MOD_build.c151
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c6
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c1
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c32
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c28
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c21
-rw-r--r--source/blender/nodes/CMakeLists.txt1
-rw-r--r--source/blender/nodes/NOD_shader.h1
-rw-r--r--source/blender/nodes/NOD_socket.h33
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c23
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c83
-rw-r--r--source/blender/nodes/intern/node_common.c195
-rw-r--r--source/blender/nodes/intern/node_socket.c355
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_brightness.c60
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_gamma.c5
-rw-r--r--source/blender/python/intern/bpy_props.c111
-rw-r--r--source/blender/python/intern/bpy_rna.c34
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c29
-rw-r--r--source/blender/quicktime/quicktime_export.h3
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h4
-rw-r--r--source/blender/render/intern/source/convertblender.c30
-rw-r--r--source/blender/render/intern/source/imagetexture.c6
-rw-r--r--source/blender/render/intern/source/occlusion.c2
-rw-r--r--source/blender/render/intern/source/pixelshading.c6
-rw-r--r--source/blender/render/intern/source/rayshade.c14
-rw-r--r--source/blender/render/intern/source/render_result.c100
-rw-r--r--source/blender/render/intern/source/render_texture.c3
-rw-r--r--source/blender/render/intern/source/rendercore.c38
-rw-r--r--source/blender/render/intern/source/shadbuf.c4
-rw-r--r--source/blender/render/intern/source/shadeinput.c4
-rw-r--r--source/blender/render/intern/source/volumetric.c2
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/WM_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c29
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c3
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp5
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h2
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp18
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.cpp18
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PythonMouse.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_PythonMouse.h1
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.h1
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp20
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h2
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp125
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h6
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp11
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h9
-rw-r--r--source/gameengine/VideoTexture/blendVideoTex.cpp6
-rw-r--r--source/tests/bl_mesh_modifiers.py2
321 files changed, 7631 insertions, 2955 deletions
diff --git a/build_files/cmake/cmake_static_check_cppcheck.py b/build_files/cmake/cmake_static_check_cppcheck.py
index 8720cb83054..6c13f3a079a 100644
--- a/build_files/cmake/cmake_static_check_cppcheck.py
+++ b/build_files/cmake/cmake_static_check_cppcheck.py
@@ -37,7 +37,8 @@ CHECKER_BIN = "cppcheck"
CHECKER_ARGS = [
# not sure why this is needed, but it is.
"-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
-
+ "--suppress=*:%s/extern/glew/include/GL/glew.h:241" % project_source_info.SOURCE_DIR,
+ # "--max-configs=1", # speeds up execution
# "--check-config", # when includes are missing
# "--enable=all", # if you want sixty hundred pedantic suggestions
]
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index e9195fe207d..f8d9eb8b3e1 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -272,7 +272,7 @@ def setup_syslibs(lenv):
syslibs += Split(lenv['BF_PTHREADS_LIB'])
if lenv['WITH_BF_COLLADA']:
syslibs.append(lenv['BF_PCRE_LIB'])
- if lenv['BF_DEBUG']:
+ if lenv['BF_DEBUG'] and (lenv['OURPLATFORM'] != 'linux'):
syslibs += [colladalib+'_d' for colladalib in Split(lenv['BF_OPENCOLLADA_LIB'])]
else:
syslibs += Split(lenv['BF_OPENCOLLADA_LIB'])
diff --git a/doc/python_api/examples/bge.constraints.py b/doc/python_api/examples/bge.constraints.py
index de2f7e0a39d..e76fc3dd13b 100644
--- a/doc/python_api/examples/bge.constraints.py
+++ b/doc/python_api/examples/bge.constraints.py
@@ -1,6 +1,6 @@
"""
Basic Physics Constraint
-++++++++++++++++++++++
+++++++++++++++++++++++++
Example of how to create a hinge Physics Constraint between two objects.
"""
from bge import logic
diff --git a/doc/python_api/examples/bge.texture.1.py b/doc/python_api/examples/bge.texture.1.py
index 918ffc9772d..fba369739f7 100644
--- a/doc/python_api/examples/bge.texture.1.py
+++ b/doc/python_api/examples/bge.texture.1.py
@@ -1,6 +1,6 @@
"""
-Texture replacement
-++++++++++++++++++++++
+Texture Replacement
++++++++++++++++++++
Example of how to replace a texture in game with an external image.
createTexture() and removeTexture() are to be called from a module Python
Controller.
diff --git a/doc/python_api/examples/bge.texture.py b/doc/python_api/examples/bge.texture.py
index 70e4d6d9377..1ba0b99fc27 100644
--- a/doc/python_api/examples/bge.texture.py
+++ b/doc/python_api/examples/bge.texture.py
@@ -1,6 +1,6 @@
"""
Basic Video Playback
-++++++++++++++++++++++
+++++++++++++++++++++
Example of how to replace a texture in game with a video. It needs to run everyframe
"""
import bge
diff --git a/doc/python_api/rst/bge.constraints.rst b/doc/python_api/rst/bge.constraints.rst
index da0a358dfed..83f2a6b4950 100644
--- a/doc/python_api/rst/bge.constraints.rst
+++ b/doc/python_api/rst/bge.constraints.rst
@@ -5,6 +5,11 @@ Physics Constraints (bge.constraints)
.. module:: bge.constraints
.. literalinclude:: ../examples/bge.constraints.py
+ :language: rest
+ :lines: 2-4
+
+.. literalinclude:: ../examples/bge.constraints.py
+ :lines: 6-
.. function:: createConstraint(physicsid, physicsid2, constrainttype, [pivotX, pivotY, pivotZ, [axisX, axisY, axisZ, [flag]]]])
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst
index eeb50a833ff..ddc05ac1d8c 100644
--- a/doc/python_api/rst/bge.render.rst
+++ b/doc/python_api/rst/bge.render.rst
@@ -77,6 +77,14 @@ Functions
:rtype: integer
+.. function:: setWindowSize(width, height)
+
+ Set the width and height of the window (in pixels). This also works for fullscreen applications.
+
+ :type width: integer
+ :type height: integer
+
+
.. function:: makeScreenshot(filename)
Writes a screenshot to the given filename.
diff --git a/doc/python_api/rst/bge.texture.rst b/doc/python_api/rst/bge.texture.rst
index 0abefcbea82..07d83f66bd4 100644
--- a/doc/python_api/rst/bge.texture.rst
+++ b/doc/python_api/rst/bge.texture.rst
@@ -37,8 +37,18 @@ When the texture object is deleted, the new texture is deleted and the old textu
.. module:: bge.texture
.. literalinclude:: ../examples/bge.texture.py
+ :language: rest
+ :lines: 2-4
+
+.. literalinclude:: ../examples/bge.texture.py
+ :lines: 6-
+
+.. literalinclude:: ../examples/bge.texture.1.py
+ :language: rest
+ :lines: 2-6
.. literalinclude:: ../examples/bge.texture.1.py
+ :lines: 8-
.. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0])
diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst
index f97c95babc9..735ad037175 100644
--- a/doc/python_api/rst/bge.types.rst
+++ b/doc/python_api/rst/bge.types.rst
@@ -66,6 +66,12 @@ Game Types (bge.types)
:type: dictionary {:ref:`keycode<keyboard-keys>`::ref:`status<input-status>`, ...}
+ .. attribute:: active_events
+
+ A dictionary containing the status of only the active keyboard events or keys. (read-only).
+
+ :type: dictionary {:ref:`keycode<keyboard-keys>`::ref:`status<input-status>`, ...}
+
.. class:: SCA_PythonMouse(PyObjectPlus)
The current mouse.
@@ -75,6 +81,12 @@ Game Types (bge.types)
a dictionary containing the status of each mouse event. (read-only).
:type: dictionary {:ref:`keycode<mouse-keys>`::ref:`status<input-status>`, ...}
+
+ .. attribute:: active_events
+
+ a dictionary containing the status of only the active mouse events. (read-only).
+
+ :type: dictionary {:ref:`keycode<mouse-keys>`::ref:`status<input-status>`, ...}
.. attribute:: position
@@ -942,7 +954,7 @@ Game Types (bge.types)
.. deprecated:: use :data:`localPosition` and :data:`worldPosition`.
- :type: :class:`mathurils.Vector`
+ :type: :class:`mathutils.Vector`
.. attribute:: orientation
@@ -980,7 +992,7 @@ Game Types (bge.types)
.. attribute:: worldScale
- The object's world scaling factor. Read-only. [sx, sy, sz]
+ The object's world scaling factor. [sx, sy, sz]
:type: :class:`mathutils.Vector`
@@ -995,6 +1007,18 @@ Game Types (bge.types)
The object's world position. [x, y, z]
:type: :class:`mathutils.Vector`
+
+ .. attribute:: localTransform
+
+ The object's local space transform matrix. 4x4 Matrix.
+
+ :type: :class:`mathutils.Matrix`
+
+ .. attribute:: worldTransform
+
+ The object's world space transform matrix. 4x4 Matrix.
+
+ :type: :class:`mathutils.Matrix`
.. attribute:: localLinearVelocity
diff --git a/extern/libmv/third_party/glog/src/config.h b/extern/libmv/third_party/glog/src/config.h
index 49c0d8905b0..102bf9e4034 100644
--- a/extern/libmv/third_party/glog/src/config.h
+++ b/extern/libmv/third_party/glog/src/config.h
@@ -2,14 +2,14 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Namespace for Google classes */
-#ifdef __APPLE__
+#if defined(__APPLE__)
#include "config_mac.h"
-#elif __FreeBSD__
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "config_freebsd.h"
-#elif __MINGW32__
+#elif defined(__MINGW32__)
#include "windows/config.h"
-#elif __GNUC__
+#elif defined(__linux__)
#include "config_linux.h"
-#elif _MSC_VER
+#elif defined(_MSC_VER)
#include "windows/config.h"
#endif
diff --git a/extern/libmv/third_party/glog/src/config_linux.h b/extern/libmv/third_party/glog/src/config_linux.h
index ffd4e778de6..faf032949bb 100644
--- a/extern/libmv/third_party/glog/src/config_linux.h
+++ b/extern/libmv/third_party/glog/src/config_linux.h
@@ -133,8 +133,10 @@
/* How to access the PC from a struct ucontext */
#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP]
-#else
+#elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
#define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_EIP]
+#else
+ #undef PC_FROM_UCONTEXT
#endif
/* Define to necessary symbol if this constant uses a non-standard name on
diff --git a/intern/boolop/SConscript b/intern/boolop/SConscript
index 0efed532cb9..1c8c912614d 100644
--- a/intern/boolop/SConscript
+++ b/intern/boolop/SConscript
@@ -8,6 +8,7 @@ incs += ' ../../source/blender/blenlib'
defs = []
if not env['WITH_BF_CARVE']:
+ import os
sources = env.Glob('intern/*.cpp')
sources.remove('intern' + os.sep + 'BOP_CarveInterface.cpp')
else:
diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp
index 4db4fdd819d..274d9cac0cf 100644
--- a/intern/boolop/intern/BOP_CarveInterface.cpp
+++ b/intern/boolop/intern/BOP_CarveInterface.cpp
@@ -15,12 +15,13 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * The Original Code is Copyright (C) 2010 by the Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Ken Hughes,
+ * Sergey Sharybin.
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -36,6 +37,9 @@
#include <carve/interpolator.hpp>
#include <carve/rescale.hpp>
+#include <iostream>
+
+using namespace carve::mesh;
typedef unsigned int uint;
#define MAX(x,y) ((x)>(y)?(x):(y))
@@ -61,10 +65,161 @@ static int isFacePlanar(CSG_IFace &face, std::vector<carve::geom3d::Vector> &ver
return 1;
}
-static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_it,
- CSG_VertexIteratorDescriptor& vertex_it,
- carve::interpolate::FaceAttr<uint> &oface_num,
- uint &num_origfaces )
+static MeshSet<3> *Carve_meshSetFromMeshes(std::vector<MeshSet<3>::mesh_t*> &meshes)
+{
+ std::vector<MeshSet<3>::mesh_t*> new_meshes;
+
+ std::vector<MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
+ for(; it!=meshes.end(); it++) {
+ MeshSet<3>::mesh_t *mesh = *it;
+ MeshSet<3>::mesh_t *new_mesh = new MeshSet<3>::mesh_t(mesh->faces);
+
+ new_meshes.push_back(new_mesh);
+ }
+
+ return new MeshSet<3>(new_meshes);
+}
+
+static void Carve_getIntersectedOperandMeshes(std::vector<MeshSet<3>::mesh_t*> &meshes,
+ std::vector<MeshSet<3>::aabb_t> &precomputedAABB,
+ MeshSet<3>::aabb_t &otherAABB,
+ std::vector<MeshSet<3>::mesh_t*> &operandMeshes)
+{
+ std::vector<MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
+ std::vector<MeshSet<3>::aabb_t>::iterator aabb_it = precomputedAABB.begin();
+ std::vector<MeshSet<3>::aabb_t> usedAABB;
+
+ while(it != meshes.end()) {
+ MeshSet<3>::mesh_t *mesh = *it;
+ MeshSet<3>::aabb_t aabb = mesh->getAABB();
+ bool isIntersect = false;
+
+ std::vector<MeshSet<3>::aabb_t>::iterator used_it = usedAABB.begin();
+ for(; used_it!=usedAABB.end(); used_it++) {
+ MeshSet<3>::aabb_t usedAABB = *used_it;
+
+ if(usedAABB.intersects(aabb) && usedAABB.intersects(otherAABB)) {
+ isIntersect = true;
+ break;
+ }
+ }
+
+ if(!isIntersect) {
+ operandMeshes.push_back(mesh);
+ usedAABB.push_back(aabb);
+
+ it = meshes.erase(it);
+ aabb_it = precomputedAABB.erase(aabb_it);
+ }
+ else {
+ it++;
+ aabb_it++;
+ }
+ }
+}
+
+static MeshSet<3> *Carve_getIntersectedOperand(std::vector<MeshSet<3>::mesh_t*> &meshes,
+ std::vector<MeshSet<3>::aabb_t> &precomputedAABB,
+ MeshSet<3>::aabb_t &otherAABB)
+{
+ std::vector<MeshSet<3>::mesh_t*> operandMeshes;
+ Carve_getIntersectedOperandMeshes(meshes, precomputedAABB, otherAABB, operandMeshes);
+
+ return Carve_meshSetFromMeshes(operandMeshes);
+}
+
+static MeshSet<3> *Carve_unionIntersectingMeshes(MeshSet<3> *poly,
+ std::vector<MeshSet<3>::aabb_t> &precomputedAABB,
+ MeshSet<3>::aabb_t &otherAABB,
+ carve::interpolate::FaceAttr<uint> &oface_num)
+{
+ if(poly->meshes.size()<=1)
+ return poly;
+
+ carve::csg::CSG csg;
+
+ oface_num.installHooks(csg);
+ csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
+
+ std::vector<MeshSet<3>::mesh_t*> orig_meshes =
+ std::vector<MeshSet<3>::mesh_t*>(poly->meshes.begin(), poly->meshes.end());
+
+ MeshSet<3> *left = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
+
+ while(orig_meshes.size()) {
+ MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
+
+ try {
+ MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
+
+ delete left;
+ delete right;
+
+ left = result;
+ }
+ catch(carve::exception e) {
+ std::cerr << "CSG failed, exception " << e.str() << std::endl;
+
+ delete right;
+ }
+ catch(...) {
+ delete left;
+ delete right;
+
+ throw "Unknown error in Carve library";
+ }
+ }
+
+ return left;
+}
+
+static MeshSet<3>::aabb_t Carve_computeAABB(MeshSet<3> *poly,
+ std::vector<MeshSet<3>::aabb_t> &precomputedAABB)
+{
+ MeshSet<3>::aabb_t overallAABB;
+ std::vector<MeshSet<3>::mesh_t*>::iterator it = poly->meshes.begin();
+
+ for(; it!=poly->meshes.end(); it++) {
+ MeshSet<3>::aabb_t aabb;
+ MeshSet<3>::mesh_t *mesh = *it;
+
+ aabb = mesh->getAABB();
+ precomputedAABB.push_back(aabb);
+
+ overallAABB.unionAABB(aabb);
+ }
+
+ return overallAABB;
+}
+
+static void Carve_prepareOperands(MeshSet<3> **left_r, MeshSet<3> **right_r,
+ carve::interpolate::FaceAttr<uint> &oface_num)
+{
+ MeshSet<3> *left, *right;
+
+ std::vector<MeshSet<3>::aabb_t> left_precomputedAABB;
+ std::vector<MeshSet<3>::aabb_t> right_precomputedAABB;
+
+ MeshSet<3>::aabb_t leftAABB = Carve_computeAABB(*left_r, left_precomputedAABB);
+ MeshSet<3>::aabb_t rightAABB = Carve_computeAABB(*right_r, right_precomputedAABB);
+
+ left = Carve_unionIntersectingMeshes(*left_r, left_precomputedAABB, rightAABB, oface_num);
+ right = Carve_unionIntersectingMeshes(*right_r, right_precomputedAABB, leftAABB, oface_num);
+
+ if(left != *left_r)
+ delete *left_r;
+
+ if(right != *right_r)
+ delete *right_r;
+
+ *left_r = left;
+ *right_r = right;
+}
+
+static MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor &face_it,
+ CSG_VertexIteratorDescriptor &vertex_it,
+ carve::interpolate::FaceAttr<uint> &oface_num,
+ uint &num_origfaces)
{
CSG_IVertex vertex;
std::vector<carve::geom3d::Vector> vertices;
@@ -126,12 +281,12 @@ static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_i
}
}
- carve::mesh::MeshSet<3> *poly = new carve::mesh::MeshSet<3> (vertices, numfaces, f);
+ MeshSet<3> *poly = new MeshSet<3> (vertices, numfaces, f);
uint i;
- carve::mesh::MeshSet<3>::face_iter face_iter = poly->faceBegin();
+ MeshSet<3>::face_iter face_iter = poly->faceBegin();
for (i = 0; face_iter != poly->faceEnd(); ++face_iter, ++i) {
- carve::mesh::MeshSet<3>::face_t *face = *face_iter;
+ MeshSet<3>::face_t *face = *face_iter;
oface_num.setAttribute(face, forig[i]);
}
@@ -139,8 +294,8 @@ static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_i
}
// check whether two faces share an edge, and if so merge them
-static uint quadMerge(std::map<carve::mesh::MeshSet<3>::vertex_t*, uint> *vertexToIndex_map,
- carve::mesh::MeshSet<3>::face_t *f1, carve::mesh::MeshSet<3>::face_t *f2,
+static uint quadMerge(std::map<MeshSet<3>::vertex_t*, uint> *vertexToIndex_map,
+ MeshSet<3>::face_t *f1, MeshSet<3>::face_t *f2,
uint v, uint quad[4])
{
uint current, n1, p1, n2, p2;
@@ -188,23 +343,23 @@ static uint quadMerge(std::map<carve::mesh::MeshSet<3>::vertex_t*, uint> *vertex
return 0;
}
-static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::interpolate::FaceAttr<uint> &oface_num,
+static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::FaceAttr<uint> &oface_num,
uint num_origfaces)
{
uint i;
- BSP_CSGMesh* outputMesh = BSP_CSGMesh::New();
+ BSP_CSGMesh *outputMesh = BSP_CSGMesh::New();
if (outputMesh == NULL)
return NULL;
- std::vector<BSP_MVertex>* vertices = new std::vector<BSP_MVertex>;
+ std::vector<BSP_MVertex> *vertices = new std::vector<BSP_MVertex>;
outputMesh->SetVertices(vertices);
- std::map<carve::mesh::MeshSet<3>::vertex_t*, uint> vertexToIndex_map;
- std::vector<carve::mesh::MeshSet<3>::vertex_t>::iterator it = poly->vertex_storage.begin();
+ std::map<MeshSet<3>::vertex_t*, uint> vertexToIndex_map;
+ std::vector<MeshSet<3>::vertex_t>::iterator it = poly->vertex_storage.begin();
for (i = 0; it != poly->vertex_storage.end(); ++i, ++it) {
- carve::mesh::MeshSet<3>::vertex_t *vertex = &(*it);
+ MeshSet<3>::vertex_t *vertex = &(*it);
vertexToIndex_map[vertex] = i;
}
@@ -217,13 +372,13 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte
}
// build vectors of faces for each original face and each vertex
- std::vector< std::vector<uint> > vi(poly->vertex_storage.size());
- std::vector< std::vector<uint> > ofaces(num_origfaces);
- carve::mesh::MeshSet<3>::face_iter face_iter = poly->faceBegin();
+ std::vector<std::vector<uint> > vi(poly->vertex_storage.size());
+ std::vector<std::vector<uint> > ofaces(num_origfaces);
+ MeshSet<3>::face_iter face_iter = poly->faceBegin();
for (i = 0; face_iter != poly->faceEnd(); ++face_iter, ++i) {
- carve::mesh::MeshSet<3>::face_t *f = *face_iter;
+ MeshSet<3>::face_t *f = *face_iter;
ofaces[oface_num.getAttribute(f)].push_back(i);
- carve::mesh::MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin();
+ MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin();
for (; edge_iter != f->end(); ++edge_iter) {
int index = vertexToIndex_map[edge_iter->vert];
vi[index].push_back(i);
@@ -242,7 +397,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte
uint findex = fl.back();
fl.pop_back();
- carve::mesh::MeshSet<3>::face_t *f = *(poly->faceBegin() + findex);
+ MeshSet<3>::face_t *f = *(poly->faceBegin() + findex);
// add all information except vertices to the output mesh
outputMesh->FaceSet().push_back(BSP_MFace());
@@ -256,7 +411,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte
// the original face
uint result = 0;
- carve::mesh::MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin();
+ MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin();
for (; edge_iter != f->end(); ++edge_iter) {
int v = vertexToIndex_map[edge_iter->vert];
for (uint pos2=0; !result && pos2 < vi[v].size();pos2++) {
@@ -266,7 +421,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte
if (findex == otherf)
continue;
- carve::mesh::MeshSet<3>::face_t *f2 = *(poly->faceBegin() + otherf);
+ MeshSet<3>::face_t *f2 = *(poly->faceBegin() + otherf);
// if other face doesn't have the same original face,
// ignore it also
@@ -302,7 +457,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte
outFace.m_verts.push_back(quadverts[2]);
outFace.m_verts.push_back(quadverts[3]);
} else {
- carve::mesh::MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin();
+ MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin();
for (; edge_iter != f->end(); ++edge_iter) {
//int index = ofacevert_num.getAttribute(f, edge_iter.idx());
int index = vertexToIndex_map[edge_iter->vert];
@@ -337,7 +492,7 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
CSG_VertexIteratorDescriptor obBVertices)
{
carve::csg::CSG::OP op;
- carve::mesh::MeshSet<3> *left, *right, *output;
+ MeshSet<3> *left, *right, *output;
carve::csg::CSG csg;
carve::geom3d::Vector min, max;
carve::interpolate::FaceAttr<uint> oface_num;
@@ -360,6 +515,8 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
left = Carve_addMesh(obAFaces, obAVertices, oface_num, num_origfaces );
right = Carve_addMesh(obBFaces, obBVertices, oface_num, num_origfaces );
+ Carve_prepareOperands(&left, &right, oface_num);
+
min.x = max.x = left->vertex_storage[0].v.x;
min.y = max.y = left->vertex_storage[0].v.y;
min.z = max.z = left->vertex_storage[0].v.z;
@@ -390,13 +547,29 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
oface_num.installHooks(csg);
- output = csg.compute( left, right, op, NULL, carve::csg::CSG::CLASSIFY_EDGE);
+
+ try {
+ output = csg.compute(left, right, op, NULL, carve::csg::CSG::CLASSIFY_EDGE);
+ }
+ catch(carve::exception e) {
+ std::cerr << "CSG failed, exception " << e.str() << std::endl;
+ }
+ catch(...) {
+ delete left;
+ delete right;
+
+ throw "Unknown error in Carve library";
+ }
+
delete left;
delete right;
+ if(!output)
+ return BOP_ERROR;
+
output->transform(rev_r);
- *outputMesh = Carve_exportMesh( output, oface_num, num_origfaces);
+ *outputMesh = Carve_exportMesh(output, oface_num, num_origfaces);
delete output;
return BOP_OK;
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index af52520d87c..5e4b3da071d 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -462,6 +462,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
else if(string_iequals(node.name(), "gamma")) {
snode = new GammaNode();
}
+ else if(string_iequals(node.name(), "brightness")) {
+ snode = new BrightContrastNode();
+ }
else if(string_iequals(node.name(), "combine_rgb")) {
snode = new CombineRGBNode();
}
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 0a3cffd5071..7e7e83b4f69 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -33,78 +33,189 @@ from . import enums
class CyclesRenderSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Scene.cycles = PointerProperty(type=cls, name="Cycles Render Settings", description="Cycles render settings")
-
- cls.device = EnumProperty(name="Device", description="Device to use for rendering",
- items=enums.devices, default="CPU")
-
- cls.feature_set = EnumProperty(name="Feature Set", description="Feature set to use for rendering",
- items=enums.feature_set, default="SUPPORTED")
-
- cls.shading_system = EnumProperty(name="Shading System", description="Shading system to use for rendering",
- items=enums.shading_systems, default="GPU_COMPATIBLE")
-
- cls.samples = IntProperty(name="Samples", description="Number of samples to render for each pixel",
- default=10, min=1, max=2147483647)
- cls.preview_samples = IntProperty(name="Preview Samples", description="Number of samples to render in the viewport, unlimited if 0",
- default=10, min=0, max=2147483647)
- cls.preview_pause = BoolProperty(name="Pause Preview", description="Pause all viewport preview renders",
- default=False)
-
- cls.no_caustics = BoolProperty(name="No Caustics", description="Leave out caustics, resulting in a darker image with less noise",
- default=False)
- cls.blur_caustics = FloatProperty(name="Blur Caustics", description="Blur caustics to reduce noise",
- default=0.0, min=0.0, max=1.0)
-
- cls.min_bounces = IntProperty(name="Min Bounces", description="Minimum number of bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)",
- default=3, min=0, max=1024)
- cls.max_bounces = IntProperty(name="Max Bounces", description="Total maximum number of bounces",
- default=8, min=0, max=1024)
-
- cls.diffuse_bounces = IntProperty(name="Diffuse Bounces", description="Maximum number of diffuse reflection bounces, bounded by total maximum",
- default=128, min=0, max=1024)
- cls.glossy_bounces = IntProperty(name="Glossy Bounces", description="Maximum number of glossy reflection bounces, bounded by total maximum",
- default=128, min=0, max=1024)
- cls.transmission_bounces = IntProperty(name="Transmission Bounces", description="Maximum number of transmission bounces, bounded by total maximum",
- default=128, min=0, max=1024)
-
- cls.transparent_min_bounces = IntProperty(name="Transparent Min Bounces", description="Minimum number of transparent bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)",
- default=8, min=0, max=1024)
- cls.transparent_max_bounces = IntProperty(name="Transparent Max Bounces", description="Maximum number of transparent bounces",
- default=8, min=0, max=1024)
- cls.use_transparent_shadows = BoolProperty(name="Transparent Shadows", description="Use transparency of surfaces for rendering shadows",
- default=True)
-
- cls.film_exposure = FloatProperty(name="Exposure", description="Image brightness scale",
- default=1.0, min=0.0, max=10.0)
- cls.film_transparent = BoolProperty(name="Transparent", description="World background is transparent",
- default=False)
-
- cls.filter_type = EnumProperty(name="Filter Type", description="Pixel filter type",
- items=enums.filter_types, default="GAUSSIAN")
- cls.filter_width = FloatProperty(name="Filter Width", description="Pixel filter width",
- default=1.5, min=0.01, max=10.0)
-
- cls.seed = IntProperty(name="Seed", description="Seed value for integrator to get different noise patterns",
- default=0, min=0, max=2147483647)
-
- cls.debug_tile_size = IntProperty(name="Tile Size", description="",
- default=1024, min=1, max=4096)
- cls.debug_min_size = IntProperty(name="Min Size", description="",
- default=64, min=1, max=4096)
- cls.debug_reset_timeout = FloatProperty(name="Reset timeout", description="",
- default=0.1, min=0.01, max=10.0)
- cls.debug_cancel_timeout = FloatProperty(name="Cancel timeout", description="",
- default=0.1, min=0.01, max=10.0)
- cls.debug_text_timeout = FloatProperty(name="Text timeout", description="",
- default=1.0, min=0.01, max=10.0)
-
- cls.debug_bvh_type = EnumProperty(name="Viewport BVH Type", description="Choose between faster updates, or faster render",
- items=enums.bvh_types, default="DYNAMIC_BVH")
- cls.debug_use_spatial_splits = BoolProperty(name="Use Spatial Splits", description="Use BVH spatial splits: longer builder time, faster render",
- default=False)
- cls.use_cache = BoolProperty(name="Cache BVH", description="Cache last built BVH to disk for faster re-render if no geometry changed",
- default=False)
+ bpy.types.Scene.cycles = PointerProperty(
+ name="Cycles Render Settings",
+ description="Cycles render settings",
+ type=cls,
+ )
+ cls.device = EnumProperty(
+ name="Device",
+ description="Device to use for rendering",
+ items=enums.devices,
+ default='CPU',
+ )
+ cls.feature_set = EnumProperty(
+ name="Feature Set",
+ description="Feature set to use for rendering",
+ items=enums.feature_set,
+ default='SUPPORTED',
+ )
+ cls.shading_system = EnumProperty(
+ name="Shading System",
+ description="Shading system to use for rendering",
+ items=enums.shading_systems,
+ default='GPU_COMPATIBLE',
+ )
+
+ cls.samples = IntProperty(
+ name="Samples",
+ description="Number of samples to render for each pixel",
+ min=1, max=2147483647,
+ default=10,
+ )
+ cls.preview_samples = IntProperty(
+ name="Preview Samples",
+ description="Number of samples to render in the viewport, unlimited if 0",
+ min=0, max=2147483647,
+ default=10,
+ )
+ cls.preview_pause = BoolProperty(
+ name="Pause Preview",
+ description="Pause all viewport preview renders",
+ default=False,
+ )
+
+ cls.no_caustics = BoolProperty(
+ name="No Caustics",
+ description="Leave out caustics, resulting in a darker image with less noise",
+ default=False,
+ )
+ cls.blur_caustics = FloatProperty(
+ name="Blur Caustics",
+ description="Blur caustics to reduce noise",
+ min=0.0, max=1.0,
+ default=0.0,
+ )
+
+ cls.min_bounces = IntProperty(
+ name="Min Bounces",
+ description="Minimum number of bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)",
+ min=0, max=1024,
+ default=3,
+ )
+ cls.max_bounces = IntProperty(
+ name="Max Bounces",
+ description="Total maximum number of bounces",
+ min=0, max=1024,
+ default=8,
+ )
+
+ cls.diffuse_bounces = IntProperty(
+ name="Diffuse Bounces",
+ description="Maximum number of diffuse reflection bounces, bounded by total maximum",
+ min=0, max=1024,
+ default=128,
+ )
+ cls.glossy_bounces = IntProperty(
+ name="Glossy Bounces",
+ description="Maximum number of glossy reflection bounces, bounded by total maximum",
+ min=0, max=1024,
+ default=128,
+ )
+ cls.transmission_bounces = IntProperty(
+ name="Transmission Bounces",
+ description="Maximum number of transmission bounces, bounded by total maximum",
+ min=0, max=1024,
+ default=128,
+ )
+
+ cls.transparent_min_bounces = IntProperty(
+ name="Transparent Min Bounces",
+ description="Minimum number of transparent bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)",
+ min=0, max=1024,
+ default=8,
+ )
+ cls.transparent_max_bounces = IntProperty(
+ name="Transparent Max Bounces",
+ description="Maximum number of transparent bounces",
+ min=0, max=1024,
+ default=8,
+ )
+ cls.use_transparent_shadows = BoolProperty(
+ name="Transparent Shadows",
+ description="Use transparency of surfaces for rendering shadows",
+ default=True,
+ )
+
+ cls.film_exposure = FloatProperty(
+ name="Exposure",
+ description="Image brightness scale",
+ min=0.0, max=10.0,
+ default=1.0,
+ )
+ cls.film_transparent = BoolProperty(
+ name="Transparent",
+ description="World background is transparent",
+ default=False,
+ )
+
+ cls.filter_type = EnumProperty(
+ name="Filter Type",
+ description="Pixel filter type",
+ items=enums.filter_types,
+ default='GAUSSIAN',
+ )
+ cls.filter_width = FloatProperty(
+ name="Filter Width",
+ description="Pixel filter width",
+ min=0.01, max=10.0,
+ default=1.5,
+ )
+
+ cls.seed = IntProperty(
+ name="Seed",
+ description="Seed value for integrator to get different noise patterns",
+ min=0, max=2147483647,
+ default=0,
+ )
+
+ cls.debug_tile_size = IntProperty(
+ name="Tile Size",
+ description="",
+ min=1, max=4096,
+ default=1024,
+ )
+ cls.debug_min_size = IntProperty(
+ name="Min Size",
+ description="",
+ min=1, max=4096,
+ default=64,
+ )
+ cls.debug_reset_timeout = FloatProperty(
+ name="Reset timeout",
+ description="",
+ min=0.01, max=10.0,
+ default=0.1,
+ )
+ cls.debug_cancel_timeout = FloatProperty(
+ name="Cancel timeout",
+ description="",
+ min=0.01, max=10.0,
+ default=0.1,
+ )
+ cls.debug_text_timeout = FloatProperty(
+ name="Text timeout",
+ description="",
+ min=0.01, max=10.0,
+ default=1.0,
+ )
+
+ cls.debug_bvh_type = EnumProperty(
+ name="Viewport BVH Type",
+ description="Choose between faster updates, or faster render",
+ items=enums.bvh_types,
+ default='DYNAMIC_BVH',
+ )
+ cls.debug_use_spatial_splits = BoolProperty(
+ name="Use Spatial Splits",
+ description="Use BVH spatial splits: longer builder time, faster render",
+ default=False,
+ )
+ cls.use_cache = BoolProperty(
+ name="Cache BVH",
+ description="Cache last built BVH to disk for faster re-render if no geometry changed",
+ default=False,
+ )
@classmethod
def unregister(cls):
@@ -114,14 +225,31 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
class CyclesCameraSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Camera.cycles = PointerProperty(type=cls, name="Cycles Camera Settings", description="Cycles camera settings")
-
- cls.aperture_size = FloatProperty(name="Aperture Size", description="Radius of the aperture for depth of field",
- default=0.0, min=0.0, max=10.0)
- cls.aperture_blades = IntProperty(name="Aperture Blades", description="Number of blades in aperture for polygonal bokeh (at least 3)",
- default=0, min=0, max=100)
- cls.aperture_rotation = FloatProperty(name="Aperture Rotation", description="Rotation of blades in aperture",
- default=0, soft_min=-math.pi, soft_max=math.pi, subtype='ANGLE')
+ bpy.types.Camera.cycles = PointerProperty(
+ name="Cycles Camera Settings",
+ description="Cycles camera settings",
+ type=cls,
+ )
+
+ cls.aperture_size = FloatProperty(
+ name="Aperture Size",
+ description="Radius of the aperture for depth of field",
+ min=0.0, max=10.0,
+ default=0.0,
+ )
+ cls.aperture_blades = IntProperty(
+ name="Aperture Blades",
+ description="Number of blades in aperture for polygonal bokeh (at least 3)",
+ min=0, max=100,
+ default=0,
+ )
+ cls.aperture_rotation = FloatProperty(
+ name="Aperture Rotation",
+ description="Rotation of blades in aperture",
+ soft_min=-math.pi, soft_max=math.pi,
+ subtype='ANGLE',
+ default=0,
+ )
@classmethod
def unregister(cls):
@@ -131,9 +259,21 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
class CyclesMaterialSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Material.cycles = PointerProperty(type=cls, name="Cycles Material Settings", description="Cycles material settings")
- cls.sample_as_light = BoolProperty(name="Sample as Lamp", description="Use direct light sampling for this material, disabling may reduce overall noise for large objects that emit little light compared to other light sources", default=True)
- cls.homogeneous_volume = BoolProperty(name="Homogeneous Volume", description="When using volume rendering, assume volume has the same density everywhere, for faster rendering", default=False)
+ bpy.types.Material.cycles = PointerProperty(
+ name="Cycles Material Settings",
+ description="Cycles material settings",
+ type=cls,
+ )
+ cls.sample_as_light = BoolProperty(
+ name="Sample as Lamp",
+ description="Use direct light sampling for this material, disabling may reduce overall noise for large objects that emit little light compared to other light sources",
+ default=True,
+ )
+ cls.homogeneous_volume = BoolProperty(
+ name="Homogeneous Volume",
+ description="When using volume rendering, assume volume has the same density everywhere, for faster rendering",
+ default=False,
+ )
@classmethod
def unregister(cls):
@@ -143,8 +283,16 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
class CyclesLampSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Lamp.cycles = PointerProperty(type=cls, name="Cycles Lamp Settings", description="Cycles lamp settings")
- cls.cast_shadow = BoolProperty(name="Cast Shadow", description="Lamp casts shadows", default=True)
+ bpy.types.Lamp.cycles = PointerProperty(
+ name="Cycles Lamp Settings",
+ description="Cycles lamp settings",
+ type=cls,
+ )
+ cls.cast_shadow = BoolProperty(
+ name="Cast Shadow",
+ description="Lamp casts shadows",
+ default=True,
+ )
@classmethod
def unregister(cls):
@@ -154,7 +302,22 @@ class CyclesLampSettings(bpy.types.PropertyGroup):
class CyclesWorldSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.World.cycles = PointerProperty(type=cls, name="Cycles World Settings", description="Cycles world settings")
+ bpy.types.World.cycles = PointerProperty(
+ name="Cycles World Settings",
+ description="Cycles world settings",
+ type=cls,
+ )
+ cls.sample_as_light = BoolProperty(
+ name="Sample as Lamp",
+ description="Use direct light sampling for the environment, enabling for non-solid colors is recommended",
+ default=False,
+ )
+ cls.sample_map_resolution = IntProperty(
+ name="Map Resolution",
+ description="Importance map size is resolution x resolution; higher values potentially produce less noise, at the cost of memory and speed",
+ min=4, max=8096,
+ default=256,
+ )
@classmethod
def unregister(cls):
@@ -164,13 +327,37 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
class CyclesVisibilitySettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Object.cycles_visibility = PointerProperty(type=cls, name="Cycles Visibility Settings", description="Cycles visibility settings")
-
- cls.camera = BoolProperty(name="Camera", description="Object visibility for camera rays", default=True)
- cls.diffuse = BoolProperty(name="Diffuse", description="Object visibility for diffuse reflection rays", default=True)
- cls.glossy = BoolProperty(name="Glossy", description="Object visibility for glossy reflection rays", default=True)
- cls.transmission = BoolProperty(name="Transmission", description="Object visibility for transmission rays", default=True)
- cls.shadow = BoolProperty(name="Shadow", description="Object visibility for shadow rays", default=True)
+ bpy.types.Object.cycles_visibility = PointerProperty(
+ name="Cycles Visibility Settings",
+ description="Cycles visibility settings",
+ type=cls,
+ )
+
+ cls.camera = BoolProperty(
+ name="Camera",
+ description="Object visibility for camera rays",
+ default=True,
+ )
+ cls.diffuse = BoolProperty(
+ name="Diffuse",
+ description="Object visibility for diffuse reflection rays",
+ default=True,
+ )
+ cls.glossy = BoolProperty(
+ name="Glossy",
+ description="Object visibility for glossy reflection rays",
+ default=True,
+ )
+ cls.transmission = BoolProperty(
+ name="Transmission",
+ description="Object visibility for transmission rays",
+ default=True,
+ )
+ cls.shadow = BoolProperty(
+ name="Shadow",
+ description="Object visibility for shadow rays",
+ default=True,
+ )
@classmethod
def unregister(cls):
@@ -180,15 +367,39 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup):
class CyclesMeshSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- bpy.types.Mesh.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles mesh settings")
- bpy.types.Curve.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles mesh settings")
- bpy.types.MetaBall.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles mesh settings")
-
- cls.displacement_method = EnumProperty(name="Displacement Method", description="Method to use for the displacement",
- items=enums.displacement_methods, default="BUMP")
- cls.use_subdivision = BoolProperty(name="Use Subdivision", description="Subdivide mesh for rendering",
- default=False)
- cls.dicing_rate = FloatProperty(name="Dicing Rate", description="", default=1.0, min=0.001, max=1000.0)
+ bpy.types.Mesh.cycles = PointerProperty(
+ name="Cycles Mesh Settings",
+ description="Cycles mesh settings",
+ type=cls,
+ )
+ bpy.types.Curve.cycles = PointerProperty(
+ name="Cycles Mesh Settings",
+ description="Cycles mesh settings",
+ type=cls,
+ )
+ bpy.types.MetaBall.cycles = PointerProperty(
+ name="Cycles Mesh Settings",
+ description="Cycles mesh settings",
+ type=cls,
+ )
+
+ cls.displacement_method = EnumProperty(
+ name="Displacement Method",
+ description="Method to use for the displacement",
+ items=enums.displacement_methods,
+ default='BUMP',
+ )
+ cls.use_subdivision = BoolProperty(
+ name="Use Subdivision",
+ description="Subdivide mesh for rendering",
+ default=False,
+ )
+ cls.dicing_rate = FloatProperty(
+ name="Dicing Rate",
+ description="",
+ min=0.001, max=1000.0,
+ default=1.0,
+ )
@classmethod
def unregister(cls):
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 70f38fa7e8c..6353bf37a15 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -183,6 +183,38 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
layout.separator()
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Passes:")
+ col.prop(rl, "use_pass_combined")
+ col.prop(rl, "use_pass_z")
+ col.prop(rl, "use_pass_normal")
+ col.prop(rl, "use_pass_object_index")
+ col.prop(rl, "use_pass_material_index")
+ col.prop(rl, "use_pass_emit")
+ col.prop(rl, "use_pass_environment")
+
+ col = split.column()
+ col.label()
+ col.label(text="Diffuse:")
+ row = col.row(align=True)
+ row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
+ row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
+ row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True)
+ col.label(text="Glossy:")
+ row = col.row(align=True)
+ row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
+ row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
+ row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True)
+ col.label(text="Transmission:")
+ row = col.row(align=True)
+ row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
+ row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
+ row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
+
+ layout.separator()
+
rl = rd.layers[0]
layout.prop(rl, "material_override", text="Material")
@@ -241,7 +273,7 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
- bl_label = "Surface"
+ bl_label = ""
bl_context = "material"
bl_options = {'HIDE_HEADER'}
@@ -337,16 +369,13 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
ob = context.object
visibility = ob.cycles_visibility
- split = layout.split()
-
- col = split.column()
- col.prop(visibility, "camera")
- col.prop(visibility, "diffuse")
- col.prop(visibility, "glossy")
-
- col = split.column()
- col.prop(visibility, "transmission")
- col.prop(visibility, "shadow")
+ flow = layout.column_flow()
+
+ flow.prop(visibility, "camera")
+ flow.prop(visibility, "diffuse")
+ flow.prop(visibility, "glossy")
+ flow.prop(visibility, "transmission")
+ flow.prop(visibility, "shadow")
def find_node(material, nodetype):
@@ -453,10 +482,34 @@ class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
layout = self.layout
world = context.world
+
if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
layout.prop(world, "horizon_color", text="Color")
+class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
+ bl_label = "Settings"
+ bl_context = "world"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.world and CyclesButtonsPanel.poll(context)
+
+ def draw(self, context):
+ layout = self.layout
+
+ world = context.world
+ cworld = world.cycles
+
+ col = layout.column()
+
+ col.prop(cworld, "sample_as_light")
+ row = col.row()
+ row.active = cworld.sample_as_light
+ row.prop(cworld, "sample_map_resolution")
+
+
class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_context = "world"
@@ -589,14 +642,9 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
col.template_ID(user, "texture", new="texture.new")
if tex:
- row = split.row()
- row.prop(tex, "use_nodes", icon="NODETREE", text="")
- row.label()
-
- if not tex.use_nodes:
- split = layout.split(percentage=0.2)
- split.label(text="Type:")
- split.prop(tex, "type", text="")
+ split = layout.split(percentage=0.2)
+ split.label(text="Type:")
+ split.prop(tex, "type", text="")
class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 608cb33eadd..afcfcd95063 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -16,10 +16,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "graph.h"
#include "light.h"
#include "mesh.h"
#include "object.h"
#include "scene.h"
+#include "nodes.h"
+#include "shader.h"
#include "blender_sync.h"
#include "blender_util.h"
@@ -152,6 +155,37 @@ void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob,
light->tag_update(scene);
}
+void BlenderSync::sync_background_light()
+{
+ BL::World b_world = b_scene.world();
+
+ if(b_world) {
+ PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
+ bool sample_as_light = get_boolean(cworld, "sample_as_light");
+
+ if(sample_as_light) {
+ /* test if we need to sync */
+ Light *light;
+ ObjectKey key(b_world, 0, b_world);
+
+ if(light_map.sync(&light, b_world, b_world, key) ||
+ world_recalc ||
+ b_world.ptr.data != world_map)
+ {
+ light->type = LIGHT_BACKGROUND;
+ light->map_resolution = get_int(cworld, "sample_map_resolution");
+ light->shader = scene->default_background;
+
+ light->tag_update(scene);
+ light_map.set_recalc(b_world);
+ }
+ }
+ }
+
+ world_map = b_world.ptr.data;
+ world_recalc = false;
+}
+
/* Object */
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag)
@@ -180,6 +214,7 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
/* object sync */
if(object_updated || (object->mesh && object->mesh->need_update)) {
object->name = b_ob.name().c_str();
+ object->pass_id = b_ob.pass_index();
object->tfm = tfm;
/* visibility flags for both parent */
@@ -263,6 +298,8 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
}
}
+ sync_background_light();
+
/* handle removed data and modified pointers */
if(light_map.post_sync())
scene->light_manager->tag_update(scene);
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index b052fb3e195..ff1c32831bb 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -116,9 +116,68 @@ void BlenderSession::free_session()
delete session;
}
+static PassType get_pass_type(BL::RenderPass b_pass)
+{
+ switch(b_pass.type()) {
+ case BL::RenderPass::type_COMBINED:
+ return PASS_COMBINED;
+
+ case BL::RenderPass::type_Z:
+ return PASS_DEPTH;
+ case BL::RenderPass::type_NORMAL:
+ return PASS_NORMAL;
+ case BL::RenderPass::type_OBJECT_INDEX:
+ return PASS_OBJECT_ID;
+ case BL::RenderPass::type_UV:
+ return PASS_UV;
+ case BL::RenderPass::type_MATERIAL_INDEX:
+ return PASS_MATERIAL_ID;
+
+ case BL::RenderPass::type_DIFFUSE_DIRECT:
+ return PASS_DIFFUSE_DIRECT;
+ case BL::RenderPass::type_GLOSSY_DIRECT:
+ return PASS_GLOSSY_DIRECT;
+ case BL::RenderPass::type_TRANSMISSION_DIRECT:
+ return PASS_TRANSMISSION_DIRECT;
+
+ case BL::RenderPass::type_DIFFUSE_INDIRECT:
+ return PASS_DIFFUSE_INDIRECT;
+ case BL::RenderPass::type_GLOSSY_INDIRECT:
+ return PASS_GLOSSY_INDIRECT;
+ case BL::RenderPass::type_TRANSMISSION_INDIRECT:
+ return PASS_TRANSMISSION_INDIRECT;
+
+ case BL::RenderPass::type_DIFFUSE_COLOR:
+ return PASS_DIFFUSE_COLOR;
+ case BL::RenderPass::type_GLOSSY_COLOR:
+ return PASS_GLOSSY_COLOR;
+ case BL::RenderPass::type_TRANSMISSION_COLOR:
+ return PASS_TRANSMISSION_COLOR;
+
+ case BL::RenderPass::type_EMIT:
+ return PASS_EMISSION;
+ case BL::RenderPass::type_ENVIRONMENT:
+ return PASS_BACKGROUND;
+
+ case BL::RenderPass::type_DIFFUSE:
+ case BL::RenderPass::type_SHADOW:
+ case BL::RenderPass::type_AO:
+ case BL::RenderPass::type_COLOR:
+ case BL::RenderPass::type_REFRACTION:
+ case BL::RenderPass::type_SPECULAR:
+ case BL::RenderPass::type_REFLECTION:
+ case BL::RenderPass::type_VECTOR:
+ case BL::RenderPass::type_MIST:
+ return PASS_NONE;
+ }
+
+ return PASS_NONE;
+}
+
void BlenderSession::render()
{
/* get buffer parameters */
+ SessionParams session_params = BlenderSync::get_session_params(b_userpref, b_scene, background);
BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height);
int w = buffer_params.width, h = buffer_params.height;
@@ -143,6 +202,25 @@ void BlenderSession::render()
/* set layer */
b_rlay = *b_iter;
+ /* add passes */
+ if(session_params.device.type == DEVICE_CPU) { /* todo */
+ BL::RenderLayer::passes_iterator b_pass_iter;
+
+ for(b_rlay.passes.begin(b_pass_iter); b_pass_iter != b_rlay.passes.end(); ++b_pass_iter) {
+ BL::RenderPass b_pass(*b_pass_iter);
+ PassType pass_type = get_pass_type(b_pass);
+
+ if(pass_type != PASS_NONE)
+ Pass::add(pass_type, buffer_params.passes);
+ }
+ }
+
+ scene->film->passes = buffer_params.passes;
+ scene->film->need_update = true;
+
+ /* update session */
+ session->reset(buffer_params, session_params.samples);
+
/* update scene */
sync->sync_data(b_v3d, active);
@@ -165,22 +243,41 @@ void BlenderSession::write_render_result()
{
/* get state */
RenderBuffers *buffers = session->buffers;
+
+ /* copy data from device */
+ if(!buffers->copy_from_device())
+ return;
+
+ BufferParams& params = buffers->params;
float exposure = scene->film->exposure;
double total_time, sample_time;
int sample;
+
session->progress.get_sample(sample, total_time, sample_time);
- /* get pixels */
- float4 *pixels = buffers->copy_from_device(exposure, sample);
+ vector<float> pixels(params.width*params.height*4);
- if(!pixels)
- return;
+ /* copy each pass */
+ BL::RenderLayer::passes_iterator b_iter;
+
+ for(b_rlay.passes.begin(b_iter); b_iter != b_rlay.passes.end(); ++b_iter) {
+ BL::RenderPass b_pass(*b_iter);
- /* write pixels */
- rna_RenderLayer_rect_set(&b_rlay.ptr, (float*)pixels);
- RE_engine_update_result((RenderEngine*)b_engine.ptr.data, (RenderResult*)b_rr.ptr.data);
+ /* find matching pass type */
+ PassType pass_type = get_pass_type(b_pass);
+ int components = b_pass.channels();
+
+ /* copy pixels */
+ if(buffers->get_pass(pass_type, exposure, sample, components, &pixels[0]))
+ rna_RenderPass_rect_set(&b_pass.ptr, &pixels[0]);
+ }
- delete [] pixels;
+ /* copy combined pass */
+ if(buffers->get_pass(PASS_COMBINED, exposure, sample, 4, &pixels[0]))
+ rna_RenderLayer_rect_set(&b_rlay.ptr, &pixels[0]);
+
+ /* tag result as updated */
+ RE_engine_update_result((RenderEngine*)b_engine.ptr.data, (RenderResult*)b_rr.ptr.data);
}
void BlenderSession::synchronize()
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index f5ffc321476..5310e35dc25 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -142,6 +142,10 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Shader
node = new GammaNode();
break;
}
+ case BL::ShaderNode::type_BRIGHTCONTRAST: {
+ node = new BrightContrastNode();
+ break;
+ }
case BL::ShaderNode::type_MIX_RGB: {
BL::ShaderNodeMixRGB b_mix_node(b_node);
MixNode *mix = new MixNode();
@@ -632,6 +636,7 @@ void BlenderSync::sync_materials()
ShaderGraph *graph = new ShaderGraph();
shader->name = b_mat->name().c_str();
+ shader->pass_id = b_mat->pass_index();
/* create nodes */
if(b_mat->use_nodes() && b_mat->node_tree()) {
@@ -700,9 +705,6 @@ void BlenderSync::sync_world()
if(background->modified(prevbackground))
background->tag_update(scene);
-
- world_map = b_world.ptr.data;
- world_recalc = false;
}
/* Sync Lamps */
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 7b65376bd84..5e76a0a0b1e 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -80,6 +80,7 @@ private:
Mesh *sync_mesh(BL::Object b_ob, bool object_updated);
void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag);
void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm);
+ void sync_background_light();
/* util */
void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index f4b2b7a8269..2ca599f6c67 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -162,7 +162,7 @@ public:
if(system_cpu_support_optimized()) {
for(int y = task.y; y < task.y + task.h; y++) {
for(int x = task.x; x < task.x + task.w; x++)
- kernel_cpu_optimized_path_trace(kg, (float4*)task.buffer, (unsigned int*)task.rng_state,
+ kernel_cpu_optimized_path_trace(kg, (float*)task.buffer, (unsigned int*)task.rng_state,
task.sample, x, y, task.offset, task.stride);
if(tasks.worker_cancel())
@@ -174,7 +174,7 @@ public:
{
for(int y = task.y; y < task.y + task.h; y++) {
for(int x = task.x; x < task.x + task.w; x++)
- kernel_cpu_path_trace(kg, (float4*)task.buffer, (unsigned int*)task.rng_state,
+ kernel_cpu_path_trace(kg, (float*)task.buffer, (unsigned int*)task.rng_state,
task.sample, x, y, task.offset, task.stride);
if(tasks.worker_cancel())
@@ -194,7 +194,7 @@ public:
if(system_cpu_support_optimized()) {
for(int y = task.y; y < task.y + task.h; y++)
for(int x = task.x; x < task.x + task.w; x++)
- kernel_cpu_optimized_tonemap(kg, (uchar4*)task.rgba, (float4*)task.buffer,
+ kernel_cpu_optimized_tonemap(kg, (uchar4*)task.rgba, (float*)task.buffer,
task.sample, task.resolution, x, y, task.offset, task.stride);
}
else
@@ -202,7 +202,7 @@ public:
{
for(int y = task.y; y < task.y + task.h; y++)
for(int x = task.x; x < task.x + task.w; x++)
- kernel_cpu_tonemap(kg, (uchar4*)task.rgba, (float4*)task.buffer,
+ kernel_cpu_tonemap(kg, (uchar4*)task.rgba, (float*)task.buffer,
task.sample, task.resolution, x, y, task.offset, task.stride);
}
}
@@ -217,7 +217,7 @@ public:
#ifdef WITH_OPTIMIZED_KERNEL
if(system_cpu_support_optimized()) {
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
- kernel_cpu_optimized_shader(kg, (uint4*)task.shader_input, (float3*)task.shader_output, task.shader_eval_type, x);
+ kernel_cpu_optimized_shader(kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
if(tasks.worker_cancel())
break;
@@ -227,7 +227,7 @@ public:
#endif
{
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
- kernel_cpu_shader(kg, (uint4*)task.shader_input, (float3*)task.shader_output, task.shader_eval_type, x);
+ kernel_cpu_shader(kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
if(tasks.worker_cancel())
break;
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index a4e0c0ddb56..59fe9709e61 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SRC
set(SRC_HEADERS
kernel.h
+ kernel_accumulate.h
kernel_bvh.h
kernel_camera.h
kernel_compat_cpu.h
@@ -30,6 +31,7 @@ set(SRC_HEADERS
kernel_mbvh.h
kernel_montecarlo.h
kernel_object.h
+ kernel_passes.h
kernel_path.h
kernel_qbvh.h
kernel_random.h
@@ -61,6 +63,7 @@ set(SRC_SVM_HEADERS
svm/svm_displace.h
svm/svm_fresnel.h
svm/svm_gamma.h
+ svm/svm_brightness.h
svm/svm_geometry.h
svm/svm_gradient.h
svm/svm_hsv.h
diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl
index 479cf9b2e64..f98414d4f02 100644
--- a/intern/cycles/kernel/kernel.cl
+++ b/intern/cycles/kernel/kernel.cl
@@ -28,7 +28,7 @@
__kernel void kernel_ocl_path_trace(
__constant KernelData *data,
- __global float4 *buffer,
+ __global float *buffer,
__global uint *rng_state,
#define KERNEL_TEX(type, ttype, name) \
@@ -56,7 +56,7 @@ __kernel void kernel_ocl_path_trace(
__kernel void kernel_ocl_tonemap(
__constant KernelData *data,
__global uchar4 *rgba,
- __global float4 *buffer,
+ __global float *buffer,
#define KERNEL_TEX(type, ttype, name) \
__global type *name,
@@ -80,7 +80,7 @@ __kernel void kernel_ocl_tonemap(
kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride);
}
-/*__kernel void kernel_ocl_shader(__global uint4 *input, __global float3 *output, int type, int sx)
+/*__kernel void kernel_ocl_shader(__global uint4 *input, __global float *output, int type, int sx)
{
int x = sx + get_global_id(0);
diff --git a/intern/cycles/kernel/kernel.cpp b/intern/cycles/kernel/kernel.cpp
index e66ddd86cd6..a93f6172d28 100644
--- a/intern/cycles/kernel/kernel.cpp
+++ b/intern/cycles/kernel/kernel.cpp
@@ -204,21 +204,21 @@ void kernel_tex_copy(KernelGlobals *kg, const char *name, device_ptr mem, size_t
/* Path Tracing */
-void kernel_cpu_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride)
+void kernel_cpu_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride)
{
kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
}
/* Tonemapping */
-void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride)
+void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer, int sample, int resolution, int x, int y, int offset, int stride)
{
kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride);
}
/* Shader Evaluation */
-void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float3 *output, int type, int i)
+void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i)
{
kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i);
}
diff --git a/intern/cycles/kernel/kernel.cu b/intern/cycles/kernel/kernel.cu
index c97aeb67548..fc7992c87f0 100644
--- a/intern/cycles/kernel/kernel.cu
+++ b/intern/cycles/kernel/kernel.cu
@@ -26,7 +26,7 @@
#include "kernel_path.h"
#include "kernel_displace.h"
-extern "C" __global__ void kernel_cuda_path_trace(float4 *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
+extern "C" __global__ void kernel_cuda_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
@@ -35,7 +35,7 @@ extern "C" __global__ void kernel_cuda_path_trace(float4 *buffer, uint *rng_stat
kernel_path_trace(NULL, buffer, rng_state, sample, x, y, offset, stride);
}
-extern "C" __global__ void kernel_cuda_tonemap(uchar4 *rgba, float4 *buffer, int sample, int resolution, int sx, int sy, int sw, int sh, int offset, int stride)
+extern "C" __global__ void kernel_cuda_tonemap(uchar4 *rgba, float *buffer, int sample, int resolution, int sx, int sy, int sw, int sh, int offset, int stride)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
@@ -44,7 +44,7 @@ extern "C" __global__ void kernel_cuda_tonemap(uchar4 *rgba, float4 *buffer, int
kernel_film_tonemap(NULL, rgba, buffer, sample, resolution, x, y, offset, stride);
}
-extern "C" __global__ void kernel_cuda_shader(uint4 *input, float3 *output, int type, int sx)
+extern "C" __global__ void kernel_cuda_shader(uint4 *input, float4 *output, int type, int sx)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h
index 20d43c91169..26c0bcd6d1a 100644
--- a/intern/cycles/kernel/kernel.h
+++ b/intern/cycles/kernel/kernel.h
@@ -36,19 +36,19 @@ bool kernel_osl_use(KernelGlobals *kg);
void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t size);
void kernel_tex_copy(KernelGlobals *kg, const char *name, device_ptr mem, size_t width, size_t height);
-void kernel_cpu_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state,
+void kernel_cpu_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state,
int sample, int x, int y, int offset, int stride);
-void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer,
+void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer,
int sample, int resolution, int x, int y, int offset, int stride);
-void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float3 *output,
+void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float4 *output,
int type, int i);
#ifdef WITH_OPTIMIZED_KERNEL
-void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state,
+void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state,
int sample, int x, int y, int offset, int stride);
-void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer,
+void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer,
int sample, int resolution, int x, int y, int offset, int stride);
-void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float3 *output,
+void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float4 *output,
int type, int i);
#endif
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
new file mode 100644
index 00000000000..e71fad58c96
--- /dev/null
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -0,0 +1,283 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+/* BSDF Eval
+ *
+ * BSDF evaluation result, split per BSDF type. This is used to accumulate
+ * render passes separately. */
+
+__device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
+{
+#ifdef __PASSES__
+ eval->use_light_pass = use_light_pass;
+
+ if(eval->use_light_pass) {
+ eval->diffuse = make_float3(0.0f, 0.0f, 0.0f);
+ eval->glossy = make_float3(0.0f, 0.0f, 0.0f);
+ eval->transmission = make_float3(0.0f, 0.0f, 0.0f);
+ eval->transparent = make_float3(0.0f, 0.0f, 0.0f);
+
+ if(type == CLOSURE_BSDF_TRANSPARENT_ID)
+ eval->transparent = value;
+ else if(CLOSURE_IS_BSDF_DIFFUSE(type))
+ eval->diffuse = value;
+ else if(CLOSURE_IS_BSDF_GLOSSY(type))
+ eval->glossy = value;
+ else
+ eval->transmission = value;
+ }
+ else
+ eval->diffuse = value;
+#else
+ *eval = value;
+#endif
+}
+
+__device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value)
+{
+#ifdef __PASSES__
+ if(eval->use_light_pass) {
+ if(CLOSURE_IS_BSDF_DIFFUSE(type))
+ eval->diffuse += value;
+ else if(CLOSURE_IS_BSDF_GLOSSY(type))
+ eval->glossy += value;
+ else
+ eval->transmission += value;
+
+ /* skipping transparent, this function is used by for eval(), will be zero then */
+ }
+ else
+ eval->diffuse += value;
+#else
+ *eval += value;
+#endif
+}
+
+__device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
+{
+#ifdef __PASSES__
+ if(eval->use_light_pass) {
+ return is_zero(eval->diffuse)
+ && is_zero(eval->glossy)
+ && is_zero(eval->transmission)
+ && is_zero(eval->transparent);
+ }
+ else
+ return is_zero(eval->diffuse);
+#else
+ return is_zero(*eval);
+#endif
+}
+
+__device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
+{
+#ifdef __PASSES__
+ if(eval->use_light_pass) {
+ eval->diffuse *= value;
+ eval->glossy *= value;
+ eval->transmission *= value;
+
+ /* skipping transparent, this function is used by for eval(), will be zero then */
+ }
+ else
+ eval->diffuse *= value;
+#else
+ *eval *= value;
+#endif
+}
+
+/* Path Radiance
+ *
+ * We accumulate different render passes separately. After summing at the end
+ * to get the combined result, it should be identical. We definte directly
+ * visible as the first non-transparent hit, while indirectly visible are the
+ * bounces after that. */
+
+__device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
+{
+ /* clear all */
+#ifdef __PASSES__
+ L->use_light_pass = use_light_pass;
+
+ if(use_light_pass) {
+ L->indirect = make_float3(0.0f, 0.0f, 0.0f);
+ L->direct_throughput = make_float3(0.0f, 0.0f, 0.0f);
+ L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
+
+ L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f);
+ L->color_glossy = make_float3(0.0f, 0.0f, 0.0f);
+ L->color_transmission = make_float3(0.0f, 0.0f, 0.0f);
+
+ L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f);
+ L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f);
+ L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f);
+
+ L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f);
+ L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f);
+ L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f);
+
+ L->emission = make_float3(0.0f, 0.0f, 0.0f);
+ L->background = make_float3(0.0f, 0.0f, 0.0f);
+ }
+ else
+ L->emission = make_float3(0.0f, 0.0f, 0.0f);
+#else
+ *L = make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
+
+__device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput,
+ BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label)
+{
+ float inverse_pdf = 1.0f/bsdf_pdf;
+
+#ifdef __PASSES__
+ if(L->use_light_pass) {
+ if(bounce == 0) {
+ if(bsdf_label & LABEL_TRANSPARENT) {
+ /* transparent bounce before first hit */
+ *throughput *= bsdf_eval->transparent*inverse_pdf;
+ }
+ else {
+ /* first on directly visible surface */
+ float3 value = *throughput*inverse_pdf;
+
+ L->indirect_diffuse = bsdf_eval->diffuse*value;
+ L->indirect_glossy = bsdf_eval->glossy*value;
+ L->indirect_transmission = bsdf_eval->transmission*value;
+
+ *throughput = L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission;
+
+ L->direct_throughput = *throughput;
+ }
+ }
+ else {
+ /* indirectly visible through BSDF */
+ float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent)*inverse_pdf;
+ *throughput *= sum;
+ }
+ }
+ else
+ *throughput *= bsdf_eval->diffuse*inverse_pdf;
+#else
+ *throughput *= *bsdf_eval*inverse_pdf;
+#endif
+}
+
+__device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce)
+{
+#ifdef __PASSES__
+ if(L->use_light_pass) {
+ if(bounce == 0)
+ L->emission += throughput*value;
+ else if(bounce == 1)
+ L->direct_emission += throughput*value;
+ else
+ L->indirect += throughput*value;
+ }
+ else
+ L->emission += throughput*value;
+#else
+ *L += throughput*value;
+#endif
+}
+
+__device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, int bounce)
+{
+#ifdef __PASSES__
+ if(L->use_light_pass) {
+ if(bounce == 0) {
+ /* directly visible lighting */
+ L->direct_diffuse += throughput*bsdf_eval->diffuse;
+ L->direct_glossy += throughput*bsdf_eval->glossy;
+ L->direct_transmission += throughput*bsdf_eval->transmission;
+ }
+ else {
+ /* indirectly visible lighting after BSDF bounce */
+ float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission;
+ L->indirect += throughput*sum;
+ }
+ }
+ else
+ L->emission += throughput*bsdf_eval->diffuse;
+#else
+ *L += throughput*(*bsdf_eval);
+#endif
+}
+
+__device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce)
+{
+#ifdef __PASSES__
+ if(L->use_light_pass) {
+ if(bounce == 0)
+ L->background += throughput*value;
+ else if(bounce == 1)
+ L->direct_emission += throughput*value;
+ else
+ L->indirect += throughput*value;
+ }
+ else
+ L->emission += throughput*value;
+#else
+ *L += throughput*value;
+#endif
+}
+
+__device_inline float3 safe_divide_color(float3 a, float3 b)
+{
+ float x, y, z;
+
+ x = (b.x != 0.0f)? a.x/b.x: 0.0f;
+ y = (b.y != 0.0f)? a.y/b.y: 0.0f;
+ z = (b.z != 0.0f)? a.z/b.z: 0.0f;
+
+ return make_float3(x, y, z);
+}
+
+__device_inline float3 path_radiance_sum(PathRadiance *L)
+{
+#ifdef __PASSES__
+ if(L->use_light_pass) {
+ /* this division is a bit ugly, but means we only have to keep track of
+ only a single throughput further along the path, here we recover just
+ the indirect parth that is not influenced by any particular BSDF type */
+ L->direct_emission = safe_divide_color(L->direct_emission, L->direct_throughput);
+ L->direct_diffuse += L->indirect_diffuse*L->direct_emission;
+ L->direct_glossy += L->indirect_glossy*L->direct_emission;
+ L->direct_transmission += L->indirect_transmission*L->direct_emission;
+
+ L->indirect = safe_divide_color(L->indirect, L->direct_throughput);
+ L->indirect_diffuse *= L->indirect;
+ L->indirect_glossy *= L->indirect;
+ L->indirect_transmission *= L->indirect;
+
+ return L->emission + L->background
+ + L->direct_diffuse + L->direct_glossy + L->direct_transmission
+ + L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission;
+ }
+ else
+ return L->emission;
+#else
+ return *L;
+#endif
+}
+
+CCL_NAMESPACE_END
+
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index 783ae519845..79f894bfdac 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -141,6 +141,7 @@ template<typename T> struct texture_image {
};
typedef texture<float4> texture_float4;
+typedef texture<float2> texture_float2;
typedef texture<float> texture_float;
typedef texture<uint> texture_uint;
typedef texture<int> texture_int;
diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h
index 40129a2f68f..cc719bfadbc 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -45,6 +45,7 @@
/* Textures */
typedef texture<float4, 1> texture_float4;
+typedef texture<float2, 1> texture_float2;
typedef texture<float, 1> texture_float;
typedef texture<uint, 1> texture_uint;
typedef texture<int, 1> texture_int;
diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h
index 4e2b1ea7d13..5b4290a7722 100644
--- a/intern/cycles/kernel/kernel_differential.h
+++ b/intern/cycles/kernel/kernel_differential.h
@@ -71,8 +71,8 @@ __device void differential_dudv(differential *du, differential *dv, float3 dPdu,
* and the same for dudy and dvdy. the denominator is the same for both
* solutions, so we compute it only once.
*
- * dP.dx = dPdu * dudx + dPdv * dvdx;
- * dP.dy = dPdu * dudy + dPdv * dvdy; */
+ * dP.dx = dPdu * dudx + dPdv * dvdx;
+ * dP.dy = dPdu * dudy + dPdv * dvdy; */
float det = (dPdu.x*dPdv.y - dPdv.x*dPdu.y);
diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h
index c39e5e43dbb..73666892cf3 100644
--- a/intern/cycles/kernel/kernel_displace.h
+++ b/intern/cycles/kernel/kernel_displace.h
@@ -18,7 +18,7 @@
CCL_NAMESPACE_BEGIN
-__device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float3 *output, ShaderEvalType type, int i)
+__device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float4 *output, ShaderEvalType type, int i)
{
ShaderData sd;
uint4 in = input[i];
@@ -62,7 +62,7 @@ __device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float3 *ou
}
/* write output */
- output[i] = out;
+ output[i] = make_float4(out.x, out.y, out.z, 0.0f);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index b81db721eb3..b3a5b2bfcb4 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -25,21 +25,31 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
{
/* setup shading at emitter */
ShaderData sd;
-
- shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v);
- ls->Ng = sd.Ng;
-
- /* no path flag, we're evaluating this for all closures. that's weak but
- we'd have to do multiple evaluations otherwise */
- shader_eval_surface(kg, &sd, rando, 0);
-
float3 eval;
- /* evaluate emissive closure */
- if(sd.flag & SD_EMISSION)
- eval = shader_emissive_eval(kg, &sd);
- else
- eval = make_float3(0.0f, 0.0f, 0.0f);
+ if(ls->type == LIGHT_BACKGROUND) {
+ Ray ray;
+ ray.D = ls->D;
+ ray.P = ls->P;
+ ray.dP.dx = make_float3(0.0f, 0.0f, 0.0f);
+ ray.dP.dy = make_float3(0.0f, 0.0f, 0.0f);
+ shader_setup_from_background(kg, &sd, &ray);
+ eval = shader_eval_background(kg, &sd, 0);
+ }
+ else {
+ shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v);
+ ls->Ng = sd.Ng;
+
+ /* no path flag, we're evaluating this for all closures. that's weak but
+ we'd have to do multiple evaluations otherwise */
+ shader_eval_surface(kg, &sd, rando, 0);
+
+ /* evaluate emissive closure */
+ if(sd.flag & SD_EMISSION)
+ eval = shader_emissive_eval(kg, &sd);
+ else
+ eval = make_float3(0.0f, 0.0f, 0.0f);
+ }
shader_release(kg, &sd);
@@ -47,52 +57,59 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
}
__device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
- float randt, float rando, float randu, float randv, Ray *ray, float3 *eval)
+ float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval)
{
LightSample ls;
+ float pdf = -1.0f;
+
#ifdef __MULTI_LIGHT__
if(lindex != -1) {
/* sample position on a specified light */
- light_select(kg, lindex, randu, randv, sd->P, &ls);
+ light_select(kg, lindex, randu, randv, sd->P, &ls, &pdf);
}
else
#endif
{
/* sample a light and position on int */
- light_sample(kg, randt, randu, randv, sd->P, &ls);
+ light_sample(kg, randt, randu, randv, sd->P, &ls, &pdf);
}
/* compute pdf */
- float pdf = light_sample_pdf(kg, &ls, -ls.D, ls.t);
+ if(pdf < 0.0f)
+ pdf = light_sample_pdf(kg, &ls, -ls.D, ls.t);
+
+ if(pdf == 0.0f)
+ return false;
/* evaluate closure */
- *eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D);
+ float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D);
- if(is_zero(*eval) || pdf == 0.0f)
+ if(is_zero(light_eval))
return false;
/* todo: use visbility flag to skip lights */
/* evaluate BSDF at shading point */
float bsdf_pdf;
- float3 bsdf_eval = shader_bsdf_eval(kg, sd, ls.D, &bsdf_pdf);
-
- *eval *= bsdf_eval/pdf;
- if(is_zero(*eval))
- return false;
+ shader_bsdf_eval(kg, sd, ls.D, eval, &bsdf_pdf);
- if(ls.prim != ~0) {
+ if(ls.prim != ~0 || ls.type == LIGHT_BACKGROUND) {
/* multiple importance sampling */
float mis_weight = power_heuristic(pdf, bsdf_pdf);
- *eval *= mis_weight;
+ light_eval *= mis_weight;
}
/* todo: clean up these weights */
else if(ls.shader & SHADER_AREA_LIGHT)
- *eval *= 0.25f; /* area lamp */
+ light_eval *= 0.25f; /* area lamp */
else if(ls.t != FLT_MAX)
- *eval *= 0.25f*M_1_PI_F; /* point lamp */
+ light_eval *= 0.25f*M_1_PI_F; /* point lamp */
+
+ bsdf_eval_mul(eval, light_eval/pdf);
+
+ if(bsdf_eval_is_zero(eval))
+ return false;
if(ls.shader & SHADER_CAST_SHADOW) {
/* setup ray */
@@ -125,7 +142,8 @@ __device float3 indirect_emission(KernelGlobals *kg, ShaderData *sd, float t, in
float3 L = shader_emissive_eval(kg, sd);
if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_SAMPLE_AS_LIGHT)) {
- /* multiple importance sampling */
+ /* multiple importance sampling, get triangle light pdf,
+ and compute weight with respect to BSDF pdf */
float pdf = triangle_light_pdf(kg, sd->Ng, sd->I, t);
float mis_weight = power_heuristic(bsdf_pdf, pdf);
@@ -135,5 +153,34 @@ __device float3 indirect_emission(KernelGlobals *kg, ShaderData *sd, float t, in
return L;
}
+/* Indirect Background */
+
+__device float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf)
+{
+#ifdef __BACKGROUND__
+ /* evaluate background closure */
+ ShaderData sd;
+ shader_setup_from_background(kg, &sd, ray);
+ float3 L = shader_eval_background(kg, &sd, path_flag);
+ shader_release(kg, &sd);
+
+ /* check if background light exists or if we should skip pdf */
+ int res = kernel_data.integrator.pdf_background_res;
+
+ if(!(path_flag & PATH_RAY_MIS_SKIP) && res) {
+ /* multiple importance sampling, get background light pdf for ray
+ direction, and compute weight with respect to BSDF pdf */
+ float pdf = background_light_pdf(kg, ray->D);
+ float mis_weight = power_heuristic(bsdf_pdf, pdf);
+
+ return L*mis_weight;
+ }
+
+ return L;
+#else
+ return make_float3(0.8f, 0.8f, 0.8f);
+#endif
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index cd8acc9647a..d0fb5402291 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -48,15 +48,22 @@ __device uchar4 film_float_to_byte(float4 color)
return result;
}
-__device void kernel_film_tonemap(KernelGlobals *kg, __global uchar4 *rgba, __global float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride)
+__device void kernel_film_tonemap(KernelGlobals *kg,
+ __global uchar4 *rgba, __global float *buffer,
+ int sample, int resolution, int x, int y, int offset, int stride)
{
+ /* buffer offset */
int index = offset + x + y*stride;
- float4 irradiance = buffer[index];
+ rgba += index;
+ buffer += index*kernel_data.film.pass_stride;
+
+ /* map colors */
+ float4 irradiance = *(float4*)buffer;
float4 float_result = film_map(kg, irradiance, sample);
uchar4 byte_result = film_float_to_byte(float_result);
- rgba[index] = byte_result;
+ *rgba = byte_result;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index d5d47b28d59..4c2b69c2716 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -26,6 +26,7 @@ typedef struct LightSample {
int object;
int prim;
int shader;
+ LightType type;
} LightSample;
/* Regular Light */
@@ -58,13 +59,125 @@ __device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float
return axisu*randu + axisv*randv;
}
+__device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf)
+{
+ /* for the following, the CDF values are actually a pair of floats, with the
+ function value as X and the actual CDF as Y. The last entry's function
+ value is the CDF total. */
+ int res = kernel_data.integrator.pdf_background_res;
+ int cdf_count = res + 1;
+
+ /* this is basically std::lower_bound as used by pbrt */
+ int first = 0;
+ int count = res;
+
+ while(count > 0) {
+ int step = count >> 1;
+ int middle = first + step;
+
+ if(kernel_tex_fetch(__light_background_marginal_cdf, middle).y < randv) {
+ first = middle + 1;
+ count -= step + 1;
+ }
+ else
+ count = step;
+ }
+
+ int index_v = max(0, first - 1);
+ kernel_assert(index_v >= 0 && index_v < res);
+
+ float2 cdf_v = kernel_tex_fetch(__light_background_marginal_cdf, index_v);
+ float2 cdf_next_v = kernel_tex_fetch(__light_background_marginal_cdf, index_v + 1);
+ float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res);
+
+ /* importance-sampled V direction */
+ float dv = (randv - cdf_v.y) / (cdf_next_v.y - cdf_v.y);
+ float v = (index_v + dv) / res;
+
+ /* this is basically std::lower_bound as used by pbrt */
+ first = 0;
+ count = res;
+ while(count > 0) {
+ int step = count >> 1;
+ int middle = first + step;
+
+ if(kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + middle).y < randu) {
+ first = middle + 1;
+ count -= step + 1;
+ }
+ else
+ count = step;
+ }
+
+ int index_u = max(0, first - 1);
+ kernel_assert(index_u >= 0 && index_u < res);
+
+ float2 cdf_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + index_u);
+ float2 cdf_next_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + index_u + 1);
+ float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + res);
+
+ /* importance-sampled U direction */
+ float du = (randu - cdf_u.y) / (cdf_next_u.y - cdf_u.y);
+ float u = (index_u + du) / res;
+
+ /* spherical coordinates */
+ float theta = v * M_PI_F;
+ float phi = u * M_PI_F * 2.0f;
+
+ /* compute pdf */
+ float denom = cdf_last_u.x * cdf_last_v.x;
+ float sin_theta = sinf(theta);
+
+ if(sin_theta == 0.0f || denom == 0.0f)
+ *pdf = 0.0f;
+ else
+ *pdf = (cdf_u.x * cdf_v.x)/(2.0f * M_PI_F * M_PI_F * sin_theta * denom);
+
+ *pdf *= kernel_data.integrator.pdf_lights;
+
+ /* compute direction */
+ return spherical_to_direction(theta, phi);
+}
+
+__device float background_light_pdf(KernelGlobals *kg, float3 direction)
+{
+ float2 uv = direction_to_equirectangular(direction);
+ int res = kernel_data.integrator.pdf_background_res;
+
+ float sin_theta = sinf(uv.y * M_PI_F);
+
+ if(sin_theta == 0.0f)
+ return 0.0f;
+
+ int index_u = clamp((int)(uv.x * res), 0, res - 1);
+ int index_v = clamp((int)(uv.y * res), 0, res - 1);
+
+ /* pdfs in V direction */
+ float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * (res + 1) + res);
+ float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res);
+
+ float denom = cdf_last_u.x * cdf_last_v.x;
+
+ if(denom == 0.0f)
+ return 0.0f;
+
+ /* pdfs in U direction */
+ float2 cdf_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * (res + 1) + index_u);
+ float2 cdf_v = kernel_tex_fetch(__light_background_marginal_cdf, index_v);
+
+ float pdf = (cdf_u.x * cdf_v.x)/(2.0f * M_PI_F * M_PI_F * sin_theta * denom);
+
+ return pdf * kernel_data.integrator.pdf_lights;
+}
+
__device void regular_light_sample(KernelGlobals *kg, int point,
- float randu, float randv, float3 P, LightSample *ls)
+ float randu, float randv, float3 P, LightSample *ls, float *pdf)
{
float4 data0 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 0);
float4 data1 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 1);
LightType type = (LightType)__float_as_int(data0.x);
+ ls->type = type;
if(type == LIGHT_DISTANT) {
/* distant light */
@@ -79,6 +192,15 @@ __device void regular_light_sample(KernelGlobals *kg, int point,
ls->D = -D;
ls->t = FLT_MAX;
}
+ else if(type == LIGHT_BACKGROUND) {
+ /* infinite area light (e.g. light dome or env light) */
+ float3 D = background_light_sample(kg, randu, randv, pdf);
+
+ ls->P = D;
+ ls->Ng = D;
+ ls->D = -D;
+ ls->t = FLT_MAX;
+ }
else {
ls->P = make_float3(data0.y, data0.z, data0.w);
@@ -139,6 +261,7 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
ls->object = object;
ls->prim = prim;
ls->t = 0.0f;
+ ls->type = LIGHT_AREA;
#ifdef __INSTANCING__
/* instance transform */
@@ -192,7 +315,7 @@ __device int light_distribution_sample(KernelGlobals *kg, float randt)
/* Generic Light */
-__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float3 P, LightSample *ls)
+__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float3 P, LightSample *ls, float *pdf)
{
/* sample index */
int index = light_distribution_sample(kg, randt);
@@ -207,7 +330,7 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
}
else {
int point = -prim-1;
- regular_light_sample(kg, point, randu, randv, P, ls);
+ regular_light_sample(kg, point, randu, randv, P, ls, pdf);
}
/* compute incoming direction and distance */
@@ -227,9 +350,9 @@ __device float light_sample_pdf(KernelGlobals *kg, LightSample *ls, float3 I, fl
return pdf;
}
-__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls)
+__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls, float *pdf)
{
- regular_light_sample(kg, index, randu, randv, P, ls);
+ regular_light_sample(kg, index, randu, randv, P, ls, pdf);
}
__device float light_select_pdf(KernelGlobals *kg, LightSample *ls, float3 I, float t)
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index df291b66b23..9776baf65e4 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -104,13 +104,13 @@ __device_inline void sample_uniform_hemisphere(const float3 N,
__device float3 sample_uniform_sphere(float u1, float u2)
{
- float z = 1.0f - 2.0f*u1;
- float r = sqrtf(fmaxf(0.0f, 1.0f - z*z));
- float phi = 2.0f*M_PI_F*u2;
- float x = r*cosf(phi);
- float y = r*sinf(phi);
+ float z = 1.0f - 2.0f*u1;
+ float r = sqrtf(fmaxf(0.0f, 1.0f - z*z));
+ float phi = 2.0f*M_PI_F*u2;
+ float x = r*cosf(phi);
+ float y = r*sinf(phi);
- return make_float3(x, y, z);
+ return make_float3(x, y, z);
}
__device float power_heuristic(float a, float b)
@@ -203,6 +203,28 @@ __device float3 spherical_to_direction(float theta, float phi)
cosf(theta));
}
+/* Equirectangular */
+
+__device float2 direction_to_equirectangular(float3 dir)
+{
+ float u = (atan2f(dir.y, dir.x) + M_PI_F)/(2.0f*M_PI_F);
+ float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f;
+
+ return make_float2(u, v);
+}
+
+__device float3 equirectangular_to_direction(float u, float v)
+{
+ /* XXX check correctness? */
+ float theta = M_PI_F*v;
+ float phi = 2.0f*M_PI_F*u;
+
+ return make_float3(
+ sin(theta)*cos(phi),
+ sin(theta)*sin(phi),
+ cos(theta));
+}
+
CCL_NAMESPACE_END
#endif /* __KERNEL_MONTECARLO_CL__ */
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h
index b4c42d3bacc..318a6fea489 100644
--- a/intern/cycles/kernel/kernel_object.h
+++ b/intern/cycles/kernel/kernel_object.h
@@ -64,5 +64,15 @@ __device_inline float object_surface_area(KernelGlobals *kg, int object)
return f.x;
}
+__device_inline float object_pass_id(KernelGlobals *kg, int object)
+{
+ if(object == ~0)
+ return 0.0f;
+
+ int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
+ float4 f = kernel_tex_fetch(__objects, offset);
+ return f.y;
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_optimized.cpp b/intern/cycles/kernel/kernel_optimized.cpp
index c437e06adfa..393686bb203 100644
--- a/intern/cycles/kernel/kernel_optimized.cpp
+++ b/intern/cycles/kernel/kernel_optimized.cpp
@@ -35,21 +35,21 @@ CCL_NAMESPACE_BEGIN
/* Path Tracing */
-void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride)
+void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride)
{
kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
}
/* Tonemapping */
-void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride)
+void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer, int sample, int resolution, int x, int y, int offset, int stride)
{
kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride);
}
/* Shader Evaluate */
-void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float3 *output, int type, int i)
+void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i)
{
kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i);
}
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
new file mode 100644
index 00000000000..0e775812eda
--- /dev/null
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+__device_inline void kernel_write_pass_float(__global float *buffer, int sample, float value)
+{
+ float *buf = buffer;
+ *buf = (sample == 0)? value: *buf + value;
+}
+
+__device_inline void kernel_write_pass_float3(__global float *buffer, int sample, float3 value)
+{
+ float3 *buf = (float3*)buffer;
+ *buf = (sample == 0)? value: *buf + value;
+}
+
+__device_inline void kernel_write_pass_float4(__global float *buffer, int sample, float4 value)
+{
+ float4 *buf = (float4*)buffer;
+ *buf = (sample == 0)? value: *buf + value;
+}
+
+__device_inline void kernel_clear_passes(__global float *buffer, int sample, int pass_stride)
+{
+#ifdef __PASSES__
+ if(sample == 0 && pass_stride != 4)
+ for(int i = 4; i < pass_stride; i++)
+ buffer[i] = 0.0f;
+#endif
+}
+
+__device void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L,
+ ShaderData *sd, int sample, int path_flag, float3 throughput)
+{
+#ifdef __PASSES__
+ if(!(path_flag & PATH_RAY_CAMERA))
+ return;
+
+ int flag = kernel_data.film.pass_flag;
+
+ if(!(flag & PASS_ALL))
+ return;
+
+ /* todo: add alpha treshold */
+ if(!(path_flag & PATH_RAY_TRANSPARENT)) {
+ if(sample == 0) {
+ if(flag & PASS_DEPTH) {
+ Transform tfm = kernel_data.cam.worldtocamera;
+ float depth = len(transform(&tfm, sd->P));
+
+ kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth);
+ }
+ if(flag & PASS_OBJECT_ID) {
+ float id = object_pass_id(kg, sd->object);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id);
+ }
+ if(flag & PASS_MATERIAL_ID) {
+ float id = shader_pass_id(kg, sd);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, sample, id);
+ }
+ }
+
+ if(flag & PASS_NORMAL) {
+ float3 normal = sd->N;
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
+ }
+ if(flag & PASS_UV) {
+ float3 uv = make_float3(0.0f, 0.0f, 0.0f); /* todo: request and lookup */
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv);
+ }
+ }
+
+ if(flag & (PASS_DIFFUSE_INDIRECT|PASS_DIFFUSE_COLOR|PASS_DIFFUSE_DIRECT))
+ L->color_diffuse += shader_bsdf_diffuse(kg, sd)*throughput;
+ if(flag & (PASS_GLOSSY_INDIRECT|PASS_GLOSSY_COLOR|PASS_GLOSSY_DIRECT))
+ L->color_glossy += shader_bsdf_glossy(kg, sd)*throughput;
+ if(flag & (PASS_TRANSMISSION_INDIRECT|PASS_TRANSMISSION_COLOR|PASS_TRANSMISSION_DIRECT))
+ L->color_transmission += shader_bsdf_transmission(kg, sd)*throughput;
+#endif
+}
+
+__device void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample)
+{
+#ifdef __PASSES__
+ int flag = kernel_data.film.pass_flag;
+
+ if(!kernel_data.film.use_light_pass)
+ return;
+
+ if(flag & PASS_DIFFUSE_INDIRECT) {
+ float3 color = safe_divide_color(L->indirect_diffuse, L->color_diffuse);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, sample, color);
+ }
+ if(flag & PASS_GLOSSY_INDIRECT) {
+ float3 color = safe_divide_color(L->indirect_glossy, L->color_glossy);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, sample, color);
+ }
+ if(flag & PASS_TRANSMISSION_INDIRECT) {
+ float3 color = safe_divide_color(L->indirect_transmission, L->color_transmission);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, sample, color);
+ }
+ if(flag & PASS_DIFFUSE_DIRECT) {
+ float3 color = safe_divide_color(L->direct_diffuse, L->color_diffuse);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, sample, color);
+ }
+ if(flag & PASS_GLOSSY_DIRECT) {
+ float3 color = safe_divide_color(L->direct_glossy, L->color_glossy);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, sample, color);
+ }
+ if(flag & PASS_TRANSMISSION_DIRECT) {
+ float3 color = safe_divide_color(L->direct_transmission, L->color_transmission);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, sample, color);
+ }
+
+ if(flag & PASS_EMISSION)
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, sample, L->emission);
+ if(flag & PASS_BACKGROUND)
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_background, sample, L->background);
+
+ if(flag & PASS_DIFFUSE_COLOR)
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, sample, L->color_diffuse);
+ if(flag & PASS_GLOSSY_COLOR)
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, sample, L->color_glossy);
+ if(flag & PASS_TRANSMISSION_COLOR)
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission);
+#endif
+}
+
+CCL_NAMESPACE_END
+
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index d27ad861c6a..c0bfa320405 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -25,39 +25,16 @@
#else
#include "kernel_bvh.h"
#endif
+#include "kernel_accumulate.h"
#include "kernel_camera.h"
#include "kernel_shader.h"
#include "kernel_light.h"
#include "kernel_emission.h"
#include "kernel_random.h"
+#include "kernel_passes.h"
CCL_NAMESPACE_BEGIN
-#ifdef __MODIFY_TP__
-__device float3 path_terminate_modified_throughput(KernelGlobals *kg, __global float3 *buffer, int x, int y, int offset, int stride, int sample)
-{
- /* modify throughput to influence path termination probability, to avoid
- darker regions receiving fewer samples than lighter regions. also RGB
- are weighted differently. proper validation still remains to be done. */
- const float3 weights = make_float3(1.0f, 1.33f, 0.66f);
- const float3 one = make_float3(1.0f, 1.0f, 1.0f);
- const int minsample = 5;
- const float minL = 0.1f;
-
- if(sample >= minsample) {
- float3 L = buffer[offset + x + y*stride];
- float3 Lmin = make_float3(minL, minL, minL);
- float correct = (float)(sample+1)/(float)sample;
-
- L = film_map(L*correct, sample);
-
- return weights/clamp(L, Lmin, one);
- }
-
- return weights;
-}
-#endif
-
typedef struct PathState {
uint flag;
int bounce;
@@ -168,7 +145,7 @@ __device_inline float path_state_terminate_probability(KernelGlobals *kg, PathSt
return average(throughput);
}
-__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, Intersection *isect, float3 *light_L)
+__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, Intersection *isect, BsdfEval *L_light)
{
if(ray->t == 0.0f)
return false;
@@ -208,7 +185,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
}
if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, isect)) {
- *light_L *= throughput;
+ bsdf_eval_mul(L_light, throughput);
return false;
}
@@ -234,11 +211,14 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
return result;
}
-__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, float3 throughput)
+__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer)
{
/* initialize */
- float3 L = make_float3(0.0f, 0.0f, 0.0f);
- float Ltransparent = 0.0f;
+ PathRadiance L;
+ float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
+ float L_transparent = 0.0f;
+
+ path_radiance_init(&L, kernel_data.film.use_light_pass);
#ifdef __EMISSION__
float ray_pdf = 0.0f;
@@ -257,17 +237,12 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
if(!scene_intersect(kg, &ray, visibility, &isect)) {
/* eval background shader if nothing hit */
if(kernel_data.background.transparent && (state.flag & PATH_RAY_CAMERA)) {
- Ltransparent += average(throughput);
+ L_transparent += average(throughput);
}
else {
-#ifdef __BACKGROUND__
- ShaderData sd;
- shader_setup_from_background(kg, &sd, &ray);
- L += throughput*shader_eval_background(kg, &sd, state.flag);
- shader_release(kg, &sd);
-#else
- L += throughput*make_float3(0.8f, 0.8f, 0.8f);
-#endif
+ /* sample background shader */
+ float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf);
+ path_radiance_accum_background(&L, throughput, L_background, state.bounce);
}
break;
@@ -279,19 +254,24 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
float rbsdf = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF);
shader_eval_surface(kg, &sd, rbsdf, state.flag);
+ kernel_write_data_passes(kg, buffer, &L, &sd, sample, state.flag, throughput);
+
#ifdef __HOLDOUT__
if((sd.flag & SD_HOLDOUT) && (state.flag & PATH_RAY_CAMERA)) {
float3 holdout_weight = shader_holdout_eval(kg, &sd);
if(kernel_data.background.transparent)
- Ltransparent += average(holdout_weight*throughput);
+ /* any throughput is ok, should all be identical here */
+ L_transparent += average(holdout_weight*throughput);
}
#endif
#ifdef __EMISSION__
/* emission */
- if(sd.flag & SD_EMISSION)
- L += throughput*indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf);
+ if(sd.flag & SD_EMISSION) {
+ float3 emission = indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf);
+ path_radiance_accum_emission(&L, throughput, emission, state.bounce);
+ }
#endif
/* path termination. this is a strange place to put the termination, it's
@@ -315,7 +295,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
float light_v = path_rng(kg, rng, sample, rng_offset + PRNG_LIGHT_V);
Ray light_ray;
- float3 light_L;
+ BsdfEval L_light;
#ifdef __MULTI_LIGHT__
/* index -1 means randomly sample from distribution */
@@ -325,10 +305,10 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
#else
const int i = -1;
#endif
- if(direct_emission(kg, &sd, i, light_t, light_o, light_u, light_v, &light_ray, &light_L)) {
+ if(direct_emission(kg, &sd, i, light_t, light_o, light_u, light_v, &light_ray, &L_light)) {
/* trace shadow ray */
- if(!shadow_blocked(kg, &state, &light_ray, &isect, &light_L))
- L += throughput*light_L;
+ if(!shadow_blocked(kg, &state, &light_ray, &isect, &L_light))
+ path_radiance_accum_light(&L, throughput, &L_light, state.bounce);
}
#ifdef __MULTI_LIGHT__
}
@@ -343,7 +323,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
/* sample BSDF */
float bsdf_pdf;
- float3 bsdf_eval;
+ BsdfEval bsdf_eval;
float3 bsdf_omega_in;
differential3 bsdf_domega_in;
float bsdf_u = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_U);
@@ -355,14 +335,14 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
shader_release(kg, &sd);
- if(bsdf_pdf == 0.0f || is_zero(bsdf_eval))
+ if(bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval))
break;
/* modify throughput */
- throughput *= bsdf_eval/bsdf_pdf;
+ path_radiance_bsdf_bounce(&L, &throughput, &bsdf_eval, bsdf_pdf, state.bounce, label);
/* set labels */
-#ifdef __EMISSION__
+#if defined(__EMISSION__) || defined(__BACKGROUND__)
ray_pdf = bsdf_pdf;
#endif
@@ -379,18 +359,33 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
#endif
}
- return make_float4(L.x, L.y, L.z, 1.0f - Ltransparent);
+ float3 L_sum = path_radiance_sum(&L);
+
+ kernel_write_light_passes(kg, buffer, &L, sample);
+
+ return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}
-__device void kernel_path_trace(KernelGlobals *kg, __global float4 *buffer, __global uint *rng_state, int sample, int x, int y, int offset, int stride)
+__device void kernel_path_trace(KernelGlobals *kg,
+ __global float *buffer, __global uint *rng_state,
+ int sample, int x, int y, int offset, int stride)
{
+ /* buffer offset */
+ int index = offset + x + y*stride;
+ int pass_stride = kernel_data.film.pass_stride;
+
+ rng_state += index;
+ buffer += index*pass_stride;
+
+ kernel_clear_passes(buffer, sample, pass_stride);
+
/* initialize random numbers */
RNG rng;
float filter_u;
float filter_v;
- path_rng_init(kg, rng_state, sample, &rng, x, y, offset, stride, &filter_u, &filter_v);
+ path_rng_init(kg, rng_state, sample, &rng, x, y, &filter_u, &filter_v);
/* sample camera ray */
Ray ray;
@@ -401,23 +396,12 @@ __device void kernel_path_trace(KernelGlobals *kg, __global float4 *buffer, __gl
camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, &ray);
/* integrate */
-#ifdef __MODIFY_TP__
- float3 throughput = path_terminate_modified_throughput(kg, buffer, x, y, offset, stride, sample);
- float4 L = kernel_path_integrate(kg, &rng, sample, ray, throughput)/throughput;
-#else
- float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
- float4 L = kernel_path_integrate(kg, &rng, sample, ray, throughput);
-#endif
+ float4 L = kernel_path_integrate(kg, &rng, sample, ray, buffer);
/* accumulate result in output buffer */
- int index = offset + x + y*stride;
-
- if(sample == 0)
- buffer[index] = L;
- else
- buffer[index] += L;
+ kernel_write_pass_float4(buffer, sample, L);
- path_rng_end(kg, rng_state, rng, x, y, offset, stride);
+ path_rng_end(kg, rng_state, rng);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index 41301ebd3dc..6d15100f8a3 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -123,7 +123,7 @@ __device_inline float path_rng(KernelGlobals *kg, RNG *rng, int sample, int dime
#endif
}
-__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, int offset, int stride, float *fx, float *fy)
+__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, float *fx, float *fy)
{
#ifdef __SOBOL_FULL_SCREEN__
uint px, py;
@@ -135,19 +135,31 @@ __device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state,
*rng ^= kernel_data.integrator.seed;
- *fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x;
- *fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y;
+ if(sample == 0) {
+ *fx = 0.5f;
+ *fy = 0.5f;
+ }
+ else {
+ *fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x;
+ *fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y;
+ }
#else
- *rng = rng_state[offset + x + y*stride];
+ *rng = *rng_state;
*rng ^= kernel_data.integrator.seed;
- *fx = path_rng(kg, rng, sample, PRNG_FILTER_U);
- *fy = path_rng(kg, rng, sample, PRNG_FILTER_V);
+ if(sample == 0) {
+ *fx = 0.5f;
+ *fy = 0.5f;
+ }
+ else {
+ *fx = path_rng(kg, rng, sample, PRNG_FILTER_U);
+ *fy = path_rng(kg, rng, sample, PRNG_FILTER_V);
+ }
#endif
}
-__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng, int x, int y, int offset, int stride)
+__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
{
/* nothing to do */
}
@@ -163,21 +175,27 @@ __device float path_rng(KernelGlobals *kg, RNG *rng, int sample, int dimension)
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
}
-__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, int offset, int stride, float *fx, float *fy)
+__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, float *fx, float *fy)
{
/* load state */
- *rng = rng_state[offset + x + y*stride];
+ *rng = *rng_state;
*rng ^= kernel_data.integrator.seed;
- *fx = path_rng(kg, rng, sample, PRNG_FILTER_U);
- *fy = path_rng(kg, rng, sample, PRNG_FILTER_V);
+ if(sample == 0) {
+ *fx = 0.5f;
+ *fy = 0.5f;
+ }
+ else {
+ *fx = path_rng(kg, rng, sample, PRNG_FILTER_U);
+ *fy = path_rng(kg, rng, sample, PRNG_FILTER_V);
+ }
}
-__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng, int x, int y, int offset, int stride)
+__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
{
/* store state for next sample */
- rng_state[offset + x + y*stride] = rng;
+ *rng_state = rng;
}
#endif
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index 570e0721268..1d2cf46aa56 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -75,7 +75,7 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
if(sd->shader & SHADER_SMOOTH_NORMAL)
sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
- sd->flag = kernel_tex_fetch(__shader_flag, sd->shader & SHADER_MASK);
+ sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
#ifdef __DPDU__
/* dPdu/dPdv */
@@ -151,7 +151,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
instanced = true;
else
#endif
- sd->object = -sd->object-1;
+ sd->object = ~sd->object;
#ifdef __INSTANCING__
}
#endif
@@ -166,7 +166,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
#endif
}
- sd->flag = kernel_tex_fetch(__shader_flag, sd->shader & SHADER_MASK);
+ sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
#ifdef __DPDU__
/* dPdu/dPdv */
@@ -243,7 +243,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
sd->Ng = -sd->P;
sd->I = -sd->P;
sd->shader = kernel_data.background.shader;
- sd->flag = kernel_tex_fetch(__shader_flag, sd->shader & SHADER_MASK);
+ sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
#ifdef __INSTANCING__
sd->object = ~0;
@@ -275,8 +275,8 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
#ifdef __MULTI_CLOSURE__
-__device_inline float3 _shader_bsdf_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf,
- int skip_bsdf, float3 sum_eval, float sum_pdf, float sum_sample_weight)
+__device_inline void _shader_bsdf_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf,
+ int skip_bsdf, BsdfEval *bsdf_eval, float sum_pdf, float sum_sample_weight)
{
for(int i = 0; i< sd->num_closure; i++) {
if(i == skip_bsdf)
@@ -293,7 +293,7 @@ __device_inline float3 _shader_bsdf_multi_eval(const ShaderData *sd, const float
#endif
if(bsdf_pdf != 0.0f) {
- sum_eval += eval*sc->weight;
+ bsdf_eval_accum(bsdf_eval, sc->type, eval*sc->weight);
sum_pdf += bsdf_pdf*sc->sample_weight;
}
@@ -302,25 +302,27 @@ __device_inline float3 _shader_bsdf_multi_eval(const ShaderData *sd, const float
}
*pdf = sum_pdf/sum_sample_weight;
- return sum_eval;
}
#endif
-__device float3 shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
- const float3 omega_in, float *pdf)
+__device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
+ const float3 omega_in, BsdfEval *eval, float *pdf)
{
#ifdef __MULTI_CLOSURE__
- return _shader_bsdf_multi_eval(sd, omega_in, pdf, -1, make_float3(0.0f, 0.0f, 0.0f), 0.0f, 0.0f);
+ bsdf_eval_init(eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass);
+
+ return _shader_bsdf_multi_eval(sd, omega_in, pdf, -1, eval, 0.0f, 0.0f);
#else
const ShaderClosure *sc = &sd->closure;
+
*pdf = 0.0f;
- return svm_bsdf_eval(sd, sc, omega_in, pdf)*sc->weight;
+ *eval = svm_bsdf_eval(sd, sc, omega_in, pdf)*sc->weight;
#endif
}
__device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
- float randu, float randv, float3 *eval,
+ float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
#ifdef __MULTI_CLOSURE__
@@ -359,27 +361,28 @@ __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
const ShaderClosure *sc = &sd->closure[sampled];
int label;
+ float3 eval;
*pdf = 0.0f;
#ifdef __OSL__
- label = OSLShader::bsdf_sample(sd, sc, randu, randv, *eval, *omega_in, *domega_in, *pdf);
+ label = OSLShader::bsdf_sample(sd, sc, randu, randv, eval, *omega_in, *domega_in, *pdf);
#else
- label = svm_bsdf_sample(sd, sc, randu, randv, eval, omega_in, domega_in, pdf);
+ label = svm_bsdf_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
#endif
- *eval *= sc->weight;
+ bsdf_eval_init(bsdf_eval, sc->type, eval*sc->weight, kernel_data.film.use_light_pass);
if(sd->num_closure > 1 && *pdf != 0.0f) {
float sweight = sc->sample_weight;
- *eval = _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, *eval, *pdf*sweight, sweight);
+ _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight);
}
return label;
#else
/* sample the single closure that we picked */
*pdf = 0.0f;
- int label = svm_bsdf_sample(sd, &sd->closure, randu, randv, eval, omega_in, domega_in, pdf);
- *eval *= sd->closure.weight;
+ int label = svm_bsdf_sample(sd, &sd->closure, randu, randv, bsdf_eval, omega_in, domega_in, pdf);
+ *bsdf_eval *= sd->closure.weight;
return label;
#endif
}
@@ -421,6 +424,68 @@ __device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
#endif
}
+__device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
+{
+#ifdef __MULTI_CLOSURE__
+ float3 eval = make_float3(0.0f, 0.0f, 0.0f);
+
+ for(int i = 0; i< sd->num_closure; i++) {
+ ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
+ eval += sc->weight;
+ }
+
+ return eval;
+#else
+ if(CLOSURE_IS_BSDF_DIFFUSE(sd->closure.type))
+ return sd->closure.weight;
+ else
+ return make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
+
+__device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
+{
+#ifdef __MULTI_CLOSURE__
+ float3 eval = make_float3(0.0f, 0.0f, 0.0f);
+
+ for(int i = 0; i< sd->num_closure; i++) {
+ ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
+ eval += sc->weight;
+ }
+
+ return eval;
+#else
+ if(CLOSURE_IS_BSDF_GLOSSY(sd->closure.type))
+ return sd->closure.weight;
+ else
+ return make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
+
+__device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
+{
+#ifdef __MULTI_CLOSURE__
+ float3 eval = make_float3(0.0f, 0.0f, 0.0f);
+
+ for(int i = 0; i< sd->num_closure; i++) {
+ ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSDF_TRANSMISSION(sc->type))
+ eval += sc->weight;
+ }
+
+ return eval;
+#else
+ if(CLOSURE_IS_BSDF_TRANSMISSION(sd->closure.type))
+ return sd->closure.weight;
+ else
+ return make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
/* Emission */
@@ -588,12 +653,17 @@ __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
int prim = kernel_tex_fetch(__prim_index, isect->prim);
float4 Ns = kernel_tex_fetch(__tri_normal, prim);
int shader = __float_as_int(Ns.w);
- int flag = kernel_tex_fetch(__shader_flag, shader & SHADER_MASK);
+ int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*2);
return (flag & SD_HAS_SURFACE_TRANSPARENT) != 0;
}
#endif
+__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
+{
+ return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);
+}
+
/* Free ShaderData */
__device void shader_release(KernelGlobals *kg, ShaderData *sd)
diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h
index 2bfb1b3b88e..ca7ae432efa 100644
--- a/intern/cycles/kernel/kernel_textures.h
+++ b/intern/cycles/kernel/kernel_textures.h
@@ -33,6 +33,8 @@ KERNEL_TEX(float4, texture_float4, __attributes_float3)
/* lights */
KERNEL_TEX(float4, texture_float4, __light_distribution)
KERNEL_TEX(float4, texture_float4, __light_data)
+KERNEL_TEX(float2, texture_float2, __light_background_marginal_cdf)
+KERNEL_TEX(float2, texture_float2, __light_background_conditional_cdf)
/* shaders */
KERNEL_TEX(uint4, texture_uint4, __svm_nodes)
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 2c03a34df1f..b4b1da83162 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -70,6 +70,9 @@ CCL_NAMESPACE_BEGIN
#ifdef __KERNEL_ADV_SHADING__
#define __MULTI_CLOSURE__
#define __TRANSPARENT_SHADOWS__
+#ifdef __KERNEL_CPU__
+#define __PASSES__
+#endif
#endif
//#define __MULTI_LIGHT__
@@ -150,6 +153,75 @@ typedef enum ClosureLabel {
LABEL_STOP = 2048
} ClosureLabel;
+/* Render Passes */
+
+typedef enum PassType {
+ PASS_NONE = 0,
+ PASS_COMBINED = 1,
+ PASS_DEPTH = 2,
+ PASS_NORMAL = 8,
+ PASS_UV = 16,
+ PASS_OBJECT_ID = 32,
+ PASS_MATERIAL_ID = 64,
+ PASS_DIFFUSE_COLOR = 128,
+ PASS_GLOSSY_COLOR = 256,
+ PASS_TRANSMISSION_COLOR = 512,
+ PASS_DIFFUSE_INDIRECT = 1024,
+ PASS_GLOSSY_INDIRECT = 2048,
+ PASS_TRANSMISSION_INDIRECT = 4096,
+ PASS_DIFFUSE_DIRECT = 8192,
+ PASS_GLOSSY_DIRECT = 16384,
+ PASS_TRANSMISSION_DIRECT = 32768,
+ PASS_EMISSION = 65536,
+ PASS_BACKGROUND = 131072
+} PassType;
+
+#define PASS_ALL (~0)
+
+#ifdef __PASSES__
+
+typedef float3 PathThroughput;
+
+struct PathRadiance {
+ int use_light_pass;
+
+ float3 indirect;
+ float3 direct_throughput;
+ float3 direct_emission;
+
+ float3 color_diffuse;
+ float3 color_glossy;
+ float3 color_transmission;
+
+ float3 direct_diffuse;
+ float3 direct_glossy;
+ float3 direct_transmission;
+
+ float3 indirect_diffuse;
+ float3 indirect_glossy;
+ float3 indirect_transmission;
+
+ float3 emission;
+ float3 background;
+};
+
+struct BsdfEval {
+ int use_light_pass;
+
+ float3 diffuse;
+ float3 glossy;
+ float3 transmission;
+ float3 transparent;
+};
+
+#else
+
+typedef float3 PathThroughput;
+typedef float3 PathRadiance;
+typedef float3 BsdfEval;
+
+#endif
+
/* Shader Flag */
typedef enum ShaderFlag {
@@ -165,6 +237,7 @@ typedef enum ShaderFlag {
typedef enum LightType {
LIGHT_POINT,
LIGHT_DISTANT,
+ LIGHT_BACKGROUND,
LIGHT_AREA
} LightType;
@@ -352,7 +425,32 @@ typedef struct KernelCamera {
typedef struct KernelFilm {
float exposure;
- int pad1, pad2, pad3;
+ int pass_flag;
+ int pass_stride;
+ int use_light_pass;
+
+ int pass_combined;
+ int pass_depth;
+ int pass_normal;
+ int pass_pad;
+
+ int pass_uv;
+ int pass_object_id;
+ int pass_material_id;
+ int pass_diffuse_color;
+
+ int pass_glossy_color;
+ int pass_transmission_color;
+ int pass_diffuse_indirect;
+ int pass_glossy_indirect;
+
+ int pass_transmission_indirect;
+ int pass_diffuse_direct;
+ int pass_glossy_direct;
+ int pass_transmission_direct;
+
+ int pass_emission;
+ int pass_background;
} KernelFilm;
typedef struct KernelBackground {
@@ -379,18 +477,19 @@ typedef struct KernelIntegrator {
int num_all_lights;
float pdf_triangles;
float pdf_lights;
+ int pdf_background_res;
/* bounces */
int min_bounce;
int max_bounce;
- int max_diffuse_bounce;
- int max_glossy_bounce;
- int max_transmission_bounce;
+ int max_diffuse_bounce;
+ int max_glossy_bounce;
+ int max_transmission_bounce;
/* transparent */
- int transparent_min_bounce;
- int transparent_max_bounce;
+ int transparent_min_bounce;
+ int transparent_max_bounce;
int transparent_shadows;
/* caustics */
diff --git a/intern/cycles/kernel/osl/nodes/CMakeLists.txt b/intern/cycles/kernel/osl/nodes/CMakeLists.txt
index 1a207d6c139..d3a1cf59a37 100644
--- a/intern/cycles/kernel/osl/nodes/CMakeLists.txt
+++ b/intern/cycles/kernel/osl/nodes/CMakeLists.txt
@@ -20,6 +20,7 @@ set(SRC_OSL
node_environment_texture.osl
node_fresnel.osl
node_gamma.osl
+ node_brightness.osl
node_geometry.osl
node_glass_bsdf.osl
node_glossy_bsdf.osl
diff --git a/intern/cycles/kernel/osl/nodes/node_brightness.osl b/intern/cycles/kernel/osl/nodes/node_brightness.osl
new file mode 100644
index 00000000000..a93ff06d443
--- /dev/null
+++ b/intern/cycles/kernel/osl/nodes/node_brightness.osl
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_brightness(
+ color ColorIn = color(0.8, 0.8, 0.8),
+ float Bright = 0.0,
+ float Contrast = 0.0,
+ output ColorOut = color(0.8, 0.8, 0.8)
+{
+ float delta = Contrast * (1.0/200.0);
+ float a = 1.0 - delta * 2.0;
+ float b;
+
+ Bright *= 1.0/100.0;
+
+ /*
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
+
+ if (Contrast > 0.0) {
+ a = (a < 0.0 ? 1.0/a : 0.0);
+ b = a * (Brightness - delta);
+ }
+ else {
+ delta *= -1.0;
+ b = a * (Brightness + delta);
+ }
+
+ ColorOut = a * ColorIn + b;
+}
+
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index d22c9181a84..f1bae9c8d9f 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -131,6 +131,7 @@ CCL_NAMESPACE_END
#include "svm_hsv.h"
#include "svm_image.h"
#include "svm_gamma.h"
+#include "svm_brightness.h"
#include "svm_invert.h"
#include "svm_light_path.h"
#include "svm_magic.h"
@@ -270,6 +271,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
case NODE_GAMMA:
svm_node_gamma(sd, stack, node.y, node.z, node.w);
break;
+ case NODE_BRIGHTCONTRAST:
+ svm_node_brightness(sd, stack, node.y, node.z, node.w);
+ break;
case NODE_MIX:
svm_node_mix(kg, sd, stack, node.y, node.z, node.w, &offset);
break;
diff --git a/intern/cycles/kernel/svm/svm_brightness.h b/intern/cycles/kernel/svm/svm_brightness.h
new file mode 100644
index 00000000000..698899ffd60
--- /dev/null
+++ b/intern/cycles/kernel/svm/svm_brightness.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+__device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node)
+{
+ uint bright_offset, contrast_offset;
+ float3 color = stack_load_float3(stack, in_color);
+
+ decode_node_uchar4(node, &bright_offset, &contrast_offset, NULL, NULL);
+ float brightness = stack_load_float(stack, bright_offset);
+ float contrast = stack_load_float(stack, contrast_offset);
+
+ brightness *= 1.0f/100.0f;
+ float delta = contrast * (1.0f/200.0f);
+ float a = 1.0f - delta * 2.0f;
+ float b;
+
+ /*
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
+ if (contrast > 0.0f) {
+ a = (a > 0.0f? (1.0f / a): 0.0f);
+ b = a * (brightness - delta);
+ }
+ else {
+ delta *= -1.0f;
+ b = a * (brightness + delta);
+ }
+
+ color.x = a*color.x + b;
+ color.y = a*color.y + b;
+ color.z = a*color.z + b;
+
+ if (stack_valid(out_color))
+ stack_store_float3(stack, out_color, color);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 62e24166970..073021bdd54 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -175,9 +175,8 @@ __device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float
decode_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &srgb);
float3 co = stack_load_float3(stack, co_offset);
- float u = (atan2f(co.y, co.x) + M_PI_F)/(2*M_PI_F);
- float v = atan2f(co.z, hypotf(co.x, co.y))/M_PI_F + 0.5f;
- float4 f = svm_image_texture(kg, id, u, v);
+ float2 uv = direction_to_equirectangular(co);
+ float4 f = svm_image_texture(kg, id, uv.x, uv.y);
float3 r = make_float3(f.x, f.y, f.z);
if(srgb) {
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 8203ed4c15e..533a2944557 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -87,7 +87,8 @@ typedef enum NodeType {
NODE_INVERT = 5400,
NODE_NORMAL = 5500,
NODE_GAMMA = 5600,
- NODE_TEX_CHECKER = 5700
+ NODE_TEX_CHECKER = 5700,
+ NODE_BRIGHTCONTRAST = 5800
} NodeType;
typedef enum NodeAttributeType {
@@ -265,22 +266,26 @@ typedef enum ShaderType {
typedef enum ClosureType {
CLOSURE_BSDF_ID,
+
CLOSURE_BSDF_DIFFUSE_ID,
CLOSURE_BSDF_OREN_NAYAR_ID,
- CLOSURE_BSDF_TRANSLUCENT_ID,
+
CLOSURE_BSDF_REFLECTION_ID,
- CLOSURE_BSDF_REFRACTION_ID,
- CLOSURE_BSDF_GLASS_ID,
- CLOSURE_BSDF_TRANSPARENT_ID,
CLOSURE_BSDF_MICROFACET_GGX_ID,
- CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
- CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
CLOSURE_BSDF_WARD_ID,
- CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
- CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
CLOSURE_BSDF_WESTIN_SHEEN_ID,
+ CLOSURE_BSDF_TRANSLUCENT_ID,
+ CLOSURE_BSDF_REFRACTION_ID,
+ CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
+ CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
+ CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
+ CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
+ CLOSURE_BSDF_GLASS_ID,
+
+ CLOSURE_BSDF_TRANSPARENT_ID,
+
CLOSURE_BSSRDF_CUBIC_ID,
CLOSURE_EMISSION_ID,
CLOSURE_DEBUG_ID,
@@ -296,7 +301,10 @@ typedef enum ClosureType {
} ClosureType;
/* watch this, being lazy with memory usage */
-#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
+#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
+#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID)
+#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
+#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_GLASS_ID)
#define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
#define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
#define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index a6bbbc91901..08dda944111 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -22,6 +22,7 @@
#include "device.h"
#include "util_debug.h"
+#include "util_foreach.h"
#include "util_hash.h"
#include "util_image.h"
#include "util_math.h"
@@ -31,6 +32,48 @@
CCL_NAMESPACE_BEGIN
+/* Buffer Params */
+
+BufferParams::BufferParams()
+{
+ width = 0;
+ height = 0;
+
+ full_x = 0;
+ full_y = 0;
+ full_width = 0;
+ full_height = 0;
+
+ Pass::add(PASS_COMBINED, passes);
+}
+
+void BufferParams::get_offset_stride(int& offset, int& stride)
+{
+ offset = -(full_x + full_y*width);
+ stride = width;
+}
+
+bool BufferParams::modified(const BufferParams& params)
+{
+ return !(full_x == params.full_x
+ && full_y == params.full_y
+ && width == params.width
+ && height == params.height
+ && full_width == params.full_width
+ && full_height == params.full_height
+ && Pass::equals(passes, params.passes));
+}
+
+int BufferParams::get_passes_size()
+{
+ int size = 0;
+
+ foreach(Pass& pass, passes)
+ size += pass.components;
+
+ return size;
+}
+
/* Render Buffers */
RenderBuffers::RenderBuffers(Device *device_)
@@ -64,7 +107,7 @@ void RenderBuffers::reset(Device *device, BufferParams& params_)
device_free();
/* allocate buffer */
- buffer.resize(params.width, params.height);
+ buffer.resize(params.width*params.height*params.get_passes_size());
device->mem_alloc(buffer, MEM_READ_WRITE);
device->mem_zero(buffer);
@@ -82,31 +125,76 @@ void RenderBuffers::reset(Device *device, BufferParams& params_)
device->mem_copy_to(rng_state);
}
-float4 *RenderBuffers::copy_from_device(float exposure, int sample)
+bool RenderBuffers::copy_from_device()
{
if(!buffer.device_pointer)
- return NULL;
+ return false;
device->mem_copy_from(buffer, 0, params.width, params.height, sizeof(float4));
- float4 *out = new float4[params.width*params.height];
- float4 *in = (float4*)buffer.data_pointer;
- float scale = 1.0f/(float)sample;
-
- for(int i = params.width*params.height - 1; i >= 0; i--) {
- float4 rgba = in[i]*scale;
+ return true;
+}
+
+bool RenderBuffers::get_pass(PassType type, float exposure, int sample, int components, float *pixels)
+{
+ int pass_offset = 0;
+
+ foreach(Pass& pass, params.passes) {
+ if(pass.type != type) {
+ pass_offset += pass.components;
+ continue;
+ }
+
+ float *in = (float*)buffer.data_pointer + pass_offset;
+ int pass_stride = params.get_passes_size();
+
+ float scale = (pass.filter)? 1.0f/(float)sample: 1.0f;
+ float scale_exposure = (pass.exposure)? scale*exposure: scale;
+
+ int size = params.width*params.height;
+
+ if(components == 1) {
+ assert(pass.components == components);
+
+ /* scalar */
+ for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
+ float f = *in;
+
+ pixels[0] = f*scale_exposure;
+ }
+ }
+ else if(components == 3) {
+ assert(pass.components == 4);
+
+ /* RGB/vector */
+ for(int i = 0; i < size; i++, in += pass_stride, pixels += 3) {
+ float3 f = make_float3(in[0], in[1], in[2]);
+
+ pixels[0] = f.x*scale_exposure;
+ pixels[1] = f.y*scale_exposure;
+ pixels[2] = f.z*scale_exposure;
+ }
+ }
+ else if(components == 4) {
+ assert(pass.components == components);
+
+ /* RGBA */
+ for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
+ float4 f = make_float4(in[0], in[1], in[2], in[3]);
- rgba.x = rgba.x*exposure;
- rgba.y = rgba.y*exposure;
- rgba.z = rgba.z*exposure;
+ pixels[0] = f.x*scale_exposure;
+ pixels[1] = f.y*scale_exposure;
+ pixels[2] = f.z*scale_exposure;
- /* clamp since alpha might be > 1.0 due to russian roulette */
- rgba.w = clamp(rgba.w, 0.0f, 1.0f);
+ /* clamp since alpha might be > 1.0 due to russian roulette */
+ pixels[3] = clamp(f.w*scale, 0.0f, 1.0f);
+ }
+ }
- out[i] = rgba;
+ return true;
}
- return out;
+ return false;
}
/* Display Buffer */
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index f4a9b37c09b..3062e5ae3e4 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -21,6 +21,10 @@
#include "device_memory.h"
+#include "film.h"
+
+#include "kernel_types.h"
+
#include "util_string.h"
#include "util_thread.h"
#include "util_types.h"
@@ -45,32 +49,16 @@ public:
int full_width;
int full_height;
- BufferParams()
- {
- width = 0;
- height = 0;
-
- full_x = 0;
- full_y = 0;
- full_width = 0;
- full_height = 0;
- }
-
- void get_offset_stride(int& offset, int& stride)
- {
- offset = -(full_x + full_y*width);
- stride = width;
- }
-
- bool modified(const BufferParams& params)
- {
- return !(full_x == params.full_x
- && full_y == params.full_y
- && width == params.width
- && height == params.height
- && full_width == params.full_width
- && full_height == params.full_height);
- }
+ /* passes */
+ vector<Pass> passes;
+
+ /* functions */
+ BufferParams();
+
+ void get_offset_stride(int& offset, int& stride);
+ bool modified(const BufferParams& params);
+ void add_pass(PassType type);
+ int get_passes_size();
};
/* Render Buffers */
@@ -80,7 +68,7 @@ public:
/* buffer parameters */
BufferParams params;
/* float buffer */
- device_vector<float4> buffer;
+ device_vector<float> buffer;
/* random number generator state */
device_vector<uint> rng_state;
/* mutex, must be locked manually by callers */
@@ -90,7 +78,9 @@ public:
~RenderBuffers();
void reset(Device *device, BufferParams& params);
- float4 *copy_from_device(float exposure, int sample);
+
+ bool copy_from_device();
+ bool get_pass(PassType type, float exposure, int sample, int components, float *pixels);
protected:
void device_free();
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 0ae2866f182..bc51384b873 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -21,11 +21,111 @@
#include "film.h"
#include "scene.h"
+#include "util_foreach.h"
+
CCL_NAMESPACE_BEGIN
+/* Pass */
+
+void Pass::add(PassType type, vector<Pass>& passes)
+{
+ Pass pass;
+
+ pass.type = type;
+ pass.filter = true;
+ pass.exposure = false;
+
+ switch(type) {
+ case PASS_NONE:
+ pass.components = 0;
+ break;
+ case PASS_COMBINED:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_DEPTH:
+ pass.components = 1;
+ pass.filter = false;
+ break;
+ case PASS_NORMAL:
+ pass.components = 4;
+ break;
+ case PASS_UV:
+ pass.components = 4;
+ break;
+ case PASS_OBJECT_ID:
+ pass.components = 1;
+ pass.filter = false;
+ break;
+ case PASS_MATERIAL_ID:
+ pass.components = 1;
+ pass.filter = false;
+ break;
+ case PASS_DIFFUSE_COLOR:
+ pass.components = 4;
+ break;
+ case PASS_GLOSSY_COLOR:
+ pass.components = 4;
+ break;
+ case PASS_TRANSMISSION_COLOR:
+ pass.components = 4;
+ break;
+ case PASS_DIFFUSE_INDIRECT:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_GLOSSY_INDIRECT:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_TRANSMISSION_INDIRECT:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_DIFFUSE_DIRECT:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_GLOSSY_DIRECT:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_TRANSMISSION_DIRECT:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+
+ case PASS_EMISSION:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ case PASS_BACKGROUND:
+ pass.components = 4;
+ pass.exposure = true;
+ break;
+ }
+
+ passes.push_back(pass);
+}
+
+bool Pass::equals(const vector<Pass>& A, const vector<Pass>& B)
+{
+ if(A.size() != B.size())
+ return false;
+
+ for(int i = 0; i < A.size(); i++)
+ if(A[i].type != B[i].type)
+ return false;
+
+ return true;
+}
+
+/* Film */
+
Film::Film()
{
exposure = 0.8f;
+ Pass::add(PASS_COMBINED, passes);
need_update = true;
}
@@ -42,6 +142,82 @@ void Film::device_update(Device *device, DeviceScene *dscene)
/* update __data */
kfilm->exposure = exposure;
+ kfilm->pass_flag = 0;
+ kfilm->pass_stride = 0;
+ kfilm->use_light_pass = 0;
+
+ foreach(Pass& pass, passes) {
+ kfilm->pass_flag |= pass.type;
+
+ switch(pass.type) {
+ case PASS_COMBINED:
+ kfilm->pass_combined = kfilm->pass_stride;
+ break;
+ case PASS_DEPTH:
+ kfilm->pass_depth = kfilm->pass_stride;
+ break;
+ case PASS_NORMAL:
+ kfilm->pass_normal = kfilm->pass_stride;
+ break;
+ case PASS_UV:
+ kfilm->pass_uv = kfilm->pass_stride;
+ break;
+ case PASS_OBJECT_ID:
+ kfilm->pass_object_id = kfilm->pass_stride;
+ break;
+ case PASS_MATERIAL_ID:
+ kfilm->pass_material_id = kfilm->pass_stride;
+ break;
+ case PASS_DIFFUSE_COLOR:
+ kfilm->pass_diffuse_color = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_GLOSSY_COLOR:
+ kfilm->pass_glossy_color = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_TRANSMISSION_COLOR:
+ kfilm->pass_transmission_color = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_DIFFUSE_INDIRECT:
+ kfilm->pass_diffuse_indirect = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_GLOSSY_INDIRECT:
+ kfilm->pass_glossy_indirect = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_TRANSMISSION_INDIRECT:
+ kfilm->pass_transmission_indirect = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_DIFFUSE_DIRECT:
+ kfilm->pass_diffuse_direct = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_GLOSSY_DIRECT:
+ kfilm->pass_glossy_direct = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_TRANSMISSION_DIRECT:
+ kfilm->pass_transmission_direct = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+
+ case PASS_EMISSION:
+ kfilm->pass_emission = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ break;
+ case PASS_BACKGROUND:
+ kfilm->pass_background = kfilm->pass_stride;
+ kfilm->use_light_pass = 1;
+ case PASS_NONE:
+ break;
+ }
+
+ kfilm->pass_stride += pass.components;
+ }
need_update = false;
}
@@ -52,7 +228,8 @@ void Film::device_free(Device *device, DeviceScene *dscene)
bool Film::modified(const Film& film)
{
- return !(exposure == film.exposure);
+ return !(exposure == film.exposure
+ && Pass::equals(passes, film.passes));
}
void Film::tag_update(Scene *scene)
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index df24fad3725..511ad316460 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -20,6 +20,9 @@
#define __FILM_H__
#include "util_string.h"
+#include "util_vector.h"
+
+#include "kernel_types.h"
CCL_NAMESPACE_BEGIN
@@ -27,9 +30,21 @@ class Device;
class DeviceScene;
class Scene;
+class Pass {
+public:
+ PassType type;
+ int components;
+ bool filter;
+ bool exposure;
+
+ static void add(PassType type, vector<Pass>& passes);
+ static bool equals(const vector<Pass>& A, const vector<Pass>& B);
+};
+
class Film {
public:
float exposure;
+ vector<Pass> passes;
bool need_update;
Film();
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 74943fd0ff7..777e764558f 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -26,8 +26,74 @@
#include "util_foreach.h"
#include "util_progress.h"
+#include "kernel_montecarlo.h"
+
CCL_NAMESPACE_BEGIN
+static void dump_background_pixels(Device *device, DeviceScene *dscene, int res, vector<float3>& pixels)
+{
+ /* create input */
+ int width = res;
+ int height = res;
+
+ device_vector<uint4> d_input;
+ device_vector<float4> d_output;
+
+ uint4 *d_input_data = d_input.resize(width*height);
+
+ for(int y = 0; y < height; y++) {
+ for(int x = 0; x < width; x++) {
+ float u = x/(float)width;
+ float v = y/(float)height;
+ float3 D = -equirectangular_to_direction(u, v);
+
+ uint4 in = make_uint4(__float_as_int(D.x), __float_as_int(D.y), __float_as_int(D.z), 0);
+ d_input_data[x + y*width] = in;
+ }
+ }
+
+ /* compute on device */
+ float4 *d_output_data = d_output.resize(width*height);
+ memset((void*)d_output.data_pointer, 0, d_output.memory_size());
+
+ device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
+
+ device->mem_alloc(d_input, MEM_READ_ONLY);
+ device->mem_copy_to(d_input);
+ device->mem_alloc(d_output, MEM_WRITE_ONLY);
+
+ DeviceTask main_task(DeviceTask::SHADER);
+ main_task.shader_input = d_input.device_pointer;
+ main_task.shader_output = d_output.device_pointer;
+ main_task.shader_eval_type = SHADER_EVAL_BACKGROUND;
+ main_task.shader_x = 0;
+ main_task.shader_w = width*height;
+
+ list<DeviceTask> split_tasks;
+ main_task.split_max_size(split_tasks, 128*128);
+
+ foreach(DeviceTask& task, split_tasks) {
+ device->task_add(task);
+ device->task_wait();
+ }
+
+ device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float4));
+ device->mem_free(d_input);
+ device->mem_free(d_output);
+
+ d_output_data = reinterpret_cast<float4*>(d_output.data_pointer);
+
+ pixels.resize(width*height);
+
+ for(int y = 0; y < height; y++) {
+ for(int x = 0; x < width; x++) {
+ pixels[y*width + x].x = d_output_data[y*width + x].x;
+ pixels[y*width + x].y = d_output_data[y*width + x].y;
+ pixels[y*width + x].z = d_output_data[y*width + x].z;
+ }
+ }
+}
+
/* Light */
Light::Light()
@@ -44,6 +110,8 @@ Light::Light()
axisv = make_float3(0.0f, 0.0f, 0.0f);
sizev = 1.0f;
+ map_resolution = 512;
+
cast_shadow = true;
shader = 0;
}
@@ -66,6 +134,8 @@ LightManager::~LightManager()
void LightManager::device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
+ progress.set_status("Updating Lights", "Computing distribution");
+
/* option to always sample all point lights */
bool multi_light = false;
@@ -109,7 +179,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
/* triangles */
size_t offset = 0;
- size_t j = 0;
+ int j = 0;
foreach(Object *object, scene->objects) {
Mesh *mesh = object->mesh;
@@ -128,7 +198,10 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
/* sum area */
if(have_emission) {
Transform tfm = object->tfm;
- int object_id = (mesh->transform_applied)? -j-1: j;
+ int object_id = j;
+
+ if(mesh->transform_applied)
+ object_id = ~object_id;
for(size_t i = 0; i < mesh->triangles.size(); i++) {
Shader *shader = scene->shaders[mesh->shader[i]];
@@ -161,9 +234,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
if(!multi_light) {
float lightarea = (totarea > 0.0f)? totarea/scene->lights.size(): 1.0f;
- for(size_t i = 0; i < scene->lights.size(); i++, offset++) {
+ for(int i = 0; i < scene->lights.size(); i++, offset++) {
distribution[offset].x = totarea;
- distribution[offset].y = __int_as_float(-i-1);
+ distribution[offset].y = __int_as_float(~(int)i);
distribution[offset].z = 1.0f;
distribution[offset].w = scene->lights[i]->size;
totarea += lightarea;
@@ -229,6 +302,99 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
dscene->light_distribution.clear();
}
+void LightManager::device_update_background(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+{
+ KernelIntegrator *kintegrator = &dscene->data.integrator;
+ Light *background_light = NULL;
+
+ /* find background light */
+ foreach(Light *light, scene->lights) {
+ if(light->type == LIGHT_BACKGROUND) {
+ background_light = light;
+ break;
+ }
+ }
+
+ /* no background light found, signal renderer to skip sampling */
+ if(!background_light) {
+ kintegrator->pdf_background_res = 0;
+ return;
+ }
+
+ progress.set_status("Updating Lights", "Importance map");
+
+ assert(kintegrator->use_direct_light);
+
+ /* get the resolution from the light's size (we stuff it in there) */
+ int res = background_light->map_resolution;
+ kintegrator->pdf_background_res = res;
+
+ assert(res > 0);
+
+ vector<float3> pixels;
+ dump_background_pixels(device, dscene, res, pixels);
+
+ if(progress.get_cancel())
+ return;
+
+ /* build row distributions and column distribution for the infinite area environment light */
+ int cdf_count = res + 1;
+ float2 *marg_cdf = dscene->light_background_marginal_cdf.resize(cdf_count);
+ float2 *cond_cdf = dscene->light_background_conditional_cdf.resize(cdf_count * cdf_count);
+
+ /* conditional CDFs (rows, U direction) */
+ for(int i = 0; i < res; i++) {
+ float sin_theta = sinf(M_PI_F * (i + 0.5f) / res);
+ float3 env_color = pixels[i * res];
+ float ave_luminamce = average(env_color);
+
+ cond_cdf[i * cdf_count].x = ave_luminamce * sin_theta;
+ cond_cdf[i * cdf_count].y = 0.0f;
+
+ for(int j = 1; j < res; j++) {
+ env_color = pixels[i * res + j];
+ ave_luminamce = average(env_color);
+
+ cond_cdf[i * cdf_count + j].x = ave_luminamce * sin_theta;
+ cond_cdf[i * cdf_count + j].y = cond_cdf[i * cdf_count + j - 1].y + cond_cdf[i * cdf_count + j - 1].x / res;
+ }
+
+ float cdf_total = cond_cdf[i * cdf_count + res - 1].y + cond_cdf[i * cdf_count + res - 1].x / res;
+
+ /* stuff the total into the brightness value for the last entry, because
+ we are going to normalize the CDFs to 0.0 to 1.0 afterwards */
+ cond_cdf[i * cdf_count + res].x = cdf_total;
+
+ if(cdf_total > 0.0f)
+ for(int j = 1; j < res; j++)
+ cond_cdf[i * cdf_count + j].y /= cdf_total;
+
+ cond_cdf[i * cdf_count + res].y = 1.0f;
+ }
+
+ /* marginal CDFs (column, V direction, sum of rows) */
+ marg_cdf[0].x = cond_cdf[res].x;
+ marg_cdf[0].y = 0.0f;
+
+ for(int i = 1; i < res; i++) {
+ marg_cdf[i].x = cond_cdf[i * cdf_count + res].x;
+ marg_cdf[i].y = marg_cdf[i - 1].y + marg_cdf[i - 1].x / res;
+ }
+
+ float cdf_total = marg_cdf[res - 1].y + marg_cdf[res - 1].x / res;
+ marg_cdf[res].x = cdf_total;
+
+ if(cdf_total > 0.0f)
+ for(int i = 1; i < res; i++)
+ marg_cdf[i].y /= cdf_total;
+
+ marg_cdf[res].y = 1.0f;
+
+ /* update device */
+ device->tex_alloc("__light_background_marginal_cdf", dscene->light_background_marginal_cdf);
+ device->tex_alloc("__light_background_conditional_cdf", dscene->light_background_conditional_cdf);
+}
+
void LightManager::device_update_points(Device *device, DeviceScene *dscene, Scene *scene)
{
if(scene->lights.size() == 0)
@@ -261,6 +427,14 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
light_data[i*LIGHT_SIZE + 3] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
+ else if(light->type == LIGHT_BACKGROUND) {
+ shader_id &= ~SHADER_AREA_LIGHT;
+
+ light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), 0.0f, 0.0f, 0.0f);
+ light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), 0.0f, 0.0f, 0.0f);
+ light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ light_data[i*LIGHT_SIZE + 3] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ }
else if(light->type == LIGHT_AREA) {
float3 axisu = light->axisu*(light->sizeu*light->size);
float3 axisv = light->axisv*(light->sizev*light->size);
@@ -288,6 +462,9 @@ void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *sce
device_update_distribution(device, dscene, scene, progress);
if(progress.get_cancel()) return;
+ device_update_background(device, dscene, scene, progress);
+ if(progress.get_cancel()) return;
+
need_update = false;
}
@@ -295,9 +472,13 @@ void LightManager::device_free(Device *device, DeviceScene *dscene)
{
device->tex_free(dscene->light_distribution);
device->tex_free(dscene->light_data);
+ device->tex_free(dscene->light_background_marginal_cdf);
+ device->tex_free(dscene->light_background_conditional_cdf);
dscene->light_distribution.clear();
dscene->light_data.clear();
+ dscene->light_background_marginal_cdf.clear();
+ dscene->light_background_conditional_cdf.clear();
}
void LightManager::tag_update(Scene *scene)
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index 19cbcb55386..0ed143f5ad1 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -46,6 +46,8 @@ public:
float3 axisv;
float sizev;
+ int map_resolution;
+
bool cast_shadow;
int shader;
@@ -68,6 +70,7 @@ public:
protected:
void device_update_points(Device *device, DeviceScene *dscene, Scene *scene);
void device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_background(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp
index c4f3e43bfba..a6f8e3f6be8 100644
--- a/intern/cycles/render/mesh_displace.cpp
+++ b/intern/cycles/render/mesh_displace.cpp
@@ -89,7 +89,7 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
return false;
/* run device task */
- device_vector<float3> d_output;
+ device_vector<float4> d_output;
d_output.resize(d_input.size());
device->mem_alloc(d_input, MEM_READ_ONLY);
@@ -106,7 +106,7 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
device->task_add(task);
device->task_wait();
- device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float3));
+ device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float4));
device->mem_free(d_input);
device->mem_free(d_output);
@@ -118,7 +118,7 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
done.resize(mesh->verts.size(), false);
int k = 0;
- float3 *offset = (float3*)d_output.data_pointer;
+ float4 *offset = (float4*)d_output.data_pointer;
for(size_t i = 0; i < mesh->triangles.size(); i++) {
Mesh::Triangle t = mesh->triangles[i];
@@ -130,7 +130,8 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
for(int j = 0; j < 3; j++) {
if(!done[t.v[j]]) {
done[t.v[j]] = true;
- mesh->verts[t.v[j]] += offset[k++];
+ float3 off = float4_to_float3(offset[k++]);
+ mesh->verts[t.v[j]] += off;
}
}
}
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 7397c9c09af..982521b31f2 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1820,6 +1820,38 @@ void GammaNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_gamma");
}
+/* Bright Contrast */
+BrightContrastNode::BrightContrastNode()
+: ShaderNode("brightness")
+{
+ add_input("Color", SHADER_SOCKET_COLOR);
+ add_input("Bright", SHADER_SOCKET_FLOAT);
+ add_input("Contrast", SHADER_SOCKET_FLOAT);
+ add_output("Color", SHADER_SOCKET_COLOR);
+}
+
+void BrightContrastNode::compile(SVMCompiler& compiler)
+{
+ ShaderInput *color_in = input("Color");
+ ShaderInput *bright_in = input("Bright");
+ ShaderInput *contrast_in = input("Contrast");
+ ShaderOutput *color_out = output("Color");
+
+ compiler.stack_assign(color_in);
+ compiler.stack_assign(bright_in);
+ compiler.stack_assign(contrast_in);
+ compiler.stack_assign(color_out);
+
+ compiler.add_node(NODE_BRIGHTCONTRAST,
+ color_in->stack_offset, color_out->stack_offset,
+ compiler.encode_uchar4(bright_in->stack_offset, contrast_in->stack_offset));
+}
+
+void BrightContrastNode::compile(OSLCompiler& compiler)
+{
+ compiler.add(this, "node_brightness");
+}
+
/* Separate RGB */
SeparateRGBNode::SeparateRGBNode()
: ShaderNode("separate_rgb")
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index c2f9ead5924..338af4ef48a 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -320,6 +320,11 @@ public:
SHADER_NODE_CLASS(GammaNode)
};
+class BrightContrastNode : public ShaderNode {
+public:
+ SHADER_NODE_CLASS(BrightContrastNode)
+};
+
class SeparateRGBNode : public ShaderNode {
public:
SHADER_NODE_CLASS(SeparateRGBNode)
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 3a9f0add735..f83c85c632d 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -36,6 +36,7 @@ Object::Object()
mesh = NULL;
tfm = transform_identity();
visibility = ~0;
+ pass_id = 0;
}
Object::~Object()
@@ -135,6 +136,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
/* todo: correct for displacement, and move to a better place */
float uniform_scale;
float surface_area = 0.0f;
+ float pass_id = ob->pass_id;
if(transform_uniform_scale(tfm, uniform_scale)) {
map<Mesh*, float>::iterator it = surface_area_map.find(mesh);
@@ -171,7 +173,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
memcpy(&objects[offset], &tfm, sizeof(float4)*4);
memcpy(&objects[offset+4], &itfm, sizeof(float4)*4);
memcpy(&objects[offset+8], &ntfm, sizeof(float4)*4);
- objects[offset+12] = make_float4(surface_area, 0.0f, 0.0f, 0.0f);
+ objects[offset+12] = make_float4(surface_area, pass_id, 0.0f, 0.0f);
i++;
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index 7fe83cf7d91..14da2cfb35d 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -41,6 +41,7 @@ public:
Transform tfm;
BoundBox bounds;
ustring name;
+ int pass_id;
vector<ParamValue> attributes;
uint visibility;
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index 17bd7e20129..4a5224f8a94 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -78,6 +78,8 @@ public:
/* lights */
device_vector<float4> light_distribution;
device_vector<float4> light_data;
+ device_vector<float2> light_background_marginal_cdf;
+ device_vector<float2> light_background_conditional_cdf;
/* shaders */
device_vector<uint4> svm_nodes;
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 6e827ec94bb..12968a79ab2 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -35,6 +35,7 @@ CCL_NAMESPACE_BEGIN
Shader::Shader()
{
name = "";
+ pass_id = 0;
graph = NULL;
graph_bump = NULL;
@@ -167,7 +168,7 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
if(scene->shaders.size() == 0)
return;
- uint shader_flag_size = scene->shaders.size()*2;
+ uint shader_flag_size = scene->shaders.size()*4;
uint *shader_flag = dscene->shader_flag.resize(shader_flag_size);
uint i = 0;
@@ -184,7 +185,9 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
flag |= SD_HOMOGENEOUS_VOLUME;
shader_flag[i++] = flag;
+ shader_flag[i++] = shader->pass_id;
shader_flag[i++] = flag;
+ shader_flag[i++] = shader->pass_id;
}
device->tex_alloc("__shader_flag", dscene->shader_flag);
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index 45efa123ef6..35f3cfe27f5 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -47,6 +47,7 @@ class Shader {
public:
/* name */
string name;
+ int pass_id;
/* shader graph */
ShaderGraph *graph;
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index dfdad22e176..582086d130b 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -35,6 +35,7 @@
#include <libavcodec/avcodec.h>
#include <libavutil/rational.h>
+#include <libavutil/opt.h>
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
#define FFMPEG_HAVE_PARSE_UTILS 1
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 3ec8d3d2fbf..ee67694760b 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -271,6 +271,15 @@ public:
*/
virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0) = 0;
+
+ /**
+ * Updates the resolution while in fullscreen mode.
+ * @param setting The new setting of the display.
+ * @param window Window displayed in full screen.
+ *
+ * @return Indication of success.
+ */
+ virtual GHOST_TSuccess updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window) = 0;
/**
* Ends full screen mode.
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index be5d45128f9..0f5149de037 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -77,6 +77,12 @@ static const char* ndof_button_names[] = {
"NDOF_BUTTON_8",
"NDOF_BUTTON_9",
"NDOF_BUTTON_10",
+ // more general-purpose buttons
+ "NDOF_BUTTON_A",
+ "NDOF_BUTTON_B",
+ "NDOF_BUTTON_C",
+ // the end
+ "NDOF_BUTTON_LAST"
};
#endif
@@ -137,8 +143,39 @@ static const NDOF_ButtonT SpacePilotPro_HID_map[] = {
NDOF_BUTTON_MINUS
};
+// latest HW: button-compatible with SpacePilotPro, just fewer of them
+static const NDOF_ButtonT SpaceMousePro_HID_map[] = {
+ NDOF_BUTTON_MENU,
+ NDOF_BUTTON_FIT,
+ NDOF_BUTTON_TOP,
+ NDOF_BUTTON_NONE, // left
+ NDOF_BUTTON_RIGHT,
+ NDOF_BUTTON_FRONT,
+ NDOF_BUTTON_NONE, // bottom
+ NDOF_BUTTON_NONE, // back
+ NDOF_BUTTON_ROLL_CW,
+ NDOF_BUTTON_NONE, // roll ccw
+ NDOF_BUTTON_NONE, // iso 1
+ NDOF_BUTTON_NONE, // iso 2
+ NDOF_BUTTON_1,
+ NDOF_BUTTON_2,
+ NDOF_BUTTON_3,
+ NDOF_BUTTON_4,
+ NDOF_BUTTON_NONE, // 5
+ NDOF_BUTTON_NONE, // 6
+ NDOF_BUTTON_NONE, // 7
+ NDOF_BUTTON_NONE, // 8
+ NDOF_BUTTON_NONE, // 9
+ NDOF_BUTTON_NONE, // 10
+ NDOF_BUTTON_NONE, // esc key
+ NDOF_BUTTON_NONE, // alt key
+ NDOF_BUTTON_NONE, // shift key
+ NDOF_BUTTON_NONE, // ctrl key
+ NDOF_BUTTON_ROTATE,
+};
+
/* this is the older SpacePilot (sans Pro)
- * thanks to polosson for the info in this table */
+ * thanks to polosson for info about this device */
static const NDOF_ButtonT SpacePilot_HID_map[] = {
NDOF_BUTTON_1,
NDOF_BUTTON_2,
@@ -163,6 +200,23 @@ static const NDOF_ButtonT SpacePilot_HID_map[] = {
NDOF_BUTTON_NONE // the CONFIG button -- what does it do?
};
+/* this is the older Spaceball 5000 USB
+ * thanks to Tehrasha Darkon for info about this device */
+static const NDOF_ButtonT Spaceball5000_HID_map[] = {
+ NDOF_BUTTON_1,
+ NDOF_BUTTON_2,
+ NDOF_BUTTON_3,
+ NDOF_BUTTON_4,
+ NDOF_BUTTON_5,
+ NDOF_BUTTON_6,
+ NDOF_BUTTON_7,
+ NDOF_BUTTON_8,
+ NDOF_BUTTON_9,
+ NDOF_BUTTON_A,
+ NDOF_BUTTON_B,
+ NDOF_BUTTON_C
+};
+
GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys)
: m_system(sys)
, m_deviceType(NDOF_UnknownDevice) // each platform has its own device detection code
@@ -206,10 +260,16 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
m_buttonCount = 15;
break;
case 0xC629:
- puts("ndof: using SpacePilotPro");
+ puts("ndof: using SpacePilot Pro");
m_deviceType = NDOF_SpacePilotPro;
m_buttonCount = 31;
break;
+ case 0xC62B:
+ puts("ndof: using SpaceMouse Pro");
+ m_deviceType = NDOF_SpaceMousePro;
+ m_buttonCount = 27;
+ // ^^ actually has 15 buttons, but their HID codes range from 0 to 26
+ break;
// -- older devices --
case 0xC625:
@@ -218,6 +278,12 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
m_buttonCount = 21;
break;
+ case 0xC621:
+ puts("ndof: using Spaceball 5000");
+ m_deviceType = NDOF_Spaceball5000;
+ m_buttonCount = 12;
+ break;
+
case 0xC623:
puts("ndof: SpaceTraveler not supported, please file a bug report");
m_buttonCount = 8;
@@ -237,6 +303,8 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
else {
m_buttonMask = ~(-1 << m_buttonCount);
+ // special case for SpaceMousePro? maybe...
+
#ifdef DEBUG_NDOF_BUTTONS
printf("ndof: %d buttons -> hex:%X\n", m_buttonCount, m_buttonMask);
#endif
@@ -261,6 +329,16 @@ void GHOST_NDOFManager::updateRotation(short r[3], GHOST_TUns64 time)
void GHOST_NDOFManager::sendButtonEvent(NDOF_ButtonT button, bool press, GHOST_TUns64 time, GHOST_IWindow* window)
{
+ if (button == NDOF_BUTTON_NONE) {
+ // just being exceptionally cautious...
+ // air-tight button masking and proper function key emulation
+ // should guarantee we never get to this point
+#ifdef DEBUG_NDOF_BUTTONS
+ printf("discarding NDOF_BUTTON_NONE (should not escape the NDOF manager)\n");
+#endif
+ return;
+ }
+
GHOST_EventNDOFButton* event = new GHOST_EventNDOFButton(time, window);
GHOST_TEventNDOFButtonData* data = (GHOST_TEventNDOFButtonData*) event->getData();
@@ -317,6 +395,15 @@ void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64
default: sendButtonEvent(SpacePilotPro_HID_map[button_number], press, time, window);
}
break;
+ case NDOF_SpaceMousePro:
+ switch (button_number) {
+ case 22: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break;
+ case 23: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break;
+ case 24: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break;
+ case 25: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break;
+ default: sendButtonEvent(SpaceMousePro_HID_map[button_number], press, time, window);
+ }
+ break;
case NDOF_SpacePilot:
switch (button_number) {
case 10: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break;
@@ -327,8 +414,21 @@ void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64
default: sendButtonEvent(SpacePilot_HID_map[button_number], press, time, window);
}
break;
+ case NDOF_Spaceball5000:
+ // has no special 'keyboard' buttons
+ sendButtonEvent(Spaceball5000_HID_map[button_number], press, time, window);
+ break;
case NDOF_UnknownDevice:
- printf("ndof: button %d on unknown device (ignoring)\n", button_number);
+ printf("ndof: button %d on unknown device (", button_number);
+ // map to the 'general purpose' buttons
+ // this is mainly for old serial devices
+ if (button_number < NDOF_BUTTON_LAST - NDOF_BUTTON_1) {
+ printf("sending)\n");
+ sendButtonEvent((NDOF_ButtonT)(NDOF_BUTTON_1 + button_number), press, time, window);
+ }
+ else {
+ printf("discarding)\n");
+ }
}
int mask = 1 << button_number;
diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h
index 34759035664..c4e980bb895 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.h
+++ b/intern/ghost/intern/GHOST_NDOFManager.h
@@ -37,9 +37,11 @@ typedef enum {
NDOF_SpaceNavigator,
NDOF_SpaceExplorer,
NDOF_SpacePilotPro,
+ NDOF_SpaceMousePro,
// older devices
- NDOF_SpacePilot
+ NDOF_SpacePilot,
+ NDOF_Spaceball5000
} NDOF_DeviceT;
@@ -86,7 +88,12 @@ typedef enum {
NDOF_BUTTON_8,
NDOF_BUTTON_9,
NDOF_BUTTON_10,
-
+ // more general-purpose buttons
+ NDOF_BUTTON_A,
+ NDOF_BUTTON_B,
+ NDOF_BUTTON_C,
+ // the end
+ NDOF_BUTTON_LAST
} NDOF_ButtonT;
class GHOST_NDOFManager
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index 4efdcbc6519..944ade3f22b 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -168,6 +168,19 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting
}
+GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window)
+{
+ GHOST_TSuccess success = GHOST_kFailure;
+ GHOST_ASSERT(m_windowManager, "GHOST_System::updateFullScreen(): invalid window manager");
+ if(m_displayManager) {
+ if (m_windowManager->getFullScreen()) {
+ success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
+ }
+ }
+
+ return success;
+}
+
GHOST_TSuccess GHOST_System::endFullScreen(void)
{
GHOST_TSuccess success = GHOST_kFailure;
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 6286121719d..0bb0387a287 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -145,6 +145,15 @@ public:
*/
virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0);
+
+ /**
+ * Updates the resolution while in fullscreen mode.
+ * @param setting The new setting of the display.
+ * @param window Window displayed in full screen.
+ *
+ * @return Indication of success.
+ */
+ virtual GHOST_TSuccess updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window);
/**
* Ends full screen mode.
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 4bf4edaf092..22c16009591 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -422,6 +422,8 @@ processEvents(
return anyProcessed;
}
+
+#ifdef WITH_X11_XINPUT
/* set currently using tablet mode (stylus or eraser) depending on device ID */
static void setTabletMode(GHOST_WindowX11 * window, XID deviceid)
{
@@ -430,6 +432,7 @@ static void setTabletMode(GHOST_WindowX11 * window, XID deviceid)
else if(deviceid == window->GetXTablet().EraserID)
window->GetXTablet().CommonData.Active= GHOST_kTabletModeEraser;
}
+#endif /* WITH_X11_XINPUT */
void
GHOST_SystemX11::processEvent(XEvent *xe)
diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py
index 4a9b6b0e96e..5e1e5d0d778 100644
--- a/release/scripts/presets/keyconfig/maya.py
+++ b/release/scripts/presets/keyconfig/maya.py
@@ -219,7 +219,8 @@ kmi.properties.value_1 = 'DISABLED'
kmi.properties.value_2 = 'ENABLED'
kmi = km.keymap_items.new('view3d.game_start', 'P', 'PRESS')
kmi = km.keymap_items.new('object.select_all', 'A', 'PRESS')
-kmi = km.keymap_items.new('object.select_all', 'I', 'PRESS', ctrl=True).action = 'INVERT'
+kmi = km.keymap_items.new('object.select_all', 'I', 'PRESS', ctrl=True)
+kmi.properties.action = 'INVERT'
kmi = km.keymap_items.new('object.select_linked', 'L', 'PRESS', shift=True)
kmi = km.keymap_items.new('object.select_grouped', 'G', 'PRESS', shift=True)
kmi = km.keymap_items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True)
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 9be3b00e4cf..766daba58b8 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -814,12 +814,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
def REMESH(self, layout, ob, md):
layout.prop(md, "mode")
-
- layout.prop(md, "octree_depth")
- layout.prop(md, "scale")
+
row = layout.row()
- row.active = md.mode == "SHARP"
- row.prop(md, "sharpness")
+ row.prop(md, "octree_depth")
+ row.prop(md, "scale")
+
+ if md.mode == "SHARP":
+ layout.prop(md, "sharpness")
layout.prop(md, "remove_disconnected_pieces")
row = layout.row()
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 5e68351d9e6..4e511f18cd4 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -911,7 +911,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures")
split = layout.split(percentage=0.33)
- split.label(text="Split uv's:")
+ split.label(text="Split UVs:")
split.prop(part, "billboard_uv_split", text="Number of splits")
if psys:
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 32b94504525..dc64aacf043 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -87,6 +87,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
col.label(text="Damping:")
col.prop(cloth, "spring_damping", text="Spring")
col.prop(cloth, "air_damping", text="Air")
+ col.prop(cloth, "vel_damping", text="Velocity")
col.prop(cloth, "use_pin_cloth", text="Pinning")
sub = col.column()
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index bf8d7d8552f..e6801f00fce 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -412,14 +412,14 @@ class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
col.prop(brush, "paint_distance", text="Paint Distance")
split = layout.row().split(percentage=0.4)
sub = split.column()
- if brush.paint_source == 'DISTANCE':
+ if brush.paint_source in {'DISTANCE', 'VOLUME_DISTANCE'}:
sub.prop(brush, "use_proximity_project")
- elif brush.paint_source == 'VOLUME_DISTANCE':
+ if brush.paint_source == 'VOLUME_DISTANCE':
sub.prop(brush, "invert_proximity")
sub.prop(brush, "use_negative_volume")
sub = split.column()
- if brush.paint_source == 'DISTANCE':
+ if brush.paint_source in {'DISTANCE', 'VOLUME_DISTANCE'}:
column = sub.column()
column.active = brush.use_proximity_project
column.prop(brush, "ray_direction")
diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 8717a9b9114..114d74f1060 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -79,6 +79,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
sub = col.column(align=True)
sub.prop(fluid, "start_time", text="Start")
sub.prop(fluid, "end_time", text="End")
+ col.prop(fluid, "simulation_rate", text="Speed")
col = split.column()
col.label()
@@ -230,6 +231,10 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
if fluid.viscosity_preset == 'MANUAL':
sub.prop(fluid, "viscosity_base", text="Base")
sub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True)
+ else:
+ # just for padding to prevent jumping around
+ sub.separator()
+ sub.separator()
col.label(text="Optimization:")
col.prop(fluid, "grid_levels", slider=True)
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 55c10a56015..c179342bc44 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -172,6 +172,7 @@ class CLIP_PT_tools_tracking(Panel):
props.backwards = True
props.sequence = True
props = row.operator("clip.track_markers", text="", icon='PLAY')
+ props.backwards = False
props.sequence = True
row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
@@ -558,6 +559,9 @@ class CLIP_PT_display(Panel):
col.prop(sc, "lock_selection")
+ if sc.view == 'GRAPH':
+ col.prop(sc, "lock_time_cursor")
+
clip = sc.clip
if clip:
col.label(text="Display Aspect Ratio:")
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 409494b5cbb..aabf86c6c18 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -671,11 +671,11 @@ class IMAGE_PT_paint(Panel, ImagePaintPanel):
col.prop(brush, "color", text="")
row = col.row(align=True)
- self.prop_unified_size(row, context, brush, "size", slider=True)
+ self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
self.prop_unified_size(row, context, brush, "use_pressure_size")
row = col.row(align=True)
- self.prop_unified_strength(row, context, brush, "strength", slider=True)
+ self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
row = col.row(align=True)
@@ -820,11 +820,11 @@ class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
col = layout.column()
row = col.row(align=True)
- self.prop_unified_size(row, context, brush, "size", slider=True)
+ self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
self.prop_unified_size(row, context, brush, "use_pressure_size")
row = col.row(align=True)
- self.prop_unified_strength(row, context, brush, "strength", slider=True)
+ self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py
index 1593f2c71ec..da6d1f72123 100644
--- a/release/scripts/startup/bl_ui/space_logic.py
+++ b/release/scripts/startup/bl_ui/space_logic.py
@@ -68,7 +68,7 @@ class LOGIC_PT_properties(Panel):
row = box.row()
row.prop(prop, "name", text="")
row.prop(prop, "type", text="")
- row.prop(prop, "value", text="", toggle=True) # we don't care about the type. rna will display correctly
+ row.prop(prop, "value", text="")
row.prop(prop, "show_debug", text="", toggle=True, icon='INFO')
row.operator("object.game_property_remove", text="", icon='X', emboss=False).index = i
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index edbcf3ecf5b..d29dff49132 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -58,6 +58,11 @@ class NODE_HT_header(Header):
# Don't show "Use Nodes" Button when Engine is BI for Lamps
if snode_id and not (scene.render.use_shading_nodes == 0 and ob.type == 'LAMP'):
layout.prop(snode_id, "use_nodes")
+
+ if snode.shader_type == 'WORLD':
+ layout.template_ID(scene, "world", new="world.new")
+ if snode_id:
+ layout.prop(snode_id, "use_nodes")
elif snode.tree_type == 'TEXTURE':
layout.prop(snode, "texture_type", text="", expand=True)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index bbc04dad816..aa7cec0c01a 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -530,12 +530,12 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
else:
row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED')
- self.prop_unified_strength(row, context, brush, "strength")
+ self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
if tool == 'ROTATE':
row = col.row(align=True)
- self.prop_unified_strength(row, context, brush, "strength")
+ self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
if tool != 'SMOOTH':
@@ -627,7 +627,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_size(row, context, brush, "use_pressure_size")
row = col.row(align=True)
- self.prop_unified_strength(row, context, brush, "strength")
+ self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
row = col.row(align=True)
@@ -653,7 +653,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_size(row, context, brush, "use_pressure_size")
row = col.row(align=True)
- self.prop_unified_strength(row, context, brush, "strength")
+ self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
row = col.row(align=True)
@@ -671,7 +671,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_size(row, context, brush, "use_pressure_size")
row = col.row(align=True)
- self.prop_unified_strength(row, context, brush, "strength")
+ self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
# XXX - TODO
diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c
index 29b3047eca4..adcc7e8750a 100644
--- a/source/blender/avi/intern/endian.c
+++ b/source/blender/avi/intern/endian.c
@@ -43,6 +43,10 @@
#include "avi_intern.h"
#ifdef __BIG_ENDIAN__
+#include "MEM_guardedalloc.h"
+#endif
+
+#ifdef __BIG_ENDIAN__
static void invert (int *num)
{
int new=0,i,j;
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 5f451ce7821..a887412bbf4 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -538,6 +538,15 @@ int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]);
void weight_to_rgb(float r_rgb[3], const float weight);
+/* Update the weight MCOL preview layer.
+ * If weights are NULL, use object's active vgroup(s).
+ * Else, weights must be an array of weight float values.
+ * If indices is NULL, it must be of numVerts length.
+ * Else, it must be of num length, as indices, which contains vertices' idx to apply weights to.
+ * (other vertices are assumed zero weight).
+ */
+void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag,
+ float *weights, int num, const int *indices);
/* convert layers requested by a GLSL material to actually available layers in
* the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
@@ -584,5 +593,10 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm);
/* Set object's bounding box based on DerivedMesh min/max data */
void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm);
+/* debug only */
+#ifndef NDEBUG
+char *DM_debug_info(DerivedMesh *dm);
+void DM_debug_print(DerivedMesh *dm);
#endif
+#endif
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index a89bfbd50b1..11ab981822e 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -86,7 +86,7 @@ int bone_autoside_name (char name[64], int strip_number, short axis, float head,
struct Bone *get_named_bone (struct bArmature *arm, const char *name);
-float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist);
+float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist);
void where_is_armature (struct bArmature *arm);
void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone);
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index f24687e0fc9..42d9ae73b9a 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 261
-#define BLENDER_SUBVERSION 3
+#define BLENDER_SUBVERSION 4
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 7668d5392da..ee3edbb47e7 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -53,7 +53,7 @@ typedef struct Global {
struct Main *main;
/* strings: lastsaved */
- char ima[256], lib[256];
+ char ima[1024], lib[1024]; /* 1024 = FILE_MAX */
/* flag: if != 0 G.main->name contains valid relative base path */
int relbase_valid;
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index c829fc69b05..5cdc3537f5b 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -186,7 +186,7 @@ void BKE_image_merge(struct Image *dest, struct Image *source);
int BKE_image_has_alpha(struct Image *image);
/* image_gen.c */
-void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4]);
+void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, const float color[4]);
void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int height, int width);
void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int height, int width);
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 51bcd18fab6..05ba60b8a5b 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -50,7 +50,7 @@ struct Library;
typedef struct Main {
struct Main *next, *prev;
- char name[240]; /* 240 = FILE_MAX */
+ char name[1024]; /* 1024 = FILE_MAX */
short versionfile, subversionfile;
short minversionfile, minsubversionfile;
int revision; /* svn revision of binary that saved file */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 23073a2d8eb..f72bc5b93ec 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -99,7 +99,10 @@ typedef enum {
eModifierTypeFlag_Single = (1<<7),
/* Some modifier can't be added manually by user */
- eModifierTypeFlag_NoUserAdd = (1<<8)
+ eModifierTypeFlag_NoUserAdd = (1<<8),
+
+ /* For modifiers that use CD_WEIGHT_MCOL for preview. */
+ eModifierTypeFlag_UsesPreview = (1<<9)
} ModifierTypeFlag;
typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin);
@@ -323,6 +326,7 @@ void modifier_setError(struct ModifierData *md, const char *format, ...
__attribute__ ((format (printf, 2, 3)))
#endif
;
+int modifier_isPreview(struct ModifierData *md);
void modifiers_foreachObjectLink(struct Object *ob,
ObjectWalkFunc walk,
@@ -349,6 +353,7 @@ struct Object *modifiers_isDeformedByLattice(struct Object *ob);
int modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
int modifiers_isCorrectableDeformed(struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);
+int modifiers_isPreview(struct Object *ob);
int modifiers_indexInObject(struct Object *ob, struct ModifierData *md);
@@ -362,6 +367,9 @@ struct LinkNode *modifiers_calcDataMasks(struct Scene *scene,
struct ModifierData *md,
CustomDataMask dataMask,
int required_mode);
+struct ModifierData *modifiers_getLastPreview(struct Scene *scene,
+ struct ModifierData *md,
+ int required_mode);
struct ModifierData *modifiers_getVirtualModifierList(struct Object *ob);
/* ensure modifier correctness when changing ob->data */
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 67de699c7c4..0cccd8a366b 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -523,6 +523,7 @@ struct ShadeResult;
#define SH_NODE_VOLUME_ISOTROPIC 162
#define SH_NODE_GAMMA 163
#define SH_NODE_TEX_CHECKER 164
+#define SH_NODE_BRIGHTCONTRAST 165
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
@@ -556,25 +557,34 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
/* ************** COMPOSITE NODES *************** */
/* output socket defines */
-#define RRES_OUT_IMAGE 0
-#define RRES_OUT_ALPHA 1
-#define RRES_OUT_Z 2
-#define RRES_OUT_NORMAL 3
-#define RRES_OUT_UV 4
-#define RRES_OUT_VEC 5
-#define RRES_OUT_RGBA 6
-#define RRES_OUT_DIFF 7
-#define RRES_OUT_SPEC 8
-#define RRES_OUT_SHADOW 9
-#define RRES_OUT_AO 10
-#define RRES_OUT_REFLECT 11
-#define RRES_OUT_REFRACT 12
-#define RRES_OUT_INDIRECT 13
-#define RRES_OUT_INDEXOB 14
-#define RRES_OUT_INDEXMA 15
-#define RRES_OUT_MIST 16
-#define RRES_OUT_EMIT 17
-#define RRES_OUT_ENV 18
+#define RRES_OUT_IMAGE 0
+#define RRES_OUT_ALPHA 1
+#define RRES_OUT_Z 2
+#define RRES_OUT_NORMAL 3
+#define RRES_OUT_UV 4
+#define RRES_OUT_VEC 5
+#define RRES_OUT_RGBA 6
+#define RRES_OUT_DIFF 7
+#define RRES_OUT_SPEC 8
+#define RRES_OUT_SHADOW 9
+#define RRES_OUT_AO 10
+#define RRES_OUT_REFLECT 11
+#define RRES_OUT_REFRACT 12
+#define RRES_OUT_INDIRECT 13
+#define RRES_OUT_INDEXOB 14
+#define RRES_OUT_INDEXMA 15
+#define RRES_OUT_MIST 16
+#define RRES_OUT_EMIT 17
+#define RRES_OUT_ENV 18
+#define RRES_OUT_DIFF_DIRECT 19
+#define RRES_OUT_DIFF_INDIRECT 20
+#define RRES_OUT_DIFF_COLOR 21
+#define RRES_OUT_GLOSSY_DIRECT 22
+#define RRES_OUT_GLOSSY_INDIRECT 23
+#define RRES_OUT_GLOSSY_COLOR 24
+#define RRES_OUT_TRANSM_DIRECT 25
+#define RRES_OUT_TRANSM_INDIRECT 26
+#define RRES_OUT_TRANSM_COLOR 27
/* note: types are needed to restore callbacks, don't change values */
#define CMP_NODE_VIEWER 201
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index d3f297ece86..f720050f59c 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -61,6 +61,7 @@ struct MovieTrackingMarker *BKE_tracking_get_marker(struct MovieTrackingTrack *t
struct MovieTrackingMarker *BKE_tracking_ensure_marker(struct MovieTrackingTrack *track, int framenr);
struct MovieTrackingMarker *BKE_tracking_exact_marker(struct MovieTrackingTrack *track, int framenr);
int BKE_tracking_has_marker(struct MovieTrackingTrack *track, int framenr);
+int BKE_tracking_has_enabled_marker(struct MovieTrackingTrack *track, int framenr);
void BKE_tracking_free_track(struct MovieTrackingTrack *track);
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index b5b3c7e67eb..a6a9bb0c0f6 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -43,9 +43,9 @@ extern "C" {
/* these values need to be hardcoded in structs, dna does not recognize defines */
/* also defined in DNA_space_types.h */
#ifndef FILE_MAXDIR
-#define FILE_MAXDIR 160
-#define FILE_MAXFILE 80
-#define FILE_MAX 240
+#define FILE_MAXDIR 768
+#define FILE_MAXFILE 256
+#define FILE_MAX 1024
#endif
/* this weirdo pops up in two places ... */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 0ff46045f78..27aeeb95903 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -722,24 +722,23 @@ void vDM_ColorBand_store(ColorBand *coba)
* note that we could save some memory and allocate RGB only but then we'd need to
* re-arrange the colors when copying to the face since MCol has odd ordering,
* so leave this as is - campbell */
-static unsigned char *calc_weightpaint_vert_array(Object *ob, int const draw_flag, ColorBand *coba)
+static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, ColorBand *coba)
{
- Mesh *me = ob->data;
- unsigned char *wtcol_v = MEM_mallocN (sizeof(unsigned char) * me->totvert * 4, "weightmap_v");
+ MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
+ int numVerts = dm->getNumVerts(dm);
+ unsigned char *wtcol_v = MEM_mallocN (sizeof(unsigned char) * numVerts * 4, "weightmap_v");
- if (me->dvert) {
+ if (dv) {
unsigned char *wc = wtcol_v;
- MDeformVert *dv= me->dvert;
unsigned int i;
- /* varisbles for multipaint */
+ /* variables for multipaint */
const int defbase_tot = BLI_countlist(&ob->defbase);
const int defbase_act = ob->actdef-1;
char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__);
const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot);
- /* const int unselected = defbase_tot - selected; */ /* UNUSED */
- for (i = me->totvert; i != 0; i--, wc += 4, dv++) {
+ for (i = numVerts; i != 0; i--, wc += 4, dv++) {
calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, dg_flags, selected, draw_flag);
}
@@ -748,48 +747,94 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, int const draw_fla
else {
int col_i;
weightpaint_color((unsigned char *)&col_i, coba, 0.0f);
- fill_vn_i((int *)wtcol_v, me->totvert, col_i);
+ fill_vn_i((int *)wtcol_v, numVerts, col_i);
}
return wtcol_v;
}
-static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag)
+/* return an array of vertex weight colors from given weights, caller must free.
+ *
+ * note that we could save some memory and allocate RGB only but then we'd need to
+ * re-arrange the colors when copying to the face since MCol has odd ordering,
+ * so leave this as is - campbell */
+static unsigned char *calc_colors_from_weights_array(const int num, float *weights)
{
- ColorBand *coba= stored_cb; /* warning, not a local var */
+ unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * num * 4, "weightmap_v");
+ unsigned char *wc = wtcol_v;
+ int i;
- Mesh *me = ob->data;
- unsigned char *wtcol_v = calc_weightpaint_vert_array(ob, draw_flag, coba);
- unsigned char *wtcol_f = MEM_mallocN (sizeof(unsigned char) * me->totface*4*4, "weightmap_f");
- unsigned char *wtcol_f_step = wtcol_f;
+ for (i = 0; i < num; i++, wc += 4, weights++)
+ weightpaint_color((unsigned char *) wc, NULL, *weights);
- MFace *mf = me->mface;
+ return wtcol_v;
+}
+
+void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
+ float *weights, int num, const int *indices)
+{
+ ColorBand *coba= stored_cb; /* warning, not a local var */
+
+ MFace *mf = dm->getFaceArray(dm);
+ int numFaces = dm->getNumFaces(dm);
+ int numVerts = dm->getNumVerts(dm);
+ unsigned char *wtcol_v;
+ unsigned char *wtcol_f = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL);
int i;
- for (i=0; i<me->totface; i++, mf++, wtcol_f_step += (4 * 4)) {
+ /* If no CD_WEIGHT_MCOL existed yet, add a new one! */
+ if (!wtcol_f)
+ wtcol_f = CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces);
+
+ if (wtcol_f) {
+ unsigned char *wtcol_f_step = wtcol_f;
+
+ /* Weights are given by caller. */
+ if (weights) {
+ float *w = weights;
+ /* If indices is not NULL, it means we do not have weights for all vertices,
+ * so we must create them (and set them to zero)... */
+ if(indices) {
+ w = MEM_callocN(sizeof(float)*numVerts, "Temp weight array DM_update_weight_mcol");
+ i = num;
+ while(i--)
+ w[indices[i]] = weights[i];
+ }
+
+ /* Convert float weights to colors. */
+ wtcol_v = calc_colors_from_weights_array(numVerts, w);
+
+ if(indices)
+ MEM_freeN(w);
+ }
+
+ /* No weights given, take them from active vgroup(s). */
+ else
+ wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, coba);
+
+ /* Now copy colors in all face verts. */
+ for (i = 0; i < numFaces; i++, mf++, wtcol_f_step += (4 * 4)) {
#if 0
- unsigned int fidx= mf->v4 ? 3:2;
+ unsigned int fidx= mf->v4 ? 3:2;
#else /* better zero out triangles 4th component. else valgrind complains when the buffer's copied */
- unsigned int fidx;
- if (mf->v4) {
- fidx = 3;
- }
- else {
- fidx = 2;
- *(int *)(&wtcol_f_step[3 * 4]) = 0;
- }
+ unsigned int fidx;
+ if (mf->v4) {
+ fidx = 3;
+ }
+ else {
+ fidx = 2;
+ *(int *)(&wtcol_f_step[3 * 4]) = 0;
+ }
#endif
- do {
- copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4],
- (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]);
- } while (fidx--);
+ do {
+ copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4],
+ (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]);
+ } while (fidx--);
+ }
+ MEM_freeN(wtcol_v);
}
-
- MEM_freeN(wtcol_v);
-
- CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol_f, dm->numFaceData);
}
/* new value for useDeform -1 (hack for the gameengine):
@@ -803,7 +848,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
int needMapping, CustomDataMask dataMask, int index, int useCache)
{
Mesh *me = ob->data;
- ModifierData *firstmd, *md;
+ ModifierData *firstmd, *md, *previewmd = NULL;
LinkNode *datamasks, *curr;
CustomDataMask mask, nextmask, append_mask = 0;
float (*deformedVerts)[3] = NULL;
@@ -816,8 +861,17 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
int has_multires = mmd != NULL, multires_applied = 0;
int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
- int draw_flag= ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) |
- (scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));
+ const int draw_flag= ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) |
+ (scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));
+ /* Generic preview only in object mode! */
+ const int do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
+#if 0 /* XXX Will re-enable this when we have global mod stack options. */
+ const int do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol;
+#endif
+ const int do_final_wmcol = FALSE;
+ int do_init_wmcol = ((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol);
+ /* XXX Same as above... For now, only weights preview in WPaint mode. */
+ const int do_mod_wmcol = do_init_wmcol;
if(mmd && !mmd->sculptlvl)
has_multires = 0;
@@ -842,6 +896,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode);
curr = datamasks;
+ if(do_mod_wmcol || do_mod_mcol) {
+ /* Find the last active modifier generating a preview, or NULL if none. */
+ /* XXX Currently, DPaint modifier just ignores this.
+ * Needs a stupid hack...
+ * The whole "modifier preview" thing has to be (re?)designed, anyway! */
+ previewmd = modifiers_getLastPreview(scene, md, required_mode);
+ }
+
if(deform_r) *deform_r = NULL;
*final_r = NULL;
@@ -997,8 +1059,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
CDDM_calc_normals(dm);
}
- if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
- add_weight_mcol_dm(ob, dm, draw_flag);
+ if(do_init_wmcol)
+ DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL);
/* Constructive modifiers need to have an origindex
* otherwise they wont have anywhere to copy the data from.
@@ -1085,8 +1147,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
}
/* in case of dynamic paint, make sure preview mask remains for following modifiers */
+ /* XXX Temp and hackish solution! */
if (md->type == eModifierType_DynamicPaint)
append_mask |= CD_MASK_WEIGHT_MCOL;
+ /* In case of active preview modifier, make sure preview mask remains for following modifiers. */
+ else if ((md == previewmd) && (do_mod_wmcol)) {
+ DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL);
+ append_mask |= CD_MASK_WEIGHT_MCOL;
+ }
}
isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform);
@@ -1114,10 +1182,19 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
CDDM_apply_vert_coords(finaldm, deformedVerts);
CDDM_calc_normals(finaldm);
- if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
- add_weight_mcol_dm(ob, finaldm, draw_flag);
+#if 0 /* For later nice mod preview! */
+ /* In case we need modified weights in CD_WEIGHT_MCOL, we have to re-compute it. */
+ if(do_final_wmcol)
+ DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
+#endif
} else if(dm) {
finaldm = dm;
+
+#if 0 /* For later nice mod preview! */
+ /* In case we need modified weights in CD_WEIGHT_MCOL, we have to re-compute it. */
+ if(do_final_wmcol)
+ DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
+#endif
} else {
finaldm = CDDM_from_mesh(me, ob);
@@ -1126,8 +1203,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
CDDM_calc_normals(finaldm);
}
- if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
- add_weight_mcol_dm(ob, finaldm, draw_flag);
+ /* In this case, we should never have weight-modifying modifiers in stack... */
+ if(do_init_wmcol)
+ DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
}
/* add an orco layer if needed */
@@ -2313,3 +2391,79 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm)
#endif /* WITH_GAMEENGINE */
/* --- NAVMESH (end) --- */
+
+
+/* derivedmesh info printing function,
+ * to help track down differences DM output */
+
+#ifndef NDEBUG
+#include "BLI_dynstr.h"
+
+static void dm_debug_info_layers(DynStr *dynstr, DerivedMesh *dm, void *(*getElemDataArray)(DerivedMesh *, int))
+{
+ int type;
+
+ for (type = 0; type < CD_NUMTYPES; type++) {
+ /* note: doesnt account for multiple layers */
+ void *pt = getElemDataArray(dm, type);
+ if (pt) {
+ const char *name = CustomData_layertype_name(type);
+ const int size = CustomData_sizeof(type);
+ const char *structname;
+ int structnum;
+ CustomData_file_write_info(type, &structname, &structnum);
+ BLI_dynstr_appendf(dynstr,
+ " dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
+ name, structname, type, (void *)pt, size, (int)(MEM_allocN_len(pt) / size));
+ }
+ }
+}
+
+char *DM_debug_info(DerivedMesh *dm)
+{
+ DynStr *dynstr= BLI_dynstr_new();
+ char *ret;
+ const char *tstr;
+
+ BLI_dynstr_appendf(dynstr, "{\n");
+ BLI_dynstr_appendf(dynstr, " 'ptr': '%p',\n", (void *)dm);
+ switch (dm->type) {
+ case DM_TYPE_CDDM: tstr = "DM_TYPE_CDDM"; break;
+ case DM_TYPE_EDITMESH: tstr = "DM_TYPE_EDITMESH"; break;
+ case DM_TYPE_CCGDM: tstr = "DM_TYPE_CCGDM"; break;
+ default: tstr = "UNKNOWN"; break;
+ }
+ BLI_dynstr_appendf(dynstr, " 'type': '%s',\n", tstr);
+ BLI_dynstr_appendf(dynstr, " 'numVertData': %d,\n", dm->numVertData);
+ BLI_dynstr_appendf(dynstr, " 'numEdgeData': %d,\n", dm->numEdgeData);
+ BLI_dynstr_appendf(dynstr, " 'numFaceData': %d,\n", dm->numFaceData);
+ BLI_dynstr_appendf(dynstr, " 'deformedOnly': %d,\n", dm->deformedOnly);
+
+ BLI_dynstr_appendf(dynstr, " 'vertexLayers': (\n");
+ dm_debug_info_layers(dynstr, dm, dm->getVertDataArray);
+ BLI_dynstr_appendf(dynstr, " ),\n");
+
+ BLI_dynstr_appendf(dynstr, " 'edgeLayers': (\n");
+ dm_debug_info_layers(dynstr, dm, dm->getEdgeDataArray);
+ BLI_dynstr_appendf(dynstr, " ),\n");
+
+ BLI_dynstr_appendf(dynstr, " 'faceLayers': (\n");
+ dm_debug_info_layers(dynstr, dm, dm->getFaceDataArray);
+ BLI_dynstr_appendf(dynstr, " ),\n");
+
+ BLI_dynstr_appendf(dynstr, "}\n");
+
+ ret = BLI_dynstr_get_cstring(dynstr);
+ BLI_dynstr_free(dynstr);
+ return ret;
+}
+
+void DM_debug_print(DerivedMesh *dm)
+{
+ char *str = DM_debug_info(dm);
+ printf("%s", str);
+ fflush(stdout);
+ MEM_freeN(str);
+}
+
+#endif /* NDEBUG */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 4f83bcf7e7f..64ea862477f 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -665,7 +665,7 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, Dua
}
/* using vec with dist to bone b1 - b2 */
-float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist)
+float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist)
{
float dist=0.0f;
float bdelta[3];
@@ -677,18 +677,18 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
sub_v3_v3v3(pdelta, vec, b1);
- a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2];
- hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2]));
+ a = dot_v3v3(bdelta, pdelta);
+ hsqr = dot_v3v3(pdelta, pdelta);
- if (a < 0.0F){
+ if (a < 0.0f) {
/* If we're past the end of the bone, do a spherical field attenuation thing */
- dist= ((b1[0]-vec[0])*(b1[0]-vec[0]) +(b1[1]-vec[1])*(b1[1]-vec[1]) +(b1[2]-vec[2])*(b1[2]-vec[2])) ;
+ dist = len_squared_v3v3(b1, vec);
rad= rad1;
}
- else if (a > l){
+ else if (a > l) {
/* If we're past the end of the bone, do a spherical field attenuation thing */
- dist= ((b2[0]-vec[0])*(b2[0]-vec[0]) +(b2[1]-vec[1])*(b2[1]-vec[1]) +(b2[2]-vec[2])*(b2[2]-vec[2])) ;
- rad= rad2;
+ dist = len_squared_v3v3(b2, vec);
+ rad = rad2;
}
else {
dist= (hsqr - (a*a));
@@ -709,7 +709,7 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
if(rdist==0.0f || dist >= l)
return 0.0f;
else {
- a= (float)sqrt(dist)-rad;
+ a = sqrtf(dist)-rad;
return 1.0f-( a*a )/( rdist*rdist );
}
}
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 362fa6e5e9a..f2514c1030b 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -527,7 +527,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
float xy[2], rgba[4], *dstf;
int x, y, rowbytes, xoff, yoff, imbflag;
const int radius= brush_size(scene, brush);
- char *dst, crgb[3];
+ unsigned char *dst, crgb[3];
const float alpha= brush_alpha(scene, brush);
float brush_rgb[3];
@@ -571,10 +571,10 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
}
else {
float alpha_f; /* final float alpha to convert to char */
- F3TOCHAR3(brush->rgb, crgb);
+ rgb_float_to_uchar(crgb, brush->rgb);
for (y=0; y < ibuf->y; y++) {
- dst = (char*)ibuf->rect + y*rowbytes;
+ dst = (unsigned char *)ibuf->rect + y*rowbytes;
for (x=0; x < ibuf->x; x++, dst+=4) {
xy[0] = x + xoff;
@@ -590,19 +590,15 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
}
else if (texfall == 1) {
brush_sample_tex(scene, brush, xy, rgba, 0);
- dst[0] = FTOCHAR(rgba[0]);
- dst[1] = FTOCHAR(rgba[1]);
- dst[2] = FTOCHAR(rgba[2]);
- dst[3] = FTOCHAR(rgba[3]);
+ rgba_float_to_uchar(dst, rgba);
}
else if (texfall == 2) {
brush_sample_tex(scene, brush, xy, rgba, 0);
mul_v3_v3(rgba, brush->rgb);
alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius);
- dst[0] = FTOCHAR(rgba[0]);
- dst[1] = FTOCHAR(rgba[1]);
- dst[2] = FTOCHAR(rgba[2]);
+ rgb_float_to_uchar(dst, rgba);
+
dst[3] = FTOCHAR(alpha_f);
}
else {
@@ -843,7 +839,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
Brush *brush= painter->brush;
ImBuf *ibuf, *maskibuf, *texibuf;
float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4];
- char *b, *m, *t, *ot= NULL;
+ unsigned char *b, *m, *t, *ot= NULL;
int dotexold, origx= x, origy= y;
const int radius= brush_size(painter->scene, brush);
@@ -895,12 +891,12 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
}
else {
for (; y < h; y++) {
- b = (char*)ibuf->rect + (y*ibuf->x + origx)*4;
- t = (char*)texibuf->rect + (y*texibuf->x + origx)*4;
- m = (char*)maskibuf->rect + (y*maskibuf->x + origx)*4;
+ b = (unsigned char *)ibuf->rect + (y*ibuf->x + origx)*4;
+ t = (unsigned char *)texibuf->rect + (y*texibuf->x + origx)*4;
+ m = (unsigned char *)maskibuf->rect + (y*maskibuf->x + origx)*4;
if (dotexold)
- ot = (char*)oldtexibuf->rect + ((y - origy + yt)*oldtexibuf->x + xt)*4;
+ ot = (unsigned char *)oldtexibuf->rect + ((y - origy + yt)*oldtexibuf->x + xt)*4;
for (x=origx; x < w; x++, b+=4, m+=4, t+=4) {
if (dotexold) {
@@ -915,10 +911,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
xy[1] = y + yoff;
brush_sample_tex(scene, brush, xy, rgba, 0);
- t[0]= FTOCHAR(rgba[0]);
- t[1]= FTOCHAR(rgba[1]);
- t[2]= FTOCHAR(rgba[2]);
- t[3]= FTOCHAR(rgba[3]);
+ rgba_float_to_uchar(t, rgba);
}
b[0] = t[0]*m[0]/255;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 73428c889dc..33adc2af284 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -130,6 +130,7 @@ void cloth_init ( ClothModifierData *clmd )
clmd->sim_parms->presets = 2; /* cotton as start setting */
clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
clmd->sim_parms->reset = 0;
+ clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */
clmd->coll_parms->self_friction = 5.0;
clmd->coll_parms->friction = 5.0;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 77a4a6a429c..8118cf64429 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2775,18 +2775,22 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
/* store Z orientation before destroying obmat */
normalize_v3_v3(zz, cob->matrix[2]);
- sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);
- vec[0] /= size[0];
- vec[1] /= size[1];
- vec[2] /= size[2];
+ /* XXX That makes the constraint buggy with asymmetrically scaled objects, see #29940. */
+/* sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);*/
+/* vec[0] /= size[0];*/
+/* vec[1] /= size[1];*/
+/* vec[2] /= size[2];*/
+
+/* dist = normalize_v3(vec);*/
- dist = normalize_v3(vec);
- //dist = len_v3v3( ob->obmat[3], targetmat[3]);
+ dist = len_v3v3(cob->matrix[3], ct->matrix[3]);
+ /* Only Y constrained object axis scale should be used, to keep same length when scaling it. */
+ dist /= size[1];
/* data->orglength==0 occurs on first run, and after 'R' button is clicked */
- if (data->orglength == 0)
+ if (data->orglength == 0)
data->orglength = dist;
- if (data->bulge == 0)
+ if (data->bulge == 0)
data->bulge = 1.0;
scale[1] = dist/data->orglength;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 0f1c73c59c1..6536dfb529e 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -368,9 +368,8 @@ void tex_space_curve(Curve *cu)
dl= cu->disp.first;
while(dl) {
- if(dl->type==DL_INDEX3 || dl->type==DL_INDEX3) tot= dl->nr;
- else tot= dl->nr*dl->parts;
-
+ tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts;
+
if(tot) doit= 1;
fp= dl->verts;
while(tot--) {
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 50f42328043..501b97bd9be 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -97,6 +97,10 @@ static int neighY[8] = {0,1,1, 1, 0,-1,-1,-1};
/* brush mesh raycast status */
#define HIT_VOLUME 1
#define HIT_PROXIMITY 2
+/* dynamicPaint_findNeighbourPixel() return codes */
+#define NOT_FOUND -1
+#define ON_MESH_EDGE -2
+#define OUT_OF_TEXTURE -3
/* paint effect default movement per frame in global units */
#define EFF_MOVEMENT_PER_FRAME 0.05f
/* initial wave time factor */
@@ -134,10 +138,10 @@ typedef struct Vec3f {
float v[3];
} Vec3f;
-typedef struct BakeNeighPoint {
+typedef struct BakeAdjPoint {
float dir[3]; /* vector pointing towards this neighbour */
float dist; /* distance to */
-} BakeNeighPoint;
+} BakeAdjPoint;
/* Surface data used while processing a frame */
typedef struct PaintBakeNormal {
@@ -156,7 +160,7 @@ typedef struct PaintBakeData {
Bounds3D mesh_bounds;
/* adjacency info */
- BakeNeighPoint *bNeighs; /* current global neighbour distances and directions, if required */
+ BakeAdjPoint *bNeighs; /* current global neighbour distances and directions, if required */
double average_dist;
/* space partitioning */
VolumeGrid *grid; /* space partitioning grid to optimize brush checks */
@@ -188,12 +192,6 @@ typedef struct ImgSeqFormatData {
Vec3f *barycentricWeights; /* b-weights for all pixel samples */
} ImgSeqFormatData;
-typedef struct EffVelPoint {
- float previous_pos[3];
- float previous_vel[3];
-} EffVelPoint;
-
-
/* adjacency data flags */
#define ADJ_ON_MESH_EDGE (1<<0)
@@ -469,19 +467,25 @@ static void object_cacheIgnoreClear(Object *ob, int state)
BLI_freelistN(&pidlist);
}
-static void subframe_updateObject(Scene *scene, Object *ob, int flags, float frame)
+static int subframe_updateObject(Scene *scene, Object *ob, int flags, float frame)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
bConstraint *con;
/* if other is dynamic paint canvas, dont update */
if (pmd && pmd->canvas)
- return;
+ return 1;
/* if object has parents, update them too */
if (flags & UPDATE_PARENTS) {
- if (ob->parent) subframe_updateObject(scene, ob->parent, 0, frame);
- if (ob->track) subframe_updateObject(scene, ob->track, 0, frame);
+ int is_canvas = 0;
+ if (ob->parent) is_canvas += subframe_updateObject(scene, ob->parent, 0, frame);
+ if (ob->track) is_canvas += subframe_updateObject(scene, ob->track, 0, frame);
+
+ /* skip subframe if object is parented
+ * to vertex of a dynamic paint canvas */
+ if (is_canvas && (ob->partype == PARVERT1 || ob->partype == PARVERT3))
+ return 0;
/* also update constraint targets */
for (con = ob->constraints.first; con; con=con->next) {
@@ -518,6 +522,8 @@ static void subframe_updateObject(Scene *scene, Object *ob, int flags, float fra
}
else
where_is_object_time(scene, ob, frame);
+
+ return 0;
}
static void scene_setSubframe(Scene *scene, float subframe)
@@ -1221,7 +1227,7 @@ static int surface_usesAdjData(DynamicPaintSurface *surface)
static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int force_init)
{
PaintSurfaceData *sData = surface->data;
- PaintAdjData *ed;
+ PaintAdjData *ad;
int *temp_data;
int neigh_points = 0;
@@ -1237,17 +1243,17 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
if (!neigh_points) return;
/* allocate memory */
- ed = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj Data");
- if (!ed) return;
- ed->n_index = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Index");
- ed->n_num = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Counts");
+ ad = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj Data");
+ if (!ad) return;
+ ad->n_index = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Index");
+ ad->n_num = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Counts");
temp_data = MEM_callocN(sizeof(int)*sData->total_points, "Temp Adj Data");
- ed->n_target = MEM_callocN(sizeof(int)*neigh_points, "Surface Adj Targets");
- ed->flags = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Flags");
- ed->total_targets = neigh_points;
+ ad->n_target = MEM_callocN(sizeof(int)*neigh_points, "Surface Adj Targets");
+ ad->flags = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Flags");
+ ad->total_targets = neigh_points;
/* in case of allocation error, free memory */
- if (!ed->n_index || !ed->n_num || !ed->n_target || !temp_data) {
+ if (!ad->n_index || !ad->n_num || !ad->n_target || !temp_data) {
dynamicPaint_freeAdjData(sData);
if (temp_data) MEM_freeN(temp_data);
setError(surface->canvas, "Not enough free memory.");
@@ -1266,14 +1272,15 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
/* count number of edges per vertex */
for (i=0; i<numOfEdges; i++) {
- ed->n_num[edge[i].v1]++;
- ed->n_num[edge[i].v2]++;
+ ad->n_num[edge[i].v1]++;
+ ad->n_num[edge[i].v2]++;
temp_data[edge[i].v1]++;
temp_data[edge[i].v2]++;
}
- /* to locate points on "mesh edge" */
+ /* also add number of vertices to temp_data
+ * to locate points on "mesh edge" */
for (i=0; i<numOfFaces; i++) {
temp_data[face[i].v1]++;
temp_data[face[i].v2]++;
@@ -1287,7 +1294,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
for (i=0; i<sData->total_points; i++) {
if ((temp_data[i]%2) ||
temp_data[i] < 4)
- ed->flags[i] |= ADJ_ON_MESH_EDGE;
+ ad->flags[i] |= ADJ_ON_MESH_EDGE;
/* reset temp data */
temp_data[i] = 0;
@@ -1296,22 +1303,22 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
/* order n_index array */
n_pos = 0;
for (i=0; i<sData->total_points; i++) {
- ed->n_index[i] = n_pos;
- n_pos += ed->n_num[i];
+ ad->n_index[i] = n_pos;
+ n_pos += ad->n_num[i];
}
/* and now add neighbour data using that info */
for (i=0; i<numOfEdges; i++) {
/* first vertex */
int index = edge[i].v1;
- n_pos = ed->n_index[index]+temp_data[index];
- ed->n_target[n_pos] = edge[i].v2;
+ n_pos = ad->n_index[index]+temp_data[index];
+ ad->n_target[n_pos] = edge[i].v2;
temp_data[index]++;
/* second vertex */
index = edge[i].v2;
- n_pos = ed->n_index[index]+temp_data[index];
- ed->n_target[n_pos] = edge[i].v1;
+ n_pos = ad->n_index[index]+temp_data[index];
+ ad->n_target[n_pos] = edge[i].v1;
temp_data[index]++;
}
}
@@ -1499,10 +1506,11 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
{
int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface);
- /* dont touch image sequence types. they get handled only on bake */
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 1;
-
+ /* free existing data */
if (surface->data) dynamicPaint_freeSurfaceData(surface);
+
+ /* dont reallocate for image sequence types. they get handled only on bake */
+ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 1;
if (numOfPoints < 1) return 0;
/* allocate memory */
@@ -1573,7 +1581,6 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
int update_normals = 0;
- pmd->canvas->flags &= ~MOD_DPAINT_PREVIEW_READY;
/* loop through surfaces */
for (; surface; surface=surface->next) {
@@ -1613,11 +1620,11 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
if (col) {
#pragma omp parallel for schedule(static)
for (i=0; i<numOfFaces; i++) {
- int j=0;
+ int j = (mface[i].v4) ? 4 : 3;
Material *material = give_current_material(ob, mface[i].mat_nr+1);
- for (; j<((mface[i].v4)?4:3); j++) {
- int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4;
+ while (j--) {
+ int index = *((&mface[i].v1)+j);
if (surface->preview_id == MOD_DPAINT_SURFACE_PREV_PAINT) {
float c[3];
@@ -1650,7 +1657,6 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
}
}
}
- pmd->canvas->flags |= MOD_DPAINT_PREVIEW_READY;
}
}
@@ -1666,9 +1672,9 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
if (col) {
#pragma omp parallel for schedule(static)
for (i=0; i<numOfFaces; i++) {
- int j=0;
- for (; j<((mface[i].v4)?4:3); j++) {
- int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4;
+ int j = (mface[i].v4) ? 4 : 3;
+ while (j--) {
+ int index = *((&mface[i].v1)+j);
index *= 4;
col[i*4+j].a = FTOCHAR(fcolor[index+3]);
@@ -1690,10 +1696,9 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
if (col) {
#pragma omp parallel for schedule(static)
for (i=0; i<numOfFaces; i++) {
- int j=0;
-
- for (; j<((mface[i].v4)?4:3); j++) {
- int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4;
+ int j = (mface[i].v4) ? 4 : 3;
+ while (j--) {
+ int index = *((&mface[i].v1)+j);
col[i*4+j].a = 255;
col[i*4+j].r =
col[i*4+j].g =
@@ -1711,29 +1716,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
if (surface->flags & MOD_DPAINT_PREVIEW) {
/* Save preview results to weight layer, to be
* able to share same drawing methods */
- MFace *mface = result->getFaceArray(result);
- int numOfFaces = result->getNumFaces(result);
- int i;
- MCol *col = result->getFaceDataArray(result, CD_WEIGHT_MCOL);
- if (!col) col = CustomData_add_layer(&result->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numOfFaces);
-
- if (col) {
- #pragma omp parallel for schedule(static)
- for (i=0; i<numOfFaces; i++) {
- float temp_color[3];
- int j=0;
- for (; j<((mface[i].v4)?4:3); j++) {
- int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4;
-
- weight_to_rgb(temp_color, weight[index]);
- col[i*4+j].r = FTOCHAR(temp_color[2]);
- col[i*4+j].g = FTOCHAR(temp_color[1]);
- col[i*4+j].b = FTOCHAR(temp_color[0]);
- col[i*4+j].a = 255;
- }
- }
- pmd->canvas->flags |= MOD_DPAINT_PREVIEW_READY;
- }
+ DM_update_weight_mcol(ob, result, 0, weight, 0, NULL);
}
/* apply weights into a vertex group, if doesnt exists add a new layer */
@@ -1923,8 +1906,8 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
x = px + neighX[n_index];
y = py + neighY[n_index];
- if (x<0 || x>=w) return -1;
- if (y<0 || y>=h) return -1;
+ if (x<0 || x>=w) return OUT_OF_TEXTURE;
+ if (y<0 || y>=h) return OUT_OF_TEXTURE;
tPoint = &tempPoints[x+w*y]; /* UV neighbour */
cPoint = &tempPoints[px+w*py]; /* Origin point */
@@ -2037,8 +2020,8 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
}
}
- /* If none found return -1 */
- if (target_face == -1) return -1;
+ /* If none found pixel is on mesh edge */
+ if (target_face == -1) return ON_MESH_EDGE;
/*
* If target face is connected in UV space as well, just use original index
@@ -2076,15 +2059,15 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
final_pixel[1] = (int)floor(pixel[1]);
/* If current pixel uv is outside of texture */
- if (final_pixel[0] < 0 || final_pixel[0] >= w) return -1;
- if (final_pixel[1] < 0 || final_pixel[1] >= h) return -1;
+ if (final_pixel[0] < 0 || final_pixel[0] >= w) return OUT_OF_TEXTURE;
+ if (final_pixel[1] < 0 || final_pixel[1] >= h) return OUT_OF_TEXTURE;
final_index = final_pixel[0] + w * final_pixel[1];
/* If we ended up to our origin point ( mesh has smaller than pixel sized faces) */
- if (final_index == (px+w*py)) return -1;
+ if (final_index == (px+w*py)) return NOT_FOUND;
/* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces) */
- if (tempPoints[final_index].face_index != target_face) return -1;
+ if (tempPoints[final_index].face_index != target_face) return NOT_FOUND;
/*
* If final point is an "edge pixel", use it's "real" neighbour instead
@@ -2466,11 +2449,14 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
* If not found, -1 is returned */
int n_target = dynamicPaint_findNeighbourPixel(tempPoints, dm, uvname, w, h, tx, ty, i);
- if (n_target != -1) {
+ if (n_target >= 0) {
ed->n_target[n_pos] = final_index[n_target];
ed->n_num[final_index[index]]++;
n_pos++;
}
+ else if (n_target == ON_MESH_EDGE || n_target == OUT_OF_TEXTURE) {
+ ed->flags[final_index[index]] |= ADJ_ON_MESH_EDGE;
+ }
}
}
}
@@ -3171,8 +3157,8 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
mul_m4_v3(brushOb->obmat, mvert[ii].co);
boundInsert(&mesh_bb, mvert[ii].co);
- /* for project brush calculate average normal */
- if (brush->collision & MOD_DPAINT_COL_DIST && brush->flags & MOD_DPAINT_PROX_PROJECT) {
+ /* for proximity project calculate average normal */
+ if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) {
float nor[3];
normal_short_to_float_v3(nor, mvert[ii].no);
mul_mat3_m4_v3(brushOb->obmat, nor);
@@ -3182,7 +3168,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
}
}
- if (brush->collision & MOD_DPAINT_COL_DIST && brush->flags & MOD_DPAINT_PROX_PROJECT) {
+ if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) {
mul_v3_fl(avg_brushNor, 1.0f/(float)numOfVerts);
/* instead of null vector use positive z */
if (!(MIN3(avg_brushNor[0],avg_brushNor[1],avg_brushNor[2])))
@@ -3323,7 +3309,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
if (inner_proximity && !hit_found) continue;
/* If pure distance proximity, find the nearest point on the mesh */
- if (brush->collision != MOD_DPAINT_COL_DIST || !(brush->flags & MOD_DPAINT_PROX_PROJECT)) {
+ if (!(brush->flags & MOD_DPAINT_PROX_PROJECT)) {
if (BLI_bvhtree_find_nearest(treeData.tree, ray_start, &nearest, mesh_faces_nearest_point_dp, &treeData) != -1) {
proxDist = sqrtf(nearest.dist);
copy_v3_v3(hitCo, nearest.co);
@@ -3879,14 +3865,13 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po
/***************************** Dynamic Paint Step / Baking ******************************/
/*
-* Calculate current frame neighbouring point distances
-* and direction vectors
+* Calculate current frame distances and directions for adjacency data
*/
-static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int force_init)
+static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int force_init)
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
- BakeNeighPoint *bNeighs;
+ BakeAdjPoint *bNeighs;
PaintAdjData *adj_data = sData->adj_data;
Vec3f *realCoord = bData->realCoord;
int index;
@@ -3894,7 +3879,7 @@ static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int
if ((!surface_usesAdjDistance(surface) && !force_init) || !sData->adj_data) return;
if (bData->bNeighs) MEM_freeN(bData->bNeighs);
- bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeNeighPoint),"PaintEffectBake");
+ bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeAdjPoint),"PaintEffectBake");
if (!bNeighs) return;
#pragma omp parallel for schedule(static)
@@ -3933,7 +3918,7 @@ static void dynamicPaint_prepareNeighbourData(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])
{
- BakeNeighPoint *bNeighs = sData->bData->bNeighs;
+ BakeAdjPoint *bNeighs = sData->bData->bNeighs;
int numOfNeighs = sData->adj_data->n_num[index];
int i;
@@ -4002,7 +3987,7 @@ static void dynamicPaint_doSmudge(DynamicPaintSurface *surface, DynamicPaintBrus
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
- BakeNeighPoint *bNeighs = sData->bData->bNeighs;
+ BakeAdjPoint *bNeighs = sData->bData->bNeighs;
int index, steps, step;
float eff_scale, max_velocity = 0.0f;
@@ -4161,7 +4146,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force, PaintPoint *prevPoint, float timescale, float steps)
{
PaintSurfaceData *sData = surface->data;
- BakeNeighPoint *bNeighs = sData->bData->bNeighs;
+ BakeAdjPoint *bNeighs = sData->bData->bNeighs;
float distance_scale = getSurfaceDimension(sData)/CANVAS_REL_SIZE;
int index;
timescale /= steps;
@@ -4190,7 +4175,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
/* Loop through neighbouring points */
for (i=0; i<numOfNeighs; i++) {
int n_index = sData->adj_data->n_index[index]+i;
- float w_factor /* , p_alpha = pPoint->e_alpha */ /* UNUSED */;
+ float w_factor;
PaintPoint *ePoint = &prevPoint[sData->adj_data->n_target[n_index]];
float speed_scale = (bNeighs[n_index].dist<eff_scale) ? 1.0f : eff_scale/bNeighs[n_index].dist;
float color_mix = (MIN3(ePoint->wetness, pPoint->wetness, 1.0f))*0.25f*surface->color_spread_speed;
@@ -4327,7 +4312,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale)
{
PaintSurfaceData *sData = surface->data;
- BakeNeighPoint *bNeighs = sData->bData->bNeighs;
+ BakeAdjPoint *bNeighs = sData->bData->bNeighs;
int index;
int steps, ss;
float dt, min_dist, damp_factor;
@@ -4760,8 +4745,8 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
/* generate surface space partitioning grid */
surfaceGenerateGrid(surface);
- /* calculate current frame neighbouring point distances and global dirs */
- dynamicPaint_prepareNeighbourData(surface, 0);
+ /* calculate current frame adjacency point distances and global dirs */
+ dynamicPaint_prepareAdjacencyData(surface, 0);
/* Copy current frame vertices to check against in next frame */
copy_m4_m4(bData->prev_obmat, ob->obmat);
@@ -4844,7 +4829,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
if (!sData->adj_data)
dynamicPaint_initAdjacencyData(surface, 1);
if (!bData->bNeighs)
- dynamicPaint_prepareNeighbourData(surface, 1);
+ dynamicPaint_prepareAdjacencyData(surface, 1);
}
/* update object data on this subframe */
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index ce337608cc5..0a80e8a3d56 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1111,9 +1111,9 @@ int BKE_add_image_extension(char *string, const char imtype)
if(BLI_testextensie_array(string, imb_ext_image)
|| (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt))) {
return BLI_replace_extension(string, FILE_MAX, extension);
- } else {
+ }
+ else {
return BLI_ensure_extension(string, FILE_MAX, extension);
- return TRUE;
}
}
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index a93d0221cf0..c6cb8c9582a 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -33,7 +33,7 @@
#include "BLI_math_base.h"
#include "BLF_api.h"
-void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4])
+void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, const float color[4])
{
int x, y;
@@ -41,22 +41,17 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
if(rect_float) {
for(y= 0; y<height; y++) {
for(x= 0; x<width; x++) {
- rect_float[0]= color[0];
- rect_float[1]= color[1];
- rect_float[2]= color[2];
- rect_float[3]= color[3];
+ copy_v4_v4(rect_float, color);
rect_float+= 4;
}
}
}
if(rect) {
- char ccol[4];
+ unsigned char ccol[4];
+
+ rgba_float_to_uchar(ccol, color);
- ccol[0]= (char)(color[0]*255.0f);
- ccol[1]= (char)(color[1]*255.0f);
- ccol[2]= (char)(color[2]*255.0f);
- ccol[3]= (char)(color[3]*255.0f);
for(y= 0; y<height; y++) {
for(x= 0; x<width; x++) {
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 00a2de369a3..757d3ddf9ac 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1852,6 +1852,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
while(step < tf)
{
+ // damping velocity for artistic reasons
+ mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
+
// calculate forces
cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step, id->M);
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index eb7d07a6f7d..b2385a5cdb8 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -377,7 +377,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
if(k1->next==NULL) k[0]=k1;
k1=k1->next;
}
- k1= k[1];
+ /* k1= k[1]; */ /* UNUSED */
t[0]= k[0]->pos;
t[1]+= dpos;
t[2]= k[2]->pos + dpos;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 189ce890c2f..cba92e7a14c 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -42,12 +42,12 @@
#include "DNA_meshdata_types.h"
#include "DNA_ipo_types.h"
+#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_bpath.h"
#include "BLI_editVert.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
-#include "BLI_utildefines.h"
#include "BKE_animsys.h"
#include "BKE_main.h"
@@ -1292,11 +1292,11 @@ float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3]
{
int i, numVerts = me->totvert;
float (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos1");
-
+
if (numVerts_r) *numVerts_r = numVerts;
for (i=0; i<numVerts; i++)
- VECCOPY(cos[i], me->mvert[i].co);
-
+ copy_v3_v3(cos[i], me->mvert[i].co);
+
return cos;
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 5a389019519..911d303b4cf 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -142,6 +142,19 @@ int modifier_supportsMapping(ModifierData *md)
(mti->flags & eModifierTypeFlag_SupportsMapping));
}
+int modifier_isPreview(ModifierData *md)
+{
+ ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+
+ if (!(mti->flags & eModifierTypeFlag_UsesPreview))
+ return FALSE;
+
+ if (md->mode & eModifierMode_Realtime)
+ return TRUE;
+
+ return FALSE;
+}
+
ModifierData *modifiers_findByType(Object *ob, ModifierType type)
{
ModifierData *md = ob->modifiers.first;
@@ -385,6 +398,21 @@ LinkNode *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierData
return dataMasks;
}
+ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, int required_mode)
+{
+ ModifierData *tmp_md = NULL;
+
+ if (required_mode != eModifierMode_Realtime)
+ return tmp_md;
+
+ /* Find the latest modifier in stack generating preview. */
+ for(; md; md = md->next) {
+ if(modifier_isEnabled(scene, md, required_mode) && modifier_isPreview(md))
+ tmp_md = md;
+ }
+ return tmp_md;
+}
+
ModifierData *modifiers_getVirtualModifierList(Object *ob)
{
/* Kinda hacky, but should be fine since we are never
@@ -545,6 +573,20 @@ int modifiers_isCorrectableDeformed(Object *ob)
return 0;
}
+/* Check whether the given object has a modifier in its stack that uses WEIGHT_MCOL CD layer
+ * to preview something... Used by DynamicPaint and WeightVG currently. */
+int modifiers_isPreview(Object *ob)
+{
+ ModifierData *md = ob->modifiers.first;
+
+ for (; md; md = md->next) {
+ if (modifier_isPreview(md))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
int modifiers_indexInObject(Object *ob, ModifierData *md_seek)
{
int i= 0;
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 3b1dc2973ad..bb8e420451f 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -981,7 +981,7 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i
{
char name[FILE_MAX];
int quality, rectx, recty;
- int size= size= rendersize_to_number(proxy_render_size);
+ int size= rendersize_to_number(proxy_render_size);
ImBuf *scaleibuf;
get_proxy_fname(clip, proxy_render_size, undistorted, cfra, name);
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index fd184b9def4..12f403d028f 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -1448,9 +1448,17 @@ void BKE_nla_validate_state (AnimData *adt)
*/
// TODO: 1 solution is to tie this in with auto-blending...
if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
+ /* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy
+ * 2) Only overwrite extend mode if *not* changing it will most probably result in
+ * occlusion problems, which will occur iff
+ * - blendmode = REPLACE
+ * - all channels the same (this is fiddly to test, so is currently assumed)
+ *
+ * Should fix problems such as [#29869]
+ */
if (strip == fstrip)
strip->extendmode= NLASTRIP_EXTEND_HOLD;
- else
+ else if (strip->blendmode == NLASTRIP_MODE_REPLACE)
strip->extendmode= NLASTRIP_EXTEND_HOLD_FORWARD;
}
}
@@ -1542,6 +1550,34 @@ short BKE_nla_tweakmode_enter (AnimData *adt)
break;
}
}
+
+ /* There are situations where we may have multiple strips selected and we want to enter tweakmode on all
+ * of those at once. Usually in those cases, it will usually just be a single strip per AnimData.
+ * In such cases, compromise and take the last selected track and/or last selected strip [#28468]
+ */
+ if (activeTrack == NULL) {
+ /* try last selected track for active strip */
+ for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) {
+ if (nlt->flag & NLATRACK_SELECTED) {
+ /* assume this is the active track */
+ activeTrack= nlt;
+
+ /* try to find active strip */
+ activeStrip= BKE_nlastrip_find_active(nlt);
+ break;
+ }
+ }
+ }
+ if ((activeTrack) && (activeStrip == NULL)) {
+ /* no active strip in active or last selected track; compromise for first selected (assuming only single)... */
+ for (strip = activeTrack->strips.first; strip; strip= strip->next) {
+ if (strip->flag & (NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE)) {
+ activeStrip = strip;
+ break;
+ }
+ }
+ }
+
if ELEM3(NULL, activeTrack, activeStrip, activeStrip->act) {
if (G.f & G_DEBUG) {
printf("NLA tweakmode enter - neither active requirement found \n");
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 359470eecf2..b72abcd79f4 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -159,7 +159,6 @@ void ntreeInitTypes(bNodeTree *ntree)
static bNodeSocket *make_socket(bNodeTree *UNUSED(ntree), int in_out, const char *name, int type)
{
- bNodeSocketType *stype= ntreeGetSocketType(type);
bNodeSocket *sock;
sock= MEM_callocN(sizeof(bNodeSocket), "sock");
@@ -169,8 +168,8 @@ static bNodeSocket *make_socket(bNodeTree *UNUSED(ntree), int in_out, const char
sock->type= type;
sock->storage = NULL;
- if (stype->value_structsize > 0)
- sock->default_value = MEM_callocN(stype->value_structsize, "default socket value");
+ sock->default_value = node_socket_make_default_value(type);
+ node_socket_init_default_value(type, sock->default_value);
return sock;
}
@@ -216,8 +215,7 @@ void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock)
BLI_remlink(&node->inputs, sock);
BLI_remlink(&node->outputs, sock);
- if (sock->default_value)
- MEM_freeN(sock->default_value);
+ node_socket_free_default_value(sock->type, sock->default_value);
MEM_freeN(sock);
node->update |= NODE_UPDATE;
@@ -236,13 +234,10 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
}
for (sock=node->inputs.first; sock; sock=sock->next)
- if (sock->default_value)
- MEM_freeN(sock->default_value);
+ node_socket_free_default_value(sock->type, sock->default_value);
BLI_freelistN(&node->inputs);
for (sock=node->outputs.first; sock; sock=sock->next)
- if (sock->default_value)
- MEM_freeN(sock->default_value);
-
+ node_socket_free_default_value(sock->type, sock->default_value);
BLI_freelistN(&node->outputs);
node->update |= NODE_UPDATE;
@@ -396,7 +391,8 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
oldsock->new_sock= sock;
sock->stack_index= 0;
- sock->default_value = (oldsock->default_value ? MEM_dupallocN(oldsock->default_value) : NULL);
+ sock->default_value = node_socket_make_default_value(oldsock->type);
+ node_socket_copy_default_value(oldsock->type, sock->default_value, oldsock->default_value);
/* XXX some compositor node (e.g. image, render layers) still store
* some persistent buffer data here, need to clear this to avoid dangling pointers.
@@ -410,7 +406,8 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
oldsock->new_sock= sock;
sock->stack_index= 0;
- sock->default_value = (oldsock->default_value ? MEM_dupallocN(oldsock->default_value) : NULL);
+ sock->default_value = node_socket_make_default_value(oldsock->type);
+ node_socket_copy_default_value(oldsock->type, sock->default_value, oldsock->default_value);
/* XXX some compositor node (e.g. image, render layers) still store
* some persistent buffer data here, need to clear this to avoid dangling pointers.
@@ -658,13 +655,15 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree)
for(gsock= newtree->inputs.first, oldgsock= ntree->inputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
oldgsock->new_sock= gsock;
gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL);
- gsock->default_value = (oldgsock->default_value ? MEM_dupallocN(oldgsock->default_value) : NULL);
+ gsock->default_value = node_socket_make_default_value(oldgsock->type);
+ node_socket_copy_default_value(oldgsock->type, gsock->default_value, oldgsock->default_value);
}
BLI_duplicatelist(&newtree->outputs, &ntree->outputs);
for(gsock= newtree->outputs.first, oldgsock= ntree->outputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
oldgsock->new_sock= gsock;
gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL);
- gsock->default_value = (oldgsock->default_value ? MEM_dupallocN(oldgsock->default_value) : NULL);
+ gsock->default_value = node_socket_make_default_value(oldgsock->type);
+ node_socket_copy_default_value(oldgsock->type, gsock->default_value, oldgsock->default_value);
}
/* copy links */
@@ -790,16 +789,11 @@ void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x);
if(do_manage) {
- tar[0]= FTOCHAR(linearrgb_to_srgb(col[0]));
- tar[1]= FTOCHAR(linearrgb_to_srgb(col[1]));
- tar[2]= FTOCHAR(linearrgb_to_srgb(col[2]));
+ linearrgb_to_srgb_uchar4(tar, col);
}
else {
- tar[0]= FTOCHAR(col[0]);
- tar[1]= FTOCHAR(col[1]);
- tar[2]= FTOCHAR(col[2]);
+ rgba_float_to_uchar(tar, col);
}
- tar[3]= FTOCHAR(col[3]);
}
//else printf("prv out bound x y %d %d\n", x, y);
}
@@ -868,14 +862,12 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
for (sock=node->inputs.first; sock; sock = nextsock) {
nextsock = sock->next;
- if (sock->default_value)
- MEM_freeN(sock->default_value);
+ node_socket_free_default_value(sock->type, sock->default_value);
MEM_freeN(sock);
}
for (sock=node->outputs.first; sock; sock = nextsock) {
nextsock = sock->next;
- if (sock->default_value)
- MEM_freeN(sock->default_value);
+ node_socket_free_default_value(sock->type, sock->default_value);
MEM_freeN(sock);
}
@@ -929,12 +921,10 @@ void ntreeFreeTree(bNodeTree *ntree)
}
for (sock=ntree->inputs.first; sock; sock=sock->next)
- if (sock->default_value)
- MEM_freeN(sock->default_value);
+ node_socket_free_default_value(sock->type, sock->default_value);
BLI_freelistN(&ntree->inputs);
for (sock=ntree->outputs.first; sock; sock=sock->next)
- if (sock->default_value)
- MEM_freeN(sock->default_value);
+ node_socket_free_default_value(sock->type, sock->default_value);
BLI_freelistN(&ntree->outputs);
}
@@ -1891,6 +1881,7 @@ static void registerShaderNodes(bNodeTreeType *ttype)
register_node_type_sh_material(ttype);
register_node_type_sh_camera(ttype);
register_node_type_sh_gamma(ttype);
+ register_node_type_sh_brightcontrast(ttype);
register_node_type_sh_value(ttype);
register_node_type_sh_rgb(ttype);
register_node_type_sh_mix_rgb(ttype);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 4afe9412786..5bb0ffbb76a 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1126,6 +1126,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
fprintf(stderr,"Particle distribution error: Nothing to emit from!\n");
if(dm != finaldm) dm->release(dm);
+
+ BLI_kdtree_free(tree);
+
return 0;
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 281631168cd..c8ec71d512f 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -531,6 +531,8 @@ Scene *add_scene(const char *name)
sce->gm.recastData.detailsampledist = 6.0f;
sce->gm.recastData.detailsamplemaxerror = 1.0f;
+ sce->gm.exitkey = 218; // Blender key code for ESC
+
sound_create_scene(sce);
return sce;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 71377799651..08b53115919 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -1690,10 +1690,10 @@ static ImBuf * input_preprocess(
if(rct) {
float rgb[3];
for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) {
- rgb_byte_to_float(rct, rgb);
+ rgb_uchar_to_float(rgb, rct);
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb+1, rgb+2);
- rgb_float_to_byte(rgb, rct);
+ rgb_float_to_uchar(rct, rgb);
}
}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 60941ef78a3..424f97f57ed 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -77,6 +77,9 @@
#include "BKE_smoke.h"
+/* UNUSED so far, may be enabled later */
+/* #define USE_SMOKE_COLLISION_DM */
+
#ifdef WITH_SMOKE
#ifdef _WIN32
@@ -617,9 +620,11 @@ static void smokeModifier_freeCollision(SmokeModifierData *smd)
smd->coll->bvhtree = NULL;
}
+#ifdef USE_SMOKE_COLLISION_DM
if(smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = NULL;
+#endif
MEM_freeN(smd->coll);
smd->coll = NULL;
@@ -682,9 +687,11 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
smd->coll->bvhtree = NULL;
}
+#ifdef USE_SMOKE_COLLISION_DM
if(smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = NULL;
+#endif
}
}
@@ -772,7 +779,10 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->coll->points = NULL;
smd->coll->numpoints = 0;
smd->coll->bvhtree = NULL;
+
+#ifdef USE_SMOKE_COLLISION_DM
smd->coll->dm = NULL;
+#endif
}
}
}
@@ -1339,11 +1349,13 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
{
// XXX TODO
smd->time = scene->r.cfra;
-
+
+#ifdef USE_SMOKE_COLLISION_DM
if(smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = CDDM_copy(dm);
+#endif
// rigid movement support
copy_m4_m4(smd->coll->mat_old, smd->coll->mat);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index e773eb6dd35..ffcbd0bdc56 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -92,9 +92,17 @@ static void arena_release(CCGAllocatorHDL a) {
BLI_memarena_free(a);
}
-static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAging, int useArena, int UNUSED(useFlatSubdiv)) {
+typedef enum {
+ CCG_USE_AGING = 1,
+ CCG_USE_ARENA = 2,
+ CCG_CALC_NORMALS = 4,
+} CCGFlags;
+
+static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags flags) {
CCGMeshIFC ifc;
CCGSubSurf *ccgSS;
+ int useAging = !!(flags & CCG_USE_AGING);
+ int useArena = flags & CCG_USE_ARENA;
/* subdivLevels==0 is not allowed */
subdivLevels = MAX2(subdivLevels, 1);
@@ -102,7 +110,6 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
if (prevSS) {
int oldUseAging;
- useAging = !!useAging;
ccgSubSurf_getUseAgeCounts(prevSS, &oldUseAging, NULL, NULL, NULL);
if (oldUseAging!=useAging) {
@@ -119,7 +126,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
} else {
ifc.vertUserSize = ifc.edgeUserSize = ifc.faceUserSize = 8;
}
- ifc.vertDataSize = sizeof(DMGridData);
+ ifc.vertDataSize = sizeof(float) * (flags & CCG_CALC_NORMALS ? 6 : 3);
if (useArena) {
CCGAllocatorIFC allocatorIFC;
@@ -139,7 +146,10 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8);
}
- ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no));
+ if (flags & CCG_CALC_NORMALS)
+ ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no));
+ else
+ ccgSubSurf_setCalcVertexNormals(ccgSS, 0, 0);
return ccgSS;
}
@@ -322,7 +332,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
return;
/* create a CCGSubSurf from uv's */
- uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 0, 1, 0);
+ uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), CCG_USE_ARENA);
if(!ss_sync_from_uv(uvss, ss, dm, dmtface)) {
ccgSubSurf_free(uvss);
@@ -353,14 +363,14 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
int numVerts = ccgSubSurf_getFaceNumVerts(f);
for (S=0; S<numVerts; S++) {
- DMGridData *faceGridData= ccgSubSurf_getFaceGridDataArray(uvss, f, S);
+ float (*faceGridData)[3]= ccgSubSurf_getFaceGridDataArray(uvss, f, S);
for(y = 0; y < gridFaces; y++) {
for(x = 0; x < gridFaces; x++) {
- copy_v2_v2(tf->uv[0], faceGridData[(y + 0)*gridSize + x + 0].co);
- copy_v2_v2(tf->uv[1], faceGridData[(y + 1)*gridSize + x + 0].co);
- copy_v2_v2(tf->uv[2], faceGridData[(y + 1)*gridSize + x + 1].co);
- copy_v2_v2(tf->uv[3], faceGridData[(y + 0)*gridSize + x + 1].co);
+ copy_v2_v2(tf->uv[0], faceGridData[(y + 0)*gridSize + x + 0]);
+ copy_v2_v2(tf->uv[1], faceGridData[(y + 1)*gridSize + x + 0]);
+ copy_v2_v2(tf->uv[2], faceGridData[(y + 1)*gridSize + x + 1]);
+ copy_v2_v2(tf->uv[3], faceGridData[(y + 0)*gridSize + x + 1]);
tf++;
}
@@ -2773,7 +2783,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
int isFinalCalc, int forEditMode, int inEditMode)
{
int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF;
- int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr;
+ CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0;
int useSubsurfUv = smd->flags & eSubsurfModifierFlag_SubsurfUv;
int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges);
CCGDerivedMesh *result;
@@ -2781,8 +2791,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
if(forEditMode) {
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
- smd->emCache = _getSubSurf(smd->emCache, levels, useAging, 0,
- useSimple);
+ smd->emCache = _getSubSurf(smd->emCache, levels, useAging|CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple);
result = getCCGDerivedMesh(smd->emCache,
@@ -2796,7 +2805,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
if(levels == 0)
return dm;
- ss = _getSubSurf(NULL, levels, 0, 1, useSimple);
+ ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
@@ -2806,7 +2815,6 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
result->freeSS = 1;
} else {
int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental);
- int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr;
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
CCGSubSurf *ss;
@@ -2827,8 +2835,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
}
if(useIncremental && isFinalCalc) {
- smd->mCache = ss = _getSubSurf(smd->mCache, levels,
- useAging, 0, useSimple);
+ smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging|CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
@@ -2841,7 +2848,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
smd->mCache = NULL;
}
- ss = _getSubSurf(NULL, levels, 0, 1, useSimple);
+ ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm);
@@ -2863,7 +2870,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
* calculated vert positions is incorrect for the verts
* on the boundary of the mesh.
*/
- CCGSubSurf *ss = _getSubSurf(NULL, 1, 0, 1, 0);
+ CCGSubSurf *ss = _getSubSurf(NULL, 1, CCG_USE_ARENA);
float edge_sum[3], face_sum[3];
CCGVertIterator *vi;
DerivedMesh *dm = CDDM_from_mesh(me, NULL);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 1fe385dbf81..ba48db588c4 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -808,13 +808,14 @@ static int txt_utf8_len(const char *src)
void txt_move_up(Text *text, short sel)
{
TextLine **linep;
- int *charp, old;
+ int *charp;
+ /* int old; */ /* UNUSED */
if (!text) return;
if(sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
- old= *charp;
+ /* old= *charp; */ /* UNUSED */
if((*linep)->prev) {
int index = txt_utf8_offset_to_index((*linep)->line, *charp);
@@ -834,13 +835,14 @@ void txt_move_up(Text *text, short sel)
void txt_move_down(Text *text, short sel)
{
TextLine **linep;
- int *charp, old;
+ int *charp;
+ /* int old; */ /* UNUSED */
if (!text) return;
if(sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
- old= *charp;
+ /* old= *charp; */ /* UNUSED */
if((*linep)->next) {
int index = txt_utf8_offset_to_index((*linep)->line, *charp);
@@ -1897,6 +1899,10 @@ 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);
+ default:
+ /* should never happen */
+ BLI_assert(0);
+ unicode= 0;
}
return unicode;
@@ -1944,6 +1950,10 @@ 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);
+ default:
+ /* should never happen */
+ BLI_assert(0);
+ unicode= 0;
}
return unicode;
@@ -2747,15 +2757,19 @@ void txt_indent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
+ if (ELEM3(NULL, text, text->curl, text->sell)) {
+ return;
+ }
+
+ if (!text) return;
+ if (!text->curl) return;
+ if (!text->sell) return;
+
/* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES){
add = tab_to_spaces;
indentlen = spaceslen;
}
-
- if (!text) return;
- if (!text->curl) return;
- if (!text->sell) return;
num = 0;
while (TRUE)
@@ -2808,16 +2822,16 @@ void txt_unindent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
+ if (!text) return;
+ if (!text->curl) return;
+ if (!text->sell) return;
+
/* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES){
remove = tab_to_spaces;
indent = spaceslen;
}
- if (!text) return;
- if (!text->curl) return;
- if (!text->sell) return;
-
while(TRUE)
{
int i = 0;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 73170612ff7..ea3f076523f 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -395,6 +395,13 @@ int BKE_tracking_has_marker(MovieTrackingTrack *track, int framenr)
return BKE_tracking_exact_marker(track, framenr) != 0;
}
+int BKE_tracking_has_enabled_marker(MovieTrackingTrack *track, int framenr)
+{
+ MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+
+ return marker && (marker->flag & MARKER_DISABLED) == 0;
+}
+
void BKE_tracking_free_track(MovieTrackingTrack *track)
{
if(track->markers) MEM_freeN(track->markers);
@@ -1062,7 +1069,7 @@ void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disab
static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int grayscale)
{
BKE_tracking_disable_imbuf_channels(ibuf, track->flag&TRACK_DISABLE_RED,
- track->flag&TRACK_DISABLE_GREEN, track->flag&TRACK_DISABLE_RED, grayscale);
+ track->flag&TRACK_DISABLE_GREEN, track->flag&TRACK_DISABLE_BLUE, grayscale);
}
static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@@ -1741,8 +1748,8 @@ static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tra
track= tracksbase->first;
while(track) {
- if(BKE_tracking_has_marker(track, frame1))
- if(BKE_tracking_has_marker(track, frame2))
+ if(BKE_tracking_has_enabled_marker(track, frame1))
+ if(BKE_tracking_has_enabled_marker(track, frame2))
tot++;
track= track->next;
@@ -1758,7 +1765,7 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
if(count_tracks_on_both_keyframes(tracking, tracksbase)<8) {
- BLI_strncpy(error_msg, "At least 8 tracks on both of keyframes are needed for reconstruction", error_size);
+ BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size);
return 0;
}
@@ -1838,7 +1845,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
context->k1= camera->k1;
context->k2= camera->k2;
- context->k2= camera->k2;
+ context->k3= camera->k3;
return context;
}
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h
index bd14793e0f9..a5453f1537b 100644
--- a/source/blender/blenlib/BLI_array.h
+++ b/source/blender/blenlib/BLI_array.h
@@ -140,6 +140,10 @@
(&arr[_##arr##_count - 1]) \
)
+#define BLI_array_reserve(arr, num) \
+ BLI_array_growitems(arr, num), (void)(_##arr##_count -= num)
+
+
#define BLI_array_free(arr) \
if (arr && (char *)arr != _##arr##_static) { \
BLI_array_fake_user(arr); \
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 6d37aabd6ab..f4d6882b5d8 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -91,6 +91,9 @@ MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4]);
MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4]);
MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4]);
+MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3]);
+MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4]);
+
void BLI_init_srgb_conversion(void);
/************************** Other *************************/
@@ -101,8 +104,10 @@ void minmax_rgb(short c[3]);
void rgb_float_set_hue_float_offset(float * rgb, float hue_offset);
void rgb_byte_set_hue_float_offset(unsigned char * rgb, float hue_offset);
-void rgb_byte_to_float(const unsigned char in[3], float out[3]);
-void rgb_float_to_byte(const float in[3], unsigned char out[3]);
+void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3]);
+void rgba_uchar_to_float(float col_r[4], const unsigned char col_ub[4]);
+void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3]);
+void rgba_float_to_uchar(unsigned char col_r[4], const float col_f[4]);
/***************** lift/gamma/gain / ASC-CDL conversion *****************/
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 27da6c1025d..8d18f5253c4 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -54,6 +54,8 @@ float area_tri_v3(const float a[3], const float b[3], const float c[3]);
float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
float area_poly_v3(int nr, float verts[][3], const float normal[3]);
+int is_quad_convex_v3(const float *v1, const float *v2, const float *v3, const float *v4);
+
/********************************* Distance **********************************/
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]);
@@ -221,6 +223,9 @@ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3],
float n4[3], const float f_no[3], const float co1[3], const float co2[3],
const float co3[3], const float co4[3]);
+void accumulate_vertex_normals_poly(float **vertnos, float polyno[3],
+ float **vertcos, float vdiffs[][3], int nverts);
+
/********************************* Tangents **********************************/
typedef struct VertexTangent {
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index b75d8e0daa6..12a0b1892a1 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -171,6 +171,7 @@ float angle_v3v3v3(const float a[3], const float b[3], const float c[3]);
float angle_normalized_v3v3(const float v1[3], const float v2[3]);
void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]);
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
+void angle_poly_v3(float* angles, const float* verts[3], int len);
/********************************* Geometry **********************************/
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 9f388b68c38..e10082348be 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -40,8 +40,8 @@
// #include "BLI_blenlib.h"
-#include "BLI_mempool.h"
#include "BLI_utildefines.h"
+#include "BLI_mempool.h"
#include "BLI_ghash.h"
#include "BLO_sys_types.h" // for intptr_t support
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
index 3543b847f19..d5f66c0e75f 100644
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ b/source/blender/blenlib/intern/BLI_kdtree.c
@@ -132,19 +132,18 @@ void BLI_kdtree_balance(KDTree *tree)
tree->root= kdtree_balance(tree->nodes, tree->totnode, 0);
}
-static float squared_distance(float *v2, float *v1, float *n1, float *n2)
+static float squared_distance(float *v2, float *v1, float *UNUSED(n1), float *n2)
{
float d[3], dist;
- (void)n1; /* unused */
d[0]= v2[0]-v1[0];
d[1]= v2[1]-v1[1];
d[2]= v2[2]-v1[2];
- dist= d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
+ dist = dot_v3v3(d, d);
- //if(n1 && n2 && n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2] < 0.0f)
- if(n2 && d[0]*n2[0] + d[1]*n2[1] + d[2]*n2[2] < 0.0f)
+ //if(n1 && n2 && (dot_v3v3(n1, n2) < 0.0f))
+ if(n2 && (dot_v3v3(d, n2) < 0.0f))
dist *= 10.0f;
return dist;
diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c
index 073b4b5d0c6..cf18fbd57cd 100644
--- a/source/blender/blenlib/intern/boxpack2d.c
+++ b/source/blender/blenlib/intern/boxpack2d.c
@@ -390,7 +390,7 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he
} else if ( vert->trb && vert->brb &&
(box == vert->trb || box == vert->brb) ) {
if (vert->trb->w > vert->brb->w) {
- vert->brb->v[TR]->free &= ~(TRF|TRF);
+ vert->brb->v[TR]->free &= ~(TLF|TRF);
} else if (vert->trb->w < vert->brb->w) {
vert->trb->v[BR]->free &= ~(BLF|BRF);
} else { /*same*/
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 20df893015d..ca2aeca8f36 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -337,24 +337,29 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b)
*b /= 255.0f;
}
-void rgb_byte_to_float(const unsigned char in[3], float out[3])
+void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3])
{
- out[0]= ((float)in[0]) / 255.0f;
- out[1]= ((float)in[1]) / 255.0f;
- out[2]= ((float)in[2]) / 255.0f;
+ col_r[0]= ((float)col_ub[0]) / 255.0f;
+ col_r[1]= ((float)col_ub[1]) / 255.0f;
+ col_r[2]= ((float)col_ub[2]) / 255.0f;
}
-void rgb_float_to_byte(const float in[3], unsigned char out[3])
+void rgba_uchar_to_float(float col_r[4], const unsigned char col_ub[4])
{
- int r, g, b;
-
- r= (int)(in[0] * 255.0f);
- g= (int)(in[1] * 255.0f);
- b= (int)(in[2] * 255.0f);
-
- out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r);
- out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g);
- out[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b);
+ col_r[0]= ((float)col_ub[0]) / 255.0f;
+ col_r[1]= ((float)col_ub[1]) / 255.0f;
+ col_r[2]= ((float)col_ub[2]) / 255.0f;
+ col_r[3]= ((float)col_ub[3]) / 255.0f;
+}
+
+void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3])
+{
+ F3TOCHAR3(col_f, col_r);
+}
+
+void rgba_float_to_uchar(unsigned char col_r[4], const float col_f[4])
+{
+ F4TOCHAR4(col_f, col_r);
}
/* ********************************* color transforms ********************************* */
@@ -490,9 +495,9 @@ void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset)
{
float rgb_float[3];
- rgb_byte_to_float(rgb, rgb_float);
+ rgb_uchar_to_float(rgb_float, rgb);
rgb_float_set_hue_float_offset(rgb_float, hue_offset);
- rgb_float_to_byte(rgb_float, rgb);
+ rgb_float_to_uchar(rgb, rgb_float);
}
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 1247632cf79..386452ed592 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -62,6 +62,22 @@ MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
srgb[3] = linear[3];
}
+MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3])
+{
+ float srgb_f[3];
+
+ linearrgb_to_srgb_v3_v3(srgb_f, linear);
+ F3TOCHAR3(srgb_f, srgb);
+}
+
+MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
+{
+ float srgb_f[4];
+
+ linearrgb_to_srgb_v4(srgb_f, linear);
+ F4TOCHAR4(srgb_f, srgb);
+}
+
/* predivide versions to work on associated/premultipled alpha. if this should
be done or not depends on the background the image will be composited over,
ideally you would never do color space conversion on an image with alpha
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index ef04e5e9bce..500e27064d7 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2382,6 +2382,38 @@ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3],
}
}
+/* Add weighted face normal component into normals of the face vertices.
+ Caller must pass pre-allocated vdiffs of nverts length. */
+void accumulate_vertex_normals_poly(float **vertnos, float polyno[3],
+ float **vertcos, float vdiffs[][3], int nverts)
+{
+ int i;
+
+ /* calculate normalized edge directions for each edge in the poly */
+ for (i = 0; i < nverts; i++) {
+ sub_v3_v3v3(vdiffs[i], vertcos[(i+1) % nverts], vertcos[i]);
+ normalize_v3(vdiffs[i]);
+ }
+
+ /* accumulate angle weighted face normal */
+ {
+ const float *prev_edge = vdiffs[nverts-1];
+ int i;
+
+ for(i=0; i<nverts; i++) {
+ const float *cur_edge = vdiffs[i];
+
+ /* calculate angle between the two poly edges incident on
+ this vertex */
+ const float fac= saacos(-dot_v3v3(cur_edge, prev_edge));
+
+ /* accumulate */
+ madd_v3_v3fl(vertnos[i], polyno, fac);
+ prev_edge = cur_edge;
+ }
+ }
+}
+
/********************************* Tangents **********************************/
/* For normal map tangents we need to detect uv boundaries, and only average
@@ -2453,8 +2485,9 @@ void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], flo
cross_v3_v3v3(ct, tang, tangv);
/* check flip */
- if ((ct[0]*n[0] + ct[1]*n[1] + ct[2]*n[2]) < 0.0f)
+ if (dot_v3v3(ct, n) < 0.0f) {
negate_v3(tang);
+ }
}
else {
tang[0]= tang[1]= tang[2]= 0.0;
@@ -3038,3 +3071,26 @@ float form_factor_hemi_poly(float p[3], float n[3], float v1[3], float v2[3], fl
return contrib;
}
+
+/* evaluate if entire quad is a proper convex quad */
+ int is_quad_convex_v3(const float *v1, const float *v2, const float *v3, const float *v4)
+ {
+ float nor[3], nor1[3], nor2[3], vec[4][2];
+ int axis_a, axis_b;
+
+ /* define projection, do both trias apart, quad is undefined! */
+ normal_tri_v3(nor1, v1, v2, v3);
+ normal_tri_v3(nor2, v1, v3, v4);
+ add_v3_v3v3(nor, nor1, nor2);
+
+ axis_dominant_v3(&axis_a, &axis_b, nor);
+
+ vec[0][0]= v1[axis_a]; vec[0][1]= v1[axis_b];
+ vec[1][0]= v2[axis_a]; vec[1][1]= v2[axis_b];
+
+ vec[2][0]= v3[axis_a]; vec[2][1]= v3[axis_b];
+ vec[3][0]= v4[axis_a]; vec[3][1]= v4[axis_b];
+
+ /* linetests, the 2 diagonals have to instersect to be convex */
+ return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0) ? 1 : 0;
+}
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 5596b6f9f22..b0e6fe51810 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -811,7 +811,7 @@ void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float ang
mat[2][2] = 1.0f;
break;
default:
- assert("invalid axis");
+ assert(0);
}
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 590a48e8085..47deb705def 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -239,6 +239,20 @@ void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const
angles[3]= (float)M_PI - angle_normalized_v3v3(ed4, ed1);
}
+void angle_poly_v3(float *angles, const float *verts[3], int len)
+{
+ int i;
+ float vec[3][3];
+
+ sub_v3_v3v3(vec[2], verts[len-1], verts[0]);
+ normalize_v3(vec[2]);
+ for (i = 0; i < len; i++) {
+ sub_v3_v3v3(vec[i%3], verts[i%len], verts[(i+1)%len]);
+ normalize_v3(vec[i%3]);
+ angles[i] = (float)M_PI - angle_normalized_v3v3(vec[(i+2)%3], vec[i%3]);
+ }
+}
+
/********************************* Geometry **********************************/
/* Project v1 on v2 */
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index dc9a32222f7..9c5d8f3261f 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -515,6 +515,29 @@ MINLINE float normalize_v3_v3(float r[3], const float a[3])
return d;
}
+MINLINE double normalize_v3_d(double n[3])
+{
+ double d= n[0]*n[0] + n[1]*n[1] + n[2]*n[2];
+
+ /* a larger value causes normalize errors in a
+ scaled down models with camera xtreme close */
+ if(d > 1.0e-35) {
+ double mul;
+
+ d= sqrt(d);
+ mul = 1.0 / d;
+
+ n[0] *= mul;
+ n[1] *= mul;
+ n[2] *= mul;
+ } else {
+ n[0] = n[1] = n[2] = 0;
+ d= 0.0;
+ }
+
+ return d;
+}
+
MINLINE float normalize_v3(float n[3])
{
return normalize_v3_v3(n, n);
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index e1a08de0dd8..b3cb2856383 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -919,10 +919,6 @@ static float g[512+2][3]= {
{-0.944031, -0.326599, -0.045624},
};
-
-
-#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2])
-
#define setup(i,b0,b1,r0,r1) \
t = vec[i] + 10000.0f; \
b0 = ((int)t) & 255; \
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 38925ea5238..d63baca883e 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -65,7 +65,7 @@ typedef struct BlendFileData {
int fileflags;
int displaymode;
int globalf;
- char filename[240]; /* 240 = FILE_MAX */
+ char filename[1024]; /* 1024 = FILE_MAX */
struct bScreen* curscreen;
struct Scene* curscene;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index fa15590e4e3..0a92d2ca544 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -97,9 +97,9 @@
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_utildefines.h"
#include "BKE_anim.h"
#include "BKE_action.h"
@@ -13019,8 +13019,39 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 4))
+ {
+ {
+ /* set fluidsim rate */
+ Object *ob;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Fluidsim) {
+ FluidsimSettings *fss = (FluidsimSettings *)md;
+ fss->animRate = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
/* put compatibility code here until next subversion bump */
{
+ {
+ Object *ob;
+ for(ob=main->object.first; ob; ob= ob->id.next) {
+ ModifierData *md;
+
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData*) md;
+ if(clmd->sim_parms)
+ clmd->sim_parms->vel_damping = 1.0f;
+ }
+ }
+ }
+ }
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 1231a076502..ae4bc936193 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -89,6 +89,9 @@ Any case: direct data is ALWAYS after the lib block
#include "BLI_winstuff.h"
#endif
+/* allow writefile to use deprecated functionality (for forward compatibility code) */
+#define DNA_DEPRECATED_ALLOW
+
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_actuator_types.h"
@@ -653,7 +656,7 @@ static void write_node_socket(WriteData *wd, bNodeSocket *sock)
/* forward compatibility code, so older blenders still open */
sock->stack_type = 1;
-
+
if(sock->default_value) {
bNodeSocketValueFloat *valfloat;
bNodeSocketValueVector *valvector;
diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h
index 6bd4e5bb2b0..f07e80b36ce 100644
--- a/source/blender/blenpluginapi/iff.h
+++ b/source/blender/blenpluginapi/iff.h
@@ -63,7 +63,7 @@ typedef struct ImBuf {
int channels; /**< amount of channels in rect_float (0 = 4 channel default) */
float dither; /**< random dither value, for conversion from float -> byte rect */
short profile; /** color space/profile preset that the byte rect buffer represents */
- char profile_filename[256]; /** to be implemented properly, specific filename for custom profiles */
+ char profile_filename[1024]; /** to be implemented properly, specific filename for custom profiles */
/* mipmapping */
struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /**< MipMap levels, a series of halved images */
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index f0f3b8f4123..a0082b3258f 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -186,7 +186,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
}
/* copy the colors over, transforming from bytes to floats */
- rgb_byte_to_float(cp, color);
+ rgb_uchar_to_float(color, cp);
}
else {
// FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 5df4d42ad96..e8c9a2cf4da 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -5356,7 +5356,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent->data == arm)) {
if (ob->partype==PARBONE) {
@@ -5385,17 +5385,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
}
-
- /* Fix animation data attached to this object */
- // TODO: should we be using the database wide version instead (since drivers may break)
- if (ob->adt) {
- /* posechannels only... */
- BKE_animdata_fix_paths_rename(&ob->id, ob->adt, "pose.bones", oldname, newname, 0, 0, 1);
- }
}
-
+
+ /* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since
+ * other ID-blocks may have drivers referring to this bone [#29822]
+ */
+ BKE_all_animdata_fix_paths_rename("pose.bones", oldname, newname);
+
+ /* correct view locking */
{
- /* correct view locking */
bScreen *screen;
for(screen= G.main->screen.first; screen; screen= screen->id.next) {
ScrArea *sa;
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index 9ec27b69835..a8978a0bbde 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -450,7 +450,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo
{
int i, j;
- for (i = 0, j = 0; template_name[i] != '\0' && i < (MAXBONENAME-1) && j < (MAXBONENAME-1); i++)
+ for (i = 0, j = 0; i < (MAXBONENAME-1) && j < (MAXBONENAME-1) && template_name[i] != '\0'; i++)
{
if (template_name[i] == '&')
{
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index dcddde207f0..eb49f16584b 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -376,6 +376,10 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout,
bAction *act= ob->poselib; /* never NULL */
TimeMarker *marker;
+ wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1);
+
+ BLI_assert(ot != NULL);
+
/* set the operator execution context correctly */
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
@@ -383,9 +387,9 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout,
for (marker= act->markers.first; marker; marker= marker->next) {
PointerRNA props_ptr;
- props_ptr = uiItemFullO(layout, "POSELIB_OT_pose_add",
- marker->name, ICON_ARMATURE_DATA, NULL,
- WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ props_ptr = uiItemFullO_ptr(layout, ot,
+ marker->name, ICON_ARMATURE_DATA, NULL,
+ WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_int_set(&props_ptr, "frame", marker->frame);
RNA_string_set(&props_ptr, "name", marker->name);
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index fe9eb6dcd01..bcdda8e9eb1 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -1174,7 +1174,7 @@ void postprocessGraph(ReebGraph *rg, char mode)
fac2 = 0.5f;
break;
case SKGEN_SHARPEN:
- fac1 = fac2 = -0.25f;
+ fac1 = fac3 = -0.25f;
fac2 = 1.5f;
break;
default:
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index a20fbad874e..8c20d9be4f8 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5876,8 +5876,8 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
if(obedit->type==OB_SURF) {
pup= uiPupMenuBegin(C, "Delete", ICON_NONE);
layout= uiPupMenuLayout(pup);
- uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 0);
- uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 2);
+ uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0);
+ uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 2);
uiPupMenuEnd(C, pup);
}
else {
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index a2cbe6f7def..493fc6e277b 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -422,7 +422,7 @@ void FONT_OT_file_paste(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
/******************* text to object operator ********************/
@@ -1697,7 +1697,7 @@ void FONT_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************* delete operator *********************/
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 2058479bed8..05cde05f25c 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -67,8 +67,8 @@ int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit)
/* 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, const char cp[4], const float fp[4], int *zp, float *zpf);
+void ED_image_draw_info(struct ARegion *ar, int color_manage, 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_mesh.h b/source/blender/editors/include/ED_mesh.h
index 790fb88300d..160e3eea6cc 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -235,6 +235,10 @@ void ED_mesh_faces_add(struct Mesh *mesh, struct ReportList *reports, int count)
void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count);
void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count);
+void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int count);
+void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count);
+void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count);
+
void ED_mesh_transform(struct Mesh *me, float *mat);
void ED_mesh_calc_normals(struct Mesh *me);
void ED_mesh_material_link(struct Mesh *me, struct Material *ma);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 51d3c3f021b..f3e780d715e 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -40,6 +40,7 @@ struct bConstraint;
struct bContext;
struct bPoseChannel;
struct Curve;
+struct EnumPropertyItem;
struct KeyBlock;
struct Lattice;
struct Main;
@@ -64,6 +65,29 @@ void ED_operatortypes_object(void);
void ED_operatormacros_object(void);
void ED_keymap_object(struct wmKeyConfig *keyconf);
+/* object_relations.c */
+typedef enum eParentType {
+ PAR_OBJECT,
+ PAR_ARMATURE,
+ PAR_ARMATURE_NAME,
+ PAR_ARMATURE_ENVELOPE,
+ PAR_ARMATURE_AUTO,
+ PAR_BONE,
+ PAR_CURVE,
+ PAR_FOLLOW,
+ PAR_PATH_CONST,
+ PAR_LATTICE,
+ PAR_VERTEX,
+ PAR_TRIA
+} eParentType;
+
+extern struct EnumPropertyItem prop_clear_parent_types[];
+extern struct EnumPropertyItem prop_make_parent_types[];
+
+int ED_object_parent_set(struct bContext *C, struct wmOperator *op, struct Object *par, int partype);
+void ED_object_parent_clear(struct bContext *C, int type);
+
+
/* generic editmode keys like pet
* do_pet
* 0: No
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d1f11d60999..3f907004931 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -62,6 +62,7 @@ struct ColorBand;
struct CurveMapping;
struct Image;
struct ImageUser;
+struct wmOperatorType;
struct uiWidgetColors;
struct Tex;
struct MTex;
@@ -446,6 +447,7 @@ uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *s
uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip);
+uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip);
uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconBut(uiBlock *block,
@@ -466,6 +468,7 @@ uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon,
uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip);
+uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip);
uiBut *uiDefIconTextBut(uiBlock *block,
int type, int retval, int icon, const char *str,
@@ -485,6 +488,7 @@ uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int i
uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
+uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
/* for passing inputs to ButO buttons */
struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
@@ -773,6 +777,7 @@ void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const cha
/* 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);
void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value);
void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
@@ -781,6 +786,8 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op
void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value);
void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
+
+PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag);
PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag);
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index e9c213dec35..e5ad51169a8 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -41,7 +41,7 @@ struct Material;
typedef struct IconFile {
struct IconFile *next, *prev;
- char filename[80]; // FILE_MAXFILE size
+ char filename[256]; // FILE_MAXFILE size
int index;
} IconFile;
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 852b030c0d2..d755b17bc98 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -45,79 +45,10 @@ typedef enum {
} BIFIconID;
#define BIFICONID_FIRST (ICON_NONE)
-#define BIFNICONIDS (BIFICONID_LAST-BIFICONID_FIRST + 1)
#undef DEF_ICON
#undef DEF_VICO
-
-typedef enum {
-#define BIFCOLORSHADE_FIRST (COLORSHADE_DARK)
- COLORSHADE_DARK,
- COLORSHADE_GREY,
- COLORSHADE_MEDIUM,
- COLORSHADE_HILITE,
- COLORSHADE_LIGHT,
- COLORSHADE_WHITE
-#define BIFCOLORSHADE_LAST (COLORSHADE_WHITE)
-#define BIFNCOLORSHADES (BIFCOLORSHADE_LAST-BIFCOLORSHADE_FIRST + 1)
-} BIFColorShade;
-
-typedef enum {
-#define BIFCOLORID_FIRST (BUTGREY)
- BUTGREY = 0,
- BUTGREEN,
- BUTBLUE,
- BUTSALMON,
- MIDGREY,
- BUTPURPLE,
- BUTYELLOW,
- REDALERT,
- BUTRUST,
- BUTWHITE,
- BUTDBLUE,
- BUTPINK,
- BUTDPINK,
- BUTMACTIVE,
-
- BUTIPO,
- BUTAUDIO,
- BUTCAMERA,
- BUTRANDOM,
- BUTEDITOBJECT,
- BUTPROPERTY,
- BUTSCENE,
- BUTMOTION,
- BUTMESSAGE,
- BUTACTION,
- BUTCD,
- BUTGAME,
- BUTVISIBILITY,
- BUTYUCK,
- BUTSEASICK,
- BUTCHOKE,
- BUTIMPERIAL,
-
- BUTTEXTCOLOR,
- BUTTEXTPRESSED,
- BUTSBACKGROUND,
-
- VIEWPORTBACKCOLOR,
- VIEWPORTGRIDCOLOR,
- VIEWPORTACTIVECOLOR,
- VIEWPORTSELECTEDCOLOR,
- VIEWPORTUNSELCOLOR,
-
- EDITVERTSEL,
- EDITVERTUNSEL,
- EDITEDGESEL,
- EDITEDGEUNSEL
-
-#define BIFCOLORID_LAST (EDITEDGEUNSEL)
-#define BIFNCOLORIDS (BIFCOLORID_LAST-BIFCOLORID_FIRST + 1)
-
-} BIFColorID;
-
enum {
TH_REDALERT,
@@ -262,8 +193,10 @@ enum {
TH_STITCH_PREVIEW_VERT,
TH_STITCH_PREVIEW_STITCHABLE,
TH_STITCH_PREVIEW_UNSTITCHABLE,
- TH_STITCH_PREVIEW_ACTIVE
+ TH_STITCH_PREVIEW_ACTIVE,
+ TH_MATCH, /* highlight color for search matches */
+ TH_SELECT_HIGHLIGHT /* highlight color for selected outliner item */
};
/* XXX WARNING: previous is saved in file, so do not change order! */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 7ff69277843..8bb9ceb121c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -800,11 +800,43 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
}
}
+/* XXX, this code will shorten any allocated string to 'UI_MAX_NAME_STR'
+ * since this is really long its unlikely to be an issue,
+ * but this could be supported */
+void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const short do_strip)
+{
+
+ if (do_strip) {
+ char *cpoin= strchr(but->str, '|');
+ if(cpoin) {
+ *cpoin= '\0';
+ }
+ }
+
+ /* without this, just allow stripping of the shortcut */
+ if (shortcut_str) {
+ char *butstr_orig;
+
+ if (but->str != but->strdata) {
+ butstr_orig = but->str; /* free after using as source buffer */
+ }
+ else {
+ butstr_orig = BLI_strdup(but->str);
+ }
+ BLI_snprintf(but->strdata,
+ sizeof(but->strdata),
+ "%s|%s",
+ butstr_orig, shortcut_str);
+ MEM_freeN(butstr_orig);
+ but->str = but->strdata;
+ ui_check_but(but);
+ }
+}
static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
{
uiBut *but;
- char buf[512];
+ char buf[128];
/* for menu's */
MenuType *mt;
@@ -815,18 +847,6 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
if(block->minx != block->maxx)
return;
-
-#define UI_MENU_KEY_STR_CAT \
- char *butstr_orig= BLI_strdup(but->str); \
- BLI_snprintf(but->strdata, \
- sizeof(but->strdata), \
- "%s|%s", \
- butstr_orig, buf); \
- MEM_freeN(butstr_orig); \
- but->str= but->strdata; \
- ui_check_but(but); \
-
-
for(but=block->buttons.first; but; but=but->next) {
if(but->optype) {
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
@@ -834,7 +854,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
buf, sizeof(buf)))
{
- UI_MENU_KEY_STR_CAT
+ ui_but_add_shortcut(but, buf, FALSE);
}
}
else if ((mt= uiButGetMenuType(but))) {
@@ -851,7 +871,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE,
buf, sizeof(buf)))
{
- UI_MENU_KEY_STR_CAT
+ ui_but_add_shortcut(but, buf, FALSE);
}
}
}
@@ -1693,10 +1713,15 @@ static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *
return (BPY_button_exec(C, str_unit_convert, value, TRUE) != -1);
}
-static int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value)
+#endif /* WITH_PYTHON */
+
+
+int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value)
{
int ok= FALSE;
+#ifdef WITH_PYTHON
+
if(str[0] != '\0') {
int is_unit_but= ui_is_but_unit(but);
/* only enable verbose if we won't run again with units */
@@ -1718,10 +1743,16 @@ static int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str,
}
}
+#else /* WITH_PYTHON */
+
+ value= atof(str);
+ ok = TRUE;
+
+#endif /* WITH_PYTHON */
+
return ok;
}
-#endif // WITH_PYTHON
int ui_set_but_string(bContext *C, uiBut *but, const char *str)
{
@@ -1788,13 +1819,9 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
/* number editing */
double value;
-#ifdef WITH_PYTHON
if(ui_set_but_string_eval_num(C, but, str, &value) == FALSE) {
return 0;
}
-#else
- value= atof(str);
-#endif // WITH_PYTHON
if(!ui_is_but_float(but)) value= (int)floor(value + 0.5);
if(but->type==NUMABS) value= fabs(value);
@@ -1939,21 +1966,32 @@ static void ui_free_but(const bContext *C, uiBut *but)
WM_operator_properties_free(but->opptr);
MEM_freeN(but->opptr);
}
- if(but->func_argN) MEM_freeN(but->func_argN);
+
+ if(but->func_argN) {
+ MEM_freeN(but->func_argN);
+ }
+
if(but->active) {
/* XXX solve later, buttons should be free-able without context ideally,
* however they may have open tooltips or popup windows, which need to
* be closed using a context pointer */
- if(C)
+ if (C) {
ui_button_active_free(C, but);
- else
- if(but->active)
+ }
+ else {
+ if(but->active) {
MEM_freeN(but->active);
+ }
+ }
+ }
+ if (but->str && but->str != but->strdata) {
+ MEM_freeN(but->str);
}
- if(but->str && but->str != but->strdata) MEM_freeN(but->str);
ui_free_link(but->link);
- if((but->type == BUT_IMAGE) && but->poin) IMB_freeImBuf((struct ImBuf *)but->poin);
+ if ((but->type == BUT_IMAGE) && but->poin) {
+ IMB_freeImBuf((struct ImBuf *)but->poin);
+ }
MEM_freeN(but);
}
@@ -1968,11 +2006,13 @@ void uiFreeBlock(const bContext *C, uiBlock *block)
ui_free_but(C, but);
}
- if(block->unit)
+ if (block->unit) {
MEM_freeN(block->unit);
+ }
- if(block->func_argN)
+ if (block->func_argN) {
MEM_freeN(block->func_argN);
+ }
CTX_store_free_list(&block->contexts);
@@ -2639,8 +2679,9 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
str= BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
freestr= 1;
}
@@ -2656,10 +2697,12 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
}
}
- if(!str)
- str= RNA_property_ui_name(prop);
- if(free)
+ if (!str) {
+ str = RNA_property_ui_name(prop);
+ }
+ if (free) {
MEM_freeN(item);
+ }
}
else {
str= RNA_property_ui_name(prop);
@@ -2739,9 +2782,10 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
but->a1= ui_get_but_step_unit(but, but->a1);
}
- if(freestr)
+ if (freestr) {
MEM_freeN((void *)str);
-
+ }
+
return but;
}
@@ -2762,16 +2806,12 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons
return but;
}
-static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- wmOperatorType *ot;
-
- ot= WM_operatortype_find(opname, 0);
if(!str) {
- if(ot) str= ot->name;
- else str= opname;
+ if(ot) str = ot->name;
}
if ((!tip || tip[0]=='\0') && ot && ot->description) {
@@ -2793,6 +2833,12 @@ static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname,
return but;
}
+static uiBut *UNUSED_FUNCTION(ui_def_but_operator)(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0);
+ if (str == NULL && ot == NULL) str = opname;
+ return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
+}
static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
@@ -2999,13 +3045,20 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int
ui_check_but(but);
return but;
}
-uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+
+uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
+ but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
ui_check_but(but);
return but;
}
+uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0);
+ if (str == NULL && ot == NULL) str = opname;
+ return uiDefButO_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
+}
uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
@@ -3077,13 +3130,19 @@ uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1
ui_check_but_and_iconize(but, icon);
return but;
}
-uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
+
+uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- but= ui_def_but_operator(block, type, opname, opcontext, "", x1, y1, x2, y2, tip);
+ but= ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip);
ui_check_but_and_iconize(but, icon);
return but;
}
+uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
+{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0);
+ return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x1, y1, x2, y2, tip);
+}
/* Button containing both string label and icon */
uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
@@ -3151,14 +3210,19 @@ uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, co
but->flag|= UI_ICON_LEFT;
return but;
}
-uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
+ but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
ui_check_but_and_iconize(but, icon);
but->flag|= UI_ICON_LEFT;
return but;
}
+uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0);
+ return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x1, y1, x2, y2, tip);
+}
/* END Button containing both string label and icon */
@@ -3353,8 +3417,9 @@ void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2
void uiBlockSetNFunc(uiBlock *block, uiButHandleFunc func, void *argN, void *arg2)
{
- if(block->func_argN)
+ if (block->func_argN) {
MEM_freeN(block->func_argN);
+ }
block->funcN= func;
block->func_argN= argN;
@@ -3383,8 +3448,9 @@ void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
void uiButSetNFunc(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
{
- if(but->func_argN)
+ if (but->func_argN) {
MEM_freeN(but->func_argN);
+ }
but->funcN= funcN;
but->func_argN= argN;
@@ -3422,8 +3488,9 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const
{
uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
but->block_create_func= func;
- if(but->func_argN)
+ if (but->func_argN) {
MEM_freeN(but->func_argN);
+ }
but->func_argN= argN;
ui_check_but(but);
return but;
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 56f7fd04080..d79bc7d2974 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1461,19 +1461,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
-static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
+static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width, float height, int margin)
{
ImBuf *scaleibuf;
- int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
- const float scalex= 1.0f/zoomx;
- const float scaley= 1.0f/zoomy;
+ const float scalex= ((float)ibuf->x-2*margin) / width;
+ const float scaley= ((float)ibuf->y-2*margin) / height;
+ float off_x= (int)track_pos[0]-track_pos[0]+0.5f;
+ float off_y= (int)track_pos[1]-track_pos[1]+0.5f;
+ int x, y;
- scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
+ scaleibuf= IMB_allocImBuf(width, height, 32, IB_rect);
- for(y= 0; y<h; y++) {
- for (x= 0; x<w; x++) {
- float src_x= scalex*x;
- float src_y= scaley*y;
+ for(y= 0; y<height; y++) {
+ for (x= 0; x<width; x++) {
+ float src_x= scalex*(x)+margin-off_x;
+ float src_y= scaley*(y)+margin-off_y;
bicubic_interpolation(ibuf, scaleibuf, src_x, src_y, x, y);
}
@@ -1504,7 +1506,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
if(scopes->track_disabled) {
glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
ok= 1;
}
@@ -1512,8 +1514,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
/* additional margin around image */
/* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */
const int margin= 3;
- float zoomx, zoomy, track_pos[2], off_x, off_y, x0, y0;
- int a;
+ float zoomx, zoomy, track_pos[2], off_x, off_y;
+ int a, width, height;
ImBuf *drawibuf;
glPushMatrix();
@@ -1524,16 +1526,18 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
/* draw content of pattern area */
glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]);
- zoomx= (rect.xmax-rect.xmin) / (scopes->track_preview->x-2*margin);
- zoomy= (rect.ymax-rect.ymin) / (scopes->track_preview->y-2*margin);
+ width= rect.xmax-rect.xmin+1;
+ height = rect.ymax-rect.ymin;
+
+ zoomx= (float)width / (scopes->track_preview->x-2*margin);
+ zoomy= (float)height / (scopes->track_preview->y-2*margin);
off_x= ((int)track_pos[0]-track_pos[0]+0.5)*zoomx;
off_y= ((int)track_pos[1]-track_pos[1]+0.5)*zoomy;
- x0= (int)(off_x+rect.xmin-zoomx*(margin-0.5f))+1;
- y0= (int)(off_y+rect.ymin-zoomy*(margin-0.5f))+1;
- drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy);
- glaDrawPixelsSafe(x0, y0, rect.xmax-x0+1, rect.ymax-y0+1,
+ drawibuf= scale_trackpreview_ibuf(scopes->track_preview, track_pos, width, height, margin);
+
+ glaDrawPixelsSafe(rect.xmin, rect.ymin+1, drawibuf->x, drawibuf->y,
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
IMB_freeImBuf(drawibuf);
@@ -1568,7 +1572,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
if(!ok) {
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
}
/* outline, scale gripper */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 3a19bb2a90c..93d8f9c0c8a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1115,8 +1115,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
{
static ColorBand but_copypaste_coba = {0};
char buf[UI_MAX_DRAW_STR+1]= {0};
- double val;
-
+
if(mode=='v' && but->lock)
return;
@@ -1140,17 +1139,16 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
if(but->poin==NULL && but->rnapoin.data==NULL);
else if(mode=='c') {
- if(ui_is_but_float(but))
- BLI_snprintf(buf, sizeof(buf), "%f", ui_get_but_val(but));
- else
- BLI_snprintf(buf, sizeof(buf), "%d", (int)ui_get_but_val(but));
-
+ ui_get_but_string(but, buf, sizeof(buf));
WM_clipboard_text_set(buf, 0);
}
else {
- if (sscanf(buf, " %lf ", &val) == 1) {
+ double val;
+
+ if (ui_set_but_string_eval_num(C, but, buf, &val)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value= val;
+ ui_set_but_string(C, but, buf);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
@@ -1703,8 +1701,9 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
changed= 1;
}
- if(pbuf)
+ if (pbuf) {
MEM_freeN(pbuf);
+ }
}
/* cut & copy */
else if (copy || cut) {
@@ -4383,31 +4382,19 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
uiBut *but = (uiBut *)arg1;
if (but->optype) {
- char buf[512], *cpoin;
+ char shortcut_str[128];
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
/* complex code to change name of button */
if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
- buf, sizeof(buf)))
+ shortcut_str, sizeof(shortcut_str)))
{
- char *butstr_orig;
-
- // XXX but->str changed... should not, remove the hotkey from it
- cpoin= strchr(but->str, '|');
- if(cpoin) *cpoin= 0;
-
- butstr_orig= BLI_strdup(but->str);
- BLI_snprintf(but->strdata, sizeof(but->strdata), "%s|%s", butstr_orig, buf);
- MEM_freeN(butstr_orig);
- but->str= but->strdata;
-
- ui_check_but(but);
+ ui_but_add_shortcut(but, shortcut_str, TRUE);
}
else {
- /* shortcut was removed */
- cpoin= strchr(but->str, '|');
- if(cpoin) *cpoin= 0;
+ /* simply strip the shortcut */
+ ui_but_add_shortcut(but, NULL, TRUE);
}
}
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index a7d8c688f43..3feda5d4db4 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -665,7 +665,9 @@ static void init_iconfile_list(struct ListBase *list)
for(; i>=0; i--){
MEM_freeN(dir[i].relname);
MEM_freeN(dir[i].path);
- if (dir[i].string) MEM_freeN(dir[i].string);
+ if (dir[i].string) {
+ MEM_freeN(dir[i].string);
+ }
}
free(dir);
dir= NULL;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e31d7e39d89..2d8de475c4b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -163,7 +163,7 @@ struct uiBut {
float hardmin, hardmax, softmin, softmax;
float a1, a2;
float aspect;
- char col[4];
+ unsigned char col[4];
uiButHandleFunc func;
void *func_arg1;
@@ -356,6 +356,7 @@ extern void ui_get_but_string(uiBut *but, char *str, size_t maxlen);
extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen);
extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
extern int ui_get_but_string_max_length(uiBut *but);
+extern int ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value);
extern void ui_set_but_default(struct bContext *C, short all);
@@ -497,6 +498,7 @@ void ui_resources_free(void);
void ui_layout_add_but(uiLayout *layout, uiBut *but);
int ui_but_can_align(uiBut *but);
void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
+void ui_but_add_shortcut(uiBut *but, const char *key_str, const short do_strip);
/* interface_anim.c */
void ui_but_anim_flag(uiBut *but, float cfra);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index c8c57c12088..429cd658dea 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -66,6 +66,14 @@
#define EM_SEPR_X 6
#define EM_SEPR_Y 6
+#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \
+ if (ot == NULL) { \
+ ui_item_disabled(layout, _opname); \
+ RNA_warning("'%s' unknown operator", _opname); \
+ return_statement; \
+ } (void)0 \
+
+
/* uiLayoutRoot */
typedef struct uiLayoutRoot {
@@ -499,8 +507,9 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt
}
uiBlockSetCurLayout(block, layout);
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
}
/* callback for keymap item change button */
@@ -621,19 +630,12 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
}
/* operator items */
-PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag)
+PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag)
{
uiBlock *block= layout->root->block;
- wmOperatorType *ot= WM_operatortype_find(opname, 1);
uiBut *but;
int w;
- if(!ot) {
- ui_item_disabled(layout, opname);
- RNA_warning("unknown operator '%s'", opname);
- return PointerRNA_NULL;
- }
-
if(!name) {
name= IFACE_(ot->name);
}
@@ -649,12 +651,18 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i
if (flag & UI_ITEM_R_NO_BG)
uiBlockSetEmboss(block, UI_EMBOSSN);
- if(icon && name[0])
- but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL);
- else if(icon)
- but= uiDefIconButO(block, BUT, ot->idname, context, icon, 0, 0, w, UI_UNIT_Y, NULL);
- else
- but= uiDefButO(block, BUT, ot->idname, context, name, 0, 0, w, UI_UNIT_Y, NULL);
+ /* create the button */
+ if(icon) {
+ if (name[0]) {
+ but = uiDefIconTextButO_ptr(block, BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL);
+ }
+ else {
+ but = uiDefIconButO_ptr(block, BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL);
+ }
+ }
+ else {
+ but= uiDefButO_ptr(block, BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL);
+ }
assert(but->optype != NULL);
@@ -686,52 +694,85 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i
return PointerRNA_NULL;
}
-static const char *ui_menu_enumpropname(uiLayout *layout, const char *opname, const char *propname, int retval)
+PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag)
{
- wmOperatorType *ot= WM_operatortype_find(opname, 0);
- PointerRNA ptr;
- PropertyRNA *prop;
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
- if(!ot || !ot->srna)
- return "";
+ UI_OPERATOR_ERROR_RET(ot, opname, return PointerRNA_NULL);
- RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
- prop= RNA_struct_find_property(&ptr, propname);
+ return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag);
+}
- if(prop) {
- EnumPropertyItem *item;
- int totitem, free;
- const char *name;
+static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval)
+{
+ EnumPropertyItem *item;
+ int totitem, free;
+ const char *name;
- RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free);
- if(RNA_enum_name(item, retval, &name)) {
- if(free) MEM_freeN(item);
- return name;
- }
-
- if(free)
- MEM_freeN(item);
+ RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free);
+ if (RNA_enum_name(item, retval, &name) == 0) {
+ name = "";
}
- return "";
+ if (free) {
+ MEM_freeN(item);
+ }
+
+ return name;
}
-void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value)
+/* same as below but 'prop' is already known */
+static void uiItemEnumO_ptr__internal(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, PropertyRNA *prop, int value)
{
PointerRNA ptr;
+ WM_operator_properties_create_ptr(&ptr, ot);
+ RNA_property_enum_set(&ptr, prop, value);
- WM_operator_properties_create(&ptr, opname);
- RNA_enum_set(&ptr, propname, value);
+ if(!name)
+ name = ui_menu_enumpropname(layout, &ptr, prop, value);
+
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
+}
+void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, const char *propname, int value)
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+
+ WM_operator_properties_create_ptr(&ptr, ot);
+
+ if ((prop = RNA_struct_find_property(&ptr, propname))) {
+ /* pass */
+ }
+ else {
+ RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
+ return;
+ }
+
+ RNA_property_enum_set(&ptr, prop, value);
if(!name)
- name= ui_menu_enumpropname(layout, opname, propname, value);
+ name = ui_menu_enumpropname(layout, &ptr, prop, value);
+
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
+}
+void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value)
+{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
+
+ if(ot) {
+ uiItemEnumO_ptr(layout, ot, name, icon, propname, value);
+ }
+ else {
+ ui_item_disabled(layout, opname);
+ RNA_warning("unknown operator '%s'", opname);
+ }
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, IDProperty *properties, int context, int flag)
{
- wmOperatorType *ot= WM_operatortype_find(opname, 1);
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
+
PointerRNA ptr;
PropertyRNA *prop;
uiBut *bt;
@@ -744,7 +785,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
}
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
- prop= RNA_struct_find_property(&ptr, propname);
+ prop = RNA_struct_find_property(&ptr, propname);
/* don't let bad properties slip through */
BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM));
@@ -768,12 +809,13 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
MEM_freeN(tptr.data);
}
tptr.data= IDP_CopyProperty(properties);
- RNA_enum_set(&tptr, propname, item[i].value);
+ RNA_property_enum_set(&tptr, prop, item[i].value);
- uiItemFullO(column, opname, item[i].name, item[i].icon, tptr.data, context, flag);
+ uiItemFullO_ptr(column, ot, item[i].name, item[i].icon, tptr.data, context, flag);
+ }
+ else {
+ uiItemEnumO_ptr__internal(column, ot, item[i].name, item[i].icon, prop, item[i].value);
}
- else
- uiItemEnumO(column, opname, item[i].name, item[i].icon, propname, item[i].value);
}
else {
if(item[i].name) {
@@ -792,8 +834,9 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
}
}
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
}
}
@@ -805,15 +848,16 @@ void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname)
/* for use in cases where we have */
void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
-
- /* for getting the enum */
PropertyRNA *prop;
- WM_operator_properties_create(&ptr, opname);
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ WM_operator_properties_create_ptr(&ptr, ot);
/* enum lookup */
- if((prop= RNA_struct_find_property(&ptr, propname))) {
+ if ((prop = RNA_struct_find_property(&ptr, propname))) {
/* pass */
}
else {
@@ -825,33 +869,38 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
/* same as uiItemEnumO */
if(!name)
- name= ui_menu_enumpropname(layout, opname, propname, value);
+ name = ui_menu_enumpropname(layout, &ptr, prop, value);
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str)
{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
-
- /* for getting the enum */
PropertyRNA *prop;
+
EnumPropertyItem *item;
int value, free;
- WM_operator_properties_create(&ptr, opname);
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ WM_operator_properties_create_ptr(&ptr, ot);
/* enum lookup */
if((prop= RNA_struct_find_property(&ptr, propname))) {
RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) {
- if(free) MEM_freeN(item);
+ if(free) {
+ MEM_freeN(item);
+ }
RNA_warning("%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str);
return;
}
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
}
else {
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
@@ -862,49 +911,61 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
/* same as uiItemEnumO */
if(!name)
- name= ui_menu_enumpropname(layout, opname, propname, value);
+ name = ui_menu_enumpropname(layout, &ptr, prop, value);
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- WM_operator_properties_create(&ptr, opname);
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ WM_operator_properties_create_ptr(&ptr, ot);
RNA_boolean_set(&ptr, propname, value);
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- WM_operator_properties_create(&ptr, opname);
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ WM_operator_properties_create_ptr(&ptr, ot);
RNA_int_set(&ptr, propname, value);
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value)
{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- WM_operator_properties_create(&ptr, opname);
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ WM_operator_properties_create_ptr(&ptr, ot);
RNA_float_set(&ptr, propname, value);
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value)
{
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- WM_operator_properties_create(&ptr, opname);
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
+ WM_operator_properties_create_ptr(&ptr, ot);
RNA_string_set(&ptr, propname, value);
- uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
}
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
@@ -1096,7 +1157,9 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
if(!RNA_enum_value_from_id(item, value, &ivalue)) {
- if(free) MEM_freeN(item);
+ if (free) {
+ MEM_freeN(item);
+ }
ui_item_disabled(layout, propname);
RNA_warning("enum property value not found: %s", value);
return;
@@ -1109,8 +1172,9 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
}
}
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
}
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname)
@@ -1160,8 +1224,9 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
}
}
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
}
}
@@ -1536,14 +1601,11 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo
void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon)
{
- wmOperatorType *ot= WM_operatortype_find(opname, 1);
+ wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
MenuItemLevel *lvl;
- if(!ot) {
- ui_item_disabled(layout, opname);
- RNA_warning("unknown operator '%s'", opname);
- return;
- }
+ UI_OPERATOR_ERROR_RET(ot, opname, return);
+
if(!ot->srna) {
ui_item_disabled(layout, opname);
RNA_warning("operator missing srna '%s'", opname);
@@ -2731,8 +2793,9 @@ const char *uiLayoutIntrospect(uiLayout *layout)
{
DynStr *ds= BLI_dynstr_new();
- if(str)
+ if (str) {
MEM_freeN(str);
+ }
ui_intro_uiLayout(ds, layout);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index c21bc09ff27..d802c8640b8 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -772,8 +772,9 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
ui_panel_copy_offset(pa, pa->paneltab);
/* free panelsort array */
- for(ps= panelsort, a=0; a<tot; a++, ps++)
+ for (ps = panelsort, a = 0; a < tot; a++, ps++) {
MEM_freeN(ps->pa);
+ }
MEM_freeN(panelsort);
return done;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index c3cbb9dbe5f..8e336a363df 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -138,8 +138,9 @@ static void menudata_add_item(MenuData *md, const char *str, int retval, int ico
static void menudata_free(MenuData *md)
{
MEM_freeN((void *)md->instr);
- if (md->items)
+ if (md->items) {
MEM_freeN(md->items);
+ }
MEM_freeN(md);
}
@@ -394,8 +395,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
}
- if(free)
+ if (free) {
MEM_freeN(item);
+ }
}
}
@@ -982,8 +984,9 @@ static void ui_searchbox_region_free_cb(ARegion *ar)
int a;
/* free search data */
- for(a=0; a<data->items.maxitem; a++)
+ for (a = 0; a < data->items.maxitem; a++) {
MEM_freeN(data->items.names[a]);
+ }
MEM_freeN(data->items.names);
MEM_freeN(data->items.pointers);
MEM_freeN(data->items.icons);
@@ -1182,8 +1185,9 @@ void ui_but_search_test(uiBut *but)
uiButSetFlag(but, UI_BUT_REDALERT);
}
- for(x1=0; x1<items->maxitem; x1++)
+ for (x1 = 0; x1 < items->maxitem; x1++) {
MEM_freeN(items->names[x1]);
+ }
MEM_freeN(items->names);
MEM_freeN(items);
}
@@ -2474,7 +2478,7 @@ static void confirm_operator(bContext *C, wmOperator *op, const char *title, con
char *s, buf[512];
s= buf;
- if (title) s+= sprintf(s, "%s%%t|%s", title, item);
+ if (title) s+= BLI_snprintf(s, sizeof(buf), "%s%%t|%s", title, item);
(void)s;
handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 0862af2756a..2b0a406a421 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -850,7 +850,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply"), 0, "apply_as", MODIFIER_APPLY_DATA);
if (modifier_sameTopology(md) && !modifier_nonGeometrical(md))
- uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape"), 0, "apply_as", MODIFIER_APPLY_SHAPE);
+ uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape Key"), 0, "apply_as", MODIFIER_APPLY_SHAPE);
}
uiBlockClearButLock(block);
@@ -2267,8 +2267,9 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
/* free name */
- if(namebuf)
+ if (namebuf) {
MEM_freeN(namebuf);
+ }
}
void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype)
@@ -2372,8 +2373,9 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
icon= list_item_icon_get(C, &itemptr, rnaicon, 0);
uiItemL(row, (name)? name: "", icon);
- if(name)
+ if (name) {
MEM_freeN((void *)name);
+ }
}
i++;
@@ -2626,9 +2628,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
uiBlockBeginAlign(block);
but= uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X+10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
/* set the report's bg color in but->col - ROUNDBOX feature */
- but->col[0]= FTOCHAR(rti->col[0]);
- but->col[1]= FTOCHAR(rti->col[1]);
- but->col[2]= FTOCHAR(rti->col[2]);
+ rgb_float_to_uchar(but->col, rti->col);
but->col[3]= 255;
but= uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index f5c62f65512..19acfaccaa3 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2501,7 +2501,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
if (color_profile)
linearrgb_to_srgb_v3_v3(col, col);
- F4TOCHAR4(col, wcol->inner);
+ rgba_float_to_uchar((unsigned char *)wcol->inner, col);
wcol->shaded = 0;
wcol->alpha_check = (wcol->inner[3] < 255);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index ad20ff0b6dd..a70db7ad235 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -452,6 +452,14 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp= ts->camera_path; break;
case TH_LOCK_MARKER:
cp= ts->lock_marker; break;
+
+ case TH_MATCH:
+ cp= ts->match;
+ break;
+
+ case TH_SELECT_HIGHLIGHT:
+ cp= ts->selected_highlight;
+ break;
}
}
}
@@ -792,6 +800,9 @@ void ui_theme_init_default(void)
btheme->toops= btheme->tv3d;
SETCOLF(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
+ SETCOLF(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/
+ SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
+
/* space info */
btheme->tinfo= btheme->tv3d;
SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
@@ -1696,17 +1707,17 @@ void init_userdef_do_versions(void)
BLI_addtail(&U.addons, baddon);
}
}
-
+
if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) {
bTheme *btheme;
-
+
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
SETCOL(btheme->tui.panel.header, 0, 0, 0, 25);
btheme->tui.icon_alpha= 1.0;
}
}
-
- if (bmain->versionfile < 262){
+
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
SETCOLF(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150);
@@ -1715,10 +1726,14 @@ void init_userdef_do_versions(void)
SETCOLF(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
SETCOLF(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
SETCOLF(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
+
+ SETCOLF(btheme->toops.match, 0.2, 0.5, 0.2, 0.3);
+ SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
}
- U.use_16bit_textures = 0;
+
+ U.use_16bit_textures = 1;
}
-
+
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index b8201d762df..3eb8aba7334 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1339,8 +1339,9 @@ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy)
void UI_view2d_grid_free(View2DGrid *grid)
{
/* only free if there's a grid */
- if (grid)
+ if (grid) {
MEM_freeN(grid);
+ }
}
/* *********************************************************************** */
@@ -1754,7 +1755,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
void UI_view2d_scrollers_free(View2DScrollers *scrollers)
{
/* need to free grid as well... */
- if (scrollers->grid) MEM_freeN(scrollers->grid);
+ if (scrollers->grid) {
+ MEM_freeN(scrollers->grid);
+ }
MEM_freeN(scrollers);
}
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index e40c806fd17..d752d90ffdd 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -695,6 +695,46 @@ static void mesh_add_faces(Mesh *mesh, int len)
mesh->totface= totface;
}
+static void mesh_remove_verts(Mesh *mesh, int len)
+{
+ int totvert;
+
+ if(len == 0)
+ return;
+
+ totvert= mesh->totvert - len;
+ CustomData_free_elem(&mesh->vdata, totvert, len);
+
+ /* set final vertex list size */
+ mesh->totvert= totvert;
+}
+
+static void mesh_remove_edges(Mesh *mesh, int len)
+{
+ int totedge;
+
+ if(len == 0)
+ return;
+
+ totedge= mesh->totedge - len;
+ CustomData_free_elem(&mesh->edata, totedge, len);
+
+ mesh->totedge= totedge;
+}
+
+static void mesh_remove_faces(Mesh *mesh, int len)
+{
+ int totface;
+
+ if(len == 0)
+ return;
+
+ totface= mesh->totface - len; /* new face count */
+ CustomData_free_elem(&mesh->fdata, totface, len);
+
+ mesh->totface= totface;
+}
+
/*
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
{
@@ -742,6 +782,48 @@ void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
mesh_add_verts(mesh, count);
}
+void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_mesh) {
+ BKE_report(reports, RPT_ERROR, "Can't remove faces in edit mode");
+ return;
+ }
+ else if(count > mesh->totface) {
+ BKE_report(reports, RPT_ERROR, "Can't remove more faces than the mesh contains");
+ return;
+ }
+
+ mesh_remove_faces(mesh, count);
+}
+
+void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_mesh) {
+ BKE_report(reports, RPT_ERROR, "Can't remove edges in edit mode");
+ return;
+ }
+ else if(count > mesh->totedge) {
+ BKE_report(reports, RPT_ERROR, "Can't remove more edges than the mesh contains");
+ return;
+ }
+
+ mesh_remove_edges(mesh, count);
+}
+
+void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_mesh) {
+ BKE_report(reports, RPT_ERROR, "Can't remove vertices in edit mode");
+ return;
+ }
+ else if(count > mesh->totvert) {
+ BKE_report(reports, RPT_ERROR, "Can't remove more vertices than the mesh contains");
+ return;
+ }
+
+ mesh_remove_verts(mesh, count);
+}
+
void ED_mesh_calc_normals(Mesh *me)
{
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 90b3d45deb7..2ff90525498 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -300,6 +300,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
+
WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_edge_flip", FKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 64bbf604f67..dce2179db24 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -46,6 +46,7 @@
#include "DNA_scene_types.h"
#include "DNA_speaker_types.h"
#include "DNA_vfont_types.h"
+#include "DNA_actuator_types.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
@@ -1791,8 +1792,22 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
Key *key = ob_get_key(obn);
if(dupflag & USER_DUP_ACT) {
+ bActuator *act;
+
BKE_copy_animdata_id_action((ID *)obn->data);
- if(key) BKE_copy_animdata_id_action((ID*)key);
+ if(key) {
+ BKE_copy_animdata_id_action((ID*)key);
+ }
+
+ /* Update the duplicated action in the action actuators */
+ for (act = obn->actuators.first; act; act = act->next) {
+ if(act->type == ACT_ACTION) {
+ bActionActuator* actact = (bActionActuator*) act->data;
+ if(actact->act == ob->adt->action) {
+ actact->act = obn->adt->action;
+ }
+ }
+ }
}
if(dupflag & USER_DUP_MAT) {
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index a02b90a1d16..2fe2e71f2d9 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -807,10 +807,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
ibuf->userflags= IB_RECT_INVALID;
} else {
- char *rrgb= (char*)ibuf->rect + pixel*4;
- rrgb[0]= FTOCHAR(vec[0]);
- rrgb[1]= FTOCHAR(vec[1]);
- rrgb[2]= FTOCHAR(vec[2]);
+ unsigned char *rrgb= (unsigned char *)ibuf->rect + pixel*4;
+ rgb_float_to_uchar(rrgb, vec);
rrgb[3]= 255;
}
}
@@ -1257,7 +1255,7 @@ typedef struct BakeRender {
Main *main;
Scene *scene;
struct Object *actob;
- int tot, ready;
+ int result, ready;
ReportList *reports;
@@ -1330,7 +1328,7 @@ static void finish_bake_internal(BakeRender *bkr)
if(bkr->prev_r_raytrace == 0)
bkr->scene->r.mode &= ~R_RAYTRACE;
- if(bkr->tot) {
+ if(bkr->result==BAKE_RESULT_OK) {
Image *ima;
/* force OpenGL reload and mipmap recalc */
for(ima= G.main->image.first; ima; ima= ima->id.next) {
@@ -1357,7 +1355,7 @@ static void *do_bake_render(void *bake_v)
{
BakeRender *bkr= bake_v;
- bkr->tot= RE_bake_shade_all_selected(bkr->re, bkr->scene->r.bake_mode, bkr->actob, NULL, bkr->progress);
+ bkr->result= RE_bake_shade_all_selected(bkr->re, bkr->scene->r.bake_mode, bkr->actob, NULL, bkr->progress);
bkr->ready= 1;
return NULL;
@@ -1379,7 +1377,7 @@ static void bake_startjob(void *bkv, short *stop, short *do_update, float *progr
RE_Database_Baking(bkr->re, bmain, scene, scene->lay, scene->r.bake_mode, bkr->actob);
/* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */
- bkr->tot= RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress);
+ bkr->result= RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress);
}
static void bake_update(void *bkv)
@@ -1398,7 +1396,11 @@ static void bake_freejob(void *bkv)
BakeRender *bkr= bkv;
finish_bake_internal(bkr);
- if(bkr->tot==0) BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to");
+ if(bkr->result==BAKE_RESULT_NO_OBJECTS)
+ BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to");
+ else if(bkr->result==BAKE_RESULT_FEEDBACK_LOOP)
+ BKE_report(bkr->reports, RPT_WARNING, "Feedback loop detected");
+
MEM_freeN(bkr);
G.rendering = 0;
}
@@ -1515,7 +1517,10 @@ static int bake_image_exec(bContext *C, wmOperator *op)
}
BLI_end_threads(&threads);
- if(bkr.tot==0) BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to");
+ if(bkr.result==BAKE_RESULT_NO_OBJECTS)
+ BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to");
+ else if(bkr.result==BAKE_RESULT_FEEDBACK_LOOP)
+ BKE_report(op->reports, RPT_ERROR, "Feedback loop detected");
finish_bake_internal(&bkr);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 93f4a31f1ff..2797c08e72b 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -1236,7 +1236,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
edit_modifier_properties(ot);
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index a0bddda0413..37461377506 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -300,7 +300,7 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt)
uiLayout *layout= uiPupMenuLayout(pup);
/* create operator menu item with relevant properties filled in */
- uiItemFullO(layout, op->idname, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
+ uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
/* present the menu and be done... */
uiPupMenuEnd(C, pup);
@@ -421,43 +421,47 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot)
/********************** Clear Parent Operator ******************* */
-static EnumPropertyItem prop_clear_parent_types[] = {
+EnumPropertyItem prop_clear_parent_types[] = {
{0, "CLEAR", 0, "Clear Parent", ""},
{1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", ""},
{2, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""},
{0, NULL, 0, NULL, NULL}
};
-/* note, poll should check for editable scene */
-static int parent_clear_exec(bContext *C, wmOperator *op)
+void ED_object_parent_clear(bContext *C, int type)
{
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
- int type= RNA_enum_get(op->ptr, "type");
-
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
+ {
if(ob->parent == NULL)
continue;
if(type == 0) {
ob->parent= NULL;
- }
+ }
else if(type == 1) {
ob->parent= NULL;
object_apply_mat4(ob, ob->obmat, TRUE, FALSE);
}
else if(type == 2)
unit_m4(ob->parentinv);
-
+
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
CTX_DATA_END;
-
+
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL);
+}
+
+/* note, poll should check for editable scene */
+static int parent_clear_exec(bContext *C, wmOperator *op)
+{
+ ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type"));
return OPERATOR_FINISHED;
}
@@ -483,35 +487,6 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot)
/* ******************** Make Parent Operator *********************** */
-#define PAR_OBJECT 0
-#define PAR_ARMATURE 1
-#define PAR_ARMATURE_NAME 2
-#define PAR_ARMATURE_ENVELOPE 3
-#define PAR_ARMATURE_AUTO 4
-#define PAR_BONE 5
-#define PAR_CURVE 6
-#define PAR_FOLLOW 7
-#define PAR_PATH_CONST 8
-#define PAR_LATTICE 9
-#define PAR_VERTEX 10
-#define PAR_TRIA 11
-
-static EnumPropertyItem prop_make_parent_types[] = {
- {PAR_OBJECT, "OBJECT", 0, "Object", ""},
- {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""},
- {PAR_ARMATURE_NAME, "ARMATURE_NAME", 0, " With Empty Groups", ""},
- {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""},
- {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""},
- {PAR_BONE, "BONE", 0, "Bone", ""},
- {PAR_CURVE, "CURVE", 0, "Curve Deform", ""},
- {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""},
- {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""},
- {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""},
- {PAR_VERTEX, "VERTEX", 0, "Vertex", ""},
- {PAR_TRIA, "TRIA", 0, "Triangle", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
void ED_object_parent(Object *ob, Object *par, int type, const char *substr)
{
if (!par || BKE_object_parent_loop_check(par, ob)) {
@@ -529,13 +504,28 @@ void ED_object_parent(Object *ob, Object *par, int type, const char *substr)
BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr));
}
-static int parent_set_exec(bContext *C, wmOperator *op)
+/* Operator Property */
+EnumPropertyItem prop_make_parent_types[] = {
+ {PAR_OBJECT, "OBJECT", 0, "Object", ""},
+ {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""},
+ {PAR_ARMATURE_NAME, "ARMATURE_NAME", 0, " With Empty Groups", ""},
+ {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""},
+ {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""},
+ {PAR_BONE, "BONE", 0, "Bone", ""},
+ {PAR_CURVE, "CURVE", 0, "Curve Deform", ""},
+ {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""},
+ {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""},
+ {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""},
+ {PAR_VERTEX, "VERTEX", 0, "Vertex", ""},
+ {PAR_TRIA, "TRIA", 0, "Triangle", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+int ED_object_parent_set(bContext *C, wmOperator *op, Object *par, int partype)
{
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
- Object *par= ED_object_active_context(C);
bPoseChannel *pchan= NULL;
- int partype= RNA_enum_get(op->ptr, "type");
int pararm= ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO);
par->recalc |= OB_RECALC_OB;
@@ -543,7 +533,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
/* preconditions */
if(partype==PAR_FOLLOW || partype==PAR_PATH_CONST) {
if(par->type!=OB_CURVE)
- return OPERATOR_CANCELLED;
+ return 0;
else {
Curve *cu= par->data;
@@ -574,15 +564,14 @@ static int parent_set_exec(bContext *C, wmOperator *op)
if(pchan==NULL) {
BKE_report(op->reports, RPT_ERROR, "No active Bone");
- return OPERATOR_CANCELLED;
+ return 0;
}
}
/* context iterator */
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
-
- if(ob!=par) {
-
+ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
+ {
+ if (ob!=par) {
if (BKE_object_parent_loop_check(par, ob)) {
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
}
@@ -591,10 +580,11 @@ static int parent_set_exec(bContext *C, wmOperator *op)
/* apply transformation of previous parenting */
/* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */
-
+
/* set the parent (except for follow-path constraint option) */
- if(partype != PAR_PATH_CONST)
+ if (partype != PAR_PATH_CONST) {
ob->parent= par;
+ }
/* handle types */
if (pchan)
@@ -602,9 +592,10 @@ static int parent_set_exec(bContext *C, wmOperator *op)
else
ob->parsubstr[0]= 0;
- if(partype == PAR_PATH_CONST)
- ; /* don't do anything here, since this is not technically "parenting" */
- else if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm )
+ if (partype == PAR_PATH_CONST) {
+ /* don't do anything here, since this is not technically "parenting" */
+ }
+ else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm))
{
/* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created
* NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers
@@ -614,10 +605,10 @@ static int parent_set_exec(bContext *C, wmOperator *op)
/* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */
// XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet
- if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE))
+ if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE))
{
ModifierData *md;
-
+
switch (partype) {
case PAR_CURVE: /* curve deform */
md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Curve);
@@ -684,15 +675,27 @@ static int parent_set_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL);
-
- return OPERATOR_FINISHED;
+
+ return 1;
+}
+
+static int parent_set_exec(bContext *C, wmOperator *op)
+{
+ Object *par= ED_object_active_context(C);
+ int partype= RNA_enum_get(op->ptr, "type");
+
+ if(ED_object_parent_set(C, op, par, partype))
+ return OPERATOR_FINISHED;
+ else
+ return OPERATOR_CANCELLED;
}
+
static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
Object *ob= ED_object_active_context(C);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index f91740f4b47..7fe98a604ec 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -870,7 +870,7 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f
closest_to_plane_v3(projB, coord, norm, end);
// (vertical and horizontal refer to the plane's y and xz respectively)
// vertical distance
- dists[index] = norm[0]*end[0] + norm[1]*end[1] + norm[2]*end[2] + d;
+ dists[index] = dot_v3v3(norm, end) + d;
// vertical change
changes[index][0] = dists[index] - distToStart;
//printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]);
@@ -1111,7 +1111,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
mag= normalize_v3(norm);
if(mag) { /* zeros fix */
d = -dot_v3v3(norm, coord);
- /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */
+ /* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */
moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
}
}
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index d652d2c0e5c..dbc153de108 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -113,6 +113,18 @@ static float get_fluid_viscosity(FluidsimSettings *settings)
}
}
+static float get_fluid_rate(FluidsimSettings *settings)
+{
+ float rate = 1.0f; /* default rate if not animated... */
+
+ rate = settings->animRate;
+
+ if (rate < 0.0f)
+ rate = 0.0f;
+
+ return rate;
+}
+
static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fss)
{
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
@@ -243,7 +255,7 @@ static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *chann
channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1
- for(i=2; i<=channels->length; i++) {
+ for (i=2; i <= channels->length; i++) {
channels->timeAtFrame[i] = channels->timeAtFrame[i-1] + channels->aniFrameTime;
}
}
@@ -305,6 +317,8 @@ static void free_domain_channels(FluidAnimChannels *channels)
channels->DomainGravity = NULL;
MEM_freeN(channels->DomainViscosity);
channels->DomainViscosity = NULL;
+ MEM_freeN(channels->DomainTime);
+ channels->DomainTime = NULL;
}
static void free_all_fluidobject_channels(ListBase *fobjects)
@@ -351,14 +365,13 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
int length = channels->length;
float eval_time;
- /* XXX: first init time channel - temporary for now */
- /* init time values (should be done after evaluating animated time curve) */
+ /* init time values (assuming that time moves at a constant speed; may be overridden later) */
init_time(domainSettings, channels);
/* allocate domain animation channels */
channels->DomainGravity = MEM_callocN( length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity");
channels->DomainViscosity = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity");
- //channels->DomainTime = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime");
+ channels->DomainTime = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime");
/* allocate fluid objects */
for (base=scene->base.first; base; base= base->next) {
@@ -406,10 +419,9 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
for (i=0; i<channels->length; i++) {
FluidObject *fobj;
float viscosity, gravity[3];
- float timeAtFrame;
+ float timeAtFrame, time;
eval_time = domainSettings->bakeStart + i;
- timeAtFrame = channels->timeAtFrame[i+1];
/* XXX: This can't be used due to an anim sys optimisation that ignores recalc object animation,
* leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
@@ -425,12 +437,24 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* now scene data should be current according to animation system, so we fill the channels */
- /* Domain properties - gravity/viscosity/time */
+ /* Domain time */
+ // TODO: have option for not running sim, time mangling, in which case second case comes in handy
+ if (channels->DomainTime) {
+ time = get_fluid_rate(domainSettings) * channels->aniFrameTime;
+ timeAtFrame = channels->timeAtFrame[i] + time;
+
+ channels->timeAtFrame[i+1] = timeAtFrame;
+ set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT);
+ }
+ else {
+ timeAtFrame = channels->timeAtFrame[i+1];
+ }
+
+ /* Domain properties - gravity/viscosity */
get_fluid_gravity(gravity, scene, domainSettings);
set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC);
viscosity = get_fluid_viscosity(domainSettings);
set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT);
- // XXX : set_channel(channels->DomainTime, timeAtFrame, &time, i, CHANNEL_VEC);
/* object movement */
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
@@ -957,38 +981,6 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
/* reset to original current frame */
scene->r.cfra = origFrame;
ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1);
-
-
- /* ---- XXX: No Time animation curve for now, leaving this code here for reference
-
- { int timeIcu[1] = { FLUIDSIM_TIME };
- float timeDef[1] = { 1. };
-
- // time channel is a bit special, init by hand...
- timeAtIndex = MEM_callocN( (allchannelSize+1)*1*sizeof(float), "fluidsiminit_timeatindex");
- for(i=0; i<=scene->r.efra; i++) {
- timeAtIndex[i] = (float)(i-startFrame);
- }
- fluidsimInitChannel(scene, &channelDomainTime, allchannelSize, timeAtIndex, timeIcu,timeDef, domainSettings->ipo, CHANNEL_FLOAT ); // NDEB
- // time channel is a multiplicator for
- if(channelDomainTime) {
- for(i=0; i<allchannelSize; i++) {
- channelDomainTime[i*2+0] = aniFrameTime * channelDomainTime[i*2+0];
- if(channelDomainTime[i*2+0]<0.) channelDomainTime[i*2+0] = 0.;
- }
- }
- timeAtFrame = MEM_callocN( (allchannelSize+1)*1*sizeof(float), "fluidsiminit_timeatframe");
- timeAtFrame[0] = timeAtFrame[1] = domainSettings->animStart; // start at index 1
- if(channelDomainTime) {
- for(i=2; i<=allchannelSize; i++) {
- timeAtFrame[i] = timeAtFrame[i-1]+channelDomainTime[(i-1)*2+0];
- }
- fsset->} else {
- for(i=2; i<=allchannelSize; i++) { timeAtFrame[i] = timeAtFrame[i-1]+aniFrameTime; }
- }
-
- } // domain channel init
- */
/* ******** init domain object's matrix ******** */
copy_m4_m4(domainMat, fsDomain->obmat);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 13818ee13e4..87b77912978 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -749,7 +749,7 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot)
prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f);
RNA_def_property_flag(prop, PROP_HIDDEN);
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index e32277e3789..deeb3061ad5 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -228,7 +228,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
ot->flag= 0;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
}
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index fb20b201567..9fa91af7aec 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -38,6 +38,7 @@ set(INC_SYS
)
set(SRC
+ paint_cursor.c
paint_image.c
paint_ops.c
paint_stroke.c
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
new file mode 100644
index 00000000000..0148f11b930
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -0,0 +1,607 @@
+/*
+ * ***** 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) 2009 by Nicholas Bishop
+ * All rights reserved.
+ *
+ * Contributor(s): Jason Wilkins, Tom Musgrove.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/editors/sculpt_paint/paint_cursor.c
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_color_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_paint.h"
+
+#include "WM_api.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "ED_view3d.h"
+
+#include "paint_intern.h"
+/* still needed for sculpt_stroke_get_location, should be
+ removed eventually (TODO) */
+#include "sculpt_intern.h"
+
+/* TODOs:
+
+ Some of the cursor drawing code is doing non-draw stuff
+ (e.g. updating the brush rake angle). This should be cleaned up
+ still.
+
+ There is also some ugliness with sculpt-specific code.
+ */
+
+typedef struct Snapshot {
+ float size[3];
+ float ofs[3];
+ float rot;
+ int brush_size;
+ int winx;
+ int winy;
+ int brush_map_mode;
+ int curve_changed_timestamp;
+} Snapshot;
+
+static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
+{
+ MTex* mtex = &brush->mtex;
+
+ return (((mtex->tex) &&
+ equals_v3v3(mtex->ofs, snap->ofs) &&
+ equals_v3v3(mtex->size, snap->size) &&
+ mtex->rot == snap->rot) &&
+
+ /* make brush smaller shouldn't cause a resample */
+ ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
+ (brush_size(vc->scene, brush) <= snap->brush_size)) ||
+ (brush_size(vc->scene, brush) == snap->brush_size)) &&
+
+ (mtex->brush_map_mode == snap->brush_map_mode) &&
+ (vc->ar->winx == snap->winx) &&
+ (vc->ar->winy == snap->winy));
+}
+
+static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
+{
+ if (brush->mtex.tex) {
+ snap->brush_map_mode = brush->mtex.brush_map_mode;
+ copy_v3_v3(snap->ofs, brush->mtex.ofs);
+ copy_v3_v3(snap->size, brush->mtex.size);
+ snap->rot = brush->mtex.rot;
+ }
+ else {
+ snap->brush_map_mode = -1;
+ snap->ofs[0]= snap->ofs[1]= snap->ofs[2]= -1;
+ snap->size[0]= snap->size[1]= snap->size[2]= -1;
+ snap->rot = -1;
+ }
+
+ snap->brush_size = brush_size(vc->scene, brush);
+ snap->winx = vc->ar->winx;
+ snap->winy = vc->ar->winy;
+}
+
+static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
+{
+ static GLuint overlay_texture = 0;
+ static int init = 0;
+ static int tex_changed_timestamp = -1;
+ static int curve_changed_timestamp = -1;
+ static Snapshot snap;
+ static int old_size = -1;
+
+ GLubyte* buffer = NULL;
+
+ int size;
+ int j;
+ int refresh;
+
+#ifndef _OPENMP
+ (void)sd; /* quied unused warning */
+#endif
+
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
+
+ refresh =
+ !overlay_texture ||
+ (br->mtex.tex &&
+ (!br->mtex.tex->preview ||
+ br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
+ !br->curve ||
+ br->curve->changed_timestamp != curve_changed_timestamp ||
+ !same_snap(&snap, br, vc);
+
+ if (refresh) {
+ if (br->mtex.tex && br->mtex.tex->preview)
+ tex_changed_timestamp = br->mtex.tex->preview->changed_timestamp[0];
+
+ if (br->curve)
+ curve_changed_timestamp = br->curve->changed_timestamp;
+
+ make_snap(&snap, br, vc);
+
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ int s = brush_size(vc->scene, br);
+ int r = 1;
+
+ for (s >>= 1; s > 0; s >>= 1)
+ r++;
+
+ size = (1<<r);
+
+ if (size < 256)
+ size = 256;
+
+ if (size < old_size)
+ size = old_size;
+ }
+ else
+ size = 512;
+
+ if (old_size != size) {
+ if (overlay_texture) {
+ glDeleteTextures(1, &overlay_texture);
+ overlay_texture = 0;
+ }
+
+ init = 0;
+
+ old_size = size;
+ }
+
+ buffer = MEM_mallocN(sizeof(GLubyte)*size*size, "load_tex");
+
+ #pragma omp parallel for schedule(static) if (sd->flags & SCULPT_USE_OPENMP)
+ for (j= 0; j < size; j++) {
+ int i;
+ float y;
+ float len;
+
+ for (i= 0; i < size; i++) {
+
+ // largely duplicated from tex_strength
+
+ const float rotation = -br->mtex.rot;
+ float radius = brush_size(vc->scene, br);
+ int index = j*size + i;
+ float x;
+ float avg;
+
+ x = (float)i/size;
+ y = (float)j/size;
+
+ x -= 0.5f;
+ y -= 0.5f;
+
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) {
+ x *= vc->ar->winx / radius;
+ y *= vc->ar->winy / radius;
+ }
+ else {
+ x *= 2;
+ y *= 2;
+ }
+
+ len = sqrtf(x*x + y*y);
+
+ if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) {
+ /* it is probably worth optimizing for those cases where
+ the texture is not rotated by skipping the calls to
+ atan2, sqrtf, sin, and cos. */
+ if (br->mtex.tex && (rotation > 0.001f || rotation < -0.001f)) {
+ const float angle = atan2f(y, x) + rotation;
+
+ x = len * cosf(angle);
+ y = len * sinf(angle);
+ }
+
+ x *= br->mtex.size[0];
+ y *= br->mtex.size[1];
+
+ x += br->mtex.ofs[0];
+ y += br->mtex.ofs[1];
+
+ avg = br->mtex.tex ? paint_get_tex_pixel(br, x, y) : 1;
+
+ avg += br->texture_sample_bias;
+
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED)
+ avg *= brush_curve_strength(br, len, 1); /* Falloff curve */
+
+ buffer[index] = 255 - (GLubyte)(255*avg);
+ }
+ else {
+ buffer[index] = 0;
+ }
+ }
+ }
+
+ if (!overlay_texture)
+ glGenTextures(1, &overlay_texture);
+ }
+ else {
+ size= old_size;
+ }
+
+ glBindTexture(GL_TEXTURE_2D, overlay_texture);
+
+ if (refresh) {
+ if (!init) {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, size, size, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buffer);
+ init = 1;
+ }
+ else {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_ALPHA, GL_UNSIGNED_BYTE, buffer);
+ }
+
+ if (buffer)
+ MEM_freeN(buffer);
+ }
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+ }
+
+ return 1;
+}
+
+static int project_brush_radius(ViewContext *vc,
+ float radius,
+ const float location[3])
+{
+ float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
+
+ ED_view3d_global_to_vector(vc->rv3d, location, view);
+
+ // create a vector that is not orthogonal to view
+
+ if (fabsf(view[0]) < 0.1f) {
+ nonortho[0] = view[0] + 1.0f;
+ nonortho[1] = view[1];
+ nonortho[2] = view[2];
+ }
+ else if (fabsf(view[1]) < 0.1f) {
+ nonortho[0] = view[0];
+ nonortho[1] = view[1] + 1.0f;
+ nonortho[2] = view[2];
+ }
+ else {
+ nonortho[0] = view[0];
+ nonortho[1] = view[1];
+ nonortho[2] = view[2] + 1.0f;
+ }
+
+ // get a vector in the plane of the view
+ cross_v3_v3v3(ortho, nonortho, view);
+ normalize_v3(ortho);
+
+ // make a point on the surface of the brush tagent to the view
+ mul_v3_fl(ortho, radius);
+ 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);
+
+ // the distance between these points is the size of the projected brush in pixels
+ return len_v2v2(p1, p2);
+}
+
+static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
+ int x, int y, int* pixel_radius,
+ float location[3])
+{
+ Scene *scene = CTX_data_scene(C);
+ Paint *paint = paint_get_active(scene);
+ Brush *brush = paint_brush(paint);
+ float window[2];
+ int hit;
+
+ window[0] = x + vc->ar->winrct.xmin;
+ window[1] = y + vc->ar->winrct.ymin;
+
+ if(vc->obact->sculpt && vc->obact->sculpt->pbvh &&
+ sculpt_stroke_get_location(C, location, window)) {
+ *pixel_radius =
+ project_brush_radius(vc,
+ brush_unprojected_radius(scene, brush),
+ location);
+
+ if (*pixel_radius == 0)
+ *pixel_radius = brush_size(scene, brush);
+
+ mul_m4_v3(vc->obact->obmat, location);
+
+ hit = 1;
+ }
+ else {
+ Sculpt* sd = CTX_data_tool_settings(C)->sculpt;
+ Brush* brush = paint_brush(&sd->paint);
+
+ *pixel_radius = brush_size(scene, brush);
+ hit = 0;
+ }
+
+ return hit;
+}
+
+/* Draw an overlay that shows what effect the brush's texture will
+ have on brush strength */
+/* TODO: sculpt only for now */
+static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
+ ViewContext *vc, int x, int y)
+{
+ rctf quad;
+
+ /* check for overlay mode */
+ if(!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
+ !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
+ return;
+
+ /* save lots of GL state
+ TODO: check on whether all of these are needed? */
+ glPushAttrib(GL_COLOR_BUFFER_BIT|
+ GL_CURRENT_BIT|
+ GL_DEPTH_BUFFER_BIT|
+ GL_ENABLE_BIT|
+ GL_LINE_BIT|
+ GL_POLYGON_BIT|
+ GL_STENCIL_BUFFER_BIT|
+ GL_TRANSFORM_BIT|
+ GL_VIEWPORT_BIT|
+ GL_TEXTURE_BIT);
+
+ if(load_tex(sd, brush, vc)) {
+ glEnable(GL_BLEND);
+
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glDepthMask(GL_FALSE);
+ glDepthFunc(GL_ALWAYS);
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ /* brush rotation */
+ glTranslatef(0.5, 0.5, 0);
+ glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
+ sd->last_angle : sd->special_rotation),
+ 0.0, 0.0, 1.0);
+ glTranslatef(-0.5f, -0.5f, 0);
+
+ /* scale based on tablet pressure */
+ if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) {
+ glTranslatef(0.5f, 0.5f, 0);
+ glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1);
+ glTranslatef(-0.5f, -0.5f, 0);
+ }
+
+ if(sd->draw_anchored) {
+ const float *aim = sd->anchored_initial_mouse;
+ const rcti *win = &vc->ar->winrct;
+ quad.xmin = aim[0]-sd->anchored_size - win->xmin;
+ quad.ymin = aim[1]-sd->anchored_size - win->ymin;
+ quad.xmax = aim[0]+sd->anchored_size - win->xmin;
+ quad.ymax = aim[1]+sd->anchored_size - win->ymin;
+ }
+ else {
+ const int radius= brush_size(vc->scene, brush);
+ quad.xmin = x - radius;
+ quad.ymin = y - radius;
+ quad.xmax = x + radius;
+ quad.ymax = y + radius;
+ }
+ }
+ else {
+ quad.xmin = 0;
+ quad.ymin = 0;
+ quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin;
+ quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin;
+ }
+
+ /* set quad color */
+ glColor4f(U.sculpt_paint_overlay_col[0],
+ U.sculpt_paint_overlay_col[1],
+ U.sculpt_paint_overlay_col[2],
+ brush->texture_overlay_alpha / 100.0f);
+
+ /* draw textured quad */
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex2f(quad.xmin, quad.ymin);
+ glTexCoord2f(1, 0);
+ glVertex2f(quad.xmax, quad.ymin);
+ glTexCoord2f(1, 1);
+ glVertex2f(quad.xmax, quad.ymax);
+ glTexCoord2f(0, 1);
+ glVertex2f(quad.xmin, quad.ymax);
+ glEnd();
+
+ glPopMatrix();
+ }
+
+ glPopAttrib();
+}
+
+/* Special actions taken when paint cursor goes over mesh */
+/* TODO: sculpt only for now */
+static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
+ const float location[3])
+{
+ float unprojected_radius, projected_radius;
+
+ /* update the brush's cached 3D radius */
+ if(!brush_use_locked_size(vc->scene, brush)) {
+ /* get 2D brush radius */
+ if(sd->draw_anchored)
+ projected_radius = sd->anchored_size;
+ else {
+ if(brush->flag & BRUSH_ANCHORED)
+ projected_radius = 8;
+ else
+ projected_radius = brush_size(vc->scene, brush);
+ }
+
+ /* convert brush radius from 2D to 3D */
+ unprojected_radius = paint_calc_object_space_radius(vc, location,
+ projected_radius);
+
+ /* scale 3D brush radius by pressure */
+ if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
+ unprojected_radius *= sd->pressure_value;
+
+ /* set cached value in either Brush or UnifiedPaintSettings */
+ brush_set_unprojected_radius(vc->scene, brush, unprojected_radius);
+ }
+}
+
+static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
+{
+ Scene *scene = CTX_data_scene(C);
+ Paint *paint = paint_get_active(scene);
+ Brush *brush = paint_brush(paint);
+ ViewContext vc;
+ float final_radius;
+ float translation[2];
+ float outline_alpha, *outline_col;
+
+ /* set various defaults */
+ translation[0] = x;
+ translation[1] = y;
+ outline_alpha = 0.5;
+ outline_col = brush->add_col;
+ final_radius = brush_size(scene, brush);
+
+ /* check that brush drawing is enabled */
+ if(!(paint->flags & PAINT_SHOW_BRUSH))
+ return;
+
+ /* can't use stroke vc here because this will be called during
+ mouse over too, not just during a stroke */
+ view3d_set_viewcontext(C, &vc);
+
+ /* TODO: as sculpt and other paint modes are unified, this
+ special mode of drawing will go away */
+ if(vc.obact->sculpt) {
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ float location[3];
+ int pixel_radius, hit;
+
+ /* this is probably here so that rake takes into
+ account the brush movements before the stroke
+ starts, but this doesn't really belong in draw code
+ (TODO) */
+ {
+ const float u = 0.5f;
+ const float v = 1 - u;
+ const float r = 20;
+
+ const float dx = sd->last_x - x;
+ const float dy = sd->last_y - y;
+
+ if(dx*dx + dy*dy >= r*r) {
+ sd->last_angle = atan2(dx, dy);
+
+ sd->last_x = u*sd->last_x + v*x;
+ sd->last_y = u*sd->last_y + v*y;
+ }
+ }
+
+ /* test if brush is over the mesh */
+ hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location);
+
+ /* draw overlay */
+ paint_draw_alpha_overlay(sd, brush, &vc, x, y);
+
+ if(brush_use_locked_size(scene, brush))
+ brush_set_size(scene, brush, pixel_radius);
+
+ /* check if brush is subtracting, use different color then */
+ /* TODO: no way currently to know state of pen flip or
+ invert key modifier without starting a stroke */
+ if((!(brush->flag & BRUSH_INVERTED) ^
+ !(brush->flag & BRUSH_DIR_IN)) &&
+ ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
+ SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
+ outline_col = brush->sub_col;
+
+ /* only do if brush is over the mesh */
+ if(hit)
+ paint_cursor_on_hit(sd, brush, &vc, location);
+
+ if(sd->draw_anchored) {
+ final_radius = sd->anchored_size;
+ translation[0] = sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin;
+ translation[1] = sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin;
+ }
+ }
+
+ /* make lines pretty */
+ glEnable(GL_BLEND);
+ glEnable(GL_LINE_SMOOTH);
+
+ /* set brush color */
+ glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha);
+
+ /* draw brush outline */
+ glTranslatef(translation[0], translation[1], 0);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, final_radius, 40);
+ glTranslatef(-translation[0], -translation[1], 0);
+
+ /* restore GL state */
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+}
+
+/* Public API */
+
+void paint_cursor_start(bContext *C, int (*poll)(bContext *C))
+{
+ Paint *p = paint_get_active(CTX_data_scene(C));
+
+ if(p && !p->paint_cursor)
+ p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
+}
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 4ca05e1fbd7..73dc1e236f6 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -50,7 +50,7 @@ struct wmOperator;
struct wmOperatorType;
/* paint_stroke.c */
-typedef int (*StrokeGetLocation)(struct bContext *C, struct PaintStroke *stroke, float location[3], float mouse[2]);
+typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], float mouse[2]);
typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr);
typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 0ff0f278f17..757f501d296 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -359,7 +359,7 @@ static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
extern EnumPropertyItem uv_sculpt_tool_items[];
/* identifiers */
ot->name = "UV Sculpt Tool Set";
- ot->description = "Set the uv sculpt tool";
+ ot->description = "Set the UV sculpt tool";
ot->idname = "BRUSH_OT_uv_sculpt_tool_set";
/* api callbacks */
@@ -663,9 +663,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_uv_sculpt");
- WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
- RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
- RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "temp_relax", 1);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
ed_keymap_paint_brush_size(keymap, "tool_settings.uv_sculpt.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "uv_sculpt", 0);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 67bd6ca9255..cd8262f06bd 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -56,9 +56,6 @@
#include "ED_view3d.h"
#include "paint_intern.h"
-/* still needed for sculpt_stroke_get_location, should be
- removed eventually (TODO) */
-#include "sculpt_intern.h"
#include <float.h>
#include <math.h>
@@ -108,552 +105,6 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata
glDisable(GL_LINE_SMOOTH);
}
-typedef struct Snapshot {
- float size[3];
- float ofs[3];
- float rot;
- int brush_size;
- int winx;
- int winy;
- int brush_map_mode;
- int curve_changed_timestamp;
-} Snapshot;
-
-static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
-{
- MTex* mtex = &brush->mtex;
-
- return (((mtex->tex) &&
- equals_v3v3(mtex->ofs, snap->ofs) &&
- equals_v3v3(mtex->size, snap->size) &&
- mtex->rot == snap->rot) &&
-
- /* make brush smaller shouldn't cause a resample */
- ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
- (brush_size(vc->scene, brush) <= snap->brush_size)) ||
- (brush_size(vc->scene, brush) == snap->brush_size)) &&
-
- (mtex->brush_map_mode == snap->brush_map_mode) &&
- (vc->ar->winx == snap->winx) &&
- (vc->ar->winy == snap->winy));
-}
-
-static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
-{
- if (brush->mtex.tex) {
- snap->brush_map_mode = brush->mtex.brush_map_mode;
- copy_v3_v3(snap->ofs, brush->mtex.ofs);
- copy_v3_v3(snap->size, brush->mtex.size);
- snap->rot = brush->mtex.rot;
- }
- else {
- snap->brush_map_mode = -1;
- snap->ofs[0]= snap->ofs[1]= snap->ofs[2]= -1;
- snap->size[0]= snap->size[1]= snap->size[2]= -1;
- snap->rot = -1;
- }
-
- snap->brush_size = brush_size(vc->scene, brush);
- snap->winx = vc->ar->winx;
- snap->winy = vc->ar->winy;
-}
-
-static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
-{
- static GLuint overlay_texture = 0;
- static int init = 0;
- static int tex_changed_timestamp = -1;
- static int curve_changed_timestamp = -1;
- static Snapshot snap;
- static int old_size = -1;
-
- GLubyte* buffer = NULL;
-
- int size;
- int j;
- int refresh;
-
-#ifndef _OPENMP
- (void)sd; /* quied unused warning */
-#endif
-
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
-
- refresh =
- !overlay_texture ||
- (br->mtex.tex &&
- (!br->mtex.tex->preview ||
- br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
- !br->curve ||
- br->curve->changed_timestamp != curve_changed_timestamp ||
- !same_snap(&snap, br, vc);
-
- if (refresh) {
- if (br->mtex.tex && br->mtex.tex->preview)
- tex_changed_timestamp = br->mtex.tex->preview->changed_timestamp[0];
-
- if (br->curve)
- curve_changed_timestamp = br->curve->changed_timestamp;
-
- make_snap(&snap, br, vc);
-
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
- int s = brush_size(vc->scene, br);
- int r = 1;
-
- for (s >>= 1; s > 0; s >>= 1)
- r++;
-
- size = (1<<r);
-
- if (size < 256)
- size = 256;
-
- if (size < old_size)
- size = old_size;
- }
- else
- size = 512;
-
- if (old_size != size) {
- if (overlay_texture) {
- glDeleteTextures(1, &overlay_texture);
- overlay_texture = 0;
- }
-
- init = 0;
-
- old_size = size;
- }
-
- buffer = MEM_mallocN(sizeof(GLubyte)*size*size, "load_tex");
-
- #pragma omp parallel for schedule(static) if (sd->flags & SCULPT_USE_OPENMP)
- for (j= 0; j < size; j++) {
- int i;
- float y;
- float len;
-
- for (i= 0; i < size; i++) {
-
- // largely duplicated from tex_strength
-
- const float rotation = -br->mtex.rot;
- float radius = brush_size(vc->scene, br);
- int index = j*size + i;
- float x;
- float avg;
-
- x = (float)i/size;
- y = (float)j/size;
-
- x -= 0.5f;
- y -= 0.5f;
-
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) {
- x *= vc->ar->winx / radius;
- y *= vc->ar->winy / radius;
- }
- else {
- x *= 2;
- y *= 2;
- }
-
- len = sqrtf(x*x + y*y);
-
- if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) {
- /* it is probably worth optimizing for those cases where
- the texture is not rotated by skipping the calls to
- atan2, sqrtf, sin, and cos. */
- if (br->mtex.tex && (rotation > 0.001f || rotation < -0.001f)) {
- const float angle = atan2f(y, x) + rotation;
-
- x = len * cosf(angle);
- y = len * sinf(angle);
- }
-
- x *= br->mtex.size[0];
- y *= br->mtex.size[1];
-
- x += br->mtex.ofs[0];
- y += br->mtex.ofs[1];
-
- avg = br->mtex.tex ? paint_get_tex_pixel(br, x, y) : 1;
-
- avg += br->texture_sample_bias;
-
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED)
- avg *= brush_curve_strength(br, len, 1); /* Falloff curve */
-
- buffer[index] = 255 - (GLubyte)(255*avg);
- }
- else {
- buffer[index] = 0;
- }
- }
- }
-
- if (!overlay_texture)
- glGenTextures(1, &overlay_texture);
- }
- else {
- size= old_size;
- }
-
- glBindTexture(GL_TEXTURE_2D, overlay_texture);
-
- if (refresh) {
- if (!init) {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, size, size, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buffer);
- init = 1;
- }
- else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_ALPHA, GL_UNSIGNED_BYTE, buffer);
- }
-
- if (buffer)
- MEM_freeN(buffer);
- }
-
- glEnable(GL_TEXTURE_2D);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- }
-
- return 1;
-}
-
-static int project_brush_radius(RegionView3D* rv3d, float radius, float location[3], bglMats* mats)
-{
- float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
-
- ED_view3d_global_to_vector(rv3d, location, view);
-
- // create a vector that is not orthogonal to view
-
- if (fabsf(view[0]) < 0.1f) {
- nonortho[0] = view[0] + 1.0f;
- nonortho[1] = view[1];
- nonortho[2] = view[2];
- }
- else if (fabsf(view[1]) < 0.1f) {
- nonortho[0] = view[0];
- nonortho[1] = view[1] + 1.0f;
- nonortho[2] = view[2];
- }
- else {
- nonortho[0] = view[0];
- nonortho[1] = view[1];
- nonortho[2] = view[2] + 1.0f;
- }
-
- // get a vector in the plane of the view
- cross_v3_v3v3(ortho, nonortho, view);
- normalize_v3(ortho);
-
- // make a point on the surface of the brush tagent to the view
- mul_v3_fl(ortho, radius);
- add_v3_v3v3(offset, location, ortho);
-
- // project the center of the brush, and the tagent point to the view onto the screen
- projectf(mats, location, p1);
- projectf(mats, offset, p2);
-
- // the distance between these points is the size of the projected brush in pixels
- return len_v2v2(p1, p2);
-}
-
-static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius,
- float location[3])
-{
- struct PaintStroke *stroke;
- const Scene *scene = CTX_data_scene(C);
- float window[2];
- int hit;
-
- stroke = paint_stroke_new(C, NULL, NULL, NULL, NULL, 0);
-
- window[0] = x + stroke->vc.ar->winrct.xmin;
- window[1] = y + stroke->vc.ar->winrct.ymin;
-
- if(stroke->vc.obact->sculpt && stroke->vc.obact->sculpt->pbvh &&
- sculpt_stroke_get_location(C, stroke, location, window)) {
- *pixel_radius = project_brush_radius(stroke->vc.rv3d,
- brush_unprojected_radius(scene, stroke->brush),
- location, &stroke->mats);
-
- if (*pixel_radius == 0)
- *pixel_radius = brush_size(scene, stroke->brush);
-
- mul_m4_v3(stroke->vc.obact->obmat, location);
-
- hit = 1;
- }
- else {
- Sculpt* sd = CTX_data_tool_settings(C)->sculpt;
- Brush* brush = paint_brush(&sd->paint);
-
- *pixel_radius = brush_size(scene, brush);
- hit = 0;
- }
-
- paint_stroke_free(stroke);
-
- return hit;
-}
-
-/* Draw an overlay that shows what effect the brush's texture will
- have on brush strength */
-/* TODO: sculpt only for now */
-static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
- ViewContext *vc, int x, int y)
-{
- rctf quad;
-
- /* check for overlay mode */
- if(!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
- !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
- return;
-
- /* save lots of GL state
- TODO: check on whether all of these are needed? */
- glPushAttrib(GL_COLOR_BUFFER_BIT|
- GL_CURRENT_BIT|
- GL_DEPTH_BUFFER_BIT|
- GL_ENABLE_BIT|
- GL_LINE_BIT|
- GL_POLYGON_BIT|
- GL_STENCIL_BUFFER_BIT|
- GL_TRANSFORM_BIT|
- GL_VIEWPORT_BIT|
- GL_TEXTURE_BIT);
-
- if(load_tex(sd, brush, vc)) {
- glEnable(GL_BLEND);
-
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask(GL_FALSE);
- glDepthFunc(GL_ALWAYS);
-
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glLoadIdentity();
-
- if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
- /* brush rotation */
- glTranslatef(0.5, 0.5, 0);
- glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
- sd->last_angle : sd->special_rotation),
- 0.0, 0.0, 1.0);
- glTranslatef(-0.5f, -0.5f, 0);
-
- /* scale based on tablet pressure */
- if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) {
- glTranslatef(0.5f, 0.5f, 0);
- glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1);
- glTranslatef(-0.5f, -0.5f, 0);
- }
-
- if(sd->draw_anchored) {
- const float *aim = sd->anchored_initial_mouse;
- const rcti *win = &vc->ar->winrct;
- quad.xmin = aim[0]-sd->anchored_size - win->xmin;
- quad.ymin = aim[1]-sd->anchored_size - win->ymin;
- quad.xmax = aim[0]+sd->anchored_size - win->xmin;
- quad.ymax = aim[1]+sd->anchored_size - win->ymin;
- }
- else {
- const int radius= brush_size(vc->scene, brush);
- quad.xmin = x - radius;
- quad.ymin = y - radius;
- quad.xmax = x + radius;
- quad.ymax = y + radius;
- }
- }
- else {
- quad.xmin = 0;
- quad.ymin = 0;
- quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin;
- quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin;
- }
-
- /* set quad color */
- glColor4f(U.sculpt_paint_overlay_col[0],
- U.sculpt_paint_overlay_col[1],
- U.sculpt_paint_overlay_col[2],
- brush->texture_overlay_alpha / 100.0f);
-
- /* draw textured quad */
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0);
- glVertex2f(quad.xmin, quad.ymin);
- glTexCoord2f(1, 0);
- glVertex2f(quad.xmax, quad.ymin);
- glTexCoord2f(1, 1);
- glVertex2f(quad.xmax, quad.ymax);
- glTexCoord2f(0, 1);
- glVertex2f(quad.xmin, quad.ymax);
- glEnd();
-
- glPopMatrix();
- }
-
- glPopAttrib();
-}
-
-/* Special actions taken when paint cursor goes over mesh */
-/* TODO: sculpt only for now */
-static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
- const float location[3])
-{
- float unprojected_radius, projected_radius;
-
- /* update the brush's cached 3D radius */
- if(!brush_use_locked_size(vc->scene, brush)) {
- /* get 2D brush radius */
- if(sd->draw_anchored)
- projected_radius = sd->anchored_size;
- else {
- if(brush->flag & BRUSH_ANCHORED)
- projected_radius = 8;
- else
- projected_radius = brush_size(vc->scene, brush);
- }
-
- /* convert brush radius from 2D to 3D */
- unprojected_radius = paint_calc_object_space_radius(vc, location,
- projected_radius);
-
- /* scale 3D brush radius by pressure */
- if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
- unprojected_radius *= sd->pressure_value;
-
- /* set cached value in either Brush or UnifiedPaintSettings */
- brush_set_unprojected_radius(vc->scene, brush, unprojected_radius);
- }
-}
-
-static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
-{
- Scene *scene = CTX_data_scene(C);
- Paint *paint = paint_get_active(scene);
- Brush *brush = paint_brush(paint);
- ViewContext vc;
- float final_radius;
- float translation[2];
- float outline_alpha, *outline_col;
-
- /* set various defaults */
- translation[0] = x;
- translation[1] = y;
- outline_alpha = 0.5;
- outline_col = brush->add_col;
- final_radius = brush_size(scene, brush);
-
- /* check that brush drawing is enabled */
- if(!(paint->flags & PAINT_SHOW_BRUSH))
- return;
-
- /* can't use stroke vc here because this will be called during
- mouse over too, not just during a stroke */
- view3d_set_viewcontext(C, &vc);
-
- /* TODO: as sculpt and other paint modes are unified, this
- special mode of drawing will go away */
- if(vc.obact->sculpt) {
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- float location[3];
- int pixel_radius, hit;
- const float root_alpha = brush_alpha(scene, brush);
- float visual_strength = root_alpha*root_alpha;
- const float min_alpha = 0.20f;
- const float max_alpha = 0.80f;
-
- /* this is probably here so that rake takes into
- account the brush movements before the stroke
- starts, but this doesn't really belong in draw code
- (TODO) */
- {
- const float u = 0.5f;
- const float v = 1 - u;
- const float r = 20;
-
- const float dx = sd->last_x - x;
- const float dy = sd->last_y - y;
-
- if(dx*dx + dy*dy >= r*r) {
- sd->last_angle = atan2(dx, dy);
-
- sd->last_x = u*sd->last_x + v*x;
- sd->last_y = u*sd->last_y + v*y;
- }
- }
-
- /* test if brush is over the mesh */
- hit = sculpt_get_brush_geometry(C, x, y, &pixel_radius, location);
-
- /* draw overlay */
- paint_draw_alpha_overlay(sd, brush, &vc, x, y);
-
- if(brush_use_locked_size(scene, brush))
- brush_set_size(scene, brush, pixel_radius);
-
- /* check if brush is subtracting, use different color then */
- /* TODO: no way currently to know state of pen flip or
- invert key modifier without starting a stroke */
- if((!(brush->flag & BRUSH_INVERTED) ^
- !(brush->flag & BRUSH_DIR_IN)) &&
- ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
- SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
- SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
- outline_col = brush->sub_col;
-
- /* only do if brush is over the mesh */
- if(hit) {
- /* scale the alpha by pen pressure */
- if(sd->draw_pressure && brush_use_alpha_pressure(vc.scene, brush))
- visual_strength *= sd->pressure_value;
-
- paint_cursor_on_hit(sd, brush, &vc, location);
- }
-
- /* don't show effect of strength past the soft limit */
- if(visual_strength > 1)
- visual_strength = 1;
-
- outline_alpha = ((paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) ?
- min_alpha + (visual_strength*(max_alpha-min_alpha)) : 0.50f);
-
- if(sd->draw_anchored) {
- final_radius = sd->anchored_size;
- translation[0] = sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin;
- translation[1] = sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin;
- }
- }
-
- /* make lines pretty */
- glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH);
-
- /* set brush color */
- glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha);
-
- /* draw brush outline */
- glTranslatef(translation[0], translation[1], 0);
- glutil_draw_lined_arc(0.0, M_PI*2.0, final_radius, 40);
- glTranslatef(-translation[0], -translation[1], 0);
-
- /* restore GL state */
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
-}
-
/* if this is a tablet event, return tablet pressure and set *pen_flip
to 1 if the eraser tool is being used, 0 otherwise */
static float event_tablet_data(wmEvent *event, int *pen_flip)
@@ -712,7 +163,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
/* TODO: can remove the if statement once all modes have this */
if(stroke->get_location)
- stroke->get_location(C, stroke, location, mouse);
+ stroke->get_location(C, location, mouse);
else
zero_v3(location);
@@ -976,12 +427,3 @@ int paint_poll(bContext *C)
CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
}
-
-void paint_cursor_start(bContext *C, int (*poll)(bContext *C))
-{
- Paint *p = paint_get_active(CTX_data_scene(C));
-
- if(p && !p->paint_cursor)
- p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
-}
-
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index c9a60236d07..941e885c143 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -497,7 +497,7 @@ void vpaint_dogamma(Scene *scene)
}
*/
-static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -520,7 +520,7 @@ static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
return col;
}
-static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int temp;
@@ -543,7 +543,7 @@ static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
return col;
}
-static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int temp;
@@ -566,7 +566,7 @@ static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
return col;
}
-static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -590,7 +590,7 @@ static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
return col;
}
-static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -618,7 +618,7 @@ static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
return col;
}
-static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -651,18 +651,12 @@ static unsigned int vpaint_blend_tool(const int tool, const unsigned int col,
{
switch (tool) {
case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR:
- return mcol_blend(col, paintcol, alpha_i);
- case PAINT_BLEND_ADD:
- return mcol_add(col, paintcol, alpha_i);
- case PAINT_BLEND_SUB:
- return mcol_sub(col, paintcol, alpha_i);
- case PAINT_BLEND_MUL:
- return mcol_mul(col, paintcol, alpha_i);
- case PAINT_BLEND_LIGHTEN:
- return mcol_lighten(col, paintcol, alpha_i);
- case PAINT_BLEND_DARKEN:
- return mcol_darken(col, paintcol, alpha_i);
+ case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i);
+ case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
+ case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
+ case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
+ case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
+ case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
default:
BLI_assert(0);
return 0;
@@ -797,6 +791,33 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,
return 0.0f;
}
+
+BM_INLINE float wval_blend(const float weight, const float paintval, const float alpha)
+{
+ return (paintval * alpha) + (weight * (1.0f - alpha));
+}
+BM_INLINE float wval_add(const float weight, const float paintval, const float alpha)
+{
+ return weight + (paintval * alpha);
+}
+BM_INLINE float wval_sub(const float weight, const float paintval, const float alpha)
+{
+ return weight - (paintval * alpha);
+}
+BM_INLINE float wval_mul(const float weight, const float paintval, const float alpha)
+{ /* first mul, then blend the fac */
+ return ((1.0f - alpha) + (alpha * paintval)) * weight;
+}
+BM_INLINE float wval_lighten(const float weight, const float paintval, const float alpha)
+{
+ return (weight < paintval) ? wval_blend(weight, paintval, alpha) : weight;
+}
+BM_INLINE float wval_darken(const float weight, const float paintval, const float alpha)
+{
+ return (weight > paintval) ? wval_blend(weight, paintval, alpha) : weight;
+}
+
+
/* vpaint has 'vpaint_blend_tool' */
/* result is not clamped from [0-1] */
static float wpaint_blend_tool(const int tool,
@@ -806,19 +827,12 @@ static float wpaint_blend_tool(const int tool,
{
switch (tool) {
case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR:
- return (paintval * alpha) + (weight * (1.0f - alpha));
- case PAINT_BLEND_ADD:
- return (paintval * alpha) + weight;
- case PAINT_BLEND_SUB:
- return (paintval * alpha) - weight;
- case PAINT_BLEND_MUL:
- /* first mul, then blend the fac */
- return ((1.0f - alpha) + alpha * paintval) * weight;
- case PAINT_BLEND_LIGHTEN:
- return (weight < paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight;
- case PAINT_BLEND_DARKEN:
- return (weight > paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight;
+ case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha);
+ case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha);
+ case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha);
+ case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha);
+ case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
+ case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
default:
BLI_assert(0);
return 0.0f;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 27a0bc8f502..ce84e43955b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3105,7 +3105,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
halfway[0] = (float)dx * 0.5f + cache->initial_mouse[0];
halfway[1] = (float)dy * 0.5f + cache->initial_mouse[1];
- if (sculpt_stroke_get_location(C, stroke, out, halfway)) {
+ if (sculpt_stroke_get_location(C, out, halfway)) {
copy_v3_v3(sd->anchored_location, out);
copy_v2_v2(sd->anchored_initial_mouse, halfway);
copy_v2_v2(cache->tex_mouse, halfway);
@@ -3207,23 +3207,29 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float* tmin)
(This allows us to ignore the GL depth buffer)
Returns 0 if the ray doesn't hit the mesh, non-zero otherwise
*/
-int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float out[3], float mouse[2])
+int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2])
{
- ViewContext *vc = paint_stroke_view_context(stroke);
- Object *ob = vc->obact;
- SculptSession *ss= ob->sculpt;
- StrokeCache *cache= ss->cache;
+ ViewContext vc;
+ Object *ob;
+ SculptSession *ss;
+ StrokeCache *cache;
float ray_start[3], ray_end[3], ray_normal[3], dist;
float obimat[4][4];
float mval[2];
SculptRaycastData srd;
- mval[0] = mouse[0] - vc->ar->winrct.xmin;
- mval[1] = mouse[1] - vc->ar->winrct.ymin;
+ view3d_set_viewcontext(C, &vc);
+
+ ob = vc.obact;
+ ss = ob->sculpt;
+ cache = ss->cache;
sculpt_stroke_modifiers_check(C, ob);
- ED_view3d_win_to_segment_clip(vc->ar, vc->v3d, mval, ray_start, ray_end);
+ mval[0] = mouse[0] - vc.ar->winrct.xmin;
+ mval[1] = mouse[1] - vc.ar->winrct.ymin;
+
+ ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mval, ray_start, ray_end);
invert_m4_m4(obimat, ob->obmat);
mul_m4_v3(obimat, ray_start);
@@ -3232,7 +3238,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
sub_v3_v3v3(ray_normal, ray_end, ray_start);
dist= normalize_v3(ray_normal);
- srd.ss = vc->obact->sculpt;
+ srd.ss = vc.obact->sculpt;
srd.ray_start = ray_start;
srd.ray_normal = ray_normal;
srd.dist = dist;
@@ -3371,14 +3377,14 @@ static void sculpt_flush_update(bContext *C)
/* Returns whether the mouse/stylus is over the mesh (1)
or over the background (0) */
-static int over_mesh(bContext *C, struct wmOperator *op, float x, float y)
+static int over_mesh(bContext *C, struct wmOperator *UNUSED(op), float x, float y)
{
float mouse[2], co[3];
mouse[0] = x;
mouse[1] = y;
- return sculpt_stroke_get_location(C, op->customdata, co, mouse);
+ return sculpt_stroke_get_location(C, co, mouse);
}
static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op,
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 42205a8da04..275d1d52355 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -73,7 +73,7 @@ void sculpt_stroke_free(struct SculptStroke *);
void sculpt_stroke_add_point(struct SculptStroke *, const short x, const short y);
void sculpt_stroke_apply(struct Sculpt *sd, struct SculptStroke *);
void sculpt_stroke_apply_all(struct Sculpt *sd, struct SculptStroke *);
-int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float out[3], float mouse[2]);
+int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2]);
/* Undo */
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 4023797b11a..bf8cb58a2f5 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -121,24 +121,30 @@ typedef struct UvSculptData{
/* Edges used for adjacency info, used with laplacian smoothing */
UvEdge *uvedges;
- /* Need I say more? */
+ /* need I say more? */
int totalUvEdges;
/* data for initial stroke, used by tools like grab */
UVInitialStroke *initial_stroke;
- /* Timer to be used for airbrush-type brush */
+ /* timer to be used for airbrush-type brush */
wmTimer *timer;
- /* To determine quickly adjacent uvs */
+ /* to determine quickly adjacent uvs */
UvElementMap *elementMap;
/* uvsmooth Paint for fast reference */
Paint *uvsculpt;
+
+ /* tool to use. duplicating here to change if modifier keys are pressed */
+ char tool;
+
+ /* store invert flag here */
+ char invert;
}UvSculptData;
/*********** Improved Laplacian Relaxation Operator ************************/
-/* Original code by Raul Fernandez Hernandez "farsthary" *
+/* original code by Raul Fernandez Hernandez "farsthary" *
* adapted to uv smoothing by Antony Riakiatakis *
***************************************************************************/
@@ -292,9 +298,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
float alpha, zoomx, zoomy;
Brush *brush = paint_brush(sculptdata->uvsculpt);
ToolSettings *toolsettings = CTX_data_tool_settings(C);
- tool = RNA_boolean_get(op->ptr, "temp_relax")? UV_SCULPT_TOOL_RELAX : toolsettings->uv_sculpt_tool;
-
- invert = RNA_boolean_get(op->ptr, "invert")? -1 : 1;
+ tool = sculptdata->tool;
+ invert = sculptdata->invert? -1 : 1;
alpha = brush_alpha(scene, brush);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
@@ -463,6 +468,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
int island_index = 0;
/* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
int *uniqueUv;
+ data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH)? UV_SCULPT_TOOL_RELAX : ts->uv_sculpt_tool;
+ data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT)? 1 : 0;
data->uvsculpt = &ts->uvsculpt->paint;
@@ -632,7 +639,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
}
/* Allocate initial selection for grab tool */
- if(ts->uv_sculpt_tool == UV_SCULPT_TOOL_GRAB){
+ if(data->tool){
float radius, radius_root;
UvSculptData *sculptdata = (UvSculptData *)op->customdata;
SpaceImage *sima;
@@ -748,6 +755,13 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
{
+ static EnumPropertyItem stroke_mode_items[] = {
+ {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"},
+ {BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"},
+ {BRUSH_STROKE_SMOOTH, "RELAX", 0, "Relax", "Switch brush to relax mode for duration of stroke"},
+ {0}
+ };
+
/* identifiers */
ot->name = "Sculpt UVs";
ot->description = "Sculpt UVs using a brush";
@@ -762,6 +776,5 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
- RNA_def_boolean(ot->srna, "invert", 0, "Invert", "Inverts the operator");
- RNA_def_boolean(ot->srna, "temp_relax", 0, "Relax", "Relax Tool");
+ RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Mode", "Stroke Mode");
}
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 50c436d88f5..3f3369ac6cb 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -186,7 +186,7 @@ static void SOUND_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono");
}
@@ -207,7 +207,7 @@ static void SOUND_OT_open_mono(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono");
}
@@ -587,7 +587,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
#ifdef WITH_AUDASPACE
RNA_def_int(ot->srna, "accuracy", 1024, 1, 16777216, "Accuracy", "Sample accuracy, important for animation data (the lower the value, the more accurate)", 1, 16777216);
RNA_def_enum(ot->srna, "container", container_items, AUD_CONTAINER_FLAC, "Container", "File format");
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 4c028612320..57981431492 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -1061,7 +1061,6 @@ ID *buttons_context_id_path(const bContext *C)
if(ptr->id.data) {
return ptr->id.data;
- break;
}
}
}
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index df05521fa8d..b1a25d093d2 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -224,7 +224,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot)
ot->cancel= file_browse_cancel;
/* properties */
- WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */
@@ -241,5 +241,5 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot)
ot->cancel= file_browse_cancel;
/* properties */
- WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index eb8f30b6739..a331703690b 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -777,7 +777,9 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
else UI_ThemeColor(TH_SEL_MARKER);
}
- if(sc->flag&SC_SHOW_MARKER_SEARCH) {
+ if((sc->flag&SC_SHOW_MARKER_SEARCH) &&
+ ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0))
+ {
dx= track->search_min[0];
dy= track->search_min[1];
} else if(sc->flag&SC_SHOW_MARKER_PATTERN) {
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index e913ae77f05..6fabe802ff0 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -47,6 +47,7 @@
#include "ED_clip.h"
#include "BIF_gl.h"
+#include "BIF_glutil.h"
#include "WM_types.h"
@@ -120,6 +121,26 @@ static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
glScalef(xscale, 1.0, 1.0);
}
+static void draw_graph_sfra_efra(Scene *scene, View2D *v2d)
+{
+ UI_view2d_view_ortho(v2d);
+
+ /* currently clip editor supposes that editing clip length is equal to scene frame range */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+
+ glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ glDisable(GL_BLEND);
+
+ UI_ThemeColorShade(TH_BACK, -60);
+
+ /* thin lines where the actual frames are */
+ fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
+}
+
static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *marker, int UNUSED(coord), float val)
{
@@ -255,6 +276,9 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
draw_frame_curves(sc);
}
+ /* frame range */
+ draw_graph_sfra_efra(scene, v2d);
+
/* current frame */
draw_graph_cfra(sc, ar, scene);
}
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 8be5e520b1f..6a56de26689 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -30,6 +30,7 @@
*/
#include "DNA_object_types.h" /* SELECT */
+#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
@@ -58,6 +59,19 @@
/******************** common graph-editing utilities ********************/
+static int ED_space_clip_graph_poll(bContext *C)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ if(sc && sc->clip) {
+ ARegion *ar = CTX_wm_region(C);
+
+ return ar->regiontype == RGN_TYPE_PREVIEW;
+ }
+
+ return 0;
+}
+
typedef struct {
int action;
} SelectUserData;
@@ -278,7 +292,7 @@ void CLIP_OT_graph_select(wmOperatorType *ot)
/* api callbacks */
ot->exec= select_exec;
ot->invoke= select_invoke;
- ot->poll= ED_space_clip_poll;
+ ot->poll= ED_space_clip_graph_poll;
/* flags */
ot->flag= OPTYPE_UNDO;
@@ -357,8 +371,112 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot)
/* api callbacks */
ot->exec= delete_knot_exec;
- ot->poll= ED_space_clip_poll;
+ ot->poll= ED_space_clip_graph_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
+/******************** view all operator ********************/
+
+typedef struct {
+ float min, max;
+} ViewAllUserData;
+
+static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *UNUSED(marker),
+ int UNUSED(coord), float val)
+{
+ ViewAllUserData *data = (ViewAllUserData *)userdata;
+
+ if(val < data->min) data->min = val;
+ if(val > data->max) data->max = val;
+}
+
+static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ View2D *v2d = &ar->v2d;
+ ViewAllUserData userdata;
+ float extra;
+
+ userdata.max = -FLT_MAX;
+ userdata.min = FLT_MAX;
+
+ clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, NULL);
+
+ /* set extents of view to start/end frames */
+ v2d->cur.xmin = (float)SFRA;
+ v2d->cur.xmax = (float)EFRA;
+
+ if (userdata.min < userdata.max) {
+ v2d->cur.ymin = userdata.min;
+ v2d->cur.ymax = userdata.max;
+ }
+ else {
+ v2d->cur.ymin = -10;
+ v2d->cur.ymax = 10;
+ }
+
+ /* we need an extra "buffer" factor on either side so that the endpoints are visible */
+ extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
+ v2d->cur.xmin -= extra;
+ v2d->cur.xmax += extra;
+
+ extra= 0.01f * (v2d->cur.ymax - v2d->cur.ymin);
+ v2d->cur.ymin -= extra;
+ v2d->cur.ymax += extra;
+
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_graph_view_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "View All";
+ ot->description = "View all curves in editor";
+ ot->idname = "CLIP_OT_graph_view_all";
+
+ /* api callbacks */
+ ot->exec = view_all_exec;
+ ot->poll = ED_space_clip_graph_poll;
+}
+
+/******************** jump to current frame operator ********************/
+
+void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar)
+{
+ View2D *v2d = &ar->v2d;
+ float extra = (v2d->cur.xmax - v2d->cur.xmin) / 2.0;
+
+ /* set extents of view to start/end frames */
+ v2d->cur.xmin = (float)CFRA - extra;
+ v2d->cur.xmax = (float)CFRA + extra;
+}
+
+static int center_current_frame_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+
+ ED_clip_graph_center_current_frame(scene, ar);
+
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_graph_center_current_frame(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Center Current Frame";
+ ot->description = "Scroll view so current frame would be centered";
+ ot->idname = "CLIP_OT_graph_center_current_frame";
+
+ /* api callbacks */
+ ot->exec = center_current_frame_exec;
+ ot->poll = ED_space_clip_graph_poll;
+}
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 3f7456e90dc..9ff58a73ca2 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -55,9 +55,13 @@ void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y);
void clip_draw_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
/* clip_graph_ops.c */
+void ED_clip_graph_center_current_frame(struct Scene *scene, struct ARegion *ar);
+
void CLIP_OT_graph_select(struct wmOperatorType *ot);
void CLIP_OT_graph_delete_curve(struct wmOperatorType *ot);
void CLIP_OT_graph_delete_knot(struct wmOperatorType *ot);
+void CLIP_OT_graph_view_all(struct wmOperatorType *ot);
+void CLIP_OT_graph_center_current_frame(struct wmOperatorType *ot);
/* clip_ops.c */
void CLIP_OT_open(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 06dd96603ef..5053379d376 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -213,7 +213,7 @@ void CLIP_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************* reload clip operator *********************/
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 04871156412..9eff602fe6b 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -78,7 +78,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
ar->flag|= RGN_FLAG_HIDDEN;
ar->v2d.tot.xmin= 0.0f;
- ar->v2d.tot.ymin= (float)scene->r.sfra - 10.0f;
+ ar->v2d.tot.ymin= -10.0f;
ar->v2d.tot.xmax= (float)scene->r.efra;
ar->v2d.tot.ymax= 10.0f;
@@ -373,6 +373,8 @@ static void clip_operatortypes(void)
WM_operatortype_append(CLIP_OT_graph_select);
WM_operatortype_append(CLIP_OT_graph_delete_curve);
WM_operatortype_append(CLIP_OT_graph_delete_knot);
+ WM_operatortype_append(CLIP_OT_graph_view_all);
+ WM_operatortype_append(CLIP_OT_graph_center_current_frame);
/* object tracking */
WM_operatortype_append(CLIP_OT_tracking_object_new);
@@ -418,6 +420,13 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
RNA_enum_set(kmi->ptr, "mode", SC_MODE_DISTORTION);
RNA_boolean_set(kmi->ptr, "toggle", TRUE);
+ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0);
+ RNA_string_set(kmi->ptr, "data_path", "space_data.view");
+ RNA_string_set(kmi->ptr, "value_1", "CLIP");
+ RNA_string_set(kmi->ptr, "value_2", "GRAPH");
+
+ WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0);
+
/* ******** Hotkeys avalaible for main region only ******** */
keymap= WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0);
@@ -546,6 +555,13 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", DELKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", XKEY, KM_PRESS, KM_SHIFT, 0);
+ /* view */
+ WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PADPERIOD, KM_PRESS, 0, 0);
+
+ kmi= WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0);
+ RNA_string_set(kmi->ptr, "data_path", "space_data.lock_time_cursor");
+
transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
}
@@ -767,6 +783,9 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar)
Scene *scene= CTX_data_scene(C);
short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES;
+ if(sc->flag & SC_LOCK_TIMECURSOR)
+ ED_clip_graph_center_current_frame(scene, ar);
+
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 6cf8a988571..f21b50ec592 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1014,6 +1014,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
SpaceClip *sc= CTX_wm_space_clip(C);
MovieClip *clip= ED_space_clip(sc);
MovieTrackingTrack *track= NULL; /* selected track */
+ MovieTrackingMarker *marker;
ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
int action= RNA_enum_get(op->ptr, "action");
int framenr= sc->user.framenr;
@@ -1024,8 +1025,12 @@ static int select_all_exec(bContext *C, wmOperator *op)
track= tracksbase->first;
while(track) {
if(TRACK_VIEW_SELECTED(sc, track)) {
- action= SEL_DESELECT;
- break;
+ marker= BKE_tracking_get_marker(track, framenr);
+
+ if(MARKER_VISIBLE(sc, marker)) {
+ action= SEL_DESELECT;
+ break;
+ }
}
track= track->next;
@@ -1035,9 +1040,9 @@ static int select_all_exec(bContext *C, wmOperator *op)
track= tracksbase->first;
while(track) {
if((track->flag&TRACK_HIDDEN)==0) {
- MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
+ marker= BKE_tracking_get_marker(track, framenr);
- if(marker && MARKER_VISIBLE(sc, marker)) {
+ if(MARKER_VISIBLE(sc, marker)) {
switch (action) {
case SEL_SELECT:
track->flag|= SELECT;
@@ -1208,7 +1213,7 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip)
track= tracksbase->first;
while(track) {
if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) {
- MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, framenr);
+ MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
if (!marker || (marker->flag&MARKER_DISABLED) == 0)
tot++;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 32fe8498eaf..b5059d157b9 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -586,7 +586,7 @@ const char * filelist_dir(struct FileList* filelist)
void filelist_setdir(struct FileList* filelist, const char *dir)
{
- BLI_strncpy(filelist->dir, dir, FILE_MAX);
+ BLI_strncpy(filelist->dir, dir, sizeof(filelist->dir));
}
void filelist_imgsize(struct FileList* filelist, short w, short h)
@@ -853,10 +853,9 @@ static void filelist_read_library(struct FileList* filelist)
for(num=0; num<filelist->numfiles; num++, file++) {
if(BLO_has_bfile_extension(file->relname)) {
char name[FILE_MAX];
-
- BLI_strncpy(name, filelist->dir, sizeof(name));
- strcat(name, file->relname);
-
+
+ BLI_join_dirfile(name, sizeof(name), filelist->dir, file->relname);
+
/* prevent current file being used as acceptable dir */
if (BLI_path_cmp(G.main->name, name) != 0) {
file->type &= ~S_IFMT;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index bf31775a349..5b4e133e283 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -215,14 +215,19 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->flag |= RNA_boolean_get(op->ptr, "autoselect") ? FILE_AUTOSELECT : 0;
params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0;
}
-
- if (U.uiflag & USER_SHOW_THUMBNAILS) {
- if(params->filter & (IMAGEFILE|MOVIEFILE))
- params->display= FILE_IMGDISPLAY;
- else
+
+ if(RNA_struct_find_property(op->ptr, "display_type"))
+ params->display= RNA_enum_get(op->ptr, "display_type");
+
+ if(params->display==FILE_DEFAULTDISPLAY) {
+ if (U.uiflag & USER_SHOW_THUMBNAILS) {
+ if(params->filter & (IMAGEFILE|MOVIEFILE))
+ params->display= FILE_IMGDISPLAY;
+ else
+ params->display= FILE_SHORTDISPLAY;
+ } else {
params->display= FILE_SHORTDISPLAY;
- } else {
- params->display= FILE_SHORTDISPLAY;
+ }
}
if (is_relative_path) {
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 24b2dc9e41c..fbcb9546a1b 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1188,7 +1188,7 @@ void GRAPH_OT_sound_bake (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00);
RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00);
RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1);
@@ -2069,6 +2069,7 @@ void GRAPH_OT_smooth (wmOperatorType *ot)
/* present a special customised popup menu for this, with some filtering */
static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
+ wmOperatorType *ot = WM_operatortype_find("GRAPH_OT_fmodifier_add", 1);
uiPopupMenu *pup;
uiLayout *layout;
int i;
@@ -2086,7 +2087,7 @@ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNU
continue;
/* create operator menu item with relevant properties filled in */
- props_ptr= uiItemFullO(layout, "GRAPH_OT_fmodifier_add", fmi->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
+ props_ptr= uiItemFullO_ptr(layout, ot, fmi->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
/* the only thing that gets set from the menu is the type of F-Modifier to add */
RNA_enum_set(&props_ptr, "type", i);
/* the following properties are just repeats of existing ones... */
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 41fc861f8e4..9ec9c5ef0e0 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -111,7 +111,8 @@ 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, const char cp[4], const float fp[4], int *zp, float *zpf)
+void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y,
+ const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
{
char str[256];
float dx= 6;
@@ -211,39 +212,46 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
/* color rectangle */
if (channels==1) {
- if (fp)
+ if (fp) {
col[0] = col[1] = col[2] = fp[0];
- else if (cp)
+ }
+ else if (cp) {
col[0] = col[1] = col[2] = (float)cp[0]/255.0f;
- else
+ }
+ else {
col[0] = col[1] = col[2] = 0.0f;
+ }
+ col[3] = 1.0f;
}
else if (channels==3) {
- if (fp)
+ if (fp) {
copy_v3_v3(col, fp);
+ }
else if (cp) {
- col[0] = (float)cp[0]/255.0f;
- col[1] = (float)cp[1]/255.0f;
- col[2] = (float)cp[2]/255.0f;
+ rgb_uchar_to_float(col, cp);
}
- else
+ else {
zero_v3(col);
+ }
+ col[3] = 1.0f;
}
else if (channels==4) {
if (fp)
copy_v4_v4(col, fp);
else if (cp) {
- col[0] = (float)cp[0]/255.0f;
- col[1] = (float)cp[1]/255.0f;
- col[2] = (float)cp[2]/255.0f;
- col[3] = (float)cp[3]/255.0f;
+ rgba_uchar_to_float(col, cp);
}
- else
+ else {
zero_v4(col);
+ }
}
+ else {
+ BLI_assert(0);
+ zero_v4(col);
+ }
+
if (color_manage) {
- linearrgb_to_srgb_v3_v3(finalcol, col);
- finalcol[3] = col[3];
+ linearrgb_to_srgb_v4(finalcol, col);
}
else {
copy_v4_v4(finalcol, col);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 2a8a5b3452f..ea58b4aa737 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -868,7 +868,7 @@ void IMAGE_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************** replace image operator ********************/
@@ -928,7 +928,7 @@ void IMAGE_OT_replace(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************** save image as operator ********************/
@@ -1278,7 +1278,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
/* properties */
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, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************** save image operator ********************/
@@ -1780,12 +1780,12 @@ typedef struct ImageSampleInfo {
int x, y;
int channels;
- char col[4];
+ unsigned char col[4];
float colf[4];
int z;
float zf;
- char *colp;
+ unsigned char *colp;
float *colfp;
int *zp;
float *zfp;
@@ -1820,7 +1820,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) {
float *fp;
- char *cp;
+ unsigned char *cp;
int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y);
CLAMP(x, 0, ibuf->x-1);
@@ -1837,7 +1837,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->zfp= NULL;
if(ibuf->rect) {
- cp= (char *)(ibuf->rect + y*ibuf->x + x);
+ cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x);
info->col[0]= cp[0];
info->col[1]= cp[1];
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 87f9a5d65aa..54e8b1b490d 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -309,7 +309,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
/********************* report box operator *********************/
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 7d475973c09..143173da5bc 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -1233,7 +1233,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point
PropertyRNA *prop;
const char *layer_name;
char scene_name[MAX_ID_NAME-2];
-
+ wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
+
+ BLI_assert(ot != 0);
+
uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
if(!node->id) return;
@@ -1249,10 +1252,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point
scn_ptr = RNA_pointer_get(ptr, "scene");
RNA_string_get(&scn_ptr, "name", scene_name);
- WM_operator_properties_create(&op_ptr, "RENDER_OT_render");
+ WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_string_set(&op_ptr, "layer", layer_name);
RNA_string_set(&op_ptr, "scene", scene_name);
- uiItemFullO(row, "RENDER_OT_render", "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 5beac4ea212..71f0917a4f3 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -1334,7 +1334,7 @@ typedef struct ImageSampleInfo {
int channels;
int color_manage;
- char col[4];
+ unsigned char col[4];
float colf[4];
int draw;
@@ -3519,7 +3519,7 @@ void NODE_OT_add_file(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign");
}
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index a733d45c20b..8d82dd3fb53 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -49,6 +49,8 @@
#include "RNA_access.h"
+#include "NOD_socket.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -205,12 +207,9 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
nodeRemLink(ntree, link);
}
- if(sock_prev->default_value) {
- if(sock_from->default_value)
- MEM_freeN(sock_from->default_value);
-
- sock_from->default_value = MEM_dupallocN(sock_prev->default_value);
- }
+ node_socket_free_default_value(sock_from->type, sock_from->default_value);
+ sock_from->default_value = node_socket_make_default_value(sock_from->type);
+ node_socket_copy_default_value(sock_from->type, sock_from->default_value, sock_prev->default_value);
}
}
}
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 9d4c5705bd1..493fb854585 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -169,6 +169,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
/* note, ED_area_tag_refresh will re-execute compositor */
SpaceNode *snode= sa->spacedata.first;
int type= snode->treetype;
+ short shader_type = snode->shaderfrom;
/* preview renders */
switch(wmn->category) {
@@ -214,6 +215,11 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_refresh(sa);
}
break;
+ case NC_WORLD:
+ if(type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) {
+ ED_area_tag_refresh(sa);
+ }
+ break;
case NC_OBJECT:
if(type==NTREE_SHADER) {
if(wmn->data==ND_OB_SHADING)
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index f8abfb6f4c3..eaa04a1e09e 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1022,6 +1022,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
UI_icon_draw(x, y, ICON_MOD_VERTEX_WEIGHT); break;
case eModifierType_DynamicPaint:
UI_icon_draw(x, y, ICON_MOD_DYNAMICPAINT); break;
+ case eModifierType_Ocean:
+ UI_icon_draw(x, y, ICON_MOD_WAVE); break;
default:
UI_icon_draw(x, y, ICON_DOT); break;
}
@@ -1258,8 +1260,10 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) &&
(tselem->flag & TSE_SEARCHMATCH))
{
- /* TODO - add search highlight color to theme? */
- glColor4f(0.2f, 0.5f, 0.2f, 0.3f);
+ char col[4];
+ UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col);
+ col[3]=100;
+ glColor4ubv((GLubyte *)col);
glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1);
}
@@ -1513,8 +1517,8 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio
}
/* always draw selection fill before hierarchy */
- UI_GetThemeColor3fv(TH_BACK, col);
- glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f);
+ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col);
+ glColor3fv(col);
starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET;
outliner_draw_selection(ar, soops, &soops->tree, &starty);
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 0ccbf9127c6..562cbf45e86 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1429,3 +1429,278 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
+/* ******************** Parent Drop Operator *********************** */
+
+static int parent_drop_exec(bContext *C, wmOperator *op)
+{
+ Object *par = NULL;
+ int partype = -1;
+ char parname[32];
+
+ partype= RNA_enum_get(op->ptr, "type");
+ RNA_string_get(op->ptr, "parent", parname);
+ par= (Object *)find_id("OB", parname);
+
+ ED_object_parent_set(C, op, par, partype);
+
+ return OPERATOR_FINISHED;
+}
+
+/* Used for drag and drop parenting */
+TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement *te, float *fmval)
+{
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ TreeStoreElem *tselem= TREESTORE(te);
+
+ if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
+ /* name and first icon */
+ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
+ /* always makes active object */
+ if (te->idcode == ID_OB) {
+ return te;
+ }
+ else {
+ return NULL;
+ }
+ }
+ }
+
+ /* Not it. Let's look at its children. */
+ if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) {
+ for (te = te->subtree.first; te; te = te->next) {
+ TreeElement *te_valid;
+ te_valid= outliner_dropzone_parent(C, event, te, fmval);
+ if (te_valid) return te_valid;
+ }
+ }
+ return NULL;
+}
+
+static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ Object *par= NULL;
+ Object *ob= NULL;
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ ARegion *ar= CTX_wm_region(C);
+ Scene *scene= CTX_data_scene(C);
+ TreeElement *te= NULL;
+ TreeElement *te_found= NULL;
+ char childname[MAX_ID_NAME];
+ char parname[MAX_ID_NAME];
+ int partype= 0;
+ float fmval[2];
+
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
+
+ /* Find object hovered over */
+ for (te= soops->tree.first; te; te= te->next) {
+ te_found= outliner_dropzone_parent(C, event, te, fmval);
+ if (te_found) break;
+ }
+
+ if(te_found) {
+ RNA_string_set(op->ptr, "parent", te_found->name);
+ /* Identify parent and child */
+ RNA_string_get(op->ptr, "child", childname);
+ ob= (Object *)find_id("OB", childname);
+ RNA_string_get(op->ptr, "parent", parname);
+ par= (Object *)find_id("OB", parname);
+
+ if (ELEM(NULL, ob, par)) {
+ if (par == NULL) printf("par==NULL\n");
+ return OPERATOR_CANCELLED;
+ }
+ if (ob == par) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* check dragged object (child) is active */
+ if (ob != CTX_data_active_object(C))
+ ED_base_object_select(object_in_scene(ob, scene), BA_SELECT);
+
+ if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) {
+ ED_object_parent_set(C, op, par, partype);
+ }
+ else {
+ /* Menu creation */
+ uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", ICON_NONE);
+ uiLayout *layout= uiPupMenuLayout(pup);
+
+ PointerRNA ptr;
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_OBJECT);
+ /* Cannot use uiItemEnumO()... have multiple properties to set. */
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Object", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ /* par becomes parent, make the associated menus */
+ if (par->type==OB_ARMATURE) {
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_ARMATURE);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Armature Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_ARMATURE_NAME);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Empty Groups", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_ARMATURE_ENVELOPE);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Envelope Weights", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_ARMATURE_AUTO);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Automatic Weights", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_BONE);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Bone", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+ }
+ else if (par->type==OB_CURVE) {
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_CURVE);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Curve Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_FOLLOW);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Follow Path", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_PATH_CONST);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Path Constraint", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+ }
+ else if (par->type == OB_LATTICE) {
+ WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
+ RNA_string_set(&ptr, "parent", parname);
+ RNA_string_set(&ptr, "child", childname);
+ RNA_enum_set(&ptr, "type", PAR_LATTICE);
+ uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Lattice Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
+ }
+
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_parent_drop(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Drop to Set Parent";
+ ot->description = "Drag to parent in Outliner";
+ ot->idname= "OUTLINER_OT_parent_drop";
+
+ /* api callbacks */
+ ot->invoke= parent_drop_invoke;
+ ot->exec= parent_drop_exec;
+
+ ot->poll= ED_operator_outliner_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object");
+ RNA_def_string(ot->srna, "parent", "Object", MAX_ID_NAME, "Parent", "Parent Object");
+ RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", "");
+}
+
+int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, float *fmval)
+{
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ TreeStoreElem *tselem= TREESTORE(te);
+
+ /* Check for row */
+ if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
+ /* Ignore drop on scene tree elements */
+ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
+ if ((te->idcode == ID_SCE) &&
+ !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS))
+ {
+ return 0;
+ }
+ // Other codes to ignore?
+ }
+
+ /* Left or right of: (+), first icon, and name */
+ if ((fmval[0] < (te->xs + UI_UNIT_X)) || (fmval[0] > te->xend)) {
+ return 1;
+ }
+ else if (te->idcode != ID_OB) {
+ return 1;
+ }
+
+ return 0; // ID_OB, but mouse in undefined dropzone.
+ }
+
+ /* Not this row. Let's look at its children. */
+ if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) {
+ for (te = te->subtree.first; te; te = te->next) {
+ if (outliner_dropzone_parent_clear(C, event, te, fmval))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= NULL;
+ char obname[MAX_ID_NAME];
+
+ RNA_string_get(op->ptr, "dragged_obj", obname);
+ ob= (Object *)find_id("OB", obname);
+
+ /* check dragged object (child) is active */
+ if (ob != CTX_data_active_object(C))
+ ED_base_object_select(object_in_scene(ob, scene), BA_SELECT);
+
+ ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type"));
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_parent_clear(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Drop to Clear Parent";
+ ot->description = "Drag to clear parent in Outliner";
+ ot->idname= "OUTLINER_OT_parent_clear";
+
+ /* api callbacks */
+ ot->invoke= parent_clear_invoke;
+
+ ot->poll= ED_operator_outliner_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object");
+ RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
+}
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 4065b3e2e0b..be33fc2e37a 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -188,6 +188,9 @@ void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, Tree
void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
+TreeElement *outliner_dropzone_parent(struct bContext *C, struct wmEvent *event, struct TreeElement *te, float *fmval);
+int outliner_dropzone_parent_clear(struct bContext *C, struct wmEvent *event, struct TreeElement *te, float *fmval);
+
/* ...................................................... */
void OUTLINER_OT_item_activate(struct wmOperatorType *ot);
@@ -198,6 +201,8 @@ void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
void OUTLINER_OT_show_active(struct wmOperatorType *ot);
void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
+void OUTLINER_OT_select_border(struct wmOperatorType *ot);
+
void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot);
void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
@@ -213,6 +218,9 @@ void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot);
void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot);
void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot);
+void OUTLINER_OT_parent_drop(struct wmOperatorType *ot);
+void OUTLINER_OT_parent_clear(struct wmOperatorType *ot);
+
/* outliner_tools.c ---------------------------------------------- */
void OUTLINER_OT_operation(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index a424520c76f..17434d0f6c9 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -49,6 +49,7 @@
void outliner_operatortypes(void)
{
WM_operatortype_append(OUTLINER_OT_item_activate);
+ WM_operatortype_append(OUTLINER_OT_select_border);
WM_operatortype_append(OUTLINER_OT_item_openclose);
WM_operatortype_append(OUTLINER_OT_item_rename);
WM_operatortype_append(OUTLINER_OT_operation);
@@ -76,6 +77,9 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_drivers_add_selected);
WM_operatortype_append(OUTLINER_OT_drivers_delete_selected);
+
+ WM_operatortype_append(OUTLINER_OT_parent_drop);
+ WM_operatortype_append(OUTLINER_OT_parent_clear);
}
void outliner_keymap(wmKeyConfig *keyconf)
@@ -89,6 +93,8 @@ void outliner_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "extend", FALSE);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
+
+ WM_keymap_add_item(keymap, "OUTLINER_OT_select_border", BKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "all", FALSE);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index bf570c929cc..345e7a835f4 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -875,3 +875,78 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
}
/* ****************************************************** */
+
+/* **************** Border Select Tool ****************** */
+static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *rectf, TreeElement *te, int gesture_mode)
+{
+ TreeStoreElem *tselem= TREESTORE(te);
+
+ if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) {
+ if (gesture_mode == GESTURE_MODAL_SELECT) {
+ tselem->flag |= TSE_SELECTED;
+ }
+ else {
+ tselem->flag &= ~TSE_SELECTED;
+ }
+ }
+
+ /* Look at its children. */
+ if ((tselem->flag & TSE_CLOSED) == 0) {
+ for (te = te->subtree.first; te; te = te->next) {
+ outliner_item_border_select(scene, soops, rectf, te, gesture_mode);
+ }
+ }
+ return;
+}
+
+static int outliner_border_select_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ ARegion *ar= CTX_wm_region(C);
+ TreeElement *te;
+ rcti rect;
+ rctf rectf;
+ int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
+
+ rect.xmin= RNA_int_get(op->ptr, "xmin");
+ rect.ymin= RNA_int_get(op->ptr, "ymin");
+ UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
+
+ rect.xmax= RNA_int_get(op->ptr, "xmax");
+ rect.ymax= RNA_int_get(op->ptr, "ymax");
+ UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+
+ for(te= soops->tree.first; te; te= te->next) {
+ outliner_item_border_select(scene, soops, &rectf, te, gesture_mode);
+ }
+
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_select_border(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Border Select";
+ ot->idname= "OUTLINER_OT_select_border";
+ ot->description= "Use box selection to select tree elements";
+
+ /* api callbacks */
+ ot->invoke= WM_border_select_invoke;
+ ot->exec= outliner_border_select_exec;
+ ot->modal= WM_border_select_modal;
+ ot->cancel= WM_border_select_cancel;
+
+ ot->poll= ED_operator_outliner_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* rna */
+ WM_operator_properties_gesture_border(ot, FALSE);
+}
+
+/* ****************************************************** */
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 673ddaebc5f..a040c63b2ab 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -50,6 +50,8 @@
#include "BIF_gl.h"
+#include "RNA_access.h"
+
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -58,6 +60,7 @@
static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar)
{
+ ListBase *lb;
wmKeyMap *keymap;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
@@ -66,6 +69,88 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar)
keymap= WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0);
/* don't pass on view2d mask, it's always set with scrollbar space, hide fails */
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct);
+
+ /* Add dropboxes */
+ lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
+ WM_event_add_dropbox_handler(&ar->handlers, lb);
+}
+
+static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+ ARegion *ar= CTX_wm_region(C);
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ TreeElement *te= NULL;
+ float fmval[2];
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
+
+ if(drag->type == WM_DRAG_ID) {
+ ID *id = (ID *)drag->poin;
+ if( GS(id->name) == ID_OB ) {
+ /* Ensure item under cursor is valid drop target */
+ /* Find object hovered over */
+ for(te= soops->tree.first; te; te= te->next) {
+ TreeElement *te_valid;
+ te_valid= outliner_dropzone_parent(C, event, te, fmval);
+ if(te_valid) return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+ ID *id = (ID *)drag->poin;
+
+ RNA_string_set(drop->ptr, "child", id->name+2);
+}
+
+static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+ ARegion *ar= CTX_wm_region(C);
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ TreeElement *te= NULL;
+ float fmval[2];
+
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
+
+ if(drag->type == WM_DRAG_ID) {
+ ID *id = (ID *)drag->poin;
+ if( GS(id->name) == ID_OB ) {
+ //TODO: Check if no parent?
+ /* Ensure location under cursor is valid dropzone */
+ for(te= soops->tree.first; te; te= te->next) {
+ if(outliner_dropzone_parent_clear(C, event, te, fmval)) return 1;
+ }
+ /* Check if mouse cursor is below the tree */
+ te= soops->tree.last;
+ while(((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) {
+ te= te->subtree.last;
+ }
+ if(fmval[1] < te->ys) return 1;
+ }
+ }
+ return 0;
+}
+
+static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop)
+{
+ ID *id = (ID *)drag->poin;
+ RNA_string_set(drop->ptr, "dragged_obj", id->name+2);
+
+ /* Set to simple parent clear type. Avoid menus for drag and drop if possible.
+ * If desired, user can toggle the different "Clear Parent" types in the operator
+ * menu on tool shelf. */
+ RNA_enum_set(drop->ptr, "type", 0);
+}
+
+/* region dropbox definition */
+static void outliner_dropboxes(void)
+{
+ ListBase *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
+
+ WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy);
+ WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy);
}
static void outliner_main_area_draw(const bContext *C, ARegion *ar)
@@ -302,6 +387,7 @@ void ED_spacetype_outliner(void)
st->duplicate= outliner_duplicate;
st->operatortypes= outliner_operatortypes;
st->keymap= outliner_keymap;
+ st->dropboxes= outliner_dropboxes;
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype time region");
diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c
index b0c2de390a2..7702e952e24 100644
--- a/source/blender/editors/space_script/script_edit.c
+++ b/source/blender/editors/space_script/script_edit.c
@@ -96,8 +96,8 @@ static int script_reload_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
#else
(void)C; /* unused */
-#endif
return OPERATOR_CANCELLED;
+#endif
}
void SCRIPT_OT_reload(wmOperatorType *ot)
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index f1d3d65559d..66aefc72f33 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -402,7 +402,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES);
+ WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie");
}
@@ -454,7 +454,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES);
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory");
}
@@ -558,7 +558,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILES);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME);
}
@@ -734,7 +734,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME);
RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type");
RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 176ffd91e3b..511f1524fae 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -143,7 +143,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[
case SEQ_COLOR:
if (colvars->col) {
- rgb_float_to_byte(colvars->col, col);
+ rgb_float_to_uchar(col, colvars->col);
} else {
col[0] = col[1] = col[2] = 128;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index c46a1eebc2e..e88664ac817 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3060,5 +3060,5 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY);
}
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index eab06474546..db8c1b230ba 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -303,7 +303,7 @@ void TEXT_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path
+ WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path
RNA_def_boolean(ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
}
@@ -563,7 +563,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
ot->poll= text_edit_poll;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path
+ WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path
}
/******************* run script operator *********************/
@@ -2412,7 +2412,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
{
Text *text = st->text;
int max = wrap_width(st, ar); /* view */
- int charp; /* mem */
+ int charp = -1; /* mem */
int loop = 1, found = 0; /* flags */
char ch;
@@ -2513,9 +2513,11 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in
y--;
}
-
- if(sel) { text->sell = linep; text->selc = charp; }
- else { text->curl = linep; text->curc = charp; }
+
+ if (linep && charp != -1) {
+ if(sel) { text->sell = linep; text->selc = charp; }
+ else { text->curl = linep; text->curc = charp; }
+ }
}
static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
@@ -3187,25 +3189,25 @@ static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, wmEvent *UN
/* modified locally and externally, ahhh. offer more possibilites. */
pup= uiPupMenuBegin(C, "File Modified Outside and Inside Blender", ICON_NONE);
layout= uiPupMenuLayout(pup);
- uiItemEnumO(layout, op->type->idname, "Reload from disk (ignore local changes)", 0, "resolution", RESOLVE_RELOAD);
- uiItemEnumO(layout, op->type->idname, "Save to disk (ignore outside changes)", 0, "resolution", RESOLVE_SAVE);
- uiItemEnumO(layout, op->type->idname, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL);
+ uiItemEnumO_ptr(layout, op->type, "Reload from disk (ignore local changes)", 0, "resolution", RESOLVE_RELOAD);
+ uiItemEnumO_ptr(layout, op->type, "Save to disk (ignore outside changes)", 0, "resolution", RESOLVE_SAVE);
+ uiItemEnumO_ptr(layout, op->type, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL);
uiPupMenuEnd(C, pup);
}
else {
pup= uiPupMenuBegin(C, "File Modified Outside Blender", ICON_NONE);
layout= uiPupMenuLayout(pup);
- uiItemEnumO(layout, op->type->idname, "Reload from disk", 0, "resolution", RESOLVE_RELOAD);
- uiItemEnumO(layout, op->type->idname, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL);
- uiItemEnumO(layout, op->type->idname, "Ignore", 0, "resolution", RESOLVE_IGNORE);
+ uiItemEnumO_ptr(layout, op->type, "Reload from disk", 0, "resolution", RESOLVE_RELOAD);
+ uiItemEnumO_ptr(layout, op->type, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL);
+ uiItemEnumO_ptr(layout, op->type, "Ignore", 0, "resolution", RESOLVE_IGNORE);
uiPupMenuEnd(C, pup);
}
break;
case 2:
pup= uiPupMenuBegin(C, "File Deleted Outside Blender", ICON_NONE);
layout= uiPupMenuLayout(pup);
- uiItemEnumO(layout, op->type->idname, "Make text internal", 0, "resolution", RESOLVE_MAKE_INTERNAL);
- uiItemEnumO(layout, op->type->idname, "Recreate file", 0, "resolution", RESOLVE_SAVE);
+ uiItemEnumO_ptr(layout, op->type, "Make text internal", 0, "resolution", RESOLVE_MAKE_INTERNAL);
+ uiItemEnumO_ptr(layout, op->type, "Recreate file", 0, "resolution", RESOLVE_SAVE);
uiPupMenuEnd(C, pup);
break;
}
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 65ef3273e30..bf1b1ddc18a 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -193,6 +193,10 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
col[3] = 0.1;
break;
+ default:
+ BLI_assert(0);
+ col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
+ col[3] = 0.1;
}
glColor4fv(col);
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 17cb1ce2995..599e113ba97 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -526,7 +526,8 @@ static void draw_bone_solid_octahedral(void)
glEnableClientState(GL_VERTEX_ARRAY);
glNormalPointer(GL_FLOAT, 0, bone_octahedral_solid_normals);
glVertexPointer(3, GL_FLOAT, 0, bone_octahedral_verts);
- glDrawElements(GL_TRIANGLES, sizeof(bone_octahedral_solid_tris)/sizeof(unsigned int), GL_UNSIGNED_INT, bone_octahedral_solid_tris);
+ glDrawElements(GL_TRIANGLES, sizeof(bone_octahedral_solid_tris)/sizeof(unsigned int),
+ GL_UNSIGNED_INT, bone_octahedral_solid_tris);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
#endif
@@ -738,7 +739,9 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
/* smat, imat = mat & imat to draw screenaligned */
-static void draw_sphere_bone_wire(float smat[][4], float imat[][4], int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
+static void draw_sphere_bone_wire(float smat[][4], float imat[][4],
+ int armflag, int boneflag, short constflag, unsigned int id,
+ bPoseChannel *pchan, EditBone *ebone)
{
float head, tail /*, length*/;
float *headvec, *tailvec, dirvec[3];
@@ -843,7 +846,8 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], int armflag,
}
/* does wire only for outline selecting */
-static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
+static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id,
+ bPoseChannel *pchan, EditBone *ebone)
{
GLUquadricObj *qobj;
float head, tail, length;
@@ -973,7 +977,8 @@ static GLubyte bm_dot5[]= {0x0, 0x0, 0x10, 0x38, 0x7c, 0x38, 0x10, 0x0};
static GLubyte bm_dot7[]= {0x0, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38};
-static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
+static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id,
+ bPoseChannel *pchan, EditBone *ebone)
{
float length;
@@ -1107,7 +1112,8 @@ static void draw_b_bone_boxes(int dt, bPoseChannel *pchan, float xwidth, float l
}
}
-static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
+static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id,
+ bPoseChannel *pchan, EditBone *ebone)
{
float xwidth, length, zwidth;
@@ -1220,7 +1226,8 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len
}
}
-static void draw_wire_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
+static void draw_wire_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id,
+ bPoseChannel *pchan, EditBone *ebone)
{
Mat4 *bbones = NULL;
int segments = 0;
@@ -1340,7 +1347,8 @@ static void draw_bone(int dt, int armflag, int boneflag, short constflag, unsign
}
}
-static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int dt, int armflag, int boneflag, unsigned int id, float length)
+static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob,
+ int dt, int armflag, int boneflag, unsigned int id, float length)
{
if(ob==NULL) return;
@@ -1573,7 +1581,8 @@ static void draw_pose_dofs(Object *ob)
glColor3ub(50, 50, 255); // blue, Z axis limit
glBegin(GL_LINE_STRIP);
for (a=-16; a<=16; a++) {
- float fac= ((float)a)/16.0f * 0.5f; /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
+ /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
+ float fac= ((float)a)/16.0f * 0.5f;
phi= fac * (pchan->limitmax[2] - pchan->limitmin[2]);
@@ -1596,7 +1605,8 @@ static void draw_pose_dofs(Object *ob)
glColor3ub(255, 50, 50); // Red, X axis limit
glBegin(GL_LINE_STRIP);
for (a=-16; a<=16; a++) {
- float fac= ((float)a)/16.0f * 0.5f; /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
+ /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
+ float fac= ((float)a)/16.0f * 0.5f;
phi= (float)(0.5*M_PI) + fac * (pchan->limitmax[0] - pchan->limitmin[0]);
i= (a == -16) ? 2 : 3;
@@ -1630,7 +1640,8 @@ static void bone_matrix_translate_y(float mat[][4], float y)
}
/* assumes object is Armature with pose */
-static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, const short is_ghost, const short is_outline)
+static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt,
+ const short is_ghost, const short is_outline)
{
RegionView3D *rv3d= ar->regiondata;
Object *ob= base->object;
@@ -1730,10 +1741,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (use_custom) {
/* if drawwire, don't try to draw in solid */
- if (pchan->bone->flag & BONE_DRAWWIRE)
+ if (pchan->bone->flag & BONE_DRAWWIRE) {
draw_wire= 1;
- else
- draw_custom_bone(scene, v3d, rv3d, pchan->custom, OB_SOLID, arm->flag, flag, index, bone->length);
+ }
+ else {
+ draw_custom_bone(scene, v3d, rv3d, pchan->custom,
+ OB_SOLID, arm->flag, flag, index, bone->length);
+ }
}
else if (arm->drawtype==ARM_LINE)
; /* nothing in solid */
@@ -1817,7 +1831,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (bone == arm->act_bone)
flag |= BONE_DRAW_ACTIVE;
- draw_custom_bone(scene, v3d, rv3d, pchan->custom, OB_WIRE, arm->flag, flag, index, bone->length);
+ draw_custom_bone(scene, v3d, rv3d, pchan->custom,
+ OB_WIRE, arm->flag, flag, index, bone->length);
glPopMatrix();
}
@@ -1966,7 +1981,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
unsigned char col[4];
float col_f[4];
glGetFloatv(GL_CURRENT_COLOR, col_f); /* incase this is not set below */
- rgb_float_to_byte(col_f, col);
+ rgb_float_to_uchar(col, col_f);
col[3]= 255;
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
@@ -2580,7 +2595,3 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in
return retval;
}
-
-/* *************** END Armature drawing ******************* */
-
-
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index b1842578c20..62c12500aa8 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -349,11 +349,8 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
}
- obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255);
- obcol[1]= CLAMPIS(ob->col[1]*255, 0, 255);
- obcol[2]= CLAMPIS(ob->col[2]*255, 0, 255);
- obcol[3]= CLAMPIS(ob->col[3]*255, 0, 255);
-
+ rgba_float_to_uchar(obcol, ob->col);
+
glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
if(solidtex || v3d->drawtype==OB_TEXTURE) istex= 1;
else istex= 0;
@@ -716,7 +713,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
}
else {
if(GPU_buffer_legacy(dm)) {
- if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)
+ if (draw_flags & DRAW_MODIFIERS_PREVIEW)
dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL);
else
dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL);
@@ -852,7 +849,7 @@ static int tex_mat_set_face_editmesh_cb(void *UNUSED(userData), int index)
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
{
- if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
+ if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) {
draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags);
return;
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 193f9b1f49f..2766ddab15b 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -36,7 +36,6 @@
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
#include "DNA_constraint_types.h" // for drawing constraint
-#include "DNA_dynamicpaint_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
@@ -155,6 +154,10 @@ typedef struct drawDMFacesSel_userData {
int *orig_index;
} drawDMFacesSel_userData;
+typedef struct drawDMNormal_userData {
+ float normalsize;
+} drawDMNormal_userData;
+
typedef struct bbsObmodeMeshVerts_userData {
void *offset;
MVert *mvert;
@@ -2213,20 +2216,24 @@ void nurbs_foreachScreenVert(
static void draw_dm_face_normals__mapFunc(void *userData, int index, float *cent, float *no)
{
- ToolSettings *ts= ((Scene *)userData)->toolsettings;
+ drawDMNormal_userData *data = userData;
EditFace *efa = EM_get_face_for_index(index);
if (efa->h==0 && efa->fgonf!=EM_FGON) {
glVertex3fv(cent);
- glVertex3f( cent[0] + no[0]*ts->normalsize,
- cent[1] + no[1]*ts->normalsize,
- cent[2] + no[2]*ts->normalsize);
+ glVertex3f(cent[0] + no[0] * data->normalsize,
+ cent[1] + no[1] * data->normalsize,
+ cent[2] + no[2] * data->normalsize);
}
}
static void draw_dm_face_normals(Scene *scene, DerivedMesh *dm)
{
+ drawDMNormal_userData data;
+
+ data.normalsize = scene->toolsettings->normalsize;
+
glBegin(GL_LINES);
- dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, scene);
+ dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, &data);
glEnd();
}
@@ -2248,28 +2255,32 @@ static void draw_dm_face_centers(DerivedMesh *dm, int sel)
static void draw_dm_vert_normals__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
{
- Scene *scene= (Scene *)userData;
- ToolSettings *ts= scene->toolsettings;
+ drawDMNormal_userData *data = userData;
EditVert *eve = EM_get_vert_for_index(index);
if (eve->h==0) {
glVertex3fv(co);
if (no_f) {
- glVertex3f( co[0] + no_f[0]*ts->normalsize,
- co[1] + no_f[1]*ts->normalsize,
- co[2] + no_f[2]*ts->normalsize);
- } else {
- glVertex3f( co[0] + no_s[0]*ts->normalsize/32767.0f,
- co[1] + no_s[1]*ts->normalsize/32767.0f,
- co[2] + no_s[2]*ts->normalsize/32767.0f);
+ glVertex3f(co[0] + no_f[0] * data->normalsize,
+ co[1] + no_f[1] * data->normalsize,
+ co[2] + no_f[2] * data->normalsize);
+ }
+ else {
+ glVertex3f(co[0] + no_s[0] * (data->normalsize / 32767.0f),
+ co[1] + no_s[1] * (data->normalsize / 32767.0f),
+ co[2] + no_s[2] * (data->normalsize / 32767.0f));
}
}
}
static void draw_dm_vert_normals(Scene *scene, DerivedMesh *dm)
{
+ drawDMNormal_userData data;
+
+ data.normalsize = scene->toolsettings->normalsize;
+
glBegin(GL_LINES);
- dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, scene);
+ dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data);
glEnd();
}
@@ -2695,10 +2706,14 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, EditMesh *em, UnitSet
mul_mat3_m4_v3(ob->obmat, v1);
mul_mat3_m4_v3(ob->obmat, v2);
}
- if(unit->system)
- bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE);
- else
+
+ if(unit->system) {
+ bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3,
+ unit->system, B_UNIT_LENGTH, do_split, FALSE);
+ }
+ else {
sprintf(numstr, conv_float, len_v3v3(v1, v2));
+ }
view3d_cached_text_draw_add(vmid, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
}
@@ -2706,7 +2721,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, EditMesh *em, UnitSet
}
if(me->drawflag & ME_DRAWEXTRA_FACEAREA) {
-// XXX extern int faceselectedOR(EditFace *efa, int flag); // editmesh.h shouldn't be in this file... ok for now?
+// XXX extern int faceselectedOR(EditFace *efa, int flag); // editmesh.h shouldn't be in this file... ok for now?
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
for(efa= em->faces.first; efa; efa= efa->next) {
@@ -2729,10 +2744,14 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, EditMesh *em, UnitSet
else
area = area_tri_v3(v1, v2, v3);
- if(unit->system)
- bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA
- else
+ if(unit->system) {
+ // XXX should be B_UNIT_AREA
+ bUnit_AsString(numstr, sizeof(numstr), area * unit->scale_length, 3,
+ unit->system, B_UNIT_LENGTH, do_split, FALSE);
+ }
+ else {
sprintf(numstr, conv_float, area);
+ }
view3d_cached_text_draw_add(efa->cent, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
}
@@ -3073,27 +3092,16 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
eWireDrawMode draw_wire= OBDRAW_WIRE_OFF;
int /* totvert,*/ totedge, totface;
DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
- ModifierData *md = NULL;
const short is_obact= (ob == OBACT);
int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
if(!dm)
return;
- /* check to draw dynamic paint colors */
- if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint)))
- {
- /* check if target has an active dpaint modifier */
- if(md && (md->mode & eModifierMode_Realtime))
- {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- /* if canvas is ready to preview vertex colors */
- if (pmd->canvas && pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY &&
- DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) {
- draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW;
- }
- }
- }
+ /* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
+ * Note: Last "preview-active" modifier in stack will win! */
+ if(DM_get_face_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob))
+ draw_flags |= DRAW_MODIFIERS_PREVIEW;
/* Unwanted combination */
if (draw_flags & DRAW_FACE_SELECT) {
@@ -3134,7 +3142,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
draw_mesh_object_outline(v3d, ob, dm);
}
- if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
+ if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
dm->drawFacesGLSL(dm, GPU_enable_material);
@@ -3185,7 +3193,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
/* since we already draw wire as wp guide, dont draw over the top */
draw_wire= OBDRAW_WIRE_OFF;
}
- else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) {
+ else if (draw_flags & DRAW_MODIFIERS_PREVIEW) {
/* for object selection draws no shade */
if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) {
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
@@ -4100,7 +4108,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(v3d->zbuf) glDepthMask(1);
if((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
- rgb_float_to_byte(&(ma->r), tcol);
+ rgb_float_to_uchar(tcol, &(ma->r));
copy_v3_v3(ma_col, &ma->r);
}
@@ -6152,7 +6160,7 @@ static void drawRBpivot(bRigidBodyJointConstraint *data)
float curcol[4];
unsigned char tcol[4];
glGetFloatv(GL_CURRENT_COLOR, curcol);
- rgb_float_to_byte(curcol, tcol);
+ rgb_float_to_uchar(tcol, curcol);
tcol[3]= 255;
eul_to_mat4(mat,&data->axX);
@@ -6775,7 +6783,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
float curcol[4];
unsigned char tcol[4];
glGetFloatv(GL_CURRENT_COLOR, curcol);
- rgb_float_to_byte(curcol, tcol);
+ rgb_float_to_uchar(tcol, curcol);
tcol[3]= 255;
view3d_cached_text_draw_add(zero, ob->id.name+2, 10, 0, tcol);
}
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 8308a4a9ccf..1ed8e44a26b 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -170,7 +170,8 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
float cor[3] = {1.,1.,1.};
int gl_depth = 0, gl_blend = 0;
- /* draw slices of smoke is adapted from c++ code authored by: Johannes Schmid and Ingemar Rask, 2006, johnny@grob.org */
+ /* draw slices of smoke is adapted from c++ code authored
+ * by: Johannes Schmid and Ingemar Rask, 2006, johnny@grob.org */
float cv[][3] = {
{1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, -1.0f, 1.0f},
{1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f}
@@ -424,7 +425,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0);
for (i = 0; i < numpoints; i++) {
- glTexCoord3d((points[i * 3 + 0] - min[0] )*cor[0]/size[0], (points[i * 3 + 1] - min[1])*cor[1]/size[1], (points[i * 3 + 2] - min[2])*cor[2]/size[2]);
+ glTexCoord3d((points[i * 3 + 0] - min[0]) * cor[0] / size[0],
+ (points[i * 3 + 1] - min[1]) * cor[1] / size[1],
+ (points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
glVertex3f(points[i * 3 + 0], points[i * 3 + 1], points[i * 3 + 2]);
}
glEnd();
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index f2906ca9559..94ab847c91b 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1023,7 +1023,8 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn)
break;
}
-#if 0 // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier.
+ // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier.
+#if 0
if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) {
View3D *v3d = area->spacedata.first;
BGpic *bgpic = v3d->bgpicbase.first;
@@ -1048,7 +1049,8 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
View3D *v3d= CTX_wm_view3d(C);
Scene *scene= CTX_data_scene(C);
Base *base;
- unsigned int lay = v3d ? v3d->lay:scene->lay; /* fallback to the scene layer, allows duplicate and other oject operators to run outside the 3d view */
+ /* fallback to the scene layer, allows duplicate and other object operators to run outside the 3d view */
+ unsigned int lay = v3d ? v3d->lay:scene->lay;
if(CTX_data_dir(member)) {
CTX_data_dir_set(result, view3d_context_dir);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 1fa50124a28..4f46a746b9e 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -471,7 +471,8 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
/* emphasise division lines lighter instead of darker, if background is darker than grid */
UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10);
UI_GetColorPtrShade3ubv(col_grid, col_grid_emphasise,
- (((col_grid[0]+col_grid[1]+col_grid[2])+30) > (col_bg[0]+col_bg[1]+col_bg[2])) ? 20 : -10);
+ (((col_grid[0]+col_grid[1]+col_grid[2])+30) >
+ (col_bg[0]+col_bg[1]+col_bg[2])) ? 20 : -10);
/* set fixed axis */
vert[0][0]= vert[2][1]= grid;
@@ -923,7 +924,8 @@ static void draw_selected_name(Scene *scene, Object *ob)
BLF_draw_default(offset, 10, 0.0f, info, sizeof(info));
}
-static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift, short no_zoom)
+static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
+ rctf *viewborder_r, short no_shift, short no_zoom)
{
CameraParams params;
rctf rect_view, rect_camera;
@@ -962,7 +964,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R
size_r[1]= viewborder.ymax - viewborder.ymin;
}
-void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift)
+void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
+ rctf *viewborder_r, short no_shift)
{
view3d_camera_border(scene, ar, v3d, rv3d, viewborder_r, no_shift, FALSE);
}
@@ -1395,7 +1398,12 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax,
view3d_validate_backbuf(vc);
- glReadPixels(vc->ar->winrct.xmin+xminc, vc->ar->winrct.ymin+yminc, (xmaxc-xminc+1), (ymaxc-yminc+1), GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glReadPixels(vc->ar->winrct.xmin + xminc,
+ vc->ar->winrct.ymin + yminc,
+ (xmaxc-xminc + 1),
+ (ymaxc-yminc + 1),
+ GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+
glReadBuffer(GL_BACK);
if(ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
@@ -1819,11 +1827,13 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
* offset feature (used in group-duplicate.blend but no longer works in 2.5)
* so for now it should be ok to - campbell */
- if( (dob_next==NULL || dob_next->ob != dob->ob) || /* if this is the last no need to make a displist */
- (dob->ob->type == OB_LAMP) || /* lamp drawing messes with matrices, could be handled smarter... but this works */
- (dob->type == OB_DUPLIGROUP && dob->animated) ||
- !(bb_tmp= object_get_boundbox(dob->ob))
- ) {
+ if ( /* if this is the last no need to make a displist */
+ (dob_next==NULL || dob_next->ob != dob->ob) ||
+ /* lamp drawing messes with matrices, could be handled smarter... but this works */
+ (dob->ob->type == OB_LAMP) ||
+ (dob->type == OB_DUPLIGROUP && dob->animated) ||
+ !(bb_tmp= object_get_boundbox(dob->ob)))
+ {
// printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2);
use_displist= 0;
}
@@ -2151,7 +2161,8 @@ typedef struct View3DShadow {
GPULamp *lamp;
} View3DShadow;
-static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object *par, float obmat[][4], ListBase *shadows)
+static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object *par,
+ float obmat[][4], ListBase *shadows)
{
GPULamp *lamp;
Lamp *la = (Lamp*)ob->data;
@@ -2245,7 +2256,9 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d)
{
CustomDataMask mask= 0;
- if(ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) || ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) {
+ if ( ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) ||
+ ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX)))
+ {
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
if(scene_use_new_shading_nodes(scene)) {
@@ -2353,7 +2366,8 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
glLoadMatrixf(rv3d->viewmat);
}
-void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4])
+void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
+ int winx, int winy, float viewmat[][4], float winmat[][4])
{
RegionView3D *rv3d= ar->regiondata;
Base *base;
@@ -2478,13 +2492,15 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
glPopMatrix();
- glColor4ub(255, 255, 255, 255); // XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell
+ // XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell
+ glColor4ub(255, 255, 255, 255);
G.f &= ~G_RENDER_OGL;
}
/* 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, char err_out[256])
+ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
+ int sizex, int sizey, unsigned int flag, char err_out[256])
{
RegionView3D *rv3d= ar->regiondata;
ImBuf *ibuf;
@@ -2539,7 +2555,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in
}
/* 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, char err_out[256])
+ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height,
+ unsigned int flag, int drawtype, char err_out[256])
{
View3D v3d= {NULL};
ARegion ar= {NULL};
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index b07e0ccdc74..f617f673397 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -208,10 +208,9 @@ static void view3d_boxview_clip(ScrArea *sa)
normal_tri_v3( clip[5],bb->vec[0], bb->vec[2], bb->vec[1]);
/* then plane equations */
- for(val=0; val<5; val++) {
- clip[val][3]= - clip[val][0]*bb->vec[val][0] - clip[val][1]*bb->vec[val][1] - clip[val][2]*bb->vec[val][2];
+ for(val=0; val<6; val++) {
+ clip[val][3] = -dot_v3v3(clip[val], bb->vec[val % 5]);
}
- clip[5][3]= - clip[5][0]*bb->vec[0][0] - clip[5][1]*bb->vec[0][1] - clip[5][2]*bb->vec[0][2];
/* create bounding box */
for(ar= sa->regionbase.first; ar; ar= ar->next) {
@@ -519,52 +518,54 @@ static void viewops_data_free(bContext *C, wmOperator *op)
static const float thres = 0.93f; //cos(20 deg);
-#define COS45 0.70710678118654746
+#define COS45 0.7071068
#define SIN45 COS45
-static float snapquats[39][5] = {
+#define NUM_SNAP_QUATS 39
+
+static const float snapquats[NUM_SNAP_QUATS][5] = {
/*{q0, q1, q3, q4, view}*/
- {COS45, -SIN45, 0.0, 0.0, RV3D_VIEW_FRONT}, //front
- {0.0, 0.0, -SIN45, -SIN45, RV3D_VIEW_BACK}, //back
- {1.0, 0.0, 0.0, 0.0, RV3D_VIEW_TOP}, //top
- {0.0, -1.0, 0.0, 0.0, RV3D_VIEW_BOTTOM}, //bottom
- {0.5, -0.5, -0.5, -0.5, RV3D_VIEW_RIGHT}, //left
- {0.5, -0.5, 0.5, 0.5, RV3D_VIEW_LEFT}, //right
+ {COS45, -SIN45, 0.0, 0.0, RV3D_VIEW_FRONT},
+ {0.0, 0.0, -SIN45, -SIN45, RV3D_VIEW_BACK},
+ {1.0, 0.0, 0.0, 0.0, RV3D_VIEW_TOP},
+ {0.0, -1.0, 0.0, 0.0, RV3D_VIEW_BOTTOM},
+ {0.5, -0.5, -0.5, -0.5, RV3D_VIEW_RIGHT},
+ {0.5, -0.5, 0.5, 0.5, RV3D_VIEW_LEFT},
/* some more 45 deg snaps */
- {0.65328145027160645, -0.65328145027160645, 0.27059805393218994, 0.27059805393218994, 0},
- {0.92387950420379639, 0.0, 0.0, 0.38268342614173889, 0},
- {0.0, -0.92387950420379639, 0.38268342614173889, 0.0, 0},
- {0.35355335474014282, -0.85355335474014282, 0.35355338454246521, 0.14644660055637360, 0},
- {0.85355335474014282, -0.35355335474014282, 0.14644660055637360, 0.35355338454246521, 0},
- {0.49999994039535522, -0.49999994039535522, 0.49999997019767761, 0.49999997019767761, 0},
- {0.27059802412986755, -0.65328145027160645, 0.65328145027160645, 0.27059802412986755, 0},
- {0.65328145027160645, -0.27059802412986755, 0.27059802412986755, 0.65328145027160645, 0},
- {0.27059799432754517, -0.27059799432754517, 0.65328139066696167, 0.65328139066696167, 0},
- {0.38268336653709412, 0.0, 0.0, 0.92387944459915161, 0},
- {0.0, -0.38268336653709412, 0.92387944459915161, 0.0, 0},
- {0.14644658565521240, -0.35355335474014282, 0.85355335474014282, 0.35355335474014282, 0},
- {0.35355335474014282, -0.14644658565521240, 0.35355335474014282, 0.85355335474014282, 0},
- {0.0, 0.0, 0.92387944459915161, 0.38268336653709412, 0},
- {-0.0, 0.0, 0.38268336653709412, 0.92387944459915161, 0},
- {-0.27059802412986755, 0.27059802412986755, 0.65328133106231689, 0.65328133106231689, 0},
- {-0.38268339633941650, 0.0, 0.0, 0.92387938499450684, 0},
- {0.0, 0.38268339633941650, 0.92387938499450684, 0.0, 0},
- {-0.14644658565521240, 0.35355338454246521, 0.85355329513549805, 0.35355332493782043, 0},
- {-0.35355338454246521, 0.14644658565521240, 0.35355332493782043, 0.85355329513549805, 0},
- {-0.49999991059303284, 0.49999991059303284, 0.49999985098838806, 0.49999985098838806, 0},
- {-0.27059799432754517, 0.65328145027160645, 0.65328139066696167, 0.27059799432754517, 0},
- {-0.65328145027160645, 0.27059799432754517, 0.27059799432754517, 0.65328139066696167, 0},
- {-0.65328133106231689, 0.65328133106231689, 0.27059793472290039, 0.27059793472290039, 0},
- {-0.92387932538986206, 0.0, 0.0, 0.38268333673477173, 0},
- {0.0, 0.92387932538986206, 0.38268333673477173, 0.0, 0},
- {-0.35355329513549805, 0.85355329513549805, 0.35355329513549805, 0.14644657075405121, 0},
- {-0.85355329513549805, 0.35355329513549805, 0.14644657075405121, 0.35355329513549805, 0},
- {-0.38268330693244934, 0.92387938499450684, 0.0, 0.0, 0},
- {-0.92387938499450684, 0.38268330693244934, 0.0, 0.0, 0},
- {-COS45, 0.0, 0.0, SIN45, 0},
- {COS45, 0.0, 0.0, SIN45, 0},
- {0.0, 0.0, 0.0, 1.0, 0}
+ { 0.6532815, -0.6532815, 0.2705981, 0.2705981, 0},
+ { 0.9238795, 0.0, 0.0, 0.3826834, 0},
+ { 0.0, -0.9238795, 0.3826834, 0.0, 0},
+ { 0.3535534, -0.8535534, 0.3535534, 0.1464466, 0},
+ { 0.8535534, -0.3535534, 0.1464466, 0.3535534, 0},
+ { 0.4999999, -0.4999999, 0.5, 0.5, 0},
+ { 0.2705980, -0.6532815, 0.6532815, 0.2705980, 0},
+ { 0.6532815, -0.2705980, 0.2705980, 0.6532815, 0},
+ { 0.2705978, -0.2705980, 0.6532814, 0.6532814, 0},
+ { 0.3826834, 0.0, 0.0, 0.9238794, 0},
+ { 0.0, -0.3826834, 0.9238794, 0.0, 0},
+ { 0.1464466, -0.3535534, 0.8535534, 0.3535534, 0},
+ { 0.3535534, -0.1464466, 0.3535534, 0.8535534, 0},
+ { 0.0, 0.0, 0.9238794, 0.3826834, 0},
+ {-0.0, 0.0, 0.3826834, 0.9238794, 0},
+ {-0.2705980, 0.2705980, 0.6532813, 0.6532813, 0},
+ {-0.3826834, 0.0, 0.0, 0.9238794, 0},
+ { 0.0, 0.3826834, 0.9238794, 0.0, 0},
+ {-0.1464466, 0.3535534, 0.8535533, 0.3535533, 0},
+ {-0.3535534, 0.1464466, 0.3535533, 0.8535533, 0},
+ {-0.4999999, 0.4999999, 0.4999999, 0.4999999, 0},
+ {-0.2705980, 0.6532815, 0.6532814, 0.2705980, 0},
+ {-0.6532815, 0.2705980, 0.2705980, 0.6532814, 0},
+ {-0.6532813, 0.6532813, 0.2705979, 0.2705979, 0},
+ {-0.9238793, 0.0, 0.0, 0.3826833, 0},
+ { 0.0, 0.9238793, 0.3826833, 0.0, 0},
+ {-0.3535533, 0.8535533, 0.3535533, 0.1464466, 0},
+ {-0.8535533, 0.3535533, 0.1464466, 0.3535533, 0},
+ {-0.3826833, 0.9238794, 0.0, 0.0, 0},
+ {-0.9238794, 0.3826833, 0.0, 0.0, 0},
+ {-COS45, 0.0, 0.0, SIN45, 0},
+ { COS45, 0.0, 0.0, SIN45, 0},
+ { 0.0, 0.0, 0.0, 1.0, 0}
};
enum {
@@ -633,7 +634,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
sub_v3_v3v3(dvec, newvec, vod->trackvec);
- si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]);
+ si = len_v3(dvec);
si /= (float)(2.0 * TRACKBALLSIZE);
cross_v3_v3v3(q1+1, vod->trackvec, newvec);
@@ -725,7 +726,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
mul_qt_v3(viewquat_inv, zaxis);
- for (i = 0 ; i < 39; i++){
+ for (i = 0 ; i < NUM_SNAP_QUATS; i++){
float view = (int)snapquats[i][4];
float viewquat_inv_test[4];
@@ -962,8 +963,9 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
}
-// NDOF utility functions
-// (should these functions live in this file?)
+/* NDOF utility functions
+ * (should these functions live in this file?)
+ */
float ndof_to_axis_angle(struct wmNDOFMotionData* ndof, float axis[3])
{
return ndof->dt * normalize_v3_v3(axis, ndof->rvec);
@@ -974,7 +976,7 @@ void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4])
float axis[3];
float angle;
- angle= ndof_to_axis_angle(ndof, axis);
+ angle = ndof_to_axis_angle(ndof, axis);
axis_angle_to_quat(q, axis, angle);
}
@@ -984,69 +986,67 @@ void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4])
*/
static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
- if (event->type != NDOF_MOTION) {
+ if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
- }
else {
- View3D *v3d= CTX_wm_view3d(C);
+ View3D *v3d = CTX_wm_view3d(C);
RegionView3D* rv3d = CTX_wm_region_view3d(C);
wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata;
ED_view3d_camera_lock_init(v3d, rv3d);
- rv3d->rot_angle = 0.f; // off by default, until changed later this function
+ rv3d->rot_angle = 0.f; /* off by default, until changed later this function */
if (ndof->progress != P_FINISHING) {
const float dt = ndof->dt;
-
- // tune these until everything feels right
+
+ /* tune these until everything feels right */
const float rot_sensitivity = 1.f;
const float zoom_sensitivity = 1.f;
const float pan_sensitivity = 1.f;
-
- // rather have bool, but...
- int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec);
-
+
+ const int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec);
+
float view_inv[4];
invert_qt_qt(view_inv, rv3d->viewquat);
-
- //#define DEBUG_NDOF_MOTION
+
+ /* #define DEBUG_NDOF_MOTION */
#ifdef DEBUG_NDOF_MOTION
printf("ndof: T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f delivered to 3D view\n",
ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt);
#endif
-
- if (ndof->tvec[2]) {
- // Zoom!
- // velocity should be proportional to the linear velocity attained by rotational motion of same strength
- // [got that?]
- // proportional to arclength = radius * angle
-
- float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tvec[2];
+
+ if (ndof->tz) {
+ /* Zoom!
+ * velocity should be proportional to the linear velocity attained by rotational motion of same strength
+ * [got that?]
+ * proportional to arclength = radius * angle
+ */
+ float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz;
if (U.ndof_flag & NDOF_ZOOM_INVERT)
zoom_distance = -zoom_distance;
rv3d->dist += zoom_distance;
}
-
+
if (rv3d->viewlock == RV3D_LOCKED) {
/* rotation not allowed -- explore panning options instead */
- float pan_vec[3] = {ndof->tvec[0], ndof->tvec[1], 0.0f};
+ float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f};
mul_v3_fl(pan_vec, pan_sensitivity * rv3d->dist * dt);
-
+
/* transform motion from view to world coordinates */
invert_qt_qt(view_inv, rv3d->viewquat);
mul_qt_v3(view_inv, pan_vec);
-
+
/* move center of view opposite of hand motion (this is camera mode, not object mode) */
sub_v3_v3(rv3d->ofs, pan_vec);
}
-
+
if (has_rotation) {
-
+
rv3d->view = RV3D_VIEW_USER;
-
+
if (U.flag & USER_TRACKBALL) {
float rot[4];
float axis[3];
@@ -1061,44 +1061,46 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS)
axis[1] = -axis[1];
- // transform rotation axis from view to world coordinates
+ /* transform rotation axis from view to world coordinates */
mul_qt_v3(view_inv, axis);
-
- // update the onscreen doo-dad
+
+ /* update the onscreen doo-dad */
rv3d->rot_angle = angle;
copy_v3_v3(rv3d->rot_axis, axis);
-
+
axis_angle_to_quat(rot, axis, angle);
- // apply rotation
+ /* apply rotation */
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
+
} else {
+
/* turntable view code by John Aughey, adapted for 3D mouse by [mce] */
float angle, rot[4];
float xvec[3] = {1,0,0};
-
+
/* Determine the direction of the x vector (for rotating up and down) */
mul_qt_v3(view_inv, xvec);
-
+
/* Perform the up/down rotation */
- angle = rot_sensitivity * dt * ndof->rvec[0];
+ angle = rot_sensitivity * dt * ndof->rx;
if (U.ndof_flag & NDOF_TILT_INVERT_AXIS)
angle = -angle;
rot[0] = cos(angle);
mul_v3_v3fl(rot+1, xvec, sin(angle));
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
-
+
/* Perform the orbital rotation */
- angle = rot_sensitivity * dt * ndof->rvec[1];
+ angle = rot_sensitivity * dt * ndof->ry;
if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS)
angle = -angle;
-
- // update the onscreen doo-dad
+
+ /* update the onscreen doo-dad */
rv3d->rot_angle = angle;
rv3d->rot_axis[0] = 0;
rv3d->rot_axis[1] = 0;
rv3d->rot_axis[2] = 1;
-
+
rot[0] = cos(angle);
rot[1] = rot[2] = 0.0;
rot[3] = sin(angle);
@@ -1135,9 +1137,8 @@ void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot)
*/
static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
- if (event->type != NDOF_MOTION) {
+ if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
- }
else {
View3D *v3d= CTX_wm_view3d(C);
RegionView3D* rv3d = CTX_wm_region_view3d(C);
@@ -1145,13 +1146,13 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
ED_view3d_camera_lock_init(v3d, rv3d);
- rv3d->rot_angle = 0.f; // we're panning here! so erase any leftover rotation from other operators
+ rv3d->rot_angle = 0.f; /* we're panning here! so erase any leftover rotation from other operators */
if (ndof->progress != P_FINISHING) {
const float dt = ndof->dt;
float view_inv[4];
-#if 0 // ------------------------------------------- zoom with Z
- // tune these until everything feels right
+#if 0 /* ------------------------------------------- zoom with Z */
+ /* tune these until everything feels right */
const float zoom_sensitivity = 1.f;
const float pan_sensitivity = 1.f;
@@ -1159,18 +1160,18 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
ndof->tx, ndof->ty, 0
};
- // "zoom in" or "translate"? depends on zoom mode in user settings?
+ /* "zoom in" or "translate"? depends on zoom mode in user settings? */
if (ndof->tz) {
float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz;
rv3d->dist += zoom_distance;
}
-
+
mul_v3_fl(pan_vec, pan_sensitivity * rv3d->dist * dt);
-#else // ------------------------------------------------------- dolly with Z
- float speed = 10.f; // blender units per second
- // ^^ this is ok for default cube scene, but should scale with.. something
+#else /* ------------------------------------------------------- dolly with Z */
+ float speed = 10.f; /* blender units per second */
+ /* ^^ this is ok for default cube scene, but should scale with.. something */
- // tune these until everything feels right
+ /* tune these until everything feels right */
const float forward_sensitivity = 1.f;
const float vertical_sensitivity = 0.4f;
const float lateral_sensitivity = 0.6f;
@@ -2091,8 +2092,8 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "center", 0, "Center", "");
}
-
-static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a localview without local!, was centerview() in 2.4x */
+/* like a localview without local!, was centerview() in 2.4x */
+static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar= CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -2451,9 +2452,15 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
/* convert border to 3d coordinates */
- if (( !gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) ||
- ( !gluUnProject((double)rect.xmin, (double)rect.ymin, depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p_corner[0], &p_corner[1], &p_corner[2])))
+ if ( (!gluUnProject(cent[0], cent[1], depth_close,
+ mats.modelview, mats.projection, (GLint *)mats.viewport,
+ &p[0], &p[1], &p[2])) ||
+ (!gluUnProject((double)rect.xmin, (double)rect.ymin, depth_close,
+ mats.modelview, mats.projection, (GLint *)mats.viewport,
+ &p_corner[0], &p_corner[1], &p_corner[2])))
+ {
return OPERATOR_CANCELLED;
+ }
dvec[0] = p[0]-p_corner[0];
dvec[1] = p[1]-p_corner[1];
@@ -2474,7 +2481,10 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
new_dist = rv3d->dist;
/* convert the drawn rectangle into 3d space */
- if (depth_close!=FLT_MAX && gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) {
+ if (depth_close != FLT_MAX && gluUnProject(cent[0], cent[1], depth_close,
+ mats.modelview, mats.projection, (GLint *)mats.viewport,
+ &p[0], &p[1], &p[2]))
+ {
new_ofs[0] = -p[0];
new_ofs[1] = -p[1];
new_ofs[2] = -p[2];
@@ -2608,7 +2618,9 @@ static EnumPropertyItem prop_view_items[] = {
/* would like to make this a generic function - outside of transform */
-static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float q1, float q2, float q3, float q4, short view, int perspo, int align_active)
+static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar,
+ float q1, float q2, float q3, float q4,
+ short view, int perspo, int align_active)
{
RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */
float new_quat[4];
@@ -2707,27 +2719,33 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
switch (viewnum) {
case RV3D_VIEW_BOTTOM :
- axis_set_view(C, v3d, ar, 0.0, -1.0, 0.0, 0.0, viewnum, nextperspo, align_active);
+ axis_set_view(C, v3d, ar, 0.0, -1.0, 0.0, 0.0,
+ viewnum, nextperspo, align_active);
break;
case RV3D_VIEW_BACK:
- axis_set_view(C, v3d, ar, 0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0), viewnum, nextperspo, align_active);
+ axis_set_view(C, v3d, ar, 0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0),
+ viewnum, nextperspo, align_active);
break;
case RV3D_VIEW_LEFT:
- axis_set_view(C, v3d, ar, 0.5, -0.5, 0.5, 0.5, viewnum, nextperspo, align_active);
+ axis_set_view(C, v3d, ar, 0.5, -0.5, 0.5, 0.5,
+ viewnum, nextperspo, align_active);
break;
case RV3D_VIEW_TOP:
- axis_set_view(C, v3d, ar, 1.0, 0.0, 0.0, 0.0, viewnum, nextperspo, align_active);
+ axis_set_view(C, v3d, ar, 1.0, 0.0, 0.0, 0.0,
+ viewnum, nextperspo, align_active);
break;
case RV3D_VIEW_FRONT:
- axis_set_view(C, v3d, ar, (float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0, viewnum, nextperspo, align_active);
+ axis_set_view(C, v3d, ar, (float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0,
+ viewnum, nextperspo, align_active);
break;
case RV3D_VIEW_RIGHT:
- axis_set_view(C, v3d, ar, 0.5, -0.5, -0.5, -0.5, viewnum, nextperspo, align_active);
+ axis_set_view(C, v3d, ar, 0.5, -0.5, -0.5, -0.5,
+ viewnum, nextperspo, align_active);
break;
case RV3D_VIEW_CAMERA:
@@ -2789,7 +2807,9 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
else{
/* return to settings of last view */
/* does smooth_view too */
- axis_set_view(C, v3d, ar, rv3d->lviewquat[0], rv3d->lviewquat[1], rv3d->lviewquat[2], rv3d->lviewquat[3], rv3d->lview, rv3d->lpersp, 0);
+ axis_set_view(C, v3d, ar,
+ rv3d->lviewquat[0], rv3d->lviewquat[1], rv3d->lviewquat[2], rv3d->lviewquat[3],
+ rv3d->lview, rv3d->lpersp, 0);
}
}
break;
@@ -3221,6 +3241,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
/* re initialize */
project_int_noclip(ar, fp, mval);
flip= initgrabz(rv3d, fp[0], fp[1], fp[2]);
+ (void)flip;
}
if(mval[0]!=IS_CLIPPED) {
@@ -3385,7 +3406,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
}
/* XXX todo Zooms in on a border drawn by the user */
-int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist )
+int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3])
{
bglMats mats; /* ZBuffer depth vars */
float depth_close= FLT_MAX;
@@ -3403,8 +3424,11 @@ int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2]
cent[0] = (double)mval[0];
cent[1] = (double)mval[1];
- if (!gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
+ if (!gluUnProject(cent[0], cent[1], depth_close,
+ mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
+ {
return 0;
+ }
mouse_worldloc[0] = (float)p[0];
mouse_worldloc[1] = (float)p[1];
@@ -3428,7 +3452,8 @@ int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //
}
// no 4x4 sampling, run view_autodist_init first
-int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist )
+int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3],
+ int margin, float *force_depth) //, float *autodist )
{
bglMats mats; /* ZBuffer depth vars, could cache? */
float depth;
@@ -3447,8 +3472,12 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl
cent[1] = (double)mval[1];
bgl_get_mats(&mats);
- if (!gluUnProject(cent[0], cent[1], depth, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
+
+ if (!gluUnProject(cent[0], cent[1], depth,
+ mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
+ {
return 0;
+ }
mouse_worldloc[0] = (float)p[0];
mouse_worldloc[1] = (float)p[1];
@@ -3483,7 +3512,8 @@ static int depth_segment_cb(int x, int y, void *userData)
}
}
-int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
+int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2],
+ int margin, float *depth)
{
struct { struct ARegion *ar; int margin; float depth; } data = {NULL};
int p1[2];
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 981d46774dc..801f2d5c8eb 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -135,7 +135,8 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_DECELERATE);
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_PAN_ENABLE);
- WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PAN_DISABLE); /* XXX - Bug in the event system, middle mouse release doesnt work */
+ /* XXX - Bug in the event system, middle mouse release doesnt work */
+ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PAN_DISABLE);
/* WASD */
WM_modalkeymap_add_item(keymap, WKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_FORWARD);
@@ -170,7 +171,8 @@ typedef struct FlyInfo {
short state;
short redraw;
unsigned char use_precision;
- unsigned char use_freelook; /* if the user presses shift they can look about without movinf the direction there looking */
+ unsigned char use_freelook; /* if the user presses shift they can look about
+ * without moving the direction there looking */
int mval[2]; /* latest 2D mouse values */
wmNDOFMotionData* ndof; /* latest 3D mouse values */
@@ -195,7 +197,8 @@ typedef struct FlyInfo {
/* backup values */
float dist_backup; /* backup the views distance since we use a zero dist for fly mode */
float ofs_backup[3]; /* backup the views offset incase the user cancels flying in non camera mode */
- float rot_backup[4]; /* backup the views quat incase the user cancels flying in non camera mode. (quat for view, eul for camera) */
+ float rot_backup[4]; /* backup the views quat incase the user cancels flying in non camera mode.
+ * (quat for view, eul for camera) */
short persp_backup; /* remember if were ortho or not, only used for restoring the view if it was a ortho view */
short is_ortho_cam; /* are we flying an ortho camera in perspective view,
@@ -580,7 +583,8 @@ static void flyEvent(FlyInfo *fly, wmEvent *event)
/* impliment WASD keys */
case FLY_MODAL_DIR_FORWARD:
if (fly->speed < 0.0f) fly->speed= -fly->speed; /* flip speed rather than stopping, game like motion */
- else if (fly->axis==2) fly->speed += fly->grid; /* increse like mousewheel if were already moving in that difection*/
+ else if (fly->axis==2) fly->speed += fly->grid; /* increse like mousewheel if were already
+ * moving in that difection*/
fly->axis= 2;
break;
case FLY_MODAL_DIR_BACKWARD:
@@ -738,8 +742,10 @@ static int flyApply(bContext *C, FlyInfo *fly)
xmargin, ymargin; /* x and y margin are define the safe area where the mouses movement wont rotate the view */
#ifdef NDOF_FLY_DEBUG
- static unsigned int iteration = 1;
- printf("fly timer %d\n", iteration++);
+ {
+ static unsigned int iteration = 1;
+ printf("fly timer %d\n", iteration++);
+ }
#endif
@@ -782,7 +788,11 @@ static int flyApply(bContext *C, FlyInfo *fly)
}
/* Should we redraw? */
- if (fly->speed != 0.0f || moffset[0] || moffset[1] || fly->zlock || fly->xlock || dvec[0] || dvec[1] || dvec[2] ) {
+ if ( (fly->speed != 0.0f) ||
+ moffset[0] || moffset[1] ||
+ fly->zlock || fly->xlock ||
+ dvec[0] || dvec[1] || dvec[2])
+ {
float dvec_tmp[3];
double time_current; /*time how fast it takes for us to redraw, this is so simple scenes dont fly too fast */
float time_redraw;
@@ -792,7 +802,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
#endif
time_current= PIL_check_seconds_timer();
time_redraw= (float)(time_current - fly->time_lastdraw);
- time_redraw_clamped= MIN2(0.05f, time_redraw); /* clamt the redraw time to avoid jitter in roll correction */
+ time_redraw_clamped= MIN2(0.05f, time_redraw); /* clamp redraw time to avoid jitter in roll correction */
fly->time_lastdraw= time_current;
/*fprintf(stderr, "%f\n", time_redraw);*/ /* 0.002 is a small redraw 0.02 is larger */
@@ -818,7 +828,8 @@ static int flyApply(bContext *C, FlyInfo *fly)
mul_v3_fl(dvec_tmp, time_redraw * 200.0f * fly->grid);
}
else {
- float roll; /* similar to the angle between the camera's up and the Z-up, but its very rough so just roll*/
+ float roll; /* similar to the angle between the camera's up and the Z-up,
+ * but its very rough so just roll*/
/* rotate about the X axis- look up/down */
if (moffset[1]) {
@@ -826,7 +837,8 @@ static int flyApply(bContext *C, FlyInfo *fly)
upvec[1]=0;
upvec[2]=0;
mul_m3_v3(mat, upvec);
- axis_angle_to_quat( tmp_quat, upvec, (float)moffset[1] * time_redraw * -FLY_ROTATE_FAC); /* Rotate about the relative up vec */
+ /* Rotate about the relative up vec */
+ axis_angle_to_quat( tmp_quat, upvec, (float)moffset[1] * time_redraw * -FLY_ROTATE_FAC);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
if (fly->xlock) fly->xlock = 2; /*check for rotation*/
@@ -859,7 +871,8 @@ static int flyApply(bContext *C, FlyInfo *fly)
mul_m3_v3(mat, upvec);
}
- axis_angle_to_quat(tmp_quat, upvec, (float)moffset[0] * time_redraw * FLY_ROTATE_FAC); /* Rotate about the relative up vec */
+ /* Rotate about the relative up vec */
+ axis_angle_to_quat(tmp_quat, upvec, (float)moffset[0] * time_redraw * FLY_ROTATE_FAC);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
if (fly->xlock) fly->xlock = 2;/*check for rotation*/
@@ -880,7 +893,9 @@ static int flyApply(bContext *C, FlyInfo *fly)
upvec[2]= 1.0f;
mul_m3_v3(mat, upvec);
- axis_angle_to_quat( tmp_quat, upvec, roll*time_redraw_clamped*fly->zlock_momentum * FLY_ZUP_CORRECT_FAC); /* Rotate about the relative up vec */
+ /* Rotate about the relative up vec */
+ axis_angle_to_quat(tmp_quat, upvec,
+ roll * time_redraw_clamped * fly->zlock_momentum * FLY_ZUP_CORRECT_FAC);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
fly->zlock_momentum += FLY_ZUP_CORRECT_ACCEL;
@@ -906,7 +921,8 @@ static int flyApply(bContext *C, FlyInfo *fly)
mul_m3_v3(mat, upvec);
- axis_angle_to_quat( tmp_quat, upvec, roll*time_redraw_clamped*fly->xlock_momentum*0.1f); /* Rotate about the relative up vec */
+ /* Rotate about the relative up vec */
+ axis_angle_to_quat( tmp_quat, upvec, roll*time_redraw_clamped*fly->xlock_momentum*0.1f);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
fly->xlock_momentum += 0.05f;
@@ -949,18 +965,6 @@ static int flyApply(bContext *C, FlyInfo *fly)
add_v3_v3(rv3d->ofs, dvec);
- /* todo, dynamic keys */
-#if 0
- if (fly->zlock && fly->xlock)
- ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
- else if (fly->zlock)
- ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X off/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
- else if (fly->xlock)
- ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z off, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
- else
- ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X off/Z off, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
-#endif
-
if (rv3d->persp==RV3D_CAMOB)
move_camera(C, rv3d, fly, (fly->xlock || fly->zlock || moffset[0] || moffset[1]), fly->speed);
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 00bb8d16943..e9b339c0baf 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -231,6 +231,8 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(event->shift)
RNA_boolean_set(op->ptr, "extend", TRUE);
+ else
+ RNA_boolean_set(op->ptr, "extend", FALSE);
if(event->alt) {
int nr= RNA_int_get(op->ptr, "nr") + 10;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index e7c9a1bd3a0..07754c0883c 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -59,7 +59,7 @@ struct wmNDOFMotionData;
#define DRAW_SCENESET 4
/* draw_mesh_fancy/draw_mesh_textured draw_flags */
-#define DRAW_DYNAMIC_PAINT_PREVIEW 1
+#define DRAW_MODIFIERS_PREVIEW 1
#define DRAW_FACE_SELECT 2
/* view3d_header.c */
@@ -164,7 +164,8 @@ void VIEW3D_OT_game_start(struct wmOperatorType *ot);
int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb);
-void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens);
+void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *,
+ float *ofs, float *quat, float *dist, float *lens);
void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */
void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index ce93ca56a65..f98149d2485 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -240,6 +240,12 @@ static void EM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
/* *********************** GESTURE AND LASSO ******************* */
+typedef struct LassoSelectUserData {
+ ViewContext *vc;
+ rcti *rect;
+ int (*mcords)[2], moves, select, pass, done;
+} LassoSelectUserData;
+
static int view3d_selectable_data(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -257,7 +263,9 @@ static int view3d_selectable_data(bContext *C)
if (ob->mode & OB_MODE_SCULPT) {
return 0;
}
- if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT) && !paint_facesel_test(ob) && !paint_vertsel_test(ob)) {
+ if ((ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) &&
+ !paint_facesel_test(ob) && !paint_vertsel_test(ob))
+ {
return 0;
}
}
@@ -454,7 +462,7 @@ static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves)
static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
{
- struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData;
+ LassoSelectUserData *data = userData;
if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) {
eve->f = data->select?(eve->f|1):(eve->f&~1);
@@ -462,7 +470,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, in
}
static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index)
{
- struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData;
+ LassoSelectUserData *data = userData;
if (EM_check_backbuf(em_solidoffs+index)) {
if (data->pass==0) {
@@ -481,16 +489,16 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, in
}
static void do_lasso_select_mesh__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index))
{
- struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData;
+ LassoSelectUserData *data = userData;
if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) {
- EM_select_face_fgon(data->vc.em, efa, data->select);
+ EM_select_face_fgon(data->vc->em, efa, data->select);
}
}
static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select)
{
- struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } data;
+ LassoSelectUserData data;
ToolSettings *ts= vc->scene->toolsettings;
rcti rect;
int bbsel;
@@ -500,7 +508,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
/* set editmesh */
vc->em= ((Mesh *)vc->obedit->data)->edit_mesh;
- data.vc= *vc;
+ data.vc= vc;
data.rect = &rect;
data.mcords = mcords;
data.moves = moves;
@@ -608,7 +616,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select)
static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
{
- struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } *data = userData;
+ LassoSelectUserData *data = userData;
Object *obedit= data->vc->obedit;
Curve *cu= (Curve*)obedit->data;
@@ -637,7 +645,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP
static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, short extend, short select)
{
- struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } data;
+ LassoSelectUserData data;
/* set vc->editnurb */
data.vc = vc;
@@ -654,7 +662,7 @@ static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves,
static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, int y)
{
- struct { int (*mcords)[2]; short moves; short select; } *data = userData;
+ LassoSelectUserData *data = userData;
if (lasso_inside(data->mcords, data->moves, x, y)) {
bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
@@ -662,7 +670,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x,
}
static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select)
{
- struct { int (*mcords)[2]; short moves; short select; } data;
+ LassoSelectUserData data;
/* set editdata in vc */
data.mcords = mcords;
@@ -1622,6 +1630,11 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
/* ******************** border and circle ************************************** */
+typedef struct BoxSelectUserData {
+ ViewContext *vc;
+ rcti *rect;
+ int select, pass, done;
+} BoxSelectUserData;
int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2)
{
@@ -1647,7 +1660,7 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1,
static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
{
- struct { ViewContext *vc; rcti *rect; int select; } *data = userData;
+ BoxSelectUserData *data = userData;
Object *obedit= data->vc->obedit;
Curve *cu= (Curve*)obedit->data;
@@ -1675,7 +1688,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi
}
static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend)
{
- struct { ViewContext *vc; rcti *rect; int select; } data;
+ BoxSelectUserData data;
data.vc = vc;
data.rect = rect;
@@ -1692,7 +1705,7 @@ static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int exte
static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, int y)
{
- struct { ViewContext vc; rcti *rect; int select; } *data = userData;
+ BoxSelectUserData *data = userData;
if (BLI_in_rcti(data->rect, x, y)) {
bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
@@ -1700,9 +1713,9 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i
}
static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend)
{
- struct { ViewContext vc; rcti *rect; int select, pass, done; } data;
+ BoxSelectUserData data;
- data.vc= *vc;
+ data.vc= vc;
data.rect = rect;
data.select = select;
@@ -1717,7 +1730,7 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int ex
static void do_mesh_box_select__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
{
- struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
+ BoxSelectUserData *data = userData;
if (BLI_in_rcti(data->rect, x, y)) {
eve->f = data->select?(eve->f|1):(eve->f&~1);
@@ -1725,7 +1738,7 @@ static void do_mesh_box_select__doSelectVert(void *userData, EditVert *eve, int
}
static void do_mesh_box_select__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index)
{
- struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
+ BoxSelectUserData *data = userData;
if(EM_check_backbuf(em_solidoffs+index)) {
if (data->pass==0) {
@@ -1742,19 +1755,19 @@ static void do_mesh_box_select__doSelectEdge(void *userData, EditEdge *eed, int
}
static void do_mesh_box_select__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index))
{
- struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
+ BoxSelectUserData *data = userData;
if (BLI_in_rcti(data->rect, x, y)) {
- EM_select_face_fgon(data->vc.em, efa, data->select);
+ EM_select_face_fgon(data->vc->em, efa, data->select);
}
}
static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend)
{
- struct { ViewContext vc; rcti *rect; short select, pass, done; } data;
+ BoxSelectUserData data;
ToolSettings *ts= vc->scene->toolsettings;
int bbsel;
- data.vc= *vc;
+ data.vc= vc;
data.rect = rect;
data.select = select;
data.pass = 0;
@@ -2249,9 +2262,16 @@ void VIEW3D_OT_select(wmOperatorType *ot)
/* -------------------- circle select --------------------------------------------- */
+typedef struct CircleSelectUserData {
+ ViewContext *vc;
+ short select;
+ int mval[2];
+ float radius;
+} CircleSelectUserData;
+
static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
int mx = x - data->mval[0], my = y - data->mval[1];
float r = sqrt(mx*mx + my*my);
@@ -2261,7 +2281,7 @@ static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y
}
static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index))
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
if (edge_inside_circle(data->mval[0], data->mval[1], (short) data->radius, x0, y0, x1, y1)) {
EM_select_edge(eed, data->select);
@@ -2269,7 +2289,7 @@ static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int
}
static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index))
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
int mx = x - data->mval[0], my = y - data->mval[1];
float r = sqrt(mx*mx + my*my);
@@ -2282,7 +2302,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f
{
ToolSettings *ts= vc->scene->toolsettings;
int bbsel;
- struct {ViewContext *vc; short select; int mval[2]; float radius; } data;
+ CircleSelectUserData data;
bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f));
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
@@ -2344,7 +2364,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m
Object *ob= vc->obact;
Mesh *me = ob?ob->data:NULL;
/* int bbsel; */ /* UNUSED */
- /* struct {ViewContext *vc; short select; int mval[2]; float radius; } data = {NULL}; */ /* UNUSED */
+ /* CircleSelectUserData data = {NULL}; */ /* UNUSED */
if (me) {
em_vertoffs= me->totvert+1; /* max index array */
@@ -2359,7 +2379,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m
static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
int mx = x - data->mval[0], my = y - data->mval[1];
float r = sqrt(mx*mx + my*my);
Object *obedit= data->vc->obedit;
@@ -2390,7 +2410,7 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint
}
static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval[2], float rad)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } data;
+ CircleSelectUserData data;
/* set vc-> edit data */
@@ -2407,7 +2427,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval
static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
int mx = x - data->mval[0], my = y - data->mval[1];
float r = sqrt(mx*mx + my*my);
@@ -2417,7 +2437,7 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int
}
static void lattice_circle_select(ViewContext *vc, int select, const int mval[2], float rad)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } data;
+ CircleSelectUserData data;
/* set vc-> edit data */
@@ -2434,7 +2454,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2]
// NOTE: pose-bone case is copied from editbone case...
static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
int mx = x - data->mval[0], my = y - data->mval[1];
float r = sqrt(mx*mx + my*my);
@@ -2449,7 +2469,8 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int
}
static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } data;
+ CircleSelectUserData data;
+ bArmature *arm = vc->obact->data;
bPose *pose = vc->obact->pose;
bPoseChannel *pchan;
int change= FALSE;
@@ -2468,6 +2489,10 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f
short sco1[2], sco2[2], didpoint=0;
float vec[3];
+ /* skip invisible bones */
+ if (PBONE_VISIBLE(arm, pchan->bone) == 0)
+ continue;
+
/* project head location to screenspace */
mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_head);
project_short(vc->ar, vec, sco1);
@@ -2494,7 +2519,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f
static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head)
{
- struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
+ CircleSelectUserData *data = userData;
int mx = x - data->mval[0], my = y - data->mval[1];
float r = sqrt(mx*mx + my*my);
@@ -2517,7 +2542,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int
}
static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad)
{
- struct {ViewContext *vc; short select, mval[2]; float radius; } data;
+ CircleSelectUserData data;
bArmature *arm= vc->obedit->data;
EditBone *ebone;
int change= FALSE;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 11492ee7804..f57d8a5ec1b 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -120,7 +120,8 @@ struct SmoothViewStore {
/* will start timer if appropriate */
/* the arguments are the desired situation */
-void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens)
+void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
+ float *ofs, float *quat, float *dist, float *lens)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win= CTX_wm_window(C);
@@ -998,7 +999,8 @@ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, fl
}
/* also exposed in previewrender.c */
-int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy, rctf *viewplane, float *clipsta, float *clipend)
+int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy,
+ rctf *viewplane, float *clipsta, float *clipend)
{
CameraParams params;
@@ -1023,7 +1025,12 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick
orth= ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend);
rv3d->is_persp= !orth;
- // printf("%d %d %f %f %f %f %f %f\n", winx, winy, viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax, clipsta, clipend);
+#if 0
+ printf("%s: %d %d %f %f %f %f %f %f\n", __func__, winx, winy,
+ viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax,
+ clipsta, clipend);
+#endif
+
x1= viewplane.xmin;
y1= viewplane.ymin;
x2= viewplane.xmax;
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 73322a8292d..a40c6cfa42f 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -58,6 +58,7 @@
#include "UI_resources.h"
#include "WM_types.h"
+#include "WM_api.h"
#include "RNA_access.h"
@@ -165,12 +166,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
uiPopupMenu *pup;
uiLayout *layout;
char line[FILE_MAX + 100];
+ wmOperatorType *ot = WM_operatortype_find(opname, 1);
pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE);
layout= uiPupMenuLayout(pup);
strcpy(line, "Remove Pack");
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_REMOVE);
RNA_string_set(&props_ptr, "id", id_name);
@@ -184,29 +186,29 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
switch(checkPackedFile(local_name, pf)) {
case PF_NOFILE:
BLI_snprintf(line, sizeof(line), "Create %s", local_name);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_EQUAL:
BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_DIFFERS:
BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
@@ -217,28 +219,28 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
switch(checkPackedFile(abs_name, pf)) {
case PF_NOFILE:
BLI_snprintf(line, sizeof(line), "Create %s", abs_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_EQUAL:
BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_DIFFERS:
BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name);
- //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
- props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
+ props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 612b46746b8..5f836ec4ca7 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -103,7 +103,7 @@ static int ED_operator_uvedit_can_uv_sculpt(struct bContext *C)
return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt);
}
-static int ED_operator_uvmap_mesh(bContext *C)
+static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
{
Object *ob= CTX_data_active_object(C);
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 38c8f5bc69c..c012a23c175 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -80,10 +80,12 @@ typedef struct IslandStitchData{
float medianPoint[2];
int numOfElements;
int num_rot_elements;
- /* Flag to remember if island has been added for preview */
+ /* flag to remember if island has been added for preview */
char addedForPreview;
- /* Flag an island to be considered for determining static island */
+ /* flag an island to be considered for determining static island */
char stitchableCandidate;
+ /* if edge rotation is used, flag so that vertex rotation is not used */
+ char use_edge_rotation;
}IslandStitchData;
/* just for averaging UVs */
@@ -262,6 +264,39 @@ static void stitch_uv_rotate(float rotation, float medianPoint[2], float uv[2]){
uv[1] = uv_rotation_result[1] + medianPoint[1];
}
+static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_iter, StitchState *state){
+ float limit;
+ int do_limit;
+
+ if(element_iter == element){
+ return 0;
+ }
+
+ limit = state->limit_dist;
+ do_limit = state->use_limit;
+
+ if(do_limit){
+ MTFace *mtface_orig = CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
+ MTFace *mtface_iter = CustomData_em_get(&state->em->fdata, element_iter->face->data, CD_MTFACE);
+
+ if(fabs(mtface_orig->uv[element->tfindex][0] - mtface_iter->uv[element_iter->tfindex][0]) < limit
+ && fabs(mtface_orig->uv[element->tfindex][1] - mtface_iter->uv[element_iter->tfindex][1]) < limit){
+ return 1;
+ }else
+ return 0;
+ }else
+ return 1;
+}
+
+
+static int stitch_check_uvs_state_stitchable(UvElement *element, UvElement *element_iter, StitchState *state){
+ if((state->snap_islands && element->island == element_iter->island) ||
+ (!state->midpoints && element->island == element_iter->island))
+ return 0;
+
+ return stitch_check_uvs_stitchable(element, element_iter, state);
+}
+
/* calculate snapping for islands */
static void stitch_calculate_island_snapping(StitchState *state, StitchPreviewer *preview, IslandStitchData *island_stitch_data, int final){
@@ -324,26 +359,31 @@ static void stitch_calculate_island_snapping(StitchState *state, StitchPreviewer
static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *state, UVVertAverage *uv_average, unsigned int *uvfinal_map, IslandStitchData *island_stitch_data)
{
- UvElement *element;
- EditFace *efa;
- MTFace *mt;
- int nverts;
+ UvElement *element1, *element2;
+ EditFace *efa1;
+ EditFace *efa2;
+ MTFace *mt1;
+ MTFace *mt2;
float uv1[2], uv2[2];
float edgecos, edgesin;
int index1, index2;
+ float rotation;
- element = edge->element;
- efa = element->face;
- nverts = (efa->v4)? 4 : 3;
- mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+ element1 = state->uvs[edge->uv1];
+ element2 = state->uvs[edge->uv2];
- index1 = uvfinal_map[(*(&element->face->v1 + element->tfindex))->tmp.l];
- index2 = uvfinal_map[(*(&element->face->v1 + (element->tfindex + 1)%nverts))->tmp.l];
+ efa1 = element1->face;
+ mt1 = CustomData_em_get(&state->em->fdata, efa1->data, CD_MTFACE);
+ efa2 = element2->face;
+ mt2 = CustomData_em_get(&state->em->fdata, efa2->data, CD_MTFACE);
+
+ index1 = uvfinal_map[element1 - state->element_map->buf];
+ index2 = uvfinal_map[element2 - state->element_map->buf];
/* the idea here is to take the directions of the edges and find the rotation between final and initial
* direction. This, using inner and outer vector products, gives the angle. Directions are differences so... */
- uv1[0] = mt->uv[(element->tfindex + 1)%nverts][0] - mt->uv[element->tfindex][0];
- uv1[1] = mt->uv[(element->tfindex + 1)%nverts][1] - mt->uv[element->tfindex][1];
+ uv1[0] = mt2->uv[element2->tfindex][0] - mt1->uv[element1->tfindex][0];
+ uv1[1] = mt2->uv[element2->tfindex][1] - mt1->uv[element1->tfindex][1];
uv2[0] = uv_average[index2].uv[0] - uv_average[index1].uv[0];
uv2[1] = uv_average[index2].uv[1] - uv_average[index1].uv[1];
@@ -353,47 +393,50 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta
edgecos = uv1[0]*uv2[0] + uv1[1]*uv2[1];
edgesin = uv1[0]*uv2[1] - uv2[0]*uv1[1];
- island_stitch_data[element->island].num_rot_elements++;
- island_stitch_data[element->island].rotation += (edgesin > 0)? acos(MAX2(-1.0, MIN2(1.0, edgecos))): -acos(MAX2(-1.0, MIN2(1.0, edgecos)));
+
+ rotation = (edgesin > 0)? acos(MAX2(-1.0, MIN2(1.0, edgecos))): -acos(MAX2(-1.0, MIN2(1.0, edgecos)));
+
+ island_stitch_data[element1->island].num_rot_elements++;
+ island_stitch_data[element1->island].rotation += rotation;
}
-static void stitch_island_calculate_vert_rotation(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data, char do_static)
+
+static void stitch_island_calculate_vert_rotation(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data)
{
float edgecos = 1, edgesin = 0;
int index;
UvElement *element_iter;
+ float rotation = 0;
- if((element->island == state->static_island) && !do_static)
+ if(element->island == state->static_island && !state->midpoints)
return;
index = (*(&element->face->v1 + element->tfindex))->tmp.l;
element_iter = state->element_map->vert[index];
- if(!do_static){
- for(; element_iter; element_iter = element_iter->next){
- if((element_iter->separate) && (element_iter->flag & STITCH_STITCHABLE) &&
- (element_iter != element) && (element_iter->island == state->static_island)
- ){
- int index_tmp1, index_tmp2;
- float normal[2];
- /* easily possible*/
-
- index_tmp1 = element_iter - state->element_map->buf;
- index_tmp1 = state->map[index_tmp1];
- index_tmp2 = element - state->element_map->buf;
- index_tmp2 = state->map[index_tmp2];
-
- negate_v2_v2(normal, state->normals + index_tmp2*2);
- edgecos = dot_v2v2(normal, state->normals + index_tmp1*2);
- edgesin = cross_v2v2(normal, state->normals + index_tmp1*2);
- break;
- }
+ for(; element_iter; element_iter = element_iter->next){
+ if(element_iter->separate && stitch_check_uvs_state_stitchable(element, element_iter, state)){
+ int index_tmp1, index_tmp2;
+ float normal[2];
+ /* easily possible*/
+
+ index_tmp1 = element_iter - state->element_map->buf;
+ index_tmp1 = state->map[index_tmp1];
+ index_tmp2 = element - state->element_map->buf;
+ index_tmp2 = state->map[index_tmp2];
+
+ negate_v2_v2(normal, state->normals + index_tmp2*2);
+ edgecos = dot_v2v2(normal, state->normals + index_tmp1*2);
+ edgesin = cross_v2v2(normal, state->normals + index_tmp1*2);
+ rotation += (edgesin > 0)? acos(edgecos): -acos(edgecos);
}
}
+ if(state->midpoints)
+ rotation /= 2.0;
island_stitch_data[element->island].num_rot_elements++;
- island_stitch_data[element->island].rotation += (edgesin > 0)? acos(edgecos): -acos(edgecos);
+ island_stitch_data[element->island].rotation += rotation;
}
@@ -434,8 +477,6 @@ static void stitch_state_delete(StitchState *stitch_state)
static void determine_uv_stitchability(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data){
int vert_index;
UvElement *element_iter;
- float limit= state->limit_dist;
- int do_limit = state->use_limit;
vert_index = (*(&element->face->v1 + element->tfindex))->tmp.l;
element_iter = state->element_map->vert[vert_index];
@@ -445,18 +486,7 @@ static void determine_uv_stitchability(UvElement *element, StitchState *state, I
if(element_iter == element){
continue;
}
- if(do_limit){
- MTFace *mtface_orig = CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
- MTFace *mtface_iter = CustomData_em_get(&state->em->fdata, element_iter->face->data, CD_MTFACE);
-
- if(fabs(mtface_orig->uv[element->tfindex][0] - mtface_iter->uv[element_iter->tfindex][0]) < limit
- && fabs(mtface_orig->uv[element->tfindex][1] - mtface_iter->uv[element_iter->tfindex][1]) < limit){
- island_stitch_data[element_iter->island].stitchableCandidate = 1;
- island_stitch_data[element->island].stitchableCandidate = 1;
- element->flag |= STITCH_STITCHABLE_CANDIDATE;
- }
- }else{
- /* if no limit exists, then the mere existence of a separate uv means that the uv is stitchable */
+ if(stitch_check_uvs_stitchable(element, element_iter, state)){
island_stitch_data[element_iter->island].stitchableCandidate = 1;
island_stitch_data[element->island].stitchableCandidate = 1;
element->flag |= STITCH_STITCHABLE_CANDIDATE;
@@ -466,7 +496,6 @@ static void determine_uv_stitchability(UvElement *element, StitchState *state, I
}
-
/* set preview buffer position of UV face in editface->tmp.l */
static void stitch_set_face_preview_buffer_position(EditFace *efa, StitchPreviewer *preview)
{
@@ -489,8 +518,8 @@ static void stitch_setup_face_preview_for_uv_group(UvElement *element, StitchSta
StitchPreviewer *preview = uv_get_stitch_previewer();
/* static island does not change so returning immediately */
- //if(state->snap_islands && !state->midpoints && state->static_island == element->island)
- // return;
+ if(state->snap_islands && !state->midpoints && state->static_island == element->island)
+ return;
if(state->snap_islands){
island_stitch_data[element->island].addedForPreview = 1;
@@ -515,23 +544,8 @@ static void stitch_validate_stichability(UvElement *element, StitchState *state,
if(element_iter->separate){
if(element_iter == element)
continue;
- if(state->use_limit){
- MTFace *mtface_orig = CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
- MTFace *mtface_iter = CustomData_em_get(&state->em->fdata, element_iter->face->data, CD_MTFACE);
-
- if(fabs(mtface_orig->uv[element->tfindex][0] - mtface_iter->uv[element_iter->tfindex][0]) < state->limit_dist
- && fabs(mtface_orig->uv[element->tfindex][1] - mtface_iter->uv[element_iter->tfindex][1]) < state->limit_dist){
- if(((element_iter->island == state->static_island) || (element->island == state->static_island)) &&
- !((element_iter->island == element->island) && state->snap_islands)){
- element->flag |= STITCH_STITCHABLE;
- preview->num_stitchable++;
- stitch_setup_face_preview_for_uv_group(element, state, island_stitch_data);
- return;
- }
- }
- }else{
- if(((element_iter->island == state->static_island) || (element->island == state->static_island)) &&
- !((element_iter->island == element->island) && state->snap_islands)){
+ if(stitch_check_uvs_state_stitchable(element, element_iter, state)){
+ if((element_iter->island == state->static_island) || (element->island == state->static_island)){
element->flag |= STITCH_STITCHABLE;
preview->num_stitchable++;
stitch_setup_face_preview_for_uv_group(element, state, island_stitch_data);
@@ -551,15 +565,13 @@ static void stitch_validate_stichability(UvElement *element, StitchState *state,
static int stitch_process_data(StitchState *state, Scene *scene, int final)
{
int i;
- StitchPreviewer *preview = uv_get_stitch_previewer();
+ StitchPreviewer *preview;
IslandStitchData *island_stitch_data = NULL;
int previous_island = state->static_island;
EditFace *efa;
EditVert *ev;
UVVertAverage *final_position;
char stitch_midpoints = state->midpoints;
- /* use vertex normals for snapping rotation */
- char use_vert_normals = 1;
/* used to map uv indices to uvaverage indices for selection */
unsigned int *uvfinal_map;
@@ -578,7 +590,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
return 0;
}
- /* store Indices to editVerts. */
+ /* store indices to editVerts. */
for(ev = state->em->verts.first, i = 0; ev; ev = ev->next, i++){
ev->tmp.l = i;
}
@@ -708,26 +720,46 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
******************************************************/
final_position = MEM_callocN(state->selection_size*sizeof(*final_position), "stitch_uv_average");
- uvfinal_map = MEM_mallocN(state->em->totvert*sizeof(*uvfinal_map), "stitch_uv_final_map");
+ uvfinal_map = MEM_mallocN(state->element_map->totalUVs*sizeof(*uvfinal_map), "stitch_uv_final_map");
/* first pass, calculate final position for stitchable uvs of the static island */
for(i = 0; i < state->selection_size; i++){
UvElement *element = state->selection_stack[i];
if(element->flag & STITCH_STITCHABLE){
- UvElement *element_iter = state->element_map->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
- uvfinal_map[(*(&element->face->v1 + element->tfindex))->tmp.l] = i;
+ MTFace *mt;
+
+ UvElement *element_iter;
+
+ uvfinal_map[element - state->element_map->buf] = i;
+
+ efa = element->face;
+ mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+
+ final_position[i].uv[0] = mt->uv[element->tfindex][0];
+ final_position[i].uv[1] = mt->uv[element->tfindex][1];
+ final_position[i].count = 1;
+
+ if(state->snap_islands && element->island == state->static_island && !stitch_midpoints)
+ continue;
+
+ element_iter = state->element_map->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
+
for(;element_iter; element_iter = element_iter->next){
- if(element_iter->flag & STITCH_STITCHABLE){
- MTFace *mt;
- efa = element_iter->face;
- mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
- if(stitch_midpoints){
- final_position[i].uv[0] += mt->uv[element_iter->tfindex][0];
- final_position[i].uv[1] += mt->uv[element_iter->tfindex][1];
- final_position[i].count++;
- }else if(element_iter->island == state->static_island){
- final_position[i].uv[0] = mt->uv[element_iter->tfindex][0];
- final_position[i].uv[1] = mt->uv[element_iter->tfindex][1];
+ if(element_iter->separate){
+ if(stitch_check_uvs_state_stitchable(element, element_iter, state)){
+ efa = element_iter->face;
+ mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+ if(stitch_midpoints){
+ final_position[i].uv[0] += mt->uv[element_iter->tfindex][0];
+ final_position[i].uv[1] += mt->uv[element_iter->tfindex][1];
+ final_position[i].count++;
+ }else if(element_iter->island == state->static_island){
+ /* if multiple uvs on the static island exist,
+ * last checked remains. to disambiguate we need to limit or use
+ * edge stitch */
+ final_position[i].uv[0] = mt->uv[element_iter->tfindex][0];
+ final_position[i].uv[1] = mt->uv[element_iter->tfindex][1];
+ }
}
}
}
@@ -762,65 +794,57 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
UvEdge *edge = state->edges+i;
if((state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)){
stitch_island_calculate_edge_rotation(edge, state, final_position, uvfinal_map, island_stitch_data);
- use_vert_normals = 0;
+ island_stitch_data[state->uvs[edge->uv1]->island].use_edge_rotation = 1;
}
}
- if(use_vert_normals){
- for(i = 0; i < state->selection_size; i++){
- UvElement *element = state->selection_stack[i];
+
+ for(i = 0; i < state->selection_size; i++){
+ UvElement *element = state->selection_stack[i];
+ if(!island_stitch_data[element->island].use_edge_rotation){
if(element->flag & STITCH_STITCHABLE){
- stitch_island_calculate_vert_rotation(element, state, island_stitch_data, 0);
+ stitch_island_calculate_vert_rotation(element, state, island_stitch_data);
}
}
}
+
}
- /* third pass, propagate changes to stitchable uvs */
+ /* third pass, propagate changes to coincident uvs */
for(i = 0; i < state->selection_size; i++){
UvElement *element = state->selection_stack[i];
if(element->flag & STITCH_STITCHABLE){
- UvElement *element_iter = state->element_map->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
- for(;element_iter;){
- /* determine if uv stitchable */
- if(element_iter->separate && element_iter->flag & STITCH_STITCHABLE){
- MTFace *mt;
- efa = element_iter->face;
- mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
-
- /* propagate to coincident uvs */
- do{
- efa = element_iter->face;
- mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
-
- element_iter->flag |= STITCH_PROCESSED;
- /* either flush to preview or to the MTFace, if final */
- if(final){
- mt->uv[element_iter->tfindex][0] = final_position[i].uv[0];
- mt->uv[element_iter->tfindex][1] = final_position[i].uv[1];
-
- uvedit_uv_select(scene, efa, mt, element_iter->tfindex);
- }else if(efa->tmp.l != STITCH_NO_PREVIEW){
- if(efa->v4){
- *(preview->preview_quads+efa->tmp.l + element_iter->tfindex*2) = final_position[i].uv[0];
- *(preview->preview_quads+efa->tmp.l + element_iter->tfindex*2 + 1) = final_position[i].uv[1];
- }else{
- *(preview->preview_tris+efa->tmp.l + element_iter->tfindex*2) = final_position[i].uv[0];
- *(preview->preview_tris+efa->tmp.l + element_iter->tfindex*2 + 1) = final_position[i].uv[1];
- }
- }
+ UvElement *element_iter = element;
+ /* propagate to coincident uvs */
+ do{
+ MTFace *mt;
- /* end of calculations, keep only the selection flag */
- if( (!state->snap_islands) || ((!stitch_midpoints) && (element_iter->island == state->static_island))) {
- element_iter->flag &= STITCH_SELECTED;
- }
+ efa = element_iter->face;
+ mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
- element_iter = element_iter->next;
- }while(element_iter && !element_iter->separate);
+ element_iter->flag |= STITCH_PROCESSED;
+ /* either flush to preview or to the MTFace, if final */
+ if(final){
+ mt->uv[element_iter->tfindex][0] = final_position[i].uv[0];
+ mt->uv[element_iter->tfindex][1] = final_position[i].uv[1];
+
+ uvedit_uv_select(scene, efa, mt, element_iter->tfindex);
+ }else if(efa->tmp.l != STITCH_NO_PREVIEW){
+ if(efa->v4){
+ *(preview->preview_quads+efa->tmp.l + element_iter->tfindex*2) = final_position[i].uv[0];
+ *(preview->preview_quads+efa->tmp.l + element_iter->tfindex*2 + 1) = final_position[i].uv[1];
+ }else{
+ *(preview->preview_tris+efa->tmp.l + element_iter->tfindex*2) = final_position[i].uv[0];
+ *(preview->preview_tris+efa->tmp.l + element_iter->tfindex*2 + 1) = final_position[i].uv[1];
+ }
+ }
- continue;
+ /* end of calculations, keep only the selection flag */
+ if( (!state->snap_islands) || ((!stitch_midpoints) && (element_iter->island == state->static_island))) {
+ element_iter->flag &= STITCH_SELECTED;
}
+
element_iter = element_iter->next;
- }
+ }while(element_iter && !element_iter->separate);
}
}
@@ -888,12 +912,13 @@ static void stitch_select_uv(UvElement *element, StitchState *stitch_state, int
}
}
-static void stitch_calculate_edge_normal(EditMesh *em, UvEdge *edge, float *normal){
+static void stitch_calculate_edge_normal(EditMesh *em, UvEdge *edge, float *normal)
+{
UvElement *element = edge->element;
EditFace *efa = element->face;
MTFace *mt = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
int nverts = efa->v4?4 : 3;
- int index = index = (element->tfindex + 2)%nverts;
+ int index = (element->tfindex + 2)%nverts;
float tangent[2], internal[2];
sub_v2_v2v2(tangent, mt->uv[(element->tfindex + 1)%nverts], mt->uv[element->tfindex]);
@@ -1043,7 +1068,7 @@ static int stitch_init(bContext *C, wmOperator *op)
ghi = BLI_ghashIterator_new(edgeHash);
total_edges = 0;
/* fill the edges with data */
- for(i = 0; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)){
+ for(; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)){
UvEdge *edge = ((UvEdge *)BLI_ghashIterator_getKey(ghi));
if(edge->flag & STITCH_BOUNDARY){
total_edges++;
@@ -1429,11 +1454,15 @@ void UV_OT_stitch(wmOperatorType *ot)
/* properties */
RNA_def_boolean(ot->srna, "use_limit", 0, "Use Limit", "Stitch UVs within a specified limit distance");
- RNA_def_boolean(ot->srna, "snap_islands", 1, "Snap Islands", "Snap islands together. On edge stitch mode, rotates the islands too");
-
- RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, FLT_MAX, "Limit", "Limit distance in normalized coordinates", 0.0, FLT_MAX);
- RNA_def_int(ot->srna, "static_island", 0, 0, INT_MAX, "Static Island", "Island that stays in place when stitching islands", 0, INT_MAX);
- RNA_def_boolean(ot->srna, "midpoint_snap", 0, "Snap At Midpoint", "Uv's are stitched at midpoint instead of at static island");
+ RNA_def_boolean(ot->srna, "snap_islands", 1, "Snap Islands",
+ "Snap islands together (on edge stitch mode, rotates the islands too)");
+
+ RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, FLT_MAX, "Limit",
+ "Limit distance in normalized coordinates", 0.0, FLT_MAX);
+ RNA_def_int(ot->srna, "static_island", 0, 0, INT_MAX, "Static Island",
+ "Island that stays in place when stitching islands", 0, INT_MAX);
+ RNA_def_boolean(ot->srna, "midpoint_snap", 0, "Snap At Midpoint",
+ "UVs are stitched at midpoint instead of at static island");
prop = RNA_def_collection_runtime(ot->srna, "selection", &RNA_SelectedUvElement, "Selection", "");
/* Selection should not be editable or viewed in toolbar */
RNA_def_property_flag(prop, PROP_HIDDEN);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 3ed4df66778..f3569639454 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -306,7 +306,6 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi
MFace *face;
MEdge *edge;
EditVert *editVert;
- MTFace *texface;
EditFace *editFace, **editFaceTmp;
EditEdge *editEdge, **editEdgeTmp;
int i;
@@ -321,7 +320,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi
MVert *subsurfedVerts;
MEdge *subsurfedEdges;
MFace *subsurfedFaces;
- MTFace *subsurfedTexfaces;
+ /* MTFace *subsurfedTexfaces; */ /* UNUSED */
/* number of vertices and faces for subsurfed mesh*/
int numOfEdges, numOfFaces;
@@ -340,7 +339,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi
if(eface) {
float aspx, aspy;
- texface= CustomData_em_get(&editMesh->fdata, eface->data, CD_MTFACE);
+ MTFace *texface= CustomData_em_get(&editMesh->fdata, eface->data, CD_MTFACE);
ED_image_uv_aspect(texface->tpage, &aspx, &aspy);
@@ -368,7 +367,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi
origEdgeIndices = derivedMesh->getEdgeDataArray(derivedMesh, CD_ORIGINDEX);
origFaceIndices = derivedMesh->getFaceDataArray(derivedMesh, CD_ORIGINDEX);
- subsurfedTexfaces = derivedMesh->getFaceDataArray(derivedMesh, CD_MTFACE);
+ /* subsurfedTexfaces = derivedMesh->getFaceDataArray(derivedMesh, CD_MTFACE); */ /* UNUSED */
numOfEdges = derivedMesh->getNumEdges(derivedMesh);
numOfFaces = derivedMesh->getNumFaces(derivedMesh);
@@ -427,7 +426,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi
}
/* Now we feed the rest of the data from the subsurfed faces */
- texface= subsurfedTexfaces+i;
+ /* texface= subsurfedTexfaces+i; */ /* UNUSED */
/* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */
key = (ParamKey)face;
@@ -1204,8 +1203,10 @@ void UV_OT_unwrap(wmOperatorType *ot)
"Virtual fill holes in mesh before unwrapping, to better avoid overlaps and preserve symmetry");
RNA_def_boolean(ot->srna, "correct_aspect", 1, "Correct Aspect",
"Map UVs taking image aspect ratio into account");
- RNA_def_boolean(ot->srna, "use_subsurf_data", 0, "Use Subsurf Data", "Map UV's taking vertex position after subsurf into account");
- RNA_def_int(ot->srna, "uv_subsurf_level", 1, 1, 6, "SubSurf Target", "Number of times to subdivide before calculating UV's", 1, 6);
+ RNA_def_boolean(ot->srna, "use_subsurf_data", 0, "Use Subsurf Data",
+ "Map UVs taking vertex position after subsurf into account");
+ RNA_def_int(ot->srna, "uv_subsurf_level", 1, 1, 6, "SubSurf Target",
+ "Number of times to subdivide before calculating UVs", 1, 6);
}
/**************** Project From View operator **************/
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index adf6f4a143b..cb5d6721566 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -50,7 +50,7 @@
struct ImMetaData;
#define IB_MIPMAP_LEVELS 20
-#define IB_FILENAME_SIZE 1023
+#define IB_FILENAME_SIZE 1024
/**
* \ingroup imbuf
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index b627baf99bd..a9f020c94e8 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -136,9 +136,9 @@ struct anim {
int x, y;
/* voor op nummer */
- char name[256];
+ char name[1024];
/* voor sequence */
- char first[256];
+ char first[1024];
/* movie */
void *movie;
@@ -189,7 +189,7 @@ struct anim {
struct redcode_handle * redcodeCtx;
#endif
- char index_dir[256];
+ char index_dir[768];
int proxies_tried;
int indices_tried;
diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h
index 62608cbbd79..f9d90208078 100644
--- a/source/blender/imbuf/intern/IMB_indexer.h
+++ b/source/blender/imbuf/intern/IMB_indexer.h
@@ -62,7 +62,7 @@ typedef struct anim_index_entry {
} anim_index_entry;
struct anim_index {
- char name[256];
+ char name[1024];
int num_entries;
struct anim_index_entry * entries;
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 442309ccf7a..a8ca282de66 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -164,19 +164,6 @@ MINLINE unsigned char dither_value(unsigned short v_in, DitherContext *di, int i
/************************* Generic Buffer Conversion *************************/
-MINLINE void byte_to_float_v4(float f[4], const uchar b[4])
-{
- f[0]= b[0] * (1.0f/255.0f);
- f[1]= b[1] * (1.0f/255.0f);
- f[2]= b[2] * (1.0f/255.0f);
- f[3]= b[3] * (1.0f/255.0f);
-}
-
-MINLINE void float_to_byte_v4(uchar b[4], const float f[4])
-{
- F4TOCHAR4(f, b);
-}
-
MINLINE void ushort_to_byte_v4(uchar b[4], const unsigned short us[4])
{
b[0]= USHORTTOUCHAR(us[0]);
@@ -233,7 +220,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
if(profile_to == profile_from) {
/* no color space conversion */
for(x = 0; x < width; x++, from+=3, to+=4) {
- F3TOCHAR3(from, to);
+ rgb_float_to_uchar(to, from);
to[3] = 255;
}
}
@@ -241,7 +228,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
/* convert from linear to sRGB */
for(x = 0; x < width; x++, from+=3, to+=4) {
linearrgb_to_srgb_v3_v3(tmp, from);
- F3TOCHAR3(tmp, to);
+ rgb_float_to_uchar(to, tmp);
to[3] = 255;
}
}
@@ -249,7 +236,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
/* convert from sRGB to linear */
for(x = 0; x < width; x++, from+=3, to+=4) {
srgb_to_linearrgb_v3_v3(tmp, from);
- F3TOCHAR3(tmp, to);
+ rgb_float_to_uchar(to, tmp);
to[3] = 255;
}
}
@@ -267,7 +254,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
}
else {
for(x = 0; x < width; x++, from+=4, to+=4)
- float_to_byte_v4(to, from);
+ rgba_float_to_uchar(to, from);
}
}
else if(profile_to == IB_PROFILE_SRGB) {
@@ -316,13 +303,13 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
else if(predivide) {
for(x = 0; x < width; x++, from+=4, to+=4) {
srgb_to_linearrgb_predivide_v4(tmp, from);
- float_to_byte_v4(to, tmp);
+ rgba_float_to_uchar(to, tmp);
}
}
else {
for(x = 0; x < width; x++, from+=4, to+=4) {
srgb_to_linearrgb_v4(tmp, from);
- float_to_byte_v4(to, tmp);
+ rgba_float_to_uchar(to, tmp);
}
}
}
@@ -358,7 +345,7 @@ void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
if(profile_to == profile_from) {
/* no color space conversion */
for(x = 0; x < width; x++, from+=4, to+=4)
- byte_to_float_v4(to, from);
+ rgba_uchar_to_float(to, from);
}
else if(profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert sRGB to linear */
@@ -377,13 +364,13 @@ void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
/* convert linear to sRGB */
if(predivide) {
for(x = 0; x < width; x++, from+=4, to+=4) {
- byte_to_float_v4(tmp, from);
+ rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_predivide_v4(to, tmp);
}
}
else {
for(x = 0; x < width; x++, from+=4, to+=4) {
- byte_to_float_v4(tmp, from);
+ rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_v4(to, tmp);
}
}
@@ -502,16 +489,16 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
/* convert to sRGB to linear */
if(predivide) {
for(x = 0; x < width; x++, from+=4, to+=4) {
- byte_to_float_v4(tmp, from);
+ rgba_uchar_to_float(tmp, from);
srgb_to_linearrgb_predivide_v4(tmp, tmp);
- float_to_byte_v4(to, tmp);
+ rgba_float_to_uchar(to, tmp);
}
}
else {
for(x = 0; x < width; x++, from+=4, to+=4) {
- byte_to_float_v4(tmp, from);
+ rgba_uchar_to_float(tmp, from);
srgb_to_linearrgb_v4(tmp, tmp);
- float_to_byte_v4(to, tmp);
+ rgba_float_to_uchar(to, tmp);
}
}
}
@@ -519,16 +506,16 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
/* convert from linear to sRGB */
if(predivide) {
for(x = 0; x < width; x++, from+=4, to+=4) {
- byte_to_float_v4(tmp, from);
+ rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_predivide_v4(tmp, tmp);
- float_to_byte_v4(to, tmp);
+ rgba_float_to_uchar(to, tmp);
}
}
else {
for(x = 0; x < width; x++, from+=4, to+=4) {
- byte_to_float_v4(tmp, from);
+ rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_v4(tmp, tmp);
- float_to_byte_v4(to, tmp);
+ rgba_float_to_uchar(to, tmp);
}
}
}
@@ -658,15 +645,19 @@ void IMB_convert_profile(ImBuf *ibuf, int profile)
profile_from = IB_PROFILE_LINEAR_RGB;
else if(ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE))
profile_from = IB_PROFILE_SRGB;
- else
+ 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
+ else {
BLI_assert(0);
+ profile_to = IB_PROFILE_SRGB; /* dummy, should never happen */
+ }
/* do conversion */
if(ibuf->rect_float) {
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index bfd3bb4b0bf..cb7b8d15d52 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -128,8 +128,8 @@ typedef struct Library {
ID id;
ID *idblock;
struct FileData *filedata;
- char name[240]; /* path name used for reading, can be relative and edited in the outliner */
- char filepath[240]; /* absolute filepath, this is only for convenience,
+ char name[1024]; /* path name used for reading, can be relative and edited in the outliner */
+ char filepath[1024]; /* absolute filepath, this is only for convenience,
* 'name' is the real path used on file read but in
* some cases its useful to access the absolute one,
* This is set on file read.
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index f21c589d825..690c3c95964 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -59,7 +59,7 @@ typedef struct Brush {
struct ImBuf *icon_imbuf;
PreviewImage *preview;
- char icon_filepath[240]; /* 240 = FILE_MAX */
+ char icon_filepath[1024]; /* 1024 = FILE_MAX */
float normal_weight;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 5c333c3fc1f..1079f1db835 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -70,6 +70,7 @@ typedef struct ClothSimSettings
float goalfrict;
float velocity_smooth; /* smoothing of velocities for hair */
float collider_friction; /* friction with colliders */
+ float vel_damping; /* damp the velocity to speed up getting to the resting position */
int stepsPerFrame; /* Number of time steps per frame. */
int flags; /* flags, see CSIMSETT_FLAGS enum above. */
@@ -82,7 +83,7 @@ typedef struct ClothSimSettings
short shapekey_rest; /* vertex group for scaling structural stiffness */
short presets; /* used for presets on GUI */
short reset;
- short pad[3];
+ short pad;
struct EffectorWeights *effector_weights;
} ClothSimSettings;
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 00a0cf8881f..a4bb5715174 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -55,7 +55,7 @@ typedef struct CustomDataLayer {
#define MAX_CUSTOMDATA_LAYER_NAME 64
typedef struct CustomDataExternal {
- char filename[240]; /* FILE_MAX */
+ char filename[1024]; /* FILE_MAX */
} CustomDataExternal;
/** structure which stores custom element data associated with mesh elements
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 6dab70c6dee..2345b8dd1c0 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -128,14 +128,17 @@ typedef struct DynamicPaintSurface {
float wave_damping, wave_speed, wave_timescale, wave_spring;
char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
- char image_output_path[240]; /* 240 = FILE_MAX */
+ char image_output_path[1024]; /* 1024 = FILE_MAX */
char output_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
char output_name2[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ /* some surfaces have 2 outputs */
} DynamicPaintSurface;
/* canvas flags */
+#if 0 /* This should not be needed, having a valid WEIGHT_MCOL layer should be enough.
+ * And if not, should be a general flag. But seems unecessary for now... */
#define MOD_DPAINT_PREVIEW_READY (1<<0) /* if viewport preview is ready */
+#endif
#define MOD_DPAINT_BAKING (1<<1) /* surface is already baking, so it wont get updated (loop) */
/* Canvas settings */
diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h
index 31ad628d630..ed9f3cec987 100644
--- a/source/blender/makesdna/DNA_fileglobal_types.h
+++ b/source/blender/makesdna/DNA_fileglobal_types.h
@@ -51,7 +51,7 @@ typedef struct FileGlobal {
int revision; /* svn revision from buildinfo */
int pad;
/* file path where this was saved, for recover */
- char filename[240]; /* 240 = FILE_MAX */
+ char filename[1024]; /* 1024 = FILE_MAX */
} FileGlobal;
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index 110ac59edc9..8f6cc5bf354 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -69,7 +69,7 @@ typedef struct ImageUser {
typedef struct Image {
ID id;
- char name[240]; /* file path, 240 = FILE_MAX */
+ char name[1024]; /* file path, 1024 = FILE_MAX */
ListBase ibufs; /* not written in file */
struct GPUTexture *gputexture; /* not written in file */
@@ -120,6 +120,7 @@ typedef struct Image {
#define IMA_DEPRECATED 64
#define IMA_OLD_PREMUL 128
#define IMA_CM_PREDIVIDE 256
+#define IMA_USED_FOR_RENDER 512
/* Image.tpageflag */
#define IMA_TILES 1
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index e310f148110..dca401f12e8 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -773,7 +773,7 @@ typedef struct OceanModifierData {
int bakestart;
int bakeend;
- char cachepath[240]; // FILE_MAX
+ char cachepath[1024]; // FILE_MAX
char foamlayername[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
char cached;
char geometry_mode;
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index c08a5e95e92..1a56c273922 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -51,7 +51,7 @@ typedef struct MovieClipUser {
} MovieClipUser;
typedef struct MovieClipProxy {
- char dir[160]; /* custom directory for index and proxy files (defaults to BL_proxy) */
+ char dir[768]; /* custom directory for index and proxy files (defaults to BL_proxy) */
short tc; /* time code in use */
short quality; /* proxy build quality */
@@ -64,7 +64,7 @@ typedef struct MovieClipProxy {
typedef struct MovieClip {
ID id;
- char name[240]; /* file path, 240 = FILE_MAX */
+ char name[1024]; /* file path, 1024 = FILE_MAX */
int source; /* sequence or movie */
int lastframe; /* last accessed frame number */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index fe4f6905f42..33ac75912fa 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -85,19 +85,21 @@ typedef struct bNodeSocket {
/* execution data */
short stack_index; /* local stack index */
- short stack_type; /* deprecated, kept for forward compatibility */
+ /* XXX deprecated, kept for forward compatibility */
+ short stack_type DNA_DEPRECATED;
int pad3;
void *cache; /* cached data from execution */
/* internal data to retrieve relations and groups */
int own_index; /* group socket identifiers, to find matching pairs after reading files */
- int to_index DNA_DEPRECATED; /* XXX deprecated, only used for restoring old group node links */
+ /* XXX deprecated, only used for restoring old group node links */
+ int to_index DNA_DEPRECATED;
struct bNodeSocket *groupsock;
struct bNodeLink *link; /* a link pointer, set in ntreeUpdateTree */
- /* DEPRECATED only needed for do_versions */
- bNodeStack ns; /* custom data for inputs, only UI writes in this */
+ /* XXX deprecated, socket input values are stored in default_value now. kept for forward compatibility */
+ bNodeStack ns DNA_DEPRECATED; /* custom data for inputs, only UI writes in this */
} bNodeSocket;
/* sock->type */
@@ -347,7 +349,7 @@ typedef struct NodeHueSat {
} NodeHueSat;
typedef struct NodeImageFile {
- char name[256];
+ char name[1024]; /* 1024 = FILE_MAX */
struct ImageFormatData im_format;
int sfra, efra;
} NodeImageFile;
diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h
index 022dc53848f..90e6e97bc15 100644
--- a/source/blender/makesdna/DNA_object_fluidsim.h
+++ b/source/blender/makesdna/DNA_object_fluidsim.h
@@ -89,8 +89,8 @@ typedef struct FluidsimSettings {
struct Mesh *meshBB;
/* store output path, and file prefix for baked fluid surface */
- /* strlens; 80= FILE_MAXFILE, 160= FILE_MAXDIR */
- char surfdataPath[240];
+ /* strlens; 256= FILE_MAXFILE, 768= FILE_MAXDIR */
+ char surfdataPath[1024];
/* store start coords of axis aligned bounding box together with size */
/* values are inited during derived mesh display */
@@ -140,8 +140,8 @@ typedef struct FluidsimSettings {
int lastgoodframe;
- int pad;
-
+ /* Simulation/flow rate control (i.e. old "Fac-Time") */
+ float animRate;
} FluidsimSettings;
/* ob->fluidsimSettings defines */
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 41f79546b15..70aeaaacd44 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -186,6 +186,8 @@ typedef struct PointCache {
int endframe; /* simulation end frame */
int editframe; /* frame being edited (runtime only) */
int last_exact; /* last exact frame that's cached */
+ int last_valid; /* used for editing cache - what is the last baked frame */
+ int pad;
/* for external cache files */
int totpoint; /* number of cached points */
@@ -195,7 +197,7 @@ typedef struct PointCache {
char name[64];
char prev_name[64];
char info[64];
- char path[240]; /* file path, 240 = FILE_MAX */
+ char path[1024]; /* file path, 1024 = FILE_MAX */
char *cached_frames; /* array of length endframe-startframe+1 with flags to indicate cached frames */
/* can be later used for other per frame flags too if needed */
struct ListBase mem_cache;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 38fc513521b..1f42118dbc0 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -202,25 +202,34 @@ typedef struct SceneRenderLayer {
#define SCE_LAY_NEG_ZMASK 0x80000
/* srl->passflag */
-#define SCE_PASS_COMBINED (1<<0)
-#define SCE_PASS_Z (1<<1)
-#define SCE_PASS_RGBA (1<<2)
-#define SCE_PASS_DIFFUSE (1<<3)
-#define SCE_PASS_SPEC (1<<4)
-#define SCE_PASS_SHADOW (1<<5)
-#define SCE_PASS_AO (1<<6)
-#define SCE_PASS_REFLECT (1<<7)
-#define SCE_PASS_NORMAL (1<<8)
-#define SCE_PASS_VECTOR (1<<9)
-#define SCE_PASS_REFRACT (1<<10)
-#define SCE_PASS_INDEXOB (1<<11)
-#define SCE_PASS_UV (1<<12)
-#define SCE_PASS_INDIRECT (1<<13)
-#define SCE_PASS_MIST (1<<14)
-#define SCE_PASS_RAYHITS (1<<15)
-#define SCE_PASS_EMIT (1<<16)
-#define SCE_PASS_ENVIRONMENT (1<<17)
-#define SCE_PASS_INDEXMA (1<<18)
+#define SCE_PASS_COMBINED (1<<0)
+#define SCE_PASS_Z (1<<1)
+#define SCE_PASS_RGBA (1<<2)
+#define SCE_PASS_DIFFUSE (1<<3)
+#define SCE_PASS_SPEC (1<<4)
+#define SCE_PASS_SHADOW (1<<5)
+#define SCE_PASS_AO (1<<6)
+#define SCE_PASS_REFLECT (1<<7)
+#define SCE_PASS_NORMAL (1<<8)
+#define SCE_PASS_VECTOR (1<<9)
+#define SCE_PASS_REFRACT (1<<10)
+#define SCE_PASS_INDEXOB (1<<11)
+#define SCE_PASS_UV (1<<12)
+#define SCE_PASS_INDIRECT (1<<13)
+#define SCE_PASS_MIST (1<<14)
+#define SCE_PASS_RAYHITS (1<<15)
+#define SCE_PASS_EMIT (1<<16)
+#define SCE_PASS_ENVIRONMENT (1<<17)
+#define SCE_PASS_INDEXMA (1<<18)
+#define SCE_PASS_DIFFUSE_DIRECT (1<<19)
+#define SCE_PASS_DIFFUSE_INDIRECT (1<<20)
+#define SCE_PASS_DIFFUSE_COLOR (1<<21)
+#define SCE_PASS_GLOSSY_DIRECT (1<<22)
+#define SCE_PASS_GLOSSY_INDIRECT (1<<23)
+#define SCE_PASS_GLOSSY_COLOR (1<<24)
+#define SCE_PASS_TRANSM_DIRECT (1<<25)
+#define SCE_PASS_TRANSM_INDIRECT (1<<26)
+#define SCE_PASS_TRANSM_COLOR (1<<27)
/* note, srl->passflag is treestore element 'nr' in outliner, short still... */
@@ -471,14 +480,14 @@ typedef struct RenderData {
float bake_maxdist, bake_biasdist, bake_pad;
/* path to render output */
- char pic[240]; /* 240 = FILE_MAX */
+ char pic[1024]; /* 1024 = FILE_MAX */
/* stamps flags. */
int stamp;
short stamp_font_id, pad3; /* select one of blenders bitmap fonts */
/* stamp info user data. */
- char stamp_udata[160];
+ char stamp_udata[768];
/* foreground/background color. */
float fg_stamp[4];
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index fa501de8d6d..20399e541d7 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -41,10 +41,10 @@ struct Ipo;
struct Scene;
struct bSound;
-/* strlens; 80= FILE_MAXFILE, 160= FILE_MAXDIR */
+/* strlens; 256= FILE_MAXFILE, 768= FILE_MAXDIR */
typedef struct StripElem {
- char name[80];
+ char name[256];
int orig_width, orig_height;
} StripElem;
@@ -71,10 +71,10 @@ typedef struct StripColorBalance {
} StripColorBalance;
typedef struct StripProxy {
- char dir[160]; // custom directory for index and proxy files
+ char dir[768]; // custom directory for index and proxy files
// (defaults to BL_proxy)
- char file[80]; // custom file
+ char file[256]; // custom file
struct anim *anim; // custom proxy anim file
short tc; // time code in use
@@ -91,7 +91,7 @@ typedef struct Strip {
int rt, len, us, done;
int startstill, endstill;
StripElem *stripdata;
- char dir[160];
+ char dir[768];
StripProxy *proxy;
StripCrop *crop;
StripTransform *transform;
@@ -100,7 +100,7 @@ typedef struct Strip {
typedef struct PluginSeq {
- char name[256];
+ char name[1024]; /* 1024 = FILE_MAX */
void *handle;
char *pname;
@@ -191,8 +191,8 @@ typedef struct Editing {
/* Context vars, used to be static */
Sequence *act_seq;
- char act_imagedir[256];
- char act_sounddir[256];
+ char act_imagedir[1024]; /* 1024 = FILE_MAX */
+ char act_sounddir[1024]; /* 1024 = FILE_MAX */
int over_ofs, over_cfra;
int over_flag, pad;
@@ -353,7 +353,7 @@ typedef struct SpeedControlVars {
*/
-#define SEQ_HAS_PATH(_seq) (ELEM5((_seq)->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_SOUND, SEQ_RAM_SOUND, SEQ_HD_SOUND))
+#define SEQ_HAS_PATH(_seq) (ELEM4((_seq)->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_RAM_SOUND, SEQ_HD_SOUND))
#endif
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index ed764c4f644..753f1374774 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -138,7 +138,8 @@ typedef struct SmokeFlowSettings {
typedef struct SmokeCollSettings {
struct SmokeModifierData *smd; /* for fast RNA access */
struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */
- struct DerivedMesh *dm;
+
+// struct DerivedMesh *dm; // UNUSED, ifdef'd in code for now.
float *points;
float *points_old;
float *vel;
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index 82185c811a1..1dab9effa9e 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -49,7 +49,7 @@ typedef struct bSound {
/**
* The path to the sound file.
*/
- char name[240]; /* 240 = FILE_MAX */
+ char name[1024]; /* 1024 = FILE_MAX */
/**
* The packed file.
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index aa7a84c577b..06138bc0757 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -174,10 +174,11 @@ typedef struct SpaceSeq {
typedef struct FileSelectParams {
char title[32]; /* title, also used for the text of the execute button */
- char dir[240]; /* directory */
- char file[80]; /* file */
- char renamefile[80];
- char renameedit[80]; /* annoying but the first is only used for initialization */
+ char dir[1056]; /* directory, FILE_MAX_LIBEXTRA, 1024 + 32, this is for extreme case when 1023 length path
+ * needs to be linked in, where foo.blend/Armature need adding */
+ char file[256]; /* file */
+ char renamefile[256];
+ char renameedit[256]; /* annoying but the first is only used for initialization */
char filter_glob[64]; /* list of filetypes to filter */
@@ -343,8 +344,9 @@ typedef struct Script {
void *py_globaldict;
int flags, lastspace;
- char scriptname[256]; /* store the script file here so we can re-run it on loading blender, if "Enable Scripts" is on */
- char scriptarg[256];
+ /* store the script file here so we can re-run it on loading blender, if "Enable Scripts" is on */
+ char scriptname[1024]; /* 1024 = FILE_MAX */
+ char scriptarg[256]; /* 1024 = FILE_MAX */
} Script;
#define SCRIPT_SET_NULL(_script) _script->py_draw = _script->py_event = _script->py_button = _script->py_browsercallback = _script->py_globaldict = NULL; _script->flags = 0;
@@ -606,7 +608,8 @@ typedef struct SpaceClip {
/* FileSelectParams.display */
enum FileDisplayTypeE {
- FILE_SHORTDISPLAY = 1,
+ FILE_DEFAULTDISPLAY = 0,
+ FILE_SHORTDISPLAY,
FILE_LONGDISPLAY,
FILE_IMGDISPLAY
};
@@ -622,9 +625,11 @@ enum FileSortTypeE {
/* these values need to be hardcoded in structs, dna does not recognize defines */
/* also defined in BKE */
-#define FILE_MAXDIR 160
-#define FILE_MAXFILE 80
-#define FILE_MAX 240
+#define FILE_MAXDIR 768
+#define FILE_MAXFILE 256
+#define FILE_MAX 1024
+
+#define FILE_MAX_LIBEXTRA (FILE_MAX + 32)
/* filesel types */
#define FILE_UNIX 8
@@ -895,7 +900,8 @@ enum {
#define SC_SHOW_FILTERS (1<<13)
#define SC_SHOW_GRAPH_FRAMES (1<<14)
#define SC_SHOW_GRAPH_TRACKS (1<<15)
-#define SC_SHOW_PYRAMID_LEVELS (1<<16)
+#define SC_SHOW_PYRAMID_LEVELS (1<<16)
+#define SC_LOCK_TIMECURSOR (1<<17)
/* SpaceClip->mode */
#define SC_MODE_TRACKING 0
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 1cc84669e3b..de844fd2d7f 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -105,7 +105,7 @@ typedef unsigned short dna_ushort_fix;
#endif
typedef struct PluginTex {
- char name[160];
+ char name[1024];
void *handle;
char *pname;
@@ -200,7 +200,7 @@ typedef struct VoxelData {
struct Object *object; /* for rendering smoke sims */
float int_multiplier;
int still_frame;
- char source_path[240]; /* 240 = FILE_MAX */
+ char source_path[1024]; /* 1024 = FILE_MAX */
/* temporary data */
float *dataset;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 44bf11795c1..405e1e33720 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -60,7 +60,7 @@ struct ColorBand;
/* first font is the default (index 0), others optional */
typedef struct uiFont {
struct uiFont *next, *prev;
- char filename[256];
+ char filename[1024];/* 1024 = FILE_MAX */
short blf_id; /* from blfont lib */
short uifont_id; /* own id */
short r_to_l; /* fonts that read from left to right */
@@ -158,7 +158,7 @@ typedef struct ThemeUI {
uiPanelColors panel;
- char iconfile[80]; // FILE_MAXFILE length
+ char iconfile[256]; // FILE_MAXFILE length
float icon_alpha;
float pad;
@@ -258,6 +258,9 @@ typedef struct ThemeSpace {
char preview_stitch_stitchable[4];
char preview_stitch_unstitchable[4];
char preview_stitch_active[4];
+
+ char match[4]; /* outliner - filter match */
+ char selected_highlight[4]; /* outliner - selected item */
} ThemeSpace;
@@ -323,16 +326,16 @@ typedef struct SolidLight {
typedef struct UserDef {
int flag, dupflag;
int savetime;
- char tempdir[160]; /* FILE_MAXDIR length */
- char fontdir[160];
- char renderdir[240]; /* FILE_MAX length */
- char textudir[160];
- char plugtexdir[160];
- char plugseqdir[160];
- char pythondir[160];
- char sounddir[160];
- char image_editor[240]; /* 240 = FILE_MAX */
- char anim_player[240]; /* 240 = FILE_MAX */
+ char tempdir[768]; /* FILE_MAXDIR length */
+ char fontdir[768];
+ char renderdir[1024]; /* FILE_MAX length */
+ char textudir[768];
+ char plugtexdir[768];
+ char plugseqdir[768];
+ char pythondir[768];
+ char sounddir[768];
+ char image_editor[1024]; /* 1024 = FILE_MAX */
+ char anim_player[1024]; /* 1024 = FILE_MAX */
int anim_player_preset;
short v2d_min_gridsize; /* minimum spacing between gridlines in View2D grids */
@@ -401,8 +404,6 @@ typedef struct UserDef {
float ndof_sensitivity; /* overall sensitivity of 3D mouse */
int ndof_flag; /* flags for 3D mouse */
- char versemaster[160];
- char verseuser[160];
float glalphaclip;
short autokey_mode; /* autokeying mode */
diff --git a/source/blender/makesdna/DNA_vfont_types.h b/source/blender/makesdna/DNA_vfont_types.h
index 7132751848d..d6168af6028 100644
--- a/source/blender/makesdna/DNA_vfont_types.h
+++ b/source/blender/makesdna/DNA_vfont_types.h
@@ -42,7 +42,7 @@ struct VFontData;
typedef struct VFont {
ID id;
- char name[256];
+ char name[1024]; /* 1024 = FILE_MAX */
struct VFontData *data;
struct PackedFile * packedfile;
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
index b74972b204c..26fa793de9d 100644
--- a/source/blender/makesrna/intern/SConscript
+++ b/source/blender/makesrna/intern/SConscript
@@ -101,6 +101,10 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')
+if not env['BF_DEBUG']:
+ defs.append('NDEBUG')
+
+
makesrna_tool.Append(CPPDEFINES=defs)
makesrna_tool.Append (CPPPATH = Split(incs))
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 4eebfc52920..5339ee58acf 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -3979,6 +3979,8 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee
}
}
}
+ if(path)
+ break;
}
}
}
@@ -4745,8 +4747,15 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSE
break;
case PROP_STRING: {
const char *defvalue= ((StringPropertyRNA*)parm)->defaultvalue;
- if(defvalue && defvalue[0])
+ if(defvalue && defvalue[0]) {
+ /* causes bug [#29988], possibly this is only correct for thick wrapped
+ * need to look further into it - campbell */
+#if 0
+ BLI_strncpy(data, defvalue, size);
+#else
memcpy(data, &defvalue, size);
+#endif
+ }
break;
}
case PROP_POINTER:
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index db6cb28bd98..1327a205c19 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -289,6 +289,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down");
RNA_def_property_update(prop, 0, "rna_cloth_update");
+ prop= RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "vel_damping");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Velocity Damping",
+ "Damp velocity to help cloth reach the resting position faster "
+ "(1.0 = no damping, 0.0 = fully dampened)");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
prop= RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL);
RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions");
diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c
index 5278c1e3532..7dfb3597a29 100644
--- a/source/blender/makesrna/intern/rna_controller.c
+++ b/source/blender/makesrna/intern/rna_controller.c
@@ -48,6 +48,7 @@ EnumPropertyItem controller_type_items[] ={
#ifdef RNA_RUNTIME
#include "BKE_sca.h"
+#include "DNA_actuator_types.h"
static struct StructRNA* rna_Controller_refine(struct PointerRNA *ptr)
{
@@ -132,6 +133,18 @@ static void rna_Controller_state_number_set(struct PointerRNA *ptr, const int va
cont->state_mask = (1 << (value - 1));
}
+static void rna_Controller_actuators_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ bController *cont = (bController *)ptr->data;
+ rna_iterator_array_begin(iter, cont->links, sizeof(bActuator *), (int)cont->totlinks, 0, NULL);
+}
+
+static int rna_Controller_actuators_length(PointerRNA *ptr)
+{
+ bController *cont = (bController *)ptr->data;
+ return (int) cont->totlinks;
+}
+
#if 0 /* editable is set to false, comment for now. */
static void rna_Controller_state_get(PointerRNA *ptr, int *values)
{
@@ -212,6 +225,12 @@ void RNA_def_controller(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_BOOKMARKS, 1);
RNA_def_property_update(prop, NC_LOGIC, NULL);
+ prop= RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
+ RNA_def_property_struct_type(prop, "Actuator");
+ RNA_def_property_ui_text(prop, "Actuators", "The list containing the actuators connected to the controller");
+ RNA_def_property_collection_funcs(prop, "rna_Controller_actuators_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", "rna_Controller_actuators_length", NULL, NULL, NULL);
+
/* State */
// array of OB_MAX_STATES
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index f853e7b8dd9..99a84fc8b39 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -340,6 +340,11 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_range(prop, 0.001, 10);
RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in metres");
+ prop= RNA_def_property(srna, "simulation_rate", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "animRate");
+ RNA_def_property_range(prop, 0.0, 100.0);
+ RNA_def_property_ui_text(prop, "Simulation Speed", "Fluid motion rate (0 = stationary, 1 = normal speed)");
+
prop= RNA_def_property(srna, "viscosity_preset", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "viscosityMode");
RNA_def_property_enum_items(prop, viscosity_items);
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index f6e958ab1f5..2ada09f2df1 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1699,6 +1699,11 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop)
func= RNA_def_function(srna, "add", "ED_mesh_vertices_add");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
+#if 0 // Remove until BMesh merge
+ func= RNA_def_function(srna, "remove", "ED_mesh_vertices_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to remove", 0, INT_MAX);
+#endif
}
/* mesh.edges */
@@ -1717,7 +1722,12 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop)
func= RNA_def_function(srna, "add", "ED_mesh_edges_add");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
+ RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX);
+#if 0 // Remove until BMesh merge
+ func= RNA_def_function(srna, "remove", "ED_mesh_edges_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to remove", 0, INT_MAX);
+#endif
}
/* mesh.faces */
@@ -1746,7 +1756,12 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop)
func= RNA_def_function(srna, "add", "ED_mesh_faces_add");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
+ RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX);
+#if 0 // Remove until BMesh merge
+ func= RNA_def_function(srna, "remove", "ED_mesh_faces_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to remove", 0, INT_MAX);
+#endif
}
/* mesh.vertex_colors */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 3f3ac6ce906..50eb3d394df 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2901,7 +2901,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
srna= RNA_def_struct(brna, "OceanModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Ocean Modifier", "Simulate an ocean surface");
RNA_def_struct_sdna(srna, "OceanModifierData");
- RNA_def_struct_ui_icon(srna, ICON_MOD_FLUIDSIM);
+ RNA_def_struct_ui_icon(srna, ICON_MOD_WAVE);
/* General check if blender was built with OceanSim modifier support */
prop= RNA_def_property(srna, "is_build_enabled", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index a04ddec2098..989202f785c 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -3071,7 +3071,7 @@ static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype,
};
#undef SUBTYPE
- #define SUBTYPE(socktype, stypename, id, idname) if (subtype==PROP_##id) propsubtype = PROP_##id;
+ #define SUBTYPE(socktype, stypename, id, idname) if (subtype == (PROP_##id)) propsubtype = PROP_##id;
NODE_DEFINE_SUBTYPES
#undef SUBTYPE
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index 5ab907c87dc..2284b09e941 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -41,6 +41,7 @@ DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTO
DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" )
DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" )
DefNode( ShaderNode, SH_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" )
+DefNode( ShaderNode, SH_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" )
DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" )
DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" )
DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" )
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 877da130357..188ccccbfc4 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -63,6 +63,7 @@
#include "BKE_font.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
+#include "BKE_cdderivedmesh.h"
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
@@ -470,6 +471,44 @@ int rna_Object_is_modified(Object *ob, Scene *scene, int settings)
return object_is_modified(scene, ob) & settings;
}
+#ifndef NDEBUG
+void rna_Object_dm_info(struct Object *ob, int type, char *result)
+{
+ DerivedMesh *dm = NULL;
+ int dm_release = FALSE;
+ char *ret = NULL;
+
+ result[0] = '\0';
+
+ switch(type) {
+ case 0:
+ if (ob->type == OB_MESH) {
+ dm = CDDM_from_mesh(ob->data, ob);
+ ret = DM_debug_info(dm);
+ dm_release = TRUE;
+ }
+ break;
+ case 1:
+ dm = ob->derivedDeform;
+ break;
+ case 2:
+ dm = ob->derivedFinal;
+ break;
+ }
+
+ if (dm) {
+ ret = DM_debug_info(dm);
+ if (dm_release) {
+ dm->release(dm);
+ }
+ if (ret) {
+ strcpy(result, ret);
+ MEM_freeN(ret);
+ }
+ }
+}
+#endif /* NDEBUG */
+
#else
void RNA_api_object(StructRNA *srna)
@@ -483,6 +522,15 @@ void RNA_api_object(StructRNA *srna)
{0, NULL, 0, NULL, NULL}
};
+#ifndef NDEBUG
+ static EnumPropertyItem mesh_dm_info_items[] = {
+ {0, "SOURCE", 0, "Source", "Source mesh"},
+ {1, "DEFORM", 0, "Deform", "Objects deform mesh"},
+ {2, "FINAL", 0, "Final", "Objects final mesh"},
+ {0, NULL, 0, NULL, NULL}
+ };
+#endif
+
/* mesh */
func= RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied");
@@ -585,6 +633,20 @@ void RNA_api_object(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_boolean(func, "result", 0, "", "Object visibility");
RNA_def_function_return(func, parm);
+
+
+#ifndef NDEBUG
+ /* mesh */
+ func= RNA_def_function(srna, "dm_info", "rna_Object_dm_info");
+ RNA_def_function_ui_description(func, "Returns a string for derived mesh data");
+
+ parm= RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* weak!, no way to return dynamic string type */
+ parm= RNA_def_string(func, "result", "", 16384, "result", "");
+ RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
+ RNA_def_function_output(func, parm);
+#endif /* NDEBUG */
}
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index f00b97994d5..b88e452588e 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -472,6 +472,15 @@ static void rna_def_render_pass(BlenderRNA *brna)
{SCE_PASS_EMIT, "EMIT", 0, "Emit", ""},
{SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""},
{SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", ""},
+ {SCE_PASS_DIFFUSE_DIRECT, "DIFFUSE_DIRECT", 0, "Diffuse Direct", ""},
+ {SCE_PASS_DIFFUSE_INDIRECT, "DIFFUSE_INDIRECT", 0, "Diffuse Indirect", ""},
+ {SCE_PASS_DIFFUSE_COLOR, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
+ {SCE_PASS_GLOSSY_DIRECT, "GLOSSY_DIRECT", 0, "Glossy Direct", ""},
+ {SCE_PASS_GLOSSY_INDIRECT, "GLOSSY_INDIRECT", 0, "Glossy Indirect", ""},
+ {SCE_PASS_GLOSSY_COLOR, "GLOSSY_COLOR", 0, "Glossy Color", ""},
+ {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""},
+ {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""},
+ {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "RenderPass", NULL);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 384453fa9ec..c1df493eea5 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -887,6 +887,7 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf
#endif
#endif
+#ifdef WITH_FFMPEG
static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value)
{
Scene *scene = (Scene *) ptr->id.data;
@@ -896,10 +897,9 @@ static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value)
rd->ffcodecdata.flags |= FFMPEG_LOSSLESS_OUTPUT;
else
rd->ffcodecdata.flags &= ~FFMPEG_LOSSLESS_OUTPUT;
-#ifdef WITH_FFMPEG
ffmpeg_verify_lossless_format(rd, &rd->im_format);
-#endif
}
+#endif
static int rna_RenderSettings_active_layer_index_get(PointerRNA *ptr)
{
@@ -1457,13 +1457,13 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1);
- RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for uv sculpting");
+ RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting");
RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_SpaceImageEditor_uv_sculpt_update");
prop= RNA_def_property(srna, "uv_sculpt_lock_borders", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_LOCK_BORDERS);
- RNA_def_property_ui_text(prop, "Lock Borders", "Disables editing of boundary edges");
+ RNA_def_property_ui_text(prop, "Lock Borders", "Disable editing of boundary edges");
prop= RNA_def_property(srna, "uv_sculpt_all_islands", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_ALL_ISLANDS);
@@ -2065,6 +2065,60 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_diffuse_direct", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_DIRECT);
+ RNA_def_property_ui_text(prop, "Diffuse Direct", "Deliver diffuse direct pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_diffuse_indirect", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_INDIRECT);
+ RNA_def_property_ui_text(prop, "Diffuse Indirect", "Deliver diffuse indirect pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_diffuse_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_COLOR);
+ RNA_def_property_ui_text(prop, "Diffuse Color", "Deliver diffuse color pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_glossy_direct", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_DIRECT);
+ RNA_def_property_ui_text(prop, "Glossy Direct", "Deliver glossy direct pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_glossy_indirect", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_INDIRECT);
+ RNA_def_property_ui_text(prop, "Glossy Indirect", "Deliver glossy indirect pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_glossy_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_COLOR);
+ RNA_def_property_ui_text(prop, "Glossy Color", "Deliver glossy color pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_transmission_direct", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_DIRECT);
+ RNA_def_property_ui_text(prop, "Transmission Direct", "Deliver transmission direct pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_transmission_indirect", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_INDIRECT);
+ RNA_def_property_ui_text(prop, "Transmission Indirect", "Deliver transmission indirect pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop= RNA_def_property(srna, "use_pass_transmission_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_COLOR);
+ RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass");
+ if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+ else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
static void rna_def_scene_game_recast_data(BlenderRNA *brna)
@@ -3722,7 +3776,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE);
- RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disables non-planer quads being triangulated");
+ RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated");
/* Scene API */
RNA_api_scene_render(srna);
@@ -3896,7 +3950,7 @@ static void rna_def_selected_uv_element(BlenderRNA *brna)
PropertyRNA *prop;
srna= RNA_def_struct(brna, "SelectedUvElement", "PropertyGroup");
- RNA_def_struct_ui_text(srna, "Selected Uv Element", "");
+ RNA_def_struct_ui_text(srna, "Selected UV Element", "");
/* store the index to the UV element selected */
prop= RNA_def_property(srna, "element_index", PROP_INT, PROP_UNSIGNED);
@@ -3957,7 +4011,7 @@ void RNA_def_scene(BlenderRNA *brna)
prop= RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "World", "World used for rendering the scene");
- RNA_def_property_update(prop, NC_SCENE|ND_WORLD, NULL);
+ RNA_def_property_update(prop, NC_SCENE|ND_WORLD, "rna_Scene_glsl_update");
prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "cursor");
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 14e518da4b5..153317fb687 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -57,6 +57,7 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME);
scene_update_for_newframe(G.main, scene, (1<<20) - 1);
+ scene_camera_switch_update(scene);
/* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call
* scene_update_for_newframe which will loose any un-keyed changes [#24690] */
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index c3c84c66567..67304997571 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -476,12 +476,12 @@ static void rna_def_particle_edit(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Brush", "");
prop= RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 2, 10);
+ RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Steps", "How many steps to draw the path with");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_ParticleEdit_redo");
prop= RNA_def_property(srna, "fade_frames", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 2, 100);
+ RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Frames", "How many frames to fade");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_ParticleEdit_update");
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index 6459c145a3a..4413eee9395 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -61,6 +61,7 @@ EnumPropertyItem sensor_type_items[] ={
#ifdef RNA_RUNTIME
#include "BKE_sca.h"
+#include "DNA_controller_types.h"
static StructRNA* rna_Sensor_refine(struct PointerRNA *ptr)
{
@@ -125,6 +126,19 @@ static void rna_Sensor_type_set(struct PointerRNA *ptr, int value)
}
/* Always keep in alphabetical order */
+
+static void rna_Sensor_controllers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ rna_iterator_array_begin(iter, sens->links, sizeof(bController *), (int)sens->totlinks, 0, NULL);
+}
+
+static int rna_Sensor_controllers_length(PointerRNA *ptr)
+{
+ bSensor *sens = (bSensor *)ptr->data;
+ return (int) sens->totlinks;
+}
+
EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
{
EnumPropertyItem *item= NULL;
@@ -327,6 +341,13 @@ static void rna_def_sensor(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Tap", "Trigger controllers only for an instant, even while the sensor remains true");
RNA_def_property_update(prop, NC_LOGIC, NULL);
+ prop= RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
+ RNA_def_property_struct_type(prop, "Controller");
+ RNA_def_property_ui_text(prop, "Controllers", "The list containing the controllers connected to the sensor");
+ RNA_def_property_collection_funcs(prop, "rna_Sensor_controllers_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", "rna_Sensor_controllers_length", NULL, NULL, NULL);
+
+
RNA_api_sensor(srna);
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index d7f1c375a21..571fe05238d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2375,6 +2375,11 @@ static void rna_def_space_time(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
+ prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TIME_DRAWFRAMES);
+ RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
+
/* displaying cache status */
prop= RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY);
@@ -2895,6 +2900,12 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_LOCK_SELECTION);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, "rna_SpaceClipEditor_lock_selection_update");
+ /* lock to time cursor */
+ prop= RNA_def_property(srna, "lock_time_cursor", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Lock to Time Cursor", "Lock curves view to time cursos during playback and tracking");
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_LOCK_TIMECURSOR);
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
+
/* show markers pathes */
prop= RNA_def_property(srna, "show_track_path", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_TRACK_PATH);
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 01f3889d684..5573ceccf8f 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -1232,7 +1232,7 @@ static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop)
func= RNA_def_function(srna, "remove", "rna_trackingObject_remove");
RNA_def_function_ui_description(func, "Remove tracking object from this movie clip");
- parm= RNA_def_pointer(func, "object", "MovieTrackingObject", "", "Motion tracking object to be removed");
+ RNA_def_pointer(func, "object", "MovieTrackingObject", "", "Motion tracking object to be removed");
/* active object */
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 24486c227b7..dc4f3449c1b 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -1312,6 +1312,7 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna)
static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna)
{
StructRNA *srna;
+ PropertyRNA *prop;
/* space_outliner */
@@ -1321,6 +1322,16 @@ static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Theme Outliner", "Theme settings for the Outliner");
rna_def_userdef_theme_spaces_main(srna);
+
+ prop= RNA_def_property(srna, "match", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Filter Match", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop= RNA_def_property(srna, "selected_highlight", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Selected Highlight", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c
index afd16b41131..f6a2e4451b2 100644
--- a/source/blender/modifiers/intern/MOD_boolean_util.c
+++ b/source/blender/modifiers/intern/MOD_boolean_util.c
@@ -350,7 +350,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
GHash *material_hash = NULL;
Mesh *me1= (Mesh*)ob1->data;
Mesh *me2= (Mesh*)ob2->data;
- int i;
+ int i, *origindex_layer;
// create a new DerivedMesh
result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements);
@@ -379,6 +379,8 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
*totmat = 0;
}
+ origindex_layer = result->getFaceDataArray(result, CD_ORIGINDEX);
+
// step through the face iterators
for(i = 0; !face_it->Done(face_it->it); i++) {
Mesh *orig_me;
@@ -427,6 +429,9 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
(orig_me == me2)? mapmat: NULL);
test_index_face(mface, &result->faceData, i, csgface.vertex_number);
+
+ if(origindex_layer && orig_ob == ob2)
+ origindex_layer[i] = ORIGINDEX_NONE;
}
if (material_hash)
@@ -522,7 +527,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern(
CSG_FreeFaceDescriptor(&fd_o);
}
else
- printf("Unknown internal error in boolean");
+ printf("Unknown internal error in boolean\n");
CSG_FreeBooleanOperation(bool_op);
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 119934ea2f0..ebb5bd9ab9b 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -76,135 +76,150 @@ static int dependsOnTime(ModifierData *UNUSED(md))
}
static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
- DerivedMesh *derivedData,
- int UNUSED(useRenderParams),
- int UNUSED(isFinalCalc))
+ DerivedMesh *derivedData,
+ int UNUSED(useRenderParams),
+ int UNUSED(isFinalCalc))
{
DerivedMesh *dm = derivedData;
DerivedMesh *result;
BuildModifierData *bmd = (BuildModifierData*) md;
int i;
- int numFaces, numEdges;
+ int numFaces_dst, numEdges_dst;
int *vertMap, *edgeMap, *faceMap;
float frac;
GHashIterator *hashIter;
/* maps vert indices in old mesh to indices in new mesh */
GHash *vertHash = BLI_ghash_new(BLI_ghashutil_inthash,
- BLI_ghashutil_intcmp, "build ve apply gh");
+ BLI_ghashutil_intcmp, "build ve apply gh");
/* maps edge indices in new mesh to indices in old mesh */
GHash *edgeHash = BLI_ghash_new(BLI_ghashutil_inthash,
- BLI_ghashutil_intcmp, "build ed apply gh");
+ BLI_ghashutil_intcmp, "build ed apply gh");
- const int maxVerts= dm->getNumVerts(dm);
- const int maxEdges= dm->getNumEdges(dm);
- const int maxFaces= dm->getNumFaces(dm);
+ const int numVert_src= dm->getNumVerts(dm);
+ const int numEdge_src= dm->getNumEdges(dm);
+ const int numFace_src= dm->getNumFaces(dm);
- vertMap = MEM_callocN(sizeof(*vertMap) * maxVerts, "build modifier vertMap");
- for(i = 0; i < maxVerts; ++i) vertMap[i] = i;
- edgeMap = MEM_callocN(sizeof(*edgeMap) * maxEdges, "build modifier edgeMap");
- for(i = 0; i < maxEdges; ++i) edgeMap[i] = i;
- faceMap = MEM_callocN(sizeof(*faceMap) * maxFaces, "build modifier faceMap");
- for(i = 0; i < maxFaces; ++i) faceMap[i] = i;
+ vertMap = MEM_callocN(sizeof(*vertMap) * numVert_src, "build modifier vertMap");
+ for (i = 0; i < numVert_src; i++) vertMap[i] = i;
+ edgeMap = MEM_callocN(sizeof(*edgeMap) * numEdge_src, "build modifier edgeMap");
+ for (i = 0; i < numEdge_src; i++) edgeMap[i] = i;
+ faceMap = MEM_callocN(sizeof(*faceMap) * numFace_src, "build modifier faceMap");
+ for (i = 0; i < numFace_src; i++) faceMap[i] = i;
frac = (BKE_curframe(md->scene) - bmd->start) / bmd->length;
CLAMP(frac, 0.0f, 1.0f);
- numFaces = dm->getNumFaces(dm) * frac;
- numEdges = dm->getNumEdges(dm) * frac;
+ numFaces_dst = dm->getNumFaces(dm) * frac;
+ numEdges_dst = dm->getNumEdges(dm) * frac;
/* if there's at least one face, build based on faces */
- if(numFaces) {
- if(bmd->randomize)
+ if (numFaces_dst) {
+ if (bmd->randomize) {
BLI_array_randomize(faceMap, sizeof(*faceMap),
- maxFaces, bmd->seed);
+ numFace_src, bmd->seed);
+ }
/* get the set of all vert indices that will be in the final mesh,
- * mapped to the new indices
- */
- for(i = 0; i < numFaces; ++i) {
+ * mapped to the new indices
+ */
+ for (i = 0; i < numFaces_dst; i++) {
MFace mf;
dm->getFace(dm, faceMap[i], &mf);
- if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v1)))
+ if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v1))) {
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v1),
- SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
- if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v2)))
+ SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ }
+ if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v2))) {
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v2),
- SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
- if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v3)))
+ SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ }
+ if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v3))) {
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v3),
- SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
- if(mf.v4 && !BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v4)))
+ SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ }
+ if (mf.v4 && !BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v4))) {
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v4),
- SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ }
}
/* get the set of edges that will be in the new mesh (i.e. all edges
- * that have both verts in the new mesh)
- */
- for(i = 0; i < maxEdges; ++i) {
+ * that have both verts in the new mesh)
+ */
+ for (i = 0; i < numEdge_src; i++) {
MEdge me;
dm->getEdge(dm, i, &me);
- if(BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1))
- && BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2)))
- BLI_ghash_insert(edgeHash,
- SET_INT_IN_POINTER(BLI_ghash_size(edgeHash)), SET_INT_IN_POINTER(i));
+ if ( BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1)) &&
+ BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2)))
+ {
+ BLI_ghash_insert(edgeHash, SET_INT_IN_POINTER(BLI_ghash_size(edgeHash)),
+ SET_INT_IN_POINTER(i));
+ }
}
- } else if(numEdges) {
- if(bmd->randomize)
+ }
+ else if (numEdges_dst) {
+ if (bmd->randomize) {
BLI_array_randomize(edgeMap, sizeof(*edgeMap),
- maxEdges, bmd->seed);
+ numEdge_src, bmd->seed);
+ }
/* get the set of all vert indices that will be in the final mesh,
- * mapped to the new indices
- */
- for(i = 0; i < numEdges; ++i) {
+ * mapped to the new indices
+ */
+ for (i = 0; i < numEdges_dst; i++) {
MEdge me;
dm->getEdge(dm, edgeMap[i], &me);
- if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1)))
+ if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1))) {
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me.v1),
- SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
- if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2)))
+ SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ }
+ if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2))) {
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me.v2),
- SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
+ }
}
/* get the set of edges that will be in the new mesh
- */
- for(i = 0; i < numEdges; ++i) {
+ */
+ for (i = 0; i < numEdges_dst; i++) {
MEdge me;
dm->getEdge(dm, edgeMap[i], &me);
BLI_ghash_insert(edgeHash, SET_INT_IN_POINTER(BLI_ghash_size(edgeHash)),
- SET_INT_IN_POINTER(edgeMap[i]));
+ SET_INT_IN_POINTER(edgeMap[i]));
}
- } else {
+ }
+ else {
int numVerts = dm->getNumVerts(dm) * frac;
- if(bmd->randomize)
+ if (bmd->randomize) {
BLI_array_randomize(vertMap, sizeof(*vertMap),
- maxVerts, bmd->seed);
+ numVert_src, bmd->seed);
+ }
/* get the set of all vert indices that will be in the final mesh,
* mapped to the new indices
*/
- for(i = 0; i < numVerts; ++i)
- BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(vertMap[i]), SET_INT_IN_POINTER(i));
+ for (i = 0; i < numVerts; i++) {
+ BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(vertMap[i]),
+ SET_INT_IN_POINTER(i));
+ }
}
/* now we know the number of verts, edges and faces, we can create
- * the mesh
- */
+ * the mesh
+ */
result = CDDM_from_template(dm, BLI_ghash_size(vertHash),
- BLI_ghash_size(edgeHash), numFaces);
+ BLI_ghash_size(edgeHash), numFaces_dst);
/* copy the vertices across */
- for( hashIter = BLI_ghashIterator_new(vertHash);
- !BLI_ghashIterator_isDone(hashIter);
- BLI_ghashIterator_step(hashIter)
- ) {
+ for ( hashIter = BLI_ghashIterator_new(vertHash);
+ !BLI_ghashIterator_isDone(hashIter);
+ BLI_ghashIterator_step(hashIter))
+ {
MVert source;
MVert *dest;
int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter));
@@ -219,7 +234,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
BLI_ghashIterator_free(hashIter);
/* copy the edges across, remapping indices */
- for(i = 0; i < BLI_ghash_size(edgeHash); ++i) {
+ for (i = 0; i < BLI_ghash_size(edgeHash); i++) {
MEdge source;
MEdge *dest;
int oldIndex = GET_INT_FROM_POINTER(BLI_ghash_lookup(edgeHash, SET_INT_IN_POINTER(i)));
@@ -235,7 +250,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
}
/* copy the faces across, remapping indices */
- for(i = 0; i < numFaces; ++i) {
+ for (i = 0; i < numFaces_dst; i++) {
MFace source;
MFace *dest;
int orig_v4;
@@ -248,7 +263,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1)));
source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2)));
source.v3 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v3)));
- if(source.v4)
+ if (source.v4)
source.v4 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v4)));
DM_copy_face_data(dm, result, faceMap[i], i, 1);
@@ -258,14 +273,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
}
CDDM_calc_normals(result);
-
+
BLI_ghash_free(vertHash, NULL, NULL);
BLI_ghash_free(edgeHash, NULL, NULL);
MEM_freeN(vertMap);
MEM_freeN(edgeMap);
MEM_freeN(faceMap);
-
+
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 773e93a22ad..c7b4d41e646 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -170,8 +170,10 @@ ModifierTypeInfo modifierType_DynamicPaint = {
/* structSize */ sizeof(DynamicPaintModifierData),
/* type */ eModifierTypeType_Constructive,
/* flags */ eModifierTypeFlag_AcceptsMesh
- | eModifierTypeFlag_UsesPointCache
- | eModifierTypeFlag_Single,
+/* |eModifierTypeFlag_SupportsMapping*/
+ |eModifierTypeFlag_UsesPointCache
+ |eModifierTypeFlag_Single
+ |eModifierTypeFlag_UsesPreview,
/* copyData */ copyData,
/* deformVerts */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 0452c6a4e73..b62a497a10c 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -95,6 +95,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
fss->animStart = 0.0;
fss->animEnd = 4.0;
+ fss->animRate = 1.0;
fss->gstar = 0.005; // used as normgstar
fss->maxRefine = -1;
// maxRefine is set according to resolutionxyz during bake
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 99f5117e3cd..d16fa0c503c 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -583,7 +583,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* faces */
mf= mface + (numFaces * 2);
- origindex= result->getFaceDataArray(result, CD_ORIGINDEX);
+
for(i=0; i<newFaces; i++, mf++) {
int eidx= new_edge_arr[i];
int fidx= edge_users[eidx];
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index bdd7ab7486b..e4d1d7d0eb0 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -114,6 +114,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
dataMask |= CD_MASK_MTFACE;
+ /* No need to ask for CD_WEIGHT_MCOL... */
+
return dataMask;
}
@@ -186,8 +188,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
int defgrp_idx;
int i;
/* Flags. */
- int do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0;
- int do_rem = (wmd->edit_flags & MOD_WVG_EDIT_REMFVG) != 0;
+ int do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0;
+ int do_rem = (wmd->edit_flags & MOD_WVG_EDIT_REMFVG) != 0;
+ /* Only do weight-preview in Object, Sculpt and Pose modes! */
+#if 0
+ int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview);
+#endif
/* Get number of verts. */
numVerts = dm->getNumVerts(dm);
@@ -204,6 +210,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
return dm;
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
+ /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
+ if(!dvert)
+ /* If this modifier is not allowed to add vertices, just return. */
+ if(!do_add)
+ return dm;
+ /* Else, add a valid data layer! */
+ dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC,
+ NULL, numVerts, wmd->defgrp_name);
+ /* Ultimate security check. */
+ if(!dvert)
+ return dm;
/* Get org weights, assuming 0.0 for vertices not in given vgroup. */
org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w");
@@ -233,6 +250,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
weightvg_update_vg(dvert, defgrp_idx, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold,
do_rem, wmd->rem_threshold);
+ /* If weight preview enabled... */
+#if 0 /* XXX Currently done in mod stack :/ */
+ if(do_prev)
+ DM_update_weight_mcol(ob, dm, 0, org_w, 0, NULL);
+#endif
+
/* Freeing stuff. */
MEM_freeN(org_w);
MEM_freeN(new_w);
@@ -256,8 +279,9 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
/* structSize */ sizeof(WeightVGEditModifierData),
/* type */ eModifierTypeType_NonGeometrical,
/* flags */ eModifierTypeFlag_AcceptsMesh
-/* |eModifierTypeFlag_SupportsMapping*/
- |eModifierTypeFlag_SupportsEditmode,
+ |eModifierTypeFlag_SupportsMapping
+ |eModifierTypeFlag_SupportsEditmode
+ |eModifierTypeFlag_UsesPreview,
/* copyData */ copyData,
/* deformVerts */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 17316d891da..38de944cf45 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -156,6 +156,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
dataMask |= CD_MASK_MTFACE;
+ /* No need to ask for CD_WEIGHT_MCOL... */
+
return dataMask;
}
@@ -229,6 +231,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
int *tidx, *indices = NULL;
int numIdx = 0;
int i;
+ /* Flags. */
+#if 0
+ int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview);
+#endif
/* Get number of verts. */
numVerts = dm->getNumVerts(dm);
@@ -251,6 +257,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
}
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
+ /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
+ if(!dvert)
+ /* If not affecting all vertices, just return. */
+ if(wmd->mix_set != MOD_WVG_SET_ALL)
+ return dm;
+ /* Else, add a valid data layer! */
+ dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC,
+ NULL, numVerts, wmd->defgrp_name_a);
+ /* Ultimate security check. */
+ if(!dvert)
+ return dm;
/* Find out which vertices to work on. */
tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx");
@@ -361,6 +378,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
*/
weightvg_update_vg(dvert, defgrp_idx, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f);
+ /* If weight preview enabled... */
+#if 0 /* XXX Currently done in mod stack :/ */
+ if(do_prev)
+ DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices);
+#endif
+
/* Freeing stuff. */
MEM_freeN(org_w);
MEM_freeN(new_w);
@@ -388,8 +411,9 @@ ModifierTypeInfo modifierType_WeightVGMix = {
/* structSize */ sizeof(WeightVGMixModifierData),
/* type */ eModifierTypeType_NonGeometrical,
/* flags */ eModifierTypeFlag_AcceptsMesh
-/* |eModifierTypeFlag_SupportsMapping*/
- |eModifierTypeFlag_SupportsEditmode,
+ |eModifierTypeFlag_SupportsMapping
+ |eModifierTypeFlag_SupportsEditmode
+ |eModifierTypeFlag_UsesPreview,
/* copyData */ copyData,
/* deformVerts */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 8e0949f2a22..c1aa68d1544 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -268,6 +268,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
dataMask |= CD_MASK_MTFACE;
+ /* No need to ask for CD_WEIGHT_MCOL... */
+
return dataMask;
}
@@ -353,6 +355,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
int *tidx, *indices = NULL;
int numIdx = 0;
int i;
+ /* Flags. */
+#if 0
+ int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview);
+#endif
#if DO_PROFILE
TIMEIT_START(perf)
@@ -378,6 +384,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
return dm;
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
+ /* If no vertices were ever added to an object's vgroup, dvert might be NULL.
+ * As this modifier never add vertices to vgroup, just return. */
+ if(!dvert)
+ return dm;
/* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight.
*/
@@ -501,6 +511,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
/* Update vgroup. Note we never add nor remove vertices from vgroup here. */
weightvg_update_vg(dvert, defgrp_idx, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f);
+ /* If weight preview enabled... */
+#if 0 /* XXX Currently done in mod stack :/ */
+ if(do_prev)
+ DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices);
+#endif
+
/* Freeing stuff. */
MEM_freeN(org_w);
MEM_freeN(new_w);
@@ -531,8 +547,9 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
/* structSize */ sizeof(WeightVGProximityModifierData),
/* type */ eModifierTypeType_NonGeometrical,
/* flags */ eModifierTypeFlag_AcceptsMesh
-/* |eModifierTypeFlag_SupportsMapping*/
- |eModifierTypeFlag_SupportsEditmode,
+ |eModifierTypeFlag_SupportsMapping
+ |eModifierTypeFlag_SupportsEditmode
+ |eModifierTypeFlag_UsesPreview,
/* copyData */ copyData,
/* deformVerts */ NULL,
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 6d5c282d308..b458ae3a77d 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -115,6 +115,7 @@ set(SRC
shader/nodes/node_shader_curves.c
shader/nodes/node_shader_dynamic.c
shader/nodes/node_shader_gamma.c
+ shader/nodes/node_shader_brightness.c
shader/nodes/node_shader_geom.c
shader/nodes/node_shader_hueSatVal.c
shader/nodes/node_shader_invert.c
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index 907efd76786..63fc0f4232c 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -55,6 +55,7 @@ void register_node_type_sh_rgbtobw(struct bNodeTreeType *ttype);
void register_node_type_sh_texture(struct bNodeTreeType *ttype);
void register_node_type_sh_normal(struct bNodeTreeType *ttype);
void register_node_type_sh_gamma(struct bNodeTreeType *ttype);
+void register_node_type_sh_brightcontrast(struct bNodeTreeType *ttype);
void register_node_type_sh_geom(struct bNodeTreeType *ttype);
void register_node_type_sh_mapping(struct bNodeTreeType *ttype);
void register_node_type_sh_curve_vec(struct bNodeTreeType *ttype);
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index 6a6413d508f..fb3946bae6c 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -47,26 +47,19 @@ struct bNodeStack;
void node_socket_type_init(struct bNodeSocketType *types[]);
-struct bNodeSocket *nodeAddInputInt(struct bNodeTree *ntree, struct bNode *node, const char *name, PropertySubType subtype, int value, int min, int max);
-struct bNodeSocket *nodeAddOutputInt(struct bNodeTree *ntree, struct bNode *node, const char *name);
-
-struct bNodeSocket *nodeAddInputFloat(struct bNodeTree *ntree, struct bNode *node, const char *name, PropertySubType subtype, float value, float min, float max);
-struct bNodeSocket *nodeAddOutputFloat(struct bNodeTree *ntree, struct bNode *node, const char *name);
-
-struct bNodeSocket *nodeAddInputBoolean(struct bNodeTree *ntree, struct bNode *node, const char *name, char value);
-struct bNodeSocket *nodeAddOutputBoolean(struct bNodeTree *ntree, struct bNode *node, const char *name);
-
-struct bNodeSocket *nodeAddInputVector(struct bNodeTree *ntree, struct bNode *node, const char *name, PropertySubType subtype, float x, float y, float z, float min, float max);
-struct bNodeSocket *nodeAddOutputVector(struct bNodeTree *ntree, struct bNode *node, const char *name);
-
-struct bNodeSocket *nodeAddInputRGBA(struct bNodeTree *ntree, struct bNode *node, const char *name, float r, float g, float b, float a);
-struct bNodeSocket *nodeAddOutputRGBA(struct bNodeTree *ntree, struct bNode *node, const char *name);
-
-struct bNodeSocket *nodeAddInputShader(struct bNodeTree *ntree, struct bNode *node, const char *name);
-struct bNodeSocket *nodeAddOutputShader(struct bNodeTree *ntree, struct bNode *node, const char *name);
-
-struct bNodeSocket *nodeAddInputMesh(struct bNodeTree *ntree, struct bNode *node, const char *name);
-struct bNodeSocket *nodeAddOutputMesh(struct bNodeTree *ntree, struct bNode *node, const char *name);
+void *node_socket_make_default_value(int type);
+void node_socket_free_default_value(int type, void *default_value);
+void node_socket_init_default_value(int type, void *default_value);
+void node_socket_copy_default_value(int type, void *to_default_value, void *from_default_value);
+void node_socket_convert_default_value(int to_type, void *to_default_value, int from_type, void *from_default_value);
+
+void node_socket_set_default_value_int(void *default_value, PropertySubType subtype, int value, int min, int max);
+void node_socket_set_default_value_float(void *default_value, PropertySubType subtype, float value, float min, float max);
+void node_socket_set_default_value_boolean(void *default_value, char value);
+void node_socket_set_default_value_vector(void *default_value, PropertySubType subtype, float x, float y, float z, float min, float max);
+void node_socket_set_default_value_rgba(void *default_value, float r, float g, float b, float a);
+void node_socket_set_default_value_shader(void *default_value);
+void node_socket_set_default_value_mesh(void *default_value);
struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp);
struct bNodeSocket *node_add_output_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp);
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 93456d39c9c..dfc0bcb3f75 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -694,7 +694,28 @@ static void force_hidden_passes(bNode *node, int passflag)
if(!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL;
sock= BLI_findlink(&node->outputs, RRES_OUT_ENV);
if(!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL;
-
+
+ sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_DIRECT);
+ if(!(passflag & SCE_PASS_DIFFUSE_DIRECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_INDIRECT);
+ if(!(passflag & SCE_PASS_DIFFUSE_INDIRECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_COLOR);
+ if(!(passflag & SCE_PASS_DIFFUSE_COLOR)) sock->flag |= SOCK_UNAVAIL;
+
+ sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_DIRECT);
+ if(!(passflag & SCE_PASS_GLOSSY_DIRECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_INDIRECT);
+ if(!(passflag & SCE_PASS_GLOSSY_INDIRECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_COLOR);
+ if(!(passflag & SCE_PASS_GLOSSY_COLOR)) sock->flag |= SOCK_UNAVAIL;
+
+ sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_DIRECT);
+ if(!(passflag & SCE_PASS_TRANSM_DIRECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_INDIRECT);
+ if(!(passflag & SCE_PASS_TRANSM_INDIRECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR);
+ if(!(passflag & SCE_PASS_TRANSM_COLOR)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR);
}
/* based on rules, force sockets hidden always */
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 57b5cec4256..997bd72d5c4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -36,25 +36,34 @@
/* **************** IMAGE (and RenderResult, multilayer image) ******************** */
static bNodeSocketTemplate cmp_node_rlayers_out[]= {
- { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 0, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_VECTOR, 0, "UV", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_VECTOR, 0, "Speed", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Diffuse", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Specular", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Shadow", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "AO", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Reflect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 0, "IndexOB", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 0, "IndexMA", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Emit", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 0, "Environment",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 0, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 0, "UV", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 0, "Speed", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Diffuse", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Specular", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Shadow", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "AO", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Reflect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 0, "IndexOB", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 0, "IndexMA", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Emit", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Environment", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Diffuse Direct", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Diffuse Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Diffuse Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Glossy Direct", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Glossy Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Glossy Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Transmission Direct", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Transmission Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 0, "Transmission Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
@@ -238,6 +247,24 @@ static void outputs_multilayer_get(RenderData *rd, RenderLayer *rl, bNodeStack *
out[RRES_OUT_EMIT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_EMIT);
if(out[RRES_OUT_ENV]->hasoutput)
out[RRES_OUT_ENV]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_ENVIRONMENT);
+ if(out[RRES_OUT_DIFF_DIRECT]->hasoutput)
+ out[RRES_OUT_DIFF_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_DIRECT);
+ if(out[RRES_OUT_DIFF_INDIRECT]->hasoutput)
+ out[RRES_OUT_DIFF_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_INDIRECT);
+ if(out[RRES_OUT_DIFF_COLOR]->hasoutput)
+ out[RRES_OUT_DIFF_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_COLOR);
+ if(out[RRES_OUT_GLOSSY_DIRECT]->hasoutput)
+ out[RRES_OUT_GLOSSY_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_DIRECT);
+ if(out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput)
+ out[RRES_OUT_GLOSSY_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_INDIRECT);
+ if(out[RRES_OUT_GLOSSY_COLOR]->hasoutput)
+ out[RRES_OUT_GLOSSY_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_COLOR);
+ if(out[RRES_OUT_TRANSM_DIRECT]->hasoutput)
+ out[RRES_OUT_TRANSM_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_DIRECT);
+ if(out[RRES_OUT_TRANSM_INDIRECT]->hasoutput)
+ out[RRES_OUT_TRANSM_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_INDIRECT);
+ if(out[RRES_OUT_TRANSM_COLOR]->hasoutput)
+ out[RRES_OUT_TRANSM_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_COLOR);
}
@@ -402,6 +429,24 @@ static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStac
out[RRES_OUT_EMIT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_EMIT);
if(out[RRES_OUT_ENV]->hasoutput)
out[RRES_OUT_ENV]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_ENVIRONMENT);
+ if(out[RRES_OUT_DIFF_DIRECT]->hasoutput)
+ out[RRES_OUT_DIFF_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_DIRECT);
+ if(out[RRES_OUT_DIFF_INDIRECT]->hasoutput)
+ out[RRES_OUT_DIFF_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_INDIRECT);
+ if(out[RRES_OUT_DIFF_COLOR]->hasoutput)
+ out[RRES_OUT_DIFF_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_COLOR);
+ if(out[RRES_OUT_GLOSSY_DIRECT]->hasoutput)
+ out[RRES_OUT_GLOSSY_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_DIRECT);
+ if(out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput)
+ out[RRES_OUT_GLOSSY_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_INDIRECT);
+ if(out[RRES_OUT_GLOSSY_COLOR]->hasoutput)
+ out[RRES_OUT_GLOSSY_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_COLOR);
+ if(out[RRES_OUT_TRANSM_DIRECT]->hasoutput)
+ out[RRES_OUT_TRANSM_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_DIRECT);
+ if(out[RRES_OUT_TRANSM_INDIRECT]->hasoutput)
+ out[RRES_OUT_TRANSM_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_INDIRECT);
+ if(out[RRES_OUT_TRANSM_COLOR]->hasoutput)
+ out[RRES_OUT_TRANSM_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_COLOR);
}
static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 5a6cebb51ce..e5571b19614 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -100,8 +100,8 @@ bNodeSocket *node_group_add_extern_socket(bNodeTree *UNUSED(ntree), ListBase *lb
sock->groupsock = gsock;
sock->limit = (in_out==SOCK_IN ? 1 : 0xFFF);
- if (gsock->default_value)
- sock->default_value = MEM_dupallocN(gsock->default_value);
+ sock->default_value = node_socket_make_default_value(sock->type);
+ node_socket_copy_default_value(sock->type, sock->default_value, gsock->default_value);
if(lb)
BLI_addtail(lb, sock);
@@ -247,177 +247,6 @@ bNode *node_group_make_from_selected(bNodeTree *ntree)
return gnode;
}
-/* XXX This is a makeshift function to have useful initial group socket values.
- * In the end this should be implemented by a flexible socket data conversion system,
- * which is yet to be implemented. The idea is that beside default standard conversions,
- * such as int-to-float, it should be possible to quickly select a conversion method or
- * a chain of conversions for each input, whenever there is more than one option.
- * E.g. a vector-to-float conversion could use either of the x/y/z components or
- * the vector length.
- *
- * In the interface this could be implemented by a pseudo-script textbox on linked inputs,
- * with quick selection from a predefined list of conversion options. Some Examples:
- * - vector component 'z' (vector->float): "z"
- * - greyscale color (float->color): "grey"
- * - color luminance (color->float): "lum"
- * - matrix column 2 length (matrix->vector->float): "col[1].len"
- * - mesh vertex coordinate 'y' (mesh->vertex->vector->float): "vertex.co.y"
- *
- * The actual conversion is then done by a series of conversion functions,
- * which are defined in the socket type structs.
- */
-static void convert_socket_value(bNodeSocket *from, bNodeSocket *to)
-{
- /* XXX only one of these pointers is valid! just putting them here for convenience */
- bNodeSocketValueFloat *fromfloat= (bNodeSocketValueFloat*)from->default_value;
- bNodeSocketValueInt *fromint= (bNodeSocketValueInt*)from->default_value;
- bNodeSocketValueBoolean *frombool= (bNodeSocketValueBoolean*)from->default_value;
- bNodeSocketValueVector *fromvector= (bNodeSocketValueVector*)from->default_value;
- bNodeSocketValueRGBA *fromrgba= (bNodeSocketValueRGBA*)from->default_value;
-
- bNodeSocketValueFloat *tofloat= (bNodeSocketValueFloat*)to->default_value;
- bNodeSocketValueInt *toint= (bNodeSocketValueInt*)to->default_value;
- bNodeSocketValueBoolean *tobool= (bNodeSocketValueBoolean*)to->default_value;
- bNodeSocketValueVector *tovector= (bNodeSocketValueVector*)to->default_value;
- bNodeSocketValueRGBA *torgba= (bNodeSocketValueRGBA*)to->default_value;
-
- switch (from->type) {
- case SOCK_FLOAT:
- switch (to->type) {
- case SOCK_FLOAT:
- tofloat->value = fromfloat->value;
- break;
- case SOCK_INT:
- toint->value = (int)fromfloat->value;
- break;
- case SOCK_BOOLEAN:
- tobool->value = (fromfloat->value > 0.0f);
- break;
- case SOCK_VECTOR:
- tovector->value[0] = tovector->value[1] = tovector->value[2] = fromfloat->value;
- break;
- case SOCK_RGBA:
- torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = fromfloat->value;
- break;
- }
- break;
- case SOCK_INT:
- switch (to->type) {
- case SOCK_FLOAT:
- tofloat->value = (float)fromint->value;
- break;
- case SOCK_INT:
- toint->value = fromint->value;
- break;
- case SOCK_BOOLEAN:
- tobool->value = (fromint->value > 0);
- break;
- case SOCK_VECTOR:
- tovector->value[0] = tovector->value[1] = tovector->value[2] = (float)fromint->value;
- break;
- case SOCK_RGBA:
- torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = (float)fromint->value;
- break;
- }
- break;
- case SOCK_BOOLEAN:
- switch (to->type) {
- case SOCK_FLOAT:
- tofloat->value = (float)frombool->value;
- break;
- case SOCK_INT:
- toint->value = (int)frombool->value;
- break;
- case SOCK_BOOLEAN:
- tobool->value = frombool->value;
- break;
- case SOCK_VECTOR:
- tovector->value[0] = tovector->value[1] = tovector->value[2] = (float)frombool->value;
- break;
- case SOCK_RGBA:
- torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = (float)frombool->value;
- break;
- }
- break;
- case SOCK_VECTOR:
- switch (to->type) {
- case SOCK_FLOAT:
- tofloat->value = fromvector->value[0];
- break;
- case SOCK_INT:
- toint->value = (int)fromvector->value[0];
- break;
- case SOCK_BOOLEAN:
- tobool->value = (fromvector->value[0] > 0.0f);
- break;
- case SOCK_VECTOR:
- copy_v3_v3(tovector->value, fromvector->value);
- break;
- case SOCK_RGBA:
- copy_v3_v3(torgba->value, fromvector->value);
- torgba->value[3] = 1.0f;
- break;
- }
- break;
- case SOCK_RGBA:
- switch (to->type) {
- case SOCK_FLOAT:
- tofloat->value = fromrgba->value[0];
- break;
- case SOCK_INT:
- toint->value = (int)fromrgba->value[0];
- break;
- case SOCK_BOOLEAN:
- tobool->value = (fromrgba->value[0] > 0.0f);
- break;
- case SOCK_VECTOR:
- copy_v3_v3(tovector->value, fromrgba->value);
- break;
- case SOCK_RGBA:
- copy_v4_v4(torgba->value, fromrgba->value);
- break;
- }
- break;
- }
-}
-
-static void copy_socket_value(bNodeSocket *from, bNodeSocket *to)
-{
- /* XXX only one of these pointers is valid! just putting them here for convenience */
- bNodeSocketValueFloat *fromfloat= (bNodeSocketValueFloat*)from->default_value;
- bNodeSocketValueInt *fromint= (bNodeSocketValueInt*)from->default_value;
- bNodeSocketValueBoolean *frombool= (bNodeSocketValueBoolean*)from->default_value;
- bNodeSocketValueVector *fromvector= (bNodeSocketValueVector*)from->default_value;
- bNodeSocketValueRGBA *fromrgba= (bNodeSocketValueRGBA*)from->default_value;
-
- bNodeSocketValueFloat *tofloat= (bNodeSocketValueFloat*)to->default_value;
- bNodeSocketValueInt *toint= (bNodeSocketValueInt*)to->default_value;
- bNodeSocketValueBoolean *tobool= (bNodeSocketValueBoolean*)to->default_value;
- bNodeSocketValueVector *tovector= (bNodeSocketValueVector*)to->default_value;
- bNodeSocketValueRGBA *torgba= (bNodeSocketValueRGBA*)to->default_value;
-
- if (from->type != to->type)
- return;
-
- switch (from->type) {
- case SOCK_FLOAT:
- *tofloat = *fromfloat;
- break;
- case SOCK_INT:
- *toint = *fromint;
- break;
- case SOCK_BOOLEAN:
- *tobool = *frombool;
- break;
- case SOCK_VECTOR:
- *tovector = *fromvector;
- break;
- case SOCK_RGBA:
- *torgba = *fromrgba;
- break;
- }
-}
-
/* returns 1 if its OK */
int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
{
@@ -489,7 +318,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
}
else {
/* copy the default input value from the group socket default to the external socket */
- convert_socket_value(gsock, link->tosock);
+ node_socket_convert_default_value(link->tosock->type, link->tosock->default_value, gsock->type, gsock->default_value);
}
}
}
@@ -517,7 +346,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
}
else {
/* copy the default input value from the group node socket default to the internal socket */
- convert_socket_value(insock, link->tosock);
+ node_socket_convert_default_value(link->tosock->type, link->tosock->default_value, insock->type, insock->default_value);
nodeRemLink(wgroup, link);
}
}
@@ -600,7 +429,7 @@ bNodeSocket *node_group_expose_socket(bNodeTree *ngroup, bNodeSocket *sock, int
bNodeSocket *gsock= node_group_add_socket(ngroup, sock->name, sock->type, in_out);
/* initialize the default value. */
- copy_socket_value(sock, gsock);
+ node_socket_copy_default_value(gsock->type, gsock->default_value, sock->default_value);
return gsock;
}
@@ -616,7 +445,7 @@ void node_group_expose_all_sockets(bNodeTree *ngroup)
gsock = node_group_add_socket(ngroup, sock->name, sock->type, SOCK_IN);
/* initialize the default value. */
- copy_socket_value(sock, gsock);
+ node_socket_copy_default_value(gsock->type, gsock->default_value, sock->default_value);
sock->link = nodeAddLink(ngroup, NULL, gsock, node, sock);
}
@@ -626,7 +455,7 @@ void node_group_expose_all_sockets(bNodeTree *ngroup)
gsock = node_group_add_socket(ngroup, sock->name, sock->type, SOCK_OUT);
/* initialize the default value. */
- copy_socket_value(sock, gsock);
+ node_socket_copy_default_value(gsock->type, gsock->default_value, sock->default_value);
gsock->link = nodeAddLink(ngroup, node, sock, NULL, gsock);
}
@@ -832,11 +661,12 @@ bNodeTemplate node_forloop_template(bNode *node)
void node_forloop_init(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp)
{
- /* bNodeSocket *sock; */ /* UNUSED */
+ bNodeSocket *sock;
node->id = (ID*)ntemp->ngroup;
- /* sock = */ nodeAddInputFloat(ntree, node, "Iterations", PROP_UNSIGNED, 1, 0, 10000);
+ sock = nodeAddSocket(ntree, node, SOCK_IN, "Iterations", SOCK_FLOAT);
+ node_socket_set_default_value_float(sock->default_value, PROP_UNSIGNED, 1, 0, 10000);
/* NB: group socket input/output roles are inverted internally!
* Group "inputs" work as outputs in links and vice versa.
@@ -938,11 +768,12 @@ void node_loop_update_tree(bNodeTree *ngroup)
void node_whileloop_init(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp)
{
- /* bNodeSocket *sock; */ /* UNUSED */
+ bNodeSocket *sock;
node->id = (ID*)ntemp->ngroup;
- /* sock = */ nodeAddInputFloat(ntree, node, "Condition", PROP_NONE, 1, 0, 1);
+ sock = nodeAddSocket(ntree, node, SOCK_IN, "Condition", SOCK_FLOAT);
+ node_socket_set_default_value_float(sock->default_value, PROP_NONE, 1, 0, 1);
/* max iterations */
node->custom1 = 10000;
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index 9381eff30dd..f03aff8fb92 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -29,6 +29,7 @@
* \ingroup nodes
*/
+#include <limits.h>
#include "DNA_node_types.h"
@@ -172,171 +173,311 @@ void node_socket_type_init(bNodeSocketType *types[])
#undef INIT_TYPE
}
-struct bNodeSocket *nodeAddInputInt(struct bNodeTree *ntree, struct bNode *node, const char *name, PropertySubType subtype,
- int value, int min, int max)
+void *node_socket_make_default_value(int type)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_INT);
- bNodeSocketValueInt *dval= (bNodeSocketValueInt*)sock->default_value;
- dval->subtype = subtype;
- dval->value = value;
- dval->min = min;
- dval->max = max;
- return sock;
-}
-struct bNodeSocket *nodeAddOutputInt(struct bNodeTree *ntree, struct bNode *node, const char *name)
-{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_INT);
- return sock;
+ /* XXX currently just allocates from stype->structsize.
+ * it might become necessary to do more complex allocations for later types.
+ */
+ bNodeSocketType *stype = ntreeGetSocketType(type);
+ if (stype->value_structsize > 0) {
+ void *default_value = MEM_callocN(stype->value_structsize, "default socket value");
+ return default_value;
+ }
+ else
+ return NULL;
}
-struct bNodeSocket *nodeAddInputFloat(struct bNodeTree *ntree, struct bNode *node, const char *name, PropertySubType subtype,
- float value, float min, float max)
-{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_FLOAT);
- bNodeSocketValueFloat *dval= (bNodeSocketValueFloat*)sock->default_value;
- dval->subtype = subtype;
- dval->value = value;
- dval->min = min;
- dval->max = max;
- return sock;
-}
-struct bNodeSocket *nodeAddOutputFloat(struct bNodeTree *ntree, struct bNode *node, const char *name)
+void node_socket_free_default_value(int UNUSED(type), void *default_value)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_FLOAT);
- return sock;
+ /* XXX can just free the pointee for all current socket types. */
+ if (default_value)
+ MEM_freeN(default_value);
}
-struct bNodeSocket *nodeAddInputBoolean(struct bNodeTree *ntree, struct bNode *node, const char *name, char value)
-{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_BOOLEAN);
- bNodeSocketValueBoolean *dval= (bNodeSocketValueBoolean*)sock->default_value;
- dval->value = value;
- return sock;
-}
-struct bNodeSocket *nodeAddOutputBoolean(struct bNodeTree *ntree, struct bNode *node, const char *name)
+void node_socket_init_default_value(int type, void *default_value)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_BOOLEAN);
- return sock;
+ switch (type) {
+ case SOCK_FLOAT:
+ node_socket_set_default_value_float(default_value, PROP_NONE, 0.0f, -FLT_MAX, FLT_MAX);
+ break;
+ case SOCK_INT:
+ node_socket_set_default_value_int(default_value, PROP_NONE, 0, INT_MIN, INT_MAX);
+ break;
+ case SOCK_BOOLEAN:
+ node_socket_set_default_value_boolean(default_value, FALSE);
+ break;
+ case SOCK_VECTOR:
+ node_socket_set_default_value_vector(default_value, PROP_NONE, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX);
+ break;
+ case SOCK_RGBA:
+ node_socket_set_default_value_rgba(default_value, 0.0f, 0.0f, 0.0f, 1.0f);
+ break;
+ case SOCK_SHADER:
+ node_socket_set_default_value_shader(default_value);
+ break;
+ case SOCK_MESH:
+ node_socket_set_default_value_mesh(default_value);
+ break;
+ }
}
-struct bNodeSocket *nodeAddInputVector(struct bNodeTree *ntree, struct bNode *node, const char *name, PropertySubType subtype,
- float x, float y, float z, float min, float max)
+void node_socket_set_default_value_int(void *default_value, PropertySubType subtype, int value, int min, int max)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_VECTOR);
- bNodeSocketValueVector *dval= (bNodeSocketValueVector*)sock->default_value;
- dval->subtype = subtype;
- dval->value[0] = x;
- dval->value[1] = y;
- dval->value[2] = z;
- dval->min = min;
- dval->max = max;
- return sock;
-}
-struct bNodeSocket *nodeAddOutputVector(struct bNodeTree *ntree, struct bNode *node, const char *name)
-{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_VECTOR);
- return sock;
+ bNodeSocketValueInt *val = default_value;
+ val->subtype = subtype;
+ val->value = value;
+ val->min = min;
+ val->max = max;
}
-struct bNodeSocket *nodeAddInputRGBA(struct bNodeTree *ntree, struct bNode *node, const char *name,
- float r, float g, float b, float a)
+void node_socket_set_default_value_float(void *default_value, PropertySubType subtype, float value, float min, float max)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_RGBA);
- bNodeSocketValueRGBA *dval= (bNodeSocketValueRGBA*)sock->default_value;
- dval->value[0] = r;
- dval->value[1] = g;
- dval->value[2] = b;
- dval->value[3] = a;
- return sock;
+ bNodeSocketValueFloat *val = default_value;
+ val->subtype = subtype;
+ val->value = value;
+ val->min = min;
+ val->max = max;
}
-struct bNodeSocket *nodeAddOutputRGBA(struct bNodeTree *ntree, struct bNode *node, const char *name)
+
+void node_socket_set_default_value_boolean(void *default_value, char value)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_RGBA);
- return sock;
+ bNodeSocketValueBoolean *val = default_value;
+ val->value = value;
}
-struct bNodeSocket *nodeAddInputShader(struct bNodeTree *ntree, struct bNode *node, const char *name)
+void node_socket_set_default_value_vector(void *default_value, PropertySubType subtype, float x, float y, float z, float min, float max)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_SHADER);
- return sock;
+ bNodeSocketValueVector *val = default_value;
+ val->subtype = subtype;
+ val->value[0] = x;
+ val->value[1] = y;
+ val->value[2] = z;
+ val->min = min;
+ val->max = max;
}
-struct bNodeSocket *nodeAddOutputShader(struct bNodeTree *ntree, struct bNode *node, const char *name)
+
+void node_socket_set_default_value_rgba(void *default_value, float r, float g, float b, float a)
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_SHADER);
- return sock;
+ bNodeSocketValueRGBA *val = default_value;
+ val->value[0] = r;
+ val->value[1] = g;
+ val->value[2] = b;
+ val->value[3] = a;
}
-struct bNodeSocket *nodeAddInputMesh(struct bNodeTree *ntree, struct bNode *node, const char *name)
+void node_socket_set_default_value_shader(void *UNUSED(default_value))
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_IN, name, SOCK_MESH);
- return sock;
}
-struct bNodeSocket *nodeAddOutputMesh(struct bNodeTree *ntree, struct bNode *node, const char *name)
+
+void node_socket_set_default_value_mesh(void *UNUSED(default_value))
{
- bNodeSocket *sock= nodeAddSocket(ntree, node, SOCK_OUT, name, SOCK_MESH);
- return sock;
}
-struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp)
+
+void node_socket_copy_default_value(int type, void *to_default_value, void *from_default_value)
{
- bNodeSocket *sock;
- switch (stemp->type) {
- case SOCK_INT:
- sock = nodeAddInputInt(ntree, node, stemp->name, stemp->subtype, (int)stemp->val1, (int)stemp->min, (int)stemp->max);
- break;
+ /* XXX only one of these pointers is valid! just putting them here for convenience */
+ bNodeSocketValueFloat *fromfloat= (bNodeSocketValueFloat*)from_default_value;
+ bNodeSocketValueInt *fromint= (bNodeSocketValueInt*)from_default_value;
+ bNodeSocketValueBoolean *frombool= (bNodeSocketValueBoolean*)from_default_value;
+ bNodeSocketValueVector *fromvector= (bNodeSocketValueVector*)from_default_value;
+ bNodeSocketValueRGBA *fromrgba= (bNodeSocketValueRGBA*)from_default_value;
+
+ bNodeSocketValueFloat *tofloat= (bNodeSocketValueFloat*)to_default_value;
+ bNodeSocketValueInt *toint= (bNodeSocketValueInt*)to_default_value;
+ bNodeSocketValueBoolean *tobool= (bNodeSocketValueBoolean*)to_default_value;
+ bNodeSocketValueVector *tovector= (bNodeSocketValueVector*)to_default_value;
+ bNodeSocketValueRGBA *torgba= (bNodeSocketValueRGBA*)to_default_value;
+
+ switch (type) {
case SOCK_FLOAT:
- sock = nodeAddInputFloat(ntree, node, stemp->name, stemp->subtype, stemp->val1, stemp->min, stemp->max);
+ *tofloat = *fromfloat;
+ break;
+ case SOCK_INT:
+ *toint = *fromint;
break;
case SOCK_BOOLEAN:
- sock = nodeAddInputBoolean(ntree, node, stemp->name, (char)stemp->val1);
+ *tobool = *frombool;
break;
case SOCK_VECTOR:
- sock = nodeAddInputVector(ntree, node, stemp->name, stemp->subtype, stemp->val1, stemp->val2, stemp->val3, stemp->min, stemp->max);
+ *tovector = *fromvector;
break;
case SOCK_RGBA:
- sock = nodeAddInputRGBA(ntree, node, stemp->name, stemp->val1, stemp->val2, stemp->val3, stemp->val4);
+ *torgba = *fromrgba;
break;
- case SOCK_SHADER:
- sock = nodeAddInputShader(ntree, node, stemp->name);
+ }
+}
+
+/* XXX This is a makeshift function to have useful initial group socket values.
+ * In the end this should be implemented by a flexible socket data conversion system,
+ * which is yet to be implemented. The idea is that beside default standard conversions,
+ * such as int-to-float, it should be possible to quickly select a conversion method or
+ * a chain of conversions for each input, whenever there is more than one option.
+ * E.g. a vector-to-float conversion could use either of the x/y/z components or
+ * the vector length.
+ *
+ * In the interface this could be implemented by a pseudo-script textbox on linked inputs,
+ * with quick selection from a predefined list of conversion options. Some Examples:
+ * - vector component 'z' (vector->float): "z"
+ * - greyscale color (float->color): "grey"
+ * - color luminance (color->float): "lum"
+ * - matrix column 2 length (matrix->vector->float): "col[1].len"
+ * - mesh vertex coordinate 'y' (mesh->vertex->vector->float): "vertex.co.y"
+ *
+ * The actual conversion is then done by a series of conversion functions,
+ * which are defined in the socket type structs.
+ */
+void node_socket_convert_default_value(int to_type, void *to_default_value, int from_type, void *from_default_value)
+{
+ /* XXX only one of these pointers is valid! just putting them here for convenience */
+ bNodeSocketValueFloat *fromfloat= (bNodeSocketValueFloat*)from_default_value;
+ bNodeSocketValueInt *fromint= (bNodeSocketValueInt*)from_default_value;
+ bNodeSocketValueBoolean *frombool= (bNodeSocketValueBoolean*)from_default_value;
+ bNodeSocketValueVector *fromvector= (bNodeSocketValueVector*)from_default_value;
+ bNodeSocketValueRGBA *fromrgba= (bNodeSocketValueRGBA*)from_default_value;
+
+ bNodeSocketValueFloat *tofloat= (bNodeSocketValueFloat*)to_default_value;
+ bNodeSocketValueInt *toint= (bNodeSocketValueInt*)to_default_value;
+ bNodeSocketValueBoolean *tobool= (bNodeSocketValueBoolean*)to_default_value;
+ bNodeSocketValueVector *tovector= (bNodeSocketValueVector*)to_default_value;
+ bNodeSocketValueRGBA *torgba= (bNodeSocketValueRGBA*)to_default_value;
+
+ switch (from_type) {
+ case SOCK_FLOAT:
+ switch (to_type) {
+ case SOCK_FLOAT:
+ tofloat->value = fromfloat->value;
+ break;
+ case SOCK_INT:
+ toint->value = (int)fromfloat->value;
+ break;
+ case SOCK_BOOLEAN:
+ tobool->value = (fromfloat->value > 0.0f);
+ break;
+ case SOCK_VECTOR:
+ tovector->value[0] = tovector->value[1] = tovector->value[2] = fromfloat->value;
+ break;
+ case SOCK_RGBA:
+ torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = fromfloat->value;
+ break;
+ }
break;
- case SOCK_MESH:
- sock = nodeAddInputMesh(ntree, node, stemp->name);
+ case SOCK_INT:
+ switch (to_type) {
+ case SOCK_FLOAT:
+ tofloat->value = (float)fromint->value;
+ break;
+ case SOCK_INT:
+ toint->value = fromint->value;
+ break;
+ case SOCK_BOOLEAN:
+ tobool->value = (fromint->value > 0);
+ break;
+ case SOCK_VECTOR:
+ tovector->value[0] = tovector->value[1] = tovector->value[2] = (float)fromint->value;
+ break;
+ case SOCK_RGBA:
+ torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = (float)fromint->value;
+ break;
+ }
+ break;
+ case SOCK_BOOLEAN:
+ switch (to_type) {
+ case SOCK_FLOAT:
+ tofloat->value = (float)frombool->value;
+ break;
+ case SOCK_INT:
+ toint->value = (int)frombool->value;
+ break;
+ case SOCK_BOOLEAN:
+ tobool->value = frombool->value;
+ break;
+ case SOCK_VECTOR:
+ tovector->value[0] = tovector->value[1] = tovector->value[2] = (float)frombool->value;
+ break;
+ case SOCK_RGBA:
+ torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = (float)frombool->value;
+ break;
+ }
+ break;
+ case SOCK_VECTOR:
+ switch (to_type) {
+ case SOCK_FLOAT:
+ tofloat->value = fromvector->value[0];
+ break;
+ case SOCK_INT:
+ toint->value = (int)fromvector->value[0];
+ break;
+ case SOCK_BOOLEAN:
+ tobool->value = (fromvector->value[0] > 0.0f);
+ break;
+ case SOCK_VECTOR:
+ copy_v3_v3(tovector->value, fromvector->value);
+ break;
+ case SOCK_RGBA:
+ copy_v3_v3(torgba->value, fromvector->value);
+ torgba->value[3] = 1.0f;
+ break;
+ }
+ break;
+ case SOCK_RGBA:
+ switch (to_type) {
+ case SOCK_FLOAT:
+ tofloat->value = fromrgba->value[0];
+ break;
+ case SOCK_INT:
+ toint->value = (int)fromrgba->value[0];
+ break;
+ case SOCK_BOOLEAN:
+ tobool->value = (fromrgba->value[0] > 0.0f);
+ break;
+ case SOCK_VECTOR:
+ copy_v3_v3(tovector->value, fromrgba->value);
+ break;
+ case SOCK_RGBA:
+ copy_v4_v4(torgba->value, fromrgba->value);
+ break;
+ }
break;
- default:
- sock = nodeAddSocket(ntree, node, SOCK_IN, stemp->name, stemp->type);
}
- sock->flag |= stemp->flag;
- return sock;
}
-struct bNodeSocket *node_add_output_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp)
+
+struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp)
{
- bNodeSocket *sock;
+ bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_IN, stemp->name, stemp->type);
+ sock->flag |= stemp->flag;
+
switch (stemp->type) {
case SOCK_INT:
- sock = nodeAddOutputInt(ntree, node, stemp->name);
+ node_socket_set_default_value_int(sock->default_value, stemp->subtype, (int)stemp->val1, (int)stemp->min, (int)stemp->max);
break;
case SOCK_FLOAT:
- sock = nodeAddOutputFloat(ntree, node, stemp->name);
+ node_socket_set_default_value_float(sock->default_value, stemp->subtype, stemp->val1, stemp->min, stemp->max);
break;
case SOCK_BOOLEAN:
- sock = nodeAddOutputBoolean(ntree, node, stemp->name);
+ node_socket_set_default_value_boolean(sock->default_value, (char)stemp->val1);
break;
case SOCK_VECTOR:
- sock = nodeAddOutputVector(ntree, node, stemp->name);
+ node_socket_set_default_value_vector(sock->default_value, stemp->subtype, stemp->val1, stemp->val2, stemp->val3, stemp->min, stemp->max);
break;
case SOCK_RGBA:
- sock = nodeAddOutputRGBA(ntree, node, stemp->name);
+ node_socket_set_default_value_rgba(sock->default_value, stemp->val1, stemp->val2, stemp->val3, stemp->val4);
break;
case SOCK_SHADER:
- sock = nodeAddOutputShader(ntree, node, stemp->name);
+ node_socket_set_default_value_shader(sock->default_value);
break;
case SOCK_MESH:
- sock = nodeAddOutputMesh(ntree, node, stemp->name);
+ node_socket_set_default_value_mesh(sock->default_value);
break;
- default:
- sock = nodeAddSocket(ntree, node, SOCK_OUT, stemp->name, stemp->type);
}
+
+ return sock;
+}
+
+struct bNodeSocket *node_add_output_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp)
+{
+ bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_OUT, stemp->name, stemp->type);
return sock;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c
new file mode 100644
index 00000000000..7448a0b3bab
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c
@@ -0,0 +1,60 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+
+*/
+
+#include "node_shader_util.h"
+
+
+/* **************** Brigh and contrsast ******************** */
+
+static bNodeSocketTemplate sh_node_brightcontrast_in[]= {
+ { SOCK_RGBA, 1, "Color", 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Bright", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
+ { SOCK_FLOAT, 1, "Contrast", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_brightcontrast_out[]= {
+ { SOCK_RGBA, 0, "Color"},
+ { -1, 0, "" }
+};
+
+void register_node_type_sh_brightcontrast(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_init(&ntype, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, NULL);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c
index 1d525d71698..e2907f5ba91 100644
--- a/source/blender/nodes/shader/nodes/node_shader_gamma.c
+++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c
@@ -26,11 +26,6 @@
*/
-/** \file blender/nodes/composite/nodes/node_composite_gamma.c
- * \ingroup cmpnodes
- */
-
-
#include "node_shader_util.h"
/* **************** Gamma Tools ******************** */
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index d94ba8b9441..414ebe47e97 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -374,7 +374,12 @@ static int bpy_struct_id_used(StructRNA *srna, char *identifier)
* but being abused from C so we can pass the srna along.
* This isnt incorrect since its a python object - but be careful */
PyDoc_STRVAR(BPy_BoolProperty_doc,
-".. function:: BoolProperty(name=\"\", description=\"\", default=False, options={'ANIMATABLE'}, subtype='NONE', update=None)\n"
+".. function:: BoolProperty(name=\"\", "
+ "description=\"\", "
+ "default=False, "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "update=None)\n"
"\n"
" Returns a new boolean property definition.\n"
"\n"
@@ -438,7 +443,13 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
}
PyDoc_STRVAR(BPy_BoolVectorProperty_doc,
-".. function:: BoolVectorProperty(name=\"\", description=\"\", default=(False, False, False), options={'ANIMATABLE'}, subtype='NONE', size=3, update=None)\n"
+".. function:: BoolVectorProperty(name=\"\", "
+ "description=\"\", "
+ "default=(False, False, False), "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "size=3, "
+ "update=None)\n"
"\n"
" Returns a new vector boolean property definition.\n"
"\n"
@@ -448,7 +459,9 @@ BPY_PROPDEF_DESC_DOC
" :type default: sequence\n"
" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE'].\n"
" :type options: set\n"
-" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n"
+" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', "
+ "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', "
+ "'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n"
" :type subtype: string\n"
" :arg size: Vector dimensions in [1, and " STRINGIFY(PYRNA_STACK_ARRAY) "].\n"
" :type size: int\n"
@@ -520,7 +533,15 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(BPy_IntProperty_doc,
-".. function:: IntProperty(name=\"\", description=\"\", default=0, min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, step=1, options={'ANIMATABLE'}, subtype='NONE', update=None)\n"
+".. function:: IntProperty(name=\"\", "
+ "description=\"\", "
+ "default=0, "
+ "min=-sys.maxint, max=sys.maxint, "
+ "soft_min=-sys.maxint, soft_max=sys.maxint, "
+ "step=1, "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "update=None)\n"
"\n"
" Returns a new int property definition.\n"
"\n"
@@ -540,7 +561,8 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "update", NULL};
+ "min", "max", "soft_min", "soft_max",
+ "step", "options", "subtype", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0;
@@ -586,7 +608,15 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
}
PyDoc_STRVAR(BPy_IntVectorProperty_doc,
-".. function:: IntVectorProperty(name=\"\", description=\"\", default=(0, 0, 0), min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, options={'ANIMATABLE'}, subtype='NONE', size=3, update=None)\n"
+".. function:: IntVectorProperty(name=\"\", "
+ "description=\"\", "
+ "default=(0, 0, 0), min=-sys.maxint, max=sys.maxint, "
+ "soft_min=-sys.maxint, "
+ "soft_max=sys.maxint, "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "size=3, "
+ "update=None)\n"
"\n"
" Returns a new vector int property definition.\n"
"\n"
@@ -596,7 +626,9 @@ BPY_PROPDEF_DESC_DOC
" :type default: sequence\n"
" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE'].\n"
" :type options: set\n"
-" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n"
+" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', "
+ "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', "
+ "'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n"
" :type subtype: string\n"
" :arg size: Vector dimensions in [1, and " STRINGIFY(PYRNA_STACK_ARRAY) "].\n"
" :type size: int\n"
@@ -673,7 +705,17 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
PyDoc_STRVAR(BPy_FloatProperty_doc,
-".. function:: FloatProperty(name=\"\", description=\"\", default=0.0, min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, options={'ANIMATABLE'}, subtype='NONE', unit='NONE', update=None)\n"
+".. function:: FloatProperty(name=\"\", "
+ "description=\"\", "
+ "default=0.0, "
+ "min=sys.float_info.min, max=sys.float_info.max, "
+ "soft_min=sys.float_info.min, soft_max=sys.float_info.max, "
+ "step=3, "
+ "precision=2, "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "unit='NONE', "
+ "update=None)\n"
"\n"
" Returns a new float property definition.\n"
"\n"
@@ -750,7 +792,17 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
}
PyDoc_STRVAR(BPy_FloatVectorProperty_doc,
-".. function:: FloatVectorProperty(name=\"\", description=\"\", default=(0.0, 0.0, 0.0), min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, options={'ANIMATABLE'}, subtype='NONE', size=3, update=None)\n"
+".. function:: FloatVectorProperty(name=\"\", "
+ "description=\"\", "
+ "default=(0.0, 0.0, 0.0), "
+ "min=sys.float_info.min, max=sys.float_info.max, "
+ "soft_min=sys.float_info.min, soft_max=sys.float_info.max, "
+ "step=3, "
+ "precision=2, "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "size=3, "
+ "update=None)\n"
"\n"
" Returns a new vector float property definition.\n"
"\n"
@@ -760,7 +812,9 @@ BPY_PROPDEF_DESC_DOC
" :type default: sequence\n"
" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE'].\n"
" :type options: set\n"
-" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n"
+" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', "
+ "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', "
+ "'COLOR_GAMMA', 'LAYER', 'NONE'].\n"
" :type subtype: string\n"
BPY_PROPDEF_UNIT_DOC
" :arg size: Vector dimensions in [1, and " STRINGIFY(PYRNA_STACK_ARRAY) "].\n"
@@ -779,7 +833,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
"step", "precision", "options", "subtype", "unit", "size", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
- float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def[PYRNA_STACK_ARRAY] = {0.0f};
+ float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3;
+ float def[PYRNA_STACK_ARRAY] = {0.0f};
int precision = 2, size = 3;
PropertyRNA *prop;
PyObject *pydef = NULL;
@@ -843,7 +898,13 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
}
PyDoc_STRVAR(BPy_StringProperty_doc,
-".. function:: StringProperty(name=\"\", description=\"\", default=\"\", maxlen=0, options={'ANIMATABLE'}, subtype='NONE', update=None)\n"
+".. function:: StringProperty(name=\"\", "
+ "description=\"\", "
+ "default=\"\", "
+ "maxlen=0, "
+ "options={'ANIMATABLE'}, "
+ "subtype='NONE', "
+ "update=None)\n"
"\n"
" Returns a new string property definition.\n"
"\n"
@@ -978,7 +1039,8 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
(tmp.identifier = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
(tmp.name = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
(tmp.description = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
- (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1)) /* TODO, number isnt ensured to be unique from the script author */
+ /* TODO, number isnt ensured to be unique from the script author */
+ (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1))
{
if (is_enum_flag) {
if (item_size < 4) {
@@ -1105,7 +1167,8 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
err = -1;
}
else {
- eitems = enum_items_from_py(items_fast, NULL, &defvalue_dummy, (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0);
+ eitems = enum_items_from_py(items_fast, NULL, &defvalue_dummy,
+ (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0);
Py_DECREF(items_fast);
@@ -1132,7 +1195,12 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
}
PyDoc_STRVAR(BPy_EnumProperty_doc,
-".. function:: EnumProperty(items, name=\"\", description=\"\", default=\"\", options={'ANIMATABLE'}, update=None)\n"
+".. function:: EnumProperty(items, "
+ "name=\"\", "
+ "description=\"\", "
+ "default=\"\", "
+ "options={'ANIMATABLE'}, "
+ "update=None)\n"
"\n"
" Returns a new enumerator property definition.\n"
"\n"
@@ -1218,7 +1286,8 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL;
}
- eitems = enum_items_from_py(items_fast, def, &defvalue, (opts & PROP_ENUM_FLAG) != 0);
+ eitems = enum_items_from_py(items_fast, def, &defvalue,
+ (opts & PROP_ENUM_FLAG) != 0);
Py_DECREF(items_fast);
@@ -1287,7 +1356,10 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
}
PyDoc_STRVAR(BPy_PointerProperty_doc,
-".. function:: PointerProperty(type=\"\", description=\"\", options={'ANIMATABLE'}, update=None)\n"
+".. function:: PointerProperty(type=\"\", "
+ "description=\"\", "
+ "options={'ANIMATABLE'}, "
+ "update=None)\n"
"\n"
" Returns a new pointer property definition.\n"
"\n"
@@ -1349,7 +1421,10 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(BPy_CollectionProperty_doc,
-".. function:: CollectionProperty(items, type=\"\", description=\"\", default=\"\", options={'ANIMATABLE'})\n"
+".. function:: CollectionProperty(items, "
+ "type=\"\", "
+ "description=\"\", "
+ "options={'ANIMATABLE'})\n"
"\n"
" Returns a new collection property definition.\n"
"\n"
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4940c53551e..bfb79ea6531 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -7158,8 +7158,25 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
const char *identifier;
PyObject *py_cls_meth;
+ if (!PyType_Check(py_class)) {
+ PyErr_Format(PyExc_ValueError,
+ "register_class(...): "
+ "expected a class argument, not '%.200s'", Py_TYPE(py_class)->tp_name);
+ return NULL;
+ }
+
if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna)) {
- PyErr_SetString(PyExc_AttributeError, "register_class(...): already registered as a subclass");
+ PyErr_SetString(PyExc_ValueError,
+ "register_class(...): "
+ "already registered as a subclass");
+ return NULL;
+ }
+
+ if (!pyrna_write_check()) {
+ PyErr_Format(PyExc_RuntimeError,
+ "register_class(...): "
+ "can't run in readonly state '%.200s'",
+ ((PyTypeObject *)py_class)->tp_name);
return NULL;
}
@@ -7284,12 +7301,27 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
StructRNA *srna;
PyObject *py_cls_meth;
+ if (!PyType_Check(py_class)) {
+ PyErr_Format(PyExc_ValueError,
+ "register_class(...): "
+ "expected a class argument, not '%.200s'", Py_TYPE(py_class)->tp_name);
+ return NULL;
+ }
+
/*if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna) == NULL) {
PWM_cursor_wait(0);
PyErr_SetString(PyExc_ValueError, "unregister_class(): not a registered as a subclass");
return NULL;
}*/
+ if (!pyrna_write_check()) {
+ PyErr_Format(PyExc_RuntimeError,
+ "unregister_class(...): "
+ "can't run in readonly state '%.200s'",
+ ((PyTypeObject *)py_class)->tp_name);
+ return NULL;
+ }
+
srna = pyrna_struct_as_srna(py_class, 0, "unregister_class(...):");
if (srna == NULL)
return NULL;
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 7fe4b5ba5dd..efd73bf8c04 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -411,6 +411,34 @@ static void matrix_3x3_as_4x4(float mat[16])
/*-----------------------CLASS-METHODS----------------------------*/
//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc.
+PyDoc_STRVAR(C_Matrix_Identity_doc,
+".. classmethod:: Identity(size)\n"
+"\n"
+" Create an identity matrix.\n"
+"\n"
+" :arg size: The size of the identity matrix to construct [2, 4].\n"
+" :type size: int\n"
+" :return: A new identity matrix.\n"
+" :rtype: :class:`Matrix`\n"
+);
+static PyObject *C_Matrix_Identity(PyObject *cls, PyObject *args)
+{
+ int matSize;
+
+ if (!PyArg_ParseTuple(args, "i:Matrix.Identity", &matSize)) {
+ return NULL;
+ }
+
+ if (matSize < 2 || matSize > 4) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Matrix.Identity(): "
+ "size must be between 2 and 4");
+ return NULL;
+ }
+
+ return Matrix_CreatePyObject(NULL, matSize, matSize, Py_NEW, (PyTypeObject *)cls);
+}
+
PyDoc_STRVAR(C_Matrix_Rotation_doc,
".. classmethod:: Rotation(angle, size, axis)\n"
"\n"
@@ -2246,6 +2274,7 @@ static struct PyMethodDef Matrix_methods[] = {
{"__copy__", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc},
/* class methods */
+ {"Identity", (PyCFunction) C_Matrix_Identity, METH_VARARGS | METH_CLASS, C_Matrix_Identity_doc},
{"Rotation", (PyCFunction) C_Matrix_Rotation, METH_VARARGS | METH_CLASS, C_Matrix_Rotation_doc},
{"Scale", (PyCFunction) C_Matrix_Scale, METH_VARARGS | METH_CLASS, C_Matrix_Scale_doc},
{"Shear", (PyCFunction) C_Matrix_Shear, METH_VARARGS | METH_CLASS, C_Matrix_Shear_doc},
diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h
index f64521bda35..71827b1e202 100644
--- a/source/blender/quicktime/quicktime_export.h
+++ b/source/blender/quicktime/quicktime_export.h
@@ -50,10 +50,11 @@ typedef struct QuicktimeCodecTypeDesc {
} QuicktimeCodecTypeDesc ;
// quicktime movie output functions
+struct ImageFormatData;
struct RenderData;
+struct ReportList;
struct Scene;
struct wmOperatorType;
-struct ReportList;
int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); //for movie handle (BKE writeavi.c now)
int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index dd0a0f308ce..2f585f91d44 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -210,4 +210,8 @@ int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob
struct Image *RE_bake_shade_get_image(void);
void RE_bake_ibuf_filter(struct ImBuf *ibuf, char *mask, const int filter);
+#define BAKE_RESULT_OK 0
+#define BAKE_RESULT_NO_OBJECTS 1
+#define BAKE_RESULT_FEEDBACK_LOOP 2
+
#endif /* RE_SHADER_EXT_H */
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 1ec400138a7..fa8540b352d 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -671,7 +671,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
float *tav= RE_vertren_get_tangent(obr, ver, 0);
if (tav) {
/* orthonorm. */
- float tdn = tav[0]*ver->n[0] + tav[1]*ver->n[1] + tav[2]*ver->n[2];
+ const float tdn = dot_v3v3(tav, ver->n);
tav[0] -= ver->n[0]*tdn;
tav[1] -= ver->n[1]*tdn;
tav[2] -= ver->n[2]*tdn;
@@ -767,7 +767,7 @@ static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float
while(asf) {
for(a=0; a<4; a++) {
if(asf->vlr[a] && asf->vlr[a]!=vlr) {
- inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] );
+ inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n));
if(inp < thresh) return 1;
}
}
@@ -790,7 +790,7 @@ static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, f
if(asf->vlr[a] && asf->vlr[a]!=vlr) {
/* this face already made a copy for this vertex! */
if(asf->nver[a]) {
- inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] );
+ inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n));
if(inp >= thresh) {
return asf->nver[a];
}
@@ -2158,7 +2158,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
copy_v3_v3(view, vec);
normalize_v3(view);
- zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2];
+ zn = dot_v3v3(nor, view);
if(zn>=0.0f) hasize= 0.0f;
else hasize*= zn*zn*zn*zn;
}
@@ -2240,9 +2240,9 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
mul_m4_v3(mat, shi->co);
if(imat) {
- shi->vn[0]= imat[0][0]*vr->n[0]+imat[0][1]*vr->n[1]+imat[0][2]*vr->n[2];
- shi->vn[1]= imat[1][0]*vr->n[0]+imat[1][1]*vr->n[1]+imat[1][2]*vr->n[2];
- shi->vn[2]= imat[2][0]*vr->n[0]+imat[2][1]*vr->n[1]+imat[2][2]*vr->n[2];
+ shi->vn[0] = dot_v3v3(imat[0], vr->n);
+ shi->vn[1] = dot_v3v3(imat[1], vr->n);
+ shi->vn[2] = dot_v3v3(imat[2], vr->n);
}
if (texco & TEXCO_UV) {
@@ -4241,7 +4241,7 @@ static void check_non_flat_quads(ObjectRen *obr)
flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co);
if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co);
- xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2];
+ xn = dot_v3v3(nor, vlr->n);
if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid
@@ -4252,11 +4252,11 @@ static void check_non_flat_quads(ObjectRen *obr)
/* split direction based on vnorms */
normal_tri_v3( nor,vlr->v1->co, vlr->v2->co, vlr->v3->co);
- d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2];
+ d1 = dot_v3v3(nor, vlr->v1->n);
normal_tri_v3( nor,vlr->v2->co, vlr->v3->co, vlr->v4->co);
- d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2];
-
+ d2 = dot_v3v3(nor, vlr->v2->n);
+
if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24;
else vlr->flag &= ~R_DIVIDE_24;
@@ -5267,7 +5267,7 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con
if(vec[0]<0.0f) ang= -ang;
zco[0]= ang/pixelphix + zmulx;
- ang= 0.5f*(float)M_PI - saacos(vec[1]/sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]));
+ ang= 0.5f*(float)M_PI - saacos(vec[1] / len_v3(vec));
zco[1]= ang/pixelphiy + zmuly;
}
@@ -5487,9 +5487,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
}
// transform (=rotate) to cam space
- camco[0]= imat[0][0]*fsvec[0] + imat[0][1]*fsvec[1] + imat[0][2]*fsvec[2];
- camco[1]= imat[1][0]*fsvec[0] + imat[1][1]*fsvec[1] + imat[1][2]*fsvec[2];
- camco[2]= imat[2][0]*fsvec[0] + imat[2][1]*fsvec[1] + imat[2][2]*fsvec[2];
+ camco[0] = dot_v3v3(imat[0], fsvec);
+ camco[1] = dot_v3v3(imat[1], fsvec);
+ camco[2] = dot_v3v3(imat[2], fsvec);
// get homogenous coordinates
projectvert(camco, winmat, hoco);
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 0b6e1b8ee01..2d64828b6b3 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -131,6 +131,8 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
return retval;
ibuf= BKE_image_get_ibuf(ima, &tex->iuser);
+
+ ima->flag|= IMA_USED_FOR_RENDER;
}
if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL))
return retval;
@@ -1441,6 +1443,8 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
return retval;
ibuf= BKE_image_get_ibuf(ima, &tex->iuser);
+
+ ima->flag|= IMA_USED_FOR_RENDER;
}
if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL))
return retval;
@@ -1812,6 +1816,8 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float *res
if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) )
ibuf->rect-= (ibuf->x*ibuf->y);
+
+ ima->flag|= IMA_USED_FOR_RENDER;
}
void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result)
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index e20fd85d0f0..782e0b59388 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -1413,7 +1413,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f
if(env) {
/* sky shading using bent normal */
if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) {
- fac= 0.5f*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]);
+ fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec));
env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr;
env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng;
env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb;
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index f261ec41746..24683ec57f7 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -104,7 +104,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3])
lv[0]= rco[0]-lar->co[0];
lv[1]= rco[1]-lar->co[1];
lv[2]= rco[2]-lar->co[2];
- ld= sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2]);
+ ld = len_v3(lv);
lv[0]/= ld;
lv[1]/= ld;
lv[2]/= ld;
@@ -210,7 +210,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3])
/* dot product and reflectivity*/
- inp= 1.0-fabs(vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]);
+ inp = 1.0 - fabs(dot_v3v3(vn, lv));
/* inp= cos(0.5*M_PI-acos(inp)); */
@@ -511,7 +511,7 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const
/* Some view vector stuff. */
if(R.wrld.skytype & WO_SKYREAL) {
- blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2];
+ blend = dot_v3v3(view, R.grvec);
if(blend<0.0f) skyflag= 0;
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index f9ffc2532eb..6c0386cc8b1 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -471,7 +471,7 @@ void makeraytree(Render *re)
sub[i] = max[i]-min[i];
}
- re->maxdist= sub[0]*sub[0] + sub[1]*sub[1] + sub[2]*sub[2];
+ re->maxdist = dot_v3v3(sub, sub);
if(re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist);
re->i.infostr= "Raytree finished";
@@ -598,7 +598,7 @@ static int refraction(float refract[3], const float n[3], const float view[3], f
copy_v3_v3(refract, view);
- dot= view[0]*n[0] + view[1]*n[1] + view[2]*n[2];
+ dot = dot_v3v3(view, n);
if(dot>0.0f) {
index = 1.0f/index;
@@ -1708,7 +1708,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult *
counter+=3;
counter %= 768;
copy_v3_v3(vec, hashvectf+counter);
- if(ship->vn[0]*vec[0]+ship->vn[1]*vec[1]+ship->vn[2]*vec[2]>0.0f) {
+ if (dot_v3v3(ship->vn, vec) > 0.0f) {
vec[0]-= vec[0];
vec[1]-= vec[1];
vec[2]-= vec[2];
@@ -1771,7 +1771,7 @@ static void DS_energy(float *sphere, int tot, float vec[3])
for(a=0, fp=sphere; a<tot; a++, fp+=3) {
sub_v3_v3v3(force, vec, fp);
- fac= force[0]*force[0] + force[1]*force[1] + force[2]*force[2];
+ fac = dot_v3v3(force, force);
if(fac!=0.0f) {
fac= 1.0f/fac;
res[0]+= fac*force[0];
@@ -1997,7 +1997,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3])
normalize_v3(view);
if(envcolor==WO_AOSKYCOL) {
- const float skyfac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
+ const float skyfac= 0.5f * (1.0f + dot_v3v3(view, R.grvec));
env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr;
env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng;
env[2]+= (1.0f-skyfac)*R.wrld.horb + skyfac*R.wrld.zenb;
@@ -2101,7 +2101,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3])
while(tot--) {
- if ((vec[0]*nrm[0] + vec[1]*nrm[1] + vec[2]*nrm[2]) > bias) {
+ if (dot_v3v3(vec, nrm) > bias) {
/* only ao samples for mask */
if(R.r.mode & R_OSA) {
j++;
@@ -2135,7 +2135,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3])
normalize_v3(view);
if(envcolor==WO_AOSKYCOL) {
- const float fac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
+ const float fac = 0.5f * (1.0f + dot_v3v3(view, R.grvec));
env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr;
env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng;
env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb;
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index e825c9d842e..30853e8e1f6 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -224,6 +224,60 @@ static const char *get_pass_name(int passtype, int channel)
if(channel==1) return "Rayhits.G";
return "Rayhits.B";
}
+ if(passtype == SCE_PASS_DIFFUSE_DIRECT) {
+ if(channel==-1) return "DiffDir";
+ if(channel==0) return "DiffDir.R";
+ if(channel==1) return "DiffDir.G";
+ return "DiffDir.B";
+ }
+ if(passtype == SCE_PASS_DIFFUSE_INDIRECT) {
+ if(channel==-1) return "DiffInd";
+ if(channel==0) return "DiffInd.R";
+ if(channel==1) return "DiffInd.G";
+ return "DiffInd.B";
+ }
+ if(passtype == SCE_PASS_DIFFUSE_COLOR) {
+ if(channel==-1) return "DiffCol";
+ if(channel==0) return "DiffCol.R";
+ if(channel==1) return "DiffCol.G";
+ return "DiffCol.B";
+ }
+ if(passtype == SCE_PASS_GLOSSY_DIRECT) {
+ if(channel==-1) return "GlossDir";
+ if(channel==0) return "GlossDir.R";
+ if(channel==1) return "GlossDir.G";
+ return "GlossDir.B";
+ }
+ if(passtype == SCE_PASS_GLOSSY_INDIRECT) {
+ if(channel==-1) return "GlossInd";
+ if(channel==0) return "GlossInd.R";
+ if(channel==1) return "GlossInd.G";
+ return "GlossInd.B";
+ }
+ if(passtype == SCE_PASS_GLOSSY_COLOR) {
+ if(channel==-1) return "GlossCol";
+ if(channel==0) return "GlossCol.R";
+ if(channel==1) return "GlossCol.G";
+ return "GlossCol.B";
+ }
+ if(passtype == SCE_PASS_TRANSM_DIRECT) {
+ if(channel==-1) return "TransDir";
+ if(channel==0) return "TransDir.R";
+ if(channel==1) return "TransDir.G";
+ return "TransDir.B";
+ }
+ if(passtype == SCE_PASS_TRANSM_INDIRECT) {
+ if(channel==-1) return "TransInd";
+ if(channel==0) return "TransInd.R";
+ if(channel==1) return "TransInd.G";
+ return "TransInd.B";
+ }
+ if(passtype == SCE_PASS_TRANSM_COLOR) {
+ if(channel==-1) return "TransCol";
+ if(channel==0) return "TransCol.R";
+ if(channel==1) return "TransCol.G";
+ return "TransCol.B";
+ }
return "Unknown";
}
@@ -286,6 +340,34 @@ static int passtype_from_name(const char *str)
if(strcmp(str, "RayHits")==0)
return SCE_PASS_RAYHITS;
+
+ if(strcmp(str, "DiffDir")==0)
+ return SCE_PASS_DIFFUSE_DIRECT;
+
+ if(strcmp(str, "DiffInd")==0)
+ return SCE_PASS_DIFFUSE_INDIRECT;
+
+ if(strcmp(str, "DiffCol")==0)
+ return SCE_PASS_DIFFUSE_COLOR;
+
+ if(strcmp(str, "GlossDir")==0)
+ return SCE_PASS_GLOSSY_DIRECT;
+
+ if(strcmp(str, "GlossInd")==0)
+ return SCE_PASS_GLOSSY_INDIRECT;
+
+ if(strcmp(str, "GlossCol")==0)
+ return SCE_PASS_GLOSSY_COLOR;
+
+ if(strcmp(str, "TransDir")==0)
+ return SCE_PASS_TRANSM_DIRECT;
+
+ if(strcmp(str, "TransInd")==0)
+ return SCE_PASS_TRANSM_INDIRECT;
+
+ if(strcmp(str, "TransCol")==0)
+ return SCE_PASS_TRANSM_COLOR;
+
return 0;
}
@@ -430,6 +512,24 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST);
if(rl->passflag & SCE_PASS_RAYHITS)
render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS);
+ if(srl->passflag & SCE_PASS_DIFFUSE_DIRECT)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_DIRECT);
+ if(srl->passflag & SCE_PASS_DIFFUSE_INDIRECT)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_INDIRECT);
+ if(srl->passflag & SCE_PASS_DIFFUSE_COLOR)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_COLOR);
+ if(srl->passflag & SCE_PASS_GLOSSY_DIRECT)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_DIRECT);
+ if(srl->passflag & SCE_PASS_GLOSSY_INDIRECT)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_INDIRECT);
+ if(srl->passflag & SCE_PASS_GLOSSY_COLOR)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_COLOR);
+ if(srl->passflag & SCE_PASS_TRANSM_DIRECT)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_DIRECT);
+ if(srl->passflag & SCE_PASS_TRANSM_INDIRECT)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_INDIRECT);
+ if(srl->passflag & SCE_PASS_TRANSM_COLOR)
+ render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_COLOR);
}
/* sss, previewrender and envmap don't do layers, so we make a default one */
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 5fba0bba48c..95cad5a4e46 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -2127,7 +2127,8 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
fMagnitude *= len_v3(vN);
}
- for(xyz=0; xyz<3; xyz++)
+ if(ntap_bump->fPrevMagnitude > 0.0f)
+ for(xyz=0; xyz<3; xyz++)
ntap_bump->vNacc[xyz] *= fMagnitude / ntap_bump->fPrevMagnitude;
ntap_bump->fPrevMagnitude = fMagnitude;
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 630acf3d88a..2d3837acbfa 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2166,21 +2166,13 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
}
}
else {
- char *col= (char *)(bs->rect + bs->rectx*y + x);
+ 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)) {
- float srgb[3];
- srgb[0]= linearrgb_to_srgb(shr.combined[0]);
- srgb[1]= linearrgb_to_srgb(shr.combined[1]);
- srgb[2]= linearrgb_to_srgb(shr.combined[2]);
-
- col[0]= FTOCHAR(srgb[0]);
- col[1]= FTOCHAR(srgb[1]);
- col[2]= FTOCHAR(srgb[2]);
- } else {
- col[0]= FTOCHAR(shr.combined[0]);
- col[1]= FTOCHAR(shr.combined[1]);
- col[2]= FTOCHAR(shr.combined[2]);
+ linearrgb_to_srgb_uchar3(col, shr.combined);
+ }
+ else {
+ rgb_float_to_uchar(col, shr.combined);
}
if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) {
@@ -2212,9 +2204,7 @@ static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist,
col[3]= 1.0f;
} else {
char *col= (char *)(bs->rect + bs->rectx*y + x);
- col[0]= FTOCHAR(disp);
- col[1]= FTOCHAR(disp);
- col[2]= FTOCHAR(disp);
+ col[0] = col[1] = col[2] = FTOCHAR(disp);
col[3]= 255;
}
if (bs->rect_mask) {
@@ -2450,6 +2440,11 @@ static int get_next_bake_face(BakeShade *bs)
if(ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4))
continue;
+ if(ima->flag & IMA_USED_FOR_RENDER) {
+ ima->id.flag &= ~LIB_DOIT;
+ continue;
+ }
+
/* find the image for the first time? */
if(ima->id.flag & LIB_DOIT) {
ima->id.flag &= ~LIB_DOIT;
@@ -2594,7 +2589,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
BakeShade *handles;
ListBase threads;
Image *ima;
- int a, vdone=0, usemask=0;
+ int a, vdone=0, usemask=0, result=BAKE_RESULT_OK;
/* initialize render global */
R= *re;
@@ -2611,6 +2606,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
for(ima= G.main->image.first; ima; ima= ima->id.next) {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
ima->id.flag |= LIB_DOIT;
+ ima->flag&= ~IMA_USED_FOR_RENDER;
if(ibuf) {
ibuf->userdata = NULL; /* use for masking if needed */
if(ibuf->rect_float)
@@ -2669,6 +2665,9 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
if((ima->id.flag & LIB_DOIT)==0) {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+ if(ima->flag & IMA_USED_FOR_RENDER)
+ result= BAKE_RESULT_FEEDBACK_LOOP;
+
if(!ibuf)
continue;
@@ -2689,7 +2688,10 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
BLI_end_threads(&threads);
- return vdone;
+ if(vdone==0)
+ result= BAKE_RESULT_NO_OBJECTS;
+
+ return result;
}
struct Image *RE_bake_shade_get_image(void)
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index c14a768d1ce..88d86d5bd43 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -2068,7 +2068,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v
mul_m4_v3(obi->mat, v1);
/* from shadepixel() */
- dface= v1[0]*nor[0] + v1[1]*nor[1] + v1[2]*nor[2];
+ dface = dot_v3v3(v1, nor);
hoco[3]= 1.0f;
/* ortho viewplane cannot intersect using view vector originating in (0,0,0) */
@@ -2091,7 +2091,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v
calc_view_vector(view, x, y);
- div= nor[0]*view[0] + nor[1]*view[1] + nor[2]*view[2];
+ div = dot_v3v3(nor, view);
if (div==0.0f)
return 0;
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 580a09d5050..e0b5da817cb 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -608,7 +608,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v
if(shi->obi->flag & R_TRANSFORMED)
mul_m4_v3(shi->obi->mat, v1);
- dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2];
+ dface = dot_v3v3(v1, shi->facenor);
/* ortho viewplane cannot intersect using view vector originating in (0,0,0) */
if(R.r.mode & R_ORTHO) {
@@ -650,7 +650,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v
else {
float div;
- div= shi->facenor[0]*view[0] + shi->facenor[1]*view[1] + shi->facenor[2]*view[2];
+ div = dot_v3v3(shi->facenor, view);
if (div!=0.0f) fac= dface/div;
else fac= 0.0f;
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 3637c2de1fb..66cbb18bc57 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -274,7 +274,7 @@ static float metadensity(Object* ob, const float co[3])
}
/* ml->rad2 is not set */
- dist2 = 1.f - ((tp[0]*tp[0] + tp[1]*tp[1] + tp[2]*tp[2]) / (ml->rad*ml->rad));
+ dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad));
if (dist2 > 0.f)
dens += (ml->flag & MB_NEGATIVE) ? -ml->s*dist2*dist2*dist2 : ml->s*dist2*dist2*dist2;
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 11ac56090a3..132b57696e1 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -203,7 +203,7 @@ void WM_operator_properties_reset(struct wmOperator *op);
void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
void WM_operator_properties_free(struct PointerRNA *ptr);
-void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type, short action, short flag);
+void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type, short action, short flag, short display);
void WM_operator_properties_gesture_border(struct wmOperatorType *ot, int extend);
void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
void WM_operator_properties_select_all(struct wmOperatorType *ot);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 758cf7bd61c..357eaf2633b 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -526,14 +526,14 @@ typedef struct wmDrag {
int icon, type; /* type, see WM_DRAG defines above */
void *poin;
- char path[240]; /* FILE_MAX */
+ char path[1024]; /* FILE_MAX */
double value;
struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */
float scale;
int sx, sy;
- char opname[240]; /* FILE_MAX */ /* if set, draws operator name*/
+ char opname[200]; /* if set, draws operator name*/
} wmDrag;
/* dropboxes are like keymaps, part of the screen/area/region definition */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index ec4e035068a..faf2d3fd352 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -806,7 +806,7 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message
pup= uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION);
layout= uiPupMenuLayout(pup);
- uiItemFullO(layout, op->type->idname, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0);
+ uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
@@ -831,10 +831,17 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
}
/* default properties for fileselect */
-void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag)
+void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display)
{
PropertyRNA *prop;
+ static EnumPropertyItem file_display_items[] = {
+ {FILE_DEFAULTDISPLAY, "FILE_DEFAULTDISPLAY", 0, "Default", "Automatically determine display type for files"},
+ {FILE_SHORTDISPLAY, "FILE_SHORTDISPLAY", ICON_SHORTDISPLAY, "Short List", "Display files as short list"},
+ {FILE_LONGDISPLAY, "FILE_LONGDISPLAY", ICON_LONGDISPLAY, "Long List", "Display files as a detailed list"},
+ {FILE_IMGDISPLAY, "FILE_IMGDISPLAY", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"},
+ {0, NULL, 0, NULL, NULL}};
+
if(flag & WM_FILESEL_FILEPATH)
RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file");
@@ -881,6 +888,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
if(flag & WM_FILESEL_RELPATH)
RNA_def_boolean(ot->srna, "relative_path", TRUE, "Relative Path", "Select the file relative to the blend file");
+
+ prop= RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
}
void WM_operator_properties_select_all(wmOperatorType *ot)
@@ -1650,7 +1660,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
ot->exec= wm_open_mainfile_exec;
/* ommit window poll so this can work in background mode */
- WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file");
RNA_def_boolean(ot->srna, "use_scripts", 1, "Trusted Source", "Allow blend file execute scripts automatically, default available from system preferences");
@@ -1840,7 +1850,7 @@ static void WM_OT_link_append(wmOperatorType *ot)
ot->flag |= OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES);
+ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending");
RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects");
@@ -1921,7 +1931,7 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot)
ot->invoke= wm_recover_auto_save_invoke;
ot->poll= WM_operator_winactive;
- WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_LONGDISPLAY);
}
/* *************** save file as **************** */
@@ -2035,7 +2045,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
ot->check= blend_save_check;
/* ommit window poll so this can work in background mode */
- WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory");
RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active");
@@ -2102,7 +2112,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
ot->check= blend_save_check;
/* ommit window poll so this can work in background mode */
- WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory");
}
@@ -2156,7 +2166,7 @@ static void WM_OT_collada_export(wmOperatorType *ot)
ot->exec= wm_collada_export_exec;
ot->poll= WM_operator_winactive;
- WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
RNA_def_boolean(ot->srna, "selected", 0, "Export only selected",
"Export only selected elements");
}
@@ -2188,7 +2198,7 @@ static void WM_OT_collada_import(wmOperatorType *ot)
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);
+ WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
#endif
@@ -3807,6 +3817,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "MARKER_OT_select_border");
WM_modalkeymap_assign(keymap, "NLA_OT_select_border");
WM_modalkeymap_assign(keymap, "NODE_OT_select_border");
+ WM_modalkeymap_assign(keymap, "OUTLINER_OT_select_border");
// WM_modalkeymap_assign(keymap, "SCREEN_OT_border_select"); // template
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_select_border");
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_view_ghost_border");
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 570900bf552..ea551e42dd2 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -297,6 +297,9 @@ void ED_mesh_update(struct Mesh *mesh, struct bContext *C){}
void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count){}
void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count){}
void ED_mesh_faces_add(struct Mesh *mesh, struct ReportList *reports, int count){}
+void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count){}
+void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count){}
+void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int count){}
void ED_mesh_material_link(struct Mesh *mesh, struct Material *ma){}
int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me){return 0;}
int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me){return 0;}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 2a21b531b6b..7e7b3d2e3d4 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -59,6 +59,11 @@ void KX_BlenderCanvas::SwapBuffers()
BL_SwapBuffers(m_win);
}
+void KX_BlenderCanvas::ResizeWindow(int width, int height)
+{
+ // Not implemented for the embedded player
+}
+
void KX_BlenderCanvas::BeginFrame()
{
glEnable(GL_DEPTH_TEST);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index 1f38cf9766d..44dffb5bc54 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -78,7 +78,7 @@ public:
SwapBuffers(
);
void
- Resize(
+ ResizeWindow(
int width,
int height
);
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index c63b32830b0..1d4edb45242 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -350,6 +350,12 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
PyObject* BL_ActionActuator::PyGetChannel(PyObject* value)
{
const char *string= _PyUnicode_AsString(value);
+
+ if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
+ {
+ PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels");
+ return NULL;
+ }
if (!string) {
PyErr_SetString(PyExc_TypeError, "expected a single string");
@@ -414,6 +420,12 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
PyObject *pymat= NULL;
PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL;
bPoseChannel *pchan;
+
+ if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
+ {
+ PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels");
+ return NULL;
+ }
if(PyTuple_Size(args)==2) {
if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
@@ -574,6 +586,12 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA
PyObject *ret= PyList_New(0);
PyObject *item;
+ if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
+ {
+ PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels");
+ return NULL;
+ }
+
bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
if(pose) {
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index be14400f33a..e577a5e5f99 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -83,7 +83,7 @@
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
-#define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h
+#define FILE_MAX 1024 // repeated here to avoid dependency from BKE_utildefines.h
#include "KX_NetworkMessageActuator.h"
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
index 9c7f3831567..46c43b5e339 100644
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
@@ -84,6 +84,7 @@ PyMethodDef SCA_PythonKeyboard::Methods[] = {
PyAttributeDef SCA_PythonKeyboard::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonKeyboard, pyattr_get_events),
+ KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonKeyboard, pyattr_get_active_events),
{ NULL } //Sentinel
};
@@ -101,4 +102,21 @@ PyObject* SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBU
return self->m_event_dict;
}
+PyObject* SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v);
+
+ PyDict_Clear(self->m_event_dict);
+
+ for (int i=SCA_IInputDevice::KX_BEGINKEY; i<=SCA_IInputDevice::KX_ENDKEY; i++)
+ {
+ const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
+
+ if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
+ PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+ }
+ Py_INCREF(self->m_event_dict);
+ return self->m_event_dict;
+}
+
#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.h b/source/gameengine/GameLogic/SCA_PythonKeyboard.h
index 7ecf76d1581..f44bb40e13c 100644
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.h
+++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.h
@@ -43,6 +43,7 @@ public:
#ifdef WITH_PYTHON
static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
#endif
};
diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp
index 4f06445a79f..cdbeaba2235 100644
--- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonMouse.cpp
@@ -86,6 +86,7 @@ PyMethodDef SCA_PythonMouse::Methods[] = {
PyAttributeDef SCA_PythonMouse::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonMouse, pyattr_get_events),
+ KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonMouse, pyattr_get_active_events),
KX_PYATTRIBUTE_RW_FUNCTION("position", SCA_PythonMouse, pyattr_get_position, pyattr_set_position),
KX_PYATTRIBUTE_RW_FUNCTION("visible", SCA_PythonMouse, pyattr_get_visible, pyattr_set_visible),
{ NULL } //Sentinel
@@ -105,6 +106,22 @@ PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_
return self->m_event_dict;
}
+PyObject* SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
+
+ PyDict_Clear(self->m_event_dict);
+
+ for (int i=SCA_IInputDevice::KX_BEGINMOUSE; i<=SCA_IInputDevice::KX_ENDMOUSE; i++)
+ {
+ const SCA_InputEvent & inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
+
+ if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
+ PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+ }
+ Py_INCREF(self->m_event_dict);
+ return self->m_event_dict;
+}
PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.h b/source/gameengine/GameLogic/SCA_PythonMouse.h
index 4ad655dce8f..41d286a8048 100644
--- a/source/gameengine/GameLogic/SCA_PythonMouse.h
+++ b/source/gameengine/GameLogic/SCA_PythonMouse.h
@@ -48,6 +48,7 @@ public:
KX_PYMETHOD_DOC(SCA_PythonMouse, show);
static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value);
static PyObject* pyattr_get_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
index 6ac1323783b..a9d7ab1b93f 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h
@@ -103,6 +103,7 @@ public:
void Resize(int width, int height);
+ virtual void ResizeWindow(int width, int height){};
/**
* @section Methods inherited from abstract base class RAS_ICanvas.
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
index 4b5d2bbf96a..9b01cb5786f 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
@@ -108,6 +108,26 @@ void GPG_Canvas::SwapBuffers()
}
}
+void GPG_Canvas::ResizeWindow(int width, int height)
+{
+ if (m_window->getState() == GHOST_kWindowStateFullScreen)
+ {
+ GHOST_ISystem* system = GHOST_ISystem::getSystem();
+ GHOST_DisplaySetting setting;
+ setting.xPixels = width;
+ setting.yPixels = height;
+ //XXX allow these to be changed or kept from previous state
+ setting.bpp = 32;
+ setting.frequency = 60;
+
+ system->updateFullScreen(setting, &m_window);
+ }
+
+ m_window->setClientSize(width, height);
+
+ Resize(width, height);
+}
+
float GPG_Canvas::GetMouseNormalizedX(int x)
{
return float(x)/this->GetWidth();
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
index c1ebb09251c..217cfc5eb88 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
@@ -60,6 +60,8 @@ public:
virtual float GetMouseNormalizedX(int x);
virtual float GetMouseNormalizedY(int y);
+ virtual void ResizeWindow(int width, int height);
+
bool BeginDraw() { return true;};
void EndDraw() {};
};
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 18b8c0d533d..023c3dcbfc9 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1153,6 +1153,36 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale)
}
}
+void KX_GameObject::NodeSetWorldScale(const MT_Vector3& scale)
+{
+ if (!GetSGNode())
+ return;
+ SG_Node* parent = GetSGNode()->GetSGParent();
+ if (parent != NULL)
+ {
+ // Make sure the objects have some scale
+ MT_Vector3 p_scale = parent->GetWorldScaling();
+ if (fabs(p_scale[0]) < FLT_EPSILON ||
+ fabs(p_scale[1]) < FLT_EPSILON ||
+ fabs(p_scale[2]) < FLT_EPSILON)
+ {
+ return;
+ }
+
+ MT_Vector3 *local = new MT_Vector3(scale);
+
+ p_scale[0] = 1/p_scale[0];
+ p_scale[1] = 1/p_scale[1];
+ p_scale[2] = 1/p_scale[2];
+
+ NodeSetLocalScale(scale * p_scale);
+ }
+ else
+ {
+ NodeSetLocalScale(scale);
+ }
+}
+
void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans)
{
if (!GetSGNode())
@@ -1620,7 +1650,9 @@ PyAttributeDef KX_GameObject::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("localPosition", KX_GameObject, pyattr_get_localPosition, pyattr_set_localPosition),
KX_PYATTRIBUTE_RW_FUNCTION("worldPosition", KX_GameObject, pyattr_get_worldPosition, pyattr_set_worldPosition),
KX_PYATTRIBUTE_RW_FUNCTION("localScale", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
- KX_PYATTRIBUTE_RO_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling),
+ KX_PYATTRIBUTE_RW_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling, pyattr_set_worldScaling),
+ KX_PYATTRIBUTE_RW_FUNCTION("localTransform", KX_GameObject, pyattr_get_localTransform, pyattr_set_localTransform),
+ KX_PYATTRIBUTE_RW_FUNCTION("worldTransform", KX_GameObject, pyattr_get_worldTransform, pyattr_set_worldTransform),
KX_PYATTRIBUTE_RW_FUNCTION("linearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_worldLinearVelocity),
KX_PYATTRIBUTE_RW_FUNCTION("localLinearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_localLinearVelocity),
KX_PYATTRIBUTE_RW_FUNCTION("worldLinearVelocity", KX_GameObject, pyattr_get_worldLinearVelocity, pyattr_set_worldLinearVelocity),
@@ -2112,6 +2144,18 @@ PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIB
#endif
}
+int KX_GameObject::pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ MT_Vector3 scale;
+ if (!PyVecTo(value, scale))
+ return PY_SET_ATTR_FAIL;
+
+ self->NodeSetWorldScale(scale);
+ self->NodeUpdateGS(0.f);
+ return PY_SET_ATTR_SUCCESS;
+}
+
PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
#ifdef USE_MATHUTILS
@@ -2134,6 +2178,85 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE
return PY_SET_ATTR_SUCCESS;
}
+PyObject* KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+
+ double *mat = MT_CmMatrix4x4().getPointer();
+
+ MT_Transform trans;
+
+ trans.setOrigin(self->GetSGNode()->GetLocalPosition());
+ trans.setBasis(self->GetSGNode()->GetLocalOrientation());
+
+ MT_Vector3 scaling = self->GetSGNode()->GetLocalScale();
+ trans.scale(scaling[0], scaling[1], scaling[2]);
+
+ trans.getValue(mat);
+
+ return PyObjectFrom(MT_Matrix4x4(mat));
+}
+
+int KX_GameObject::pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+ MT_Matrix4x4 temp;
+ if (!PyMatTo(value, temp))
+ return PY_SET_ATTR_FAIL;
+
+ float transform[4][4];
+ float loc[3], size[3];
+ float rot[3][3];
+ MT_Matrix3x3 orientation;
+
+ temp.getValue(*transform);
+ mat4_to_loc_rot_size(loc, rot, size, transform);
+
+ self->NodeSetLocalPosition(MT_Point3(loc));
+
+ //MT_Matrix3x3's constructor expects a 4x4 matrix
+ orientation = MT_Matrix3x3();
+ orientation.setValue3x3(*rot);
+ self->NodeSetLocalOrientation(orientation);
+
+ self->NodeSetLocalScale(MT_Vector3(size));
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
+PyObject* KX_GameObject::pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+
+ return PyObjectFrom(MT_Matrix4x4(self->GetOpenGLMatrix()));
+}
+
+int KX_GameObject::pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+ MT_Matrix4x4 temp;
+ if (!PyMatTo(value, temp))
+ return PY_SET_ATTR_FAIL;
+
+ float transform[4][4];
+ float loc[3], size[3];
+ float rot[3][3];
+ MT_Matrix3x3 orientation;
+
+ temp.getValue(*transform);
+ mat4_to_loc_rot_size(loc, rot, size, transform);
+
+ self->NodeSetWorldPosition(MT_Point3(loc));
+
+ //MT_Matrix3x3's constructor expects a 4x4 matrix
+ orientation = MT_Matrix3x3();
+ orientation.setValue3x3(*rot);
+ self->NodeSetGlobalOrientation(orientation);
+
+ self->NodeSetWorldScale(MT_Vector3(size));
+
+ return PY_SET_ATTR_SUCCESS;
+}
PyObject* KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index cc078e96e64..a35e6f1b2cd 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -475,6 +475,7 @@ public:
void NodeSetGlobalOrientation(const MT_Matrix3x3& rot );
void NodeSetLocalScale( const MT_Vector3& scale );
+ void NodeSetWorldScale( const MT_Vector3& scale );
void NodeSetRelativeScale( const MT_Vector3& scale );
@@ -968,8 +969,13 @@ public:
static PyObject* pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 114ca735265..32106b1fdd8 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1288,6 +1288,16 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args)
Py_RETURN_NONE;
}
+static PyObject* gPySetWindowSize(PyObject*, PyObject* args)
+{
+ int width, height;
+ if (!PyArg_ParseTuple(args, "ii:resize", &width, &height))
+ return NULL;
+
+ gp_Canvas->ResizeWindow(width, height);
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef rasterizer_methods[] = {
{"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
METH_VARARGS, "getWindowWidth doc"},
@@ -1329,6 +1339,7 @@ static struct PyMethodDef rasterizer_methods[] = {
METH_VARARGS, "get the anisotropic filtering level"},
{"drawLine", (PyCFunction) gPyDrawLine,
METH_VARARGS, "draw a line on the screen"},
+ {"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index d7e2f237bb0..2c2f62c946e 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -205,6 +205,15 @@ public:
MakeScreenShot(
const char* filename
)=0;
+
+ virtual
+ void
+ ResizeWindow(
+ int width,
+ int height
+ )=0;
+
+
protected:
RAS_MouseState m_mousestate;
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp
index abfd0ed49b7..8410e9350d0 100644
--- a/source/gameengine/VideoTexture/blendVideoTex.cpp
+++ b/source/gameengine/VideoTexture/blendVideoTex.cpp
@@ -38,6 +38,7 @@ http://www.gnu.org/copyleft/lesser.txt.
//#include "TexPlayerGL.h"
#include "ImageBase.h"
+#include "VideoBase.h"
#include "FilterBase.h"
#include "Texture.h"
@@ -208,6 +209,11 @@ PyObject* initVideoTexture(void)
Py_INCREF(&TextureType);
PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_ERROR", SourceError);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_EMPTY", SourceEmpty);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_READY", SourceReady);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_PLAYING", SourcePlaying);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_STOPPED", SourceStopped);
// init last error description
Exception::m_lastError = "";
diff --git a/source/tests/bl_mesh_modifiers.py b/source/tests/bl_mesh_modifiers.py
index 789a4037659..917ccbc0d24 100644
--- a/source/tests/bl_mesh_modifiers.py
+++ b/source/tests/bl_mesh_modifiers.py
@@ -301,7 +301,7 @@ def mesh_vcol_add(obj, mode=0):
face_verts = mesh_bmesh_poly_vertices(poly)
poly_cols = mesh_bmesh_poly_elems(poly, col_list)
for i, c in enumerate(poly_cols):
- c.color = colors[i % 4]
+ c.color = colors_get(face_verts[i])
else:
for i, col in enumerate(vcol_lay.data):
face_verts = mesh.faces[i].vertices